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