confirm_pay.vue 6.4 KB

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