confirm_pay.vue 5.8 KB

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