confirm_pay.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. isBK:'',
  62. };
  63. },
  64. onPullDownRefresh(){
  65. },
  66. onLoad(option) {
  67. let self = this
  68. console.log(self.shoppingCartList,6)
  69. let list = self.shoppingCartList
  70. this.isBK = option.isBK
  71. console.log(this.isBK == '1')
  72. },
  73. onShow() {
  74. },
  75. methods: {
  76. postOrder(){
  77. let self = this
  78. let list = self.shoppingCartList
  79. for(let i=0;i<list.length;i++){
  80. let item = list[i];
  81. if(item.goodsType==1){
  82. if(item.templateType=='class'){
  83. delete item.gradObj.goodsList
  84. let goodsInputData = {
  85. type:'class',
  86. gradeId:item.gradObj.gradeId,
  87. gradeJson:JSON.stringify(item.gradObj)
  88. }
  89. item.goodsInputData = goodsInputData
  90. }
  91. if(item.templateType=='apply'){
  92. let goodsInputData = {
  93. type:'apply',
  94. applyAreasJson:JSON.stringify(item.applyAreas),
  95. examDateJson:JSON.stringify(item.examDate)
  96. }
  97. item.goodsInputData = goodsInputData
  98. }
  99. }
  100. }
  101. let data = {goodsList:list}
  102. this.$api.placeSmallOrder(data).then(res => {
  103. self.btnNo = false
  104. if(res.data.code==200){
  105. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  106. let data = res.data.data
  107. uni.requestPayment({
  108. provider: data.provider,
  109. nonceStr: data.nonceStr,
  110. package: data.package,
  111. signType: data.signType,
  112. paySign: data.sign,
  113. timeStamp: String(data.timeStamp),
  114. success: function (res) {
  115. uni.redirectTo({
  116. url: '/pages2/order/confirm_success?sn='+data.orderSn
  117. });
  118. console.log('success:' + JSON.stringify(res));
  119. },
  120. fail: function (err) {
  121. console.log('fail:' + JSON.stringify(err));
  122. }
  123. });
  124. }else{
  125. uni.showModal({
  126. title: "提示",
  127. content: res.data.msg,
  128. showCancel: false
  129. })
  130. }
  131. });
  132. },
  133. getOpenid(code){
  134. let self = this
  135. this.$api.wxOpenid({code:code}).then(res => {
  136. if(res.data.code==200){
  137. self.postOrder()
  138. }
  139. });
  140. },
  141. pay(){
  142. let self = this
  143. this.btnNo = true
  144. uni.login({
  145. provider: 'weixin',
  146. success: function(loginRes) {
  147. console.log(loginRes,69)
  148. self.getOpenid(loginRes.code)
  149. }
  150. });
  151. //
  152. },
  153. radioChange(e) {
  154. // console.log(e);
  155. },
  156. // 选中任一radio时,由radio-group触发
  157. radioGroupChange(e) {
  158. // console.log(e);
  159. },
  160. cMenu(index){
  161. this.menuIndex = index;
  162. },
  163. change(index){
  164. this.current = index;
  165. }
  166. },
  167. onReachBottom() {},
  168. computed: { ...mapGetters(['userInfo','shoppingCartList']) }
  169. };
  170. </script>
  171. <style >
  172. ::-webkit-scrollbar{
  173. width: 0;
  174. height: 0;
  175. color: transparent
  176. }
  177. page{
  178. background-color: #EAEEF1;
  179. }
  180. </style>
  181. <style scoped>
  182. .txt_left_pay{
  183. display: flex;
  184. align-items: center;
  185. height: 64rpx;
  186. font-size: 24rpx;
  187. color: #666666;
  188. }
  189. .pay_icon{
  190. width: 64rpx;
  191. height: 64rpx;
  192. margin-right: 10rpx;
  193. }
  194. .box3{
  195. width: 100%;
  196. background: #FFFFFF;
  197. border-radius: 16rpx;
  198. margin-top: 30rpx;
  199. }
  200. .tip{
  201. font-size: 24rpx;
  202. color: #999999;
  203. height: 40rpx;
  204. line-height: 40rpx;
  205. }
  206. .txt_right_sn{
  207. font-size: 30rpx;
  208. font-weight: bold;
  209. color: #666666;
  210. }
  211. .txt_right_price{
  212. font-size: 30rpx;
  213. font-weight: bold;
  214. color: #FF2D55;
  215. }
  216. .txt_left{
  217. font-size: 24rpx;
  218. color: #666666;
  219. }
  220. .txt_right{
  221. color: #333333;
  222. font-weight: bold;
  223. width: 75%;
  224. }
  225. .list_item{
  226. display: flex;
  227. justify-content: space-between;
  228. height: 90rpx;
  229. align-items: center;
  230. }
  231. .title2{
  232. font-size: 30rpx;
  233. font-weight: bold;
  234. color: #333333;
  235. height: 90rpx;
  236. line-height: 90rpx;
  237. margin-left: 30rpx;
  238. }
  239. .box2{
  240. width: 100%;
  241. background: #FFFFFF;
  242. border-radius: 16rpx;
  243. margin-top: 30rpx;
  244. }
  245. .box1_t2{
  246. font-size: 24rpx;
  247. color: #999999;
  248. text-align: center;
  249. }
  250. .box1_t1{
  251. font-size: 30rpx;
  252. font-weight: bold;
  253. color: #333333;
  254. height: 70rpx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. }
  259. .box1{
  260. width: 100%;
  261. height: 120rpx;
  262. background: #FFFFFF;
  263. border-radius: 16rpx;
  264. }
  265. .bottomBtn{
  266. position: fixed;
  267. bottom: 0;
  268. width: 100%;
  269. height: 98rpx;
  270. background: linear-gradient(0deg, #015EEA, #00C0FA);
  271. color: #FFFFFF;
  272. text-align: center;
  273. line-height: 98rpx;
  274. font-weight: bold;
  275. font-size: 30rpx;
  276. }
  277. </style>