confirm_pay.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view>
  3. <view>
  4. <view style="padding: 30rpx;">
  5. <view class="box2">
  6. <view class="title2">支付信息</view>
  7. <u-line color="#D6D6DB" />
  8. <view style="padding:10rpx 30rpx;" v-for="(item,index) in shoppingCartList">
  9. <view class="list_item">
  10. <view class="txt_left">商品名称</view>
  11. <view class="txt_right">{{item.goodsName}}</view>
  12. </view>
  13. <view class="list_item">
  14. <view class="txt_left">应付金额</view>
  15. <view class="txt_right_price">¥ {{item.standPrice}}</view>
  16. </view>
  17. <u-line color="#D6D6DB"/>
  18. </view>
  19. </view>
  20. <view class="box3">
  21. <view class="title2">支付信息</view>
  22. <u-line color="#D6D6DB" />
  23. <view style="padding:20rpx 30rpx;">
  24. <u-radio-group v-model="value" @change="radioGroupChange">
  25. <view class="list_item">
  26. <view class="txt_left_pay"><image src="/static/wepay.png" class="pay_icon"></image>微信支付</view>
  27. <view ><u-radio @change="radioChange" name="wepay"></u-radio></view>
  28. </view>
  29. <view class="list_item" v-if="false">
  30. <view class="txt_left_pay"><image src="/static/unipay.png" class="pay_icon"></image>云闪付</view>
  31. <view ><u-radio @change="radioChange" name="unipay"></u-radio></view>
  32. </view>
  33. </u-radio-group>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <button class="bottomBtn" @click="pay()" :disabled="btnNo">确认支付</button>
  39. </view>
  40. </template>
  41. <script>
  42. import { mapGetters } from 'vuex';
  43. export default {
  44. components: {
  45. },
  46. data() {
  47. return {
  48. list:[
  49. {
  50. name: '网课'
  51. },
  52. {
  53. name: '题库通'
  54. }
  55. ],
  56. array:['全部','建设工程施工管理','机电全科','机电工程管理与实','机电全科','全科'],
  57. current:0,
  58. menuIndex:0,
  59. value:'wepay',
  60. btnNo:false
  61. };
  62. },
  63. onPullDownRefresh(){
  64. },
  65. onLoad(option) {
  66. let self = this
  67. console.log(self.shoppingCartList,6)
  68. let list = self.shoppingCartList
  69. },
  70. onShow() {
  71. },
  72. methods: {
  73. postOrder(){
  74. let self = this
  75. let list = self.shoppingCartList
  76. for(let i=0;i<list.length;i++){
  77. let item = list[i];
  78. if(item.goodsType==1){
  79. if(item.templateType=='class'){
  80. delete item.gradObj.goodsList
  81. let goodsInputData = {
  82. type:'class',
  83. gradeId:item.gradObj.gradeId,
  84. gradeJson:JSON.stringify(item.gradObj)
  85. }
  86. item.goodsInputData = goodsInputData
  87. }
  88. if(item.templateType=='apply'){
  89. let goodsInputData = {
  90. type:'apply',
  91. applyAreasJson:JSON.stringify(item.applyAreas),
  92. examDateJson:JSON.stringify(item.examDate)
  93. }
  94. item.goodsInputData = goodsInputData
  95. }
  96. }
  97. }
  98. let data = {goodsList:list}
  99. this.$api.placeSmallOrder(data).then(res => {
  100. self.btnNo = false
  101. if(res.data.code==200){
  102. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  103. let data = res.data.data
  104. uni.requestPayment({
  105. provider: data.provider,
  106. nonceStr: data.nonceStr,
  107. package: data.package,
  108. signType: data.signType,
  109. paySign: data.sign,
  110. timeStamp: String(data.timeStamp),
  111. success: function (res) {
  112. uni.redirectTo({
  113. url: '/pages2/order/confirm_success?sn='+data.orderSn
  114. });
  115. console.log('success:' + JSON.stringify(res));
  116. },
  117. fail: function (err) {
  118. console.log('fail:' + JSON.stringify(err));
  119. }
  120. });
  121. }else{
  122. uni.showModal({
  123. title: "提示",
  124. content: res.data.msg,
  125. showCancel: false
  126. })
  127. }
  128. });
  129. },
  130. getOpenid(code){
  131. let self = this
  132. this.$api.wxOpenid({code:code}).then(res => {
  133. if(res.data.code==200){
  134. self.postOrder()
  135. }
  136. });
  137. },
  138. pay(){
  139. let self = this
  140. this.btnNo = true
  141. uni.login({
  142. provider: 'weixin',
  143. success: function(loginRes) {
  144. console.log(loginRes,69)
  145. self.getOpenid(loginRes.code)
  146. }
  147. });
  148. //
  149. },
  150. radioChange(e) {
  151. // console.log(e);
  152. },
  153. // 选中任一radio时,由radio-group触发
  154. radioGroupChange(e) {
  155. // console.log(e);
  156. },
  157. cMenu(index){
  158. this.menuIndex = index;
  159. },
  160. change(index){
  161. this.current = index;
  162. }
  163. },
  164. onReachBottom() {},
  165. computed: { ...mapGetters(['userInfo','shoppingCartList']) }
  166. };
  167. </script>
  168. <style >
  169. ::-webkit-scrollbar{
  170. width: 0;
  171. height: 0;
  172. color: transparent
  173. }
  174. page{
  175. background-color: #EAEEF1;
  176. }
  177. </style>
  178. <style scoped>
  179. .txt_left_pay{
  180. display: flex;
  181. align-items: center;
  182. height: 64rpx;
  183. font-size: 24rpx;
  184. color: #666666;
  185. }
  186. .pay_icon{
  187. width: 64rpx;
  188. height: 64rpx;
  189. margin-right: 10rpx;
  190. }
  191. .box3{
  192. width: 100%;
  193. background: #FFFFFF;
  194. border-radius: 16rpx;
  195. margin-top: 30rpx;
  196. }
  197. .tip{
  198. font-size: 24rpx;
  199. color: #999999;
  200. height: 40rpx;
  201. line-height: 40rpx;
  202. }
  203. .txt_right_sn{
  204. font-size: 30rpx;
  205. font-weight: bold;
  206. color: #666666;
  207. }
  208. .txt_right_price{
  209. font-size: 30rpx;
  210. font-weight: bold;
  211. color: #FF2D55;
  212. }
  213. .txt_left{
  214. font-size: 24rpx;
  215. color: #666666;
  216. }
  217. .txt_right{
  218. color: #333333;
  219. font-weight: bold;
  220. width: 75%;
  221. }
  222. .list_item{
  223. display: flex;
  224. justify-content: space-between;
  225. height: 90rpx;
  226. align-items: center;
  227. }
  228. .title2{
  229. font-size: 30rpx;
  230. font-weight: bold;
  231. color: #333333;
  232. height: 90rpx;
  233. line-height: 90rpx;
  234. margin-left: 30rpx;
  235. }
  236. .box2{
  237. width: 100%;
  238. background: #FFFFFF;
  239. border-radius: 16rpx;
  240. margin-top: 30rpx;
  241. }
  242. .box1_t2{
  243. font-size: 24rpx;
  244. color: #999999;
  245. text-align: center;
  246. }
  247. .box1_t1{
  248. font-size: 30rpx;
  249. font-weight: bold;
  250. color: #333333;
  251. height: 70rpx;
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. }
  256. .box1{
  257. width: 100%;
  258. height: 120rpx;
  259. background: #FFFFFF;
  260. border-radius: 16rpx;
  261. }
  262. .bottomBtn{
  263. position: fixed;
  264. bottom: 0;
  265. width: 100%;
  266. height: 98rpx;
  267. background: linear-gradient(0deg, #015EEA, #00C0FA);
  268. color: #FFFFFF;
  269. text-align: center;
  270. line-height: 98rpx;
  271. font-weight: bold;
  272. font-size: 30rpx;
  273. }
  274. </style>