confirm_pay.vue 5.8 KB

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