index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="orderPay" :style="colorStyle">
  3. <view class="header">
  4. <view class="orderNum">订单编号 {{orderInfo.order_id}}</view>
  5. <view class="money">
  6. ¥
  7. <text class="num">{{orderInfo.pay_price}}</text>
  8. </view>
  9. </view>
  10. <view class="list" v-if="cartInfo.length">
  11. <view class="title acea-row row-between-wrapper">
  12. <view>商品列表</view>
  13. <view class="total">共<text class="num">{{cartInfo.length}}</text>件商品</view>
  14. </view>
  15. <view class="item acea-row row-between-wrapper" v-for="(item, index) in cartInfo" :key="index">
  16. <view class="pictrue">
  17. <image :src='item.productInfo.attrInfo.image' v-if="item.productInfo.attrInfo"></image>
  18. <image :src='item.productInfo.image' v-else></image>
  19. </view>
  20. <view class="picTxt">
  21. <view class="acea-row row-between-wrapper">
  22. <view class="name line1">{{item.productInfo.store_name}}</view>
  23. <view class="num">x {{item.cart_num}}</view>
  24. </view>
  25. <view class='info line1' v-if="item.productInfo.attrInfo">{{item.productInfo.attrInfo.suk}}</view>
  26. <view class="money" v-if="item.productInfo.attrInfo">¥{{item.productInfo.attrInfo.price}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="bnt acea-row row-center-wrapper" @tap.stop="goPay">立即支付</view>
  31. <payment :payMode="cartArr" :pay_close="pay_close" :totalPrice="orderInfo.pay_price" @onChangeFun="onChangeFun"
  32. :order_id="orderInfo.order_id"></payment>
  33. </view>
  34. </template>
  35. <script>
  36. import colors from '@/mixins/color.js';
  37. import {
  38. toLogin
  39. } from '@/libs/login.js';
  40. import {
  41. payCashier
  42. } from '@/api/order.js';
  43. import {
  44. mapGetters
  45. } from 'vuex';
  46. import {
  47. getUserInfo
  48. } from '@/api/user.js';
  49. import payment from '@/components/payment';
  50. export default {
  51. computed: mapGetters(['isLogin']),
  52. components: {
  53. payment
  54. },
  55. mixins: [colors],
  56. data() {
  57. return {
  58. storeId: 0,
  59. orderInfo: {},
  60. cartInfo: [],
  61. pay_close: false,
  62. //支付方式
  63. cartArr: [{
  64. "name": "微信支付",
  65. "icon": "icon-weixin2",
  66. value: 'weixin',
  67. title: '使用微信快捷支付',
  68. payStatus: 1,
  69. },
  70. {
  71. "name": "支付宝支付",
  72. "icon": "icon-zhifubao",
  73. value: 'alipay',
  74. title: '使用线上支付宝支付',
  75. payStatus: 1,
  76. },
  77. {
  78. "name": "余额支付",
  79. "icon": "icon-yuezhifu",
  80. value: 'yue',
  81. title: '可用余额:',
  82. payStatus: 1,
  83. }
  84. // {
  85. // "name": "线下支付",
  86. // "icon": "icon-yuezhifu1",
  87. // value: 'offline',
  88. // title: '选择线下付款方式',
  89. // payStatus: 2,
  90. // }
  91. ]
  92. }
  93. },
  94. onLoad(options) {
  95. // #ifdef APP-PLUS || H5
  96. if (options.store_id) {
  97. this.storeId = options.store_id
  98. }
  99. // #endif
  100. // #ifdef MP
  101. if (options.scene) {
  102. let value = this.$util.getUrlParams(decodeURIComponent(options.scene));
  103. if (value.store_id) this.storeId = value.store_id;
  104. }
  105. // #endif
  106. },
  107. onShow() {
  108. if (this.isLogin) {
  109. this.orderList();
  110. this.getUserInfo();
  111. } else {
  112. toLogin();
  113. }
  114. },
  115. methods: {
  116. orderList() {
  117. payCashier(this.storeId).then(res => {
  118. this.orderInfo = res.data;
  119. this.cartInfo = res.data.cartInfo;
  120. //微信支付是否开启
  121. this.cartArr[0].payStatus = res.data.pay_weixin_open || 0
  122. //支付宝是否开启
  123. this.cartArr[1].payStatus = 0;
  124. //#ifdef MP
  125. this.cartArr[1].payStatus = 0;
  126. //#endif
  127. this.cartArr[2].payStatus = res.data.yue_pay_status == 1?res.data.yue_pay_status:0;
  128. }).catch(err => {
  129. return this.$util.Tips({
  130. title: err
  131. });
  132. })
  133. },
  134. /**
  135. * 事件回调
  136. *
  137. */
  138. onChangeFun: function(e) {
  139. let opt = e;
  140. let action = opt.action || null;
  141. let value = opt.value != undefined ? opt.value : null;
  142. action && this[action] && this[action](value);
  143. },
  144. payClose: function() {
  145. this.pay_close = false;
  146. },
  147. goPay() {
  148. this.pay_close = true;
  149. },
  150. /**
  151. * 支付成功回调
  152. *
  153. */
  154. pay_complete: function() {
  155. this.pay_close = false;
  156. uni.navigateTo({
  157. url: '/pages/goods/order_pay_status/index?order_id=' + this.orderInfo.order_id + '&msg=' +
  158. '支付成功' +
  159. '&type=3' + '&totalPrice=' + this.orderInfo.pay_price
  160. })
  161. },
  162. /**
  163. * 支付失败回调
  164. *
  165. */
  166. pay_fail: function() {
  167. this.pay_close = false;
  168. uni.navigateTo({
  169. url: '/pages/goods/order_pay_status/index?order_id=' + this.orderInfo.order_id + '&msg=' +
  170. '取消支付' +
  171. '&type=3' + '&totalPrice=' + this.orderInfo.pay_price
  172. })
  173. },
  174. /**
  175. * 获取用户信息
  176. *
  177. */
  178. getUserInfo: function() {
  179. let that = this;
  180. getUserInfo().then(res => {
  181. that.cartArr[2].number = res.data.now_money;
  182. that.$set(that, 'cartArr', that.cartArr);
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. .orderPay {
  190. .bnt {
  191. width: 690rpx;
  192. height: 86rpx;
  193. border-radius: 43rpx;
  194. background-color: var(--view-theme);
  195. font-size: 32rpx;
  196. color: #fff;
  197. position: fixed;
  198. bottom: 50rpx;
  199. left: 50%;
  200. margin-left: -345rpx;
  201. }
  202. .list {
  203. background-color: #fff;
  204. border-radius: 20rpx 20rpx 0 0;
  205. margin-top: -30rpx;
  206. .title {
  207. height: 99rpx;
  208. font-size: 30rpx;
  209. color: #333;
  210. padding: 0 30rpx;
  211. border-bottom: 1rpx solid #F0F0F0;
  212. .total {
  213. font-size: 30rpx;
  214. color: #999999;
  215. .num {
  216. color: var(--view-theme);
  217. margin: 0 8rpx;
  218. }
  219. }
  220. }
  221. .item {
  222. margin-left: 30rpx;
  223. padding-right: 30rpx;
  224. border-bottom: 1rpx solid #F0F0F0;
  225. height: 180rpx;
  226. .pictrue {
  227. width: 130rpx;
  228. height: 130rpx;
  229. border-radius: 6rpx;
  230. image {
  231. width: 100%;
  232. height: 100%;
  233. border-radius: 6rpx;
  234. }
  235. }
  236. .picTxt {
  237. width: 538rpx;
  238. .name {
  239. width: 490rpx;
  240. font-size: 28rpx;
  241. color: #333;
  242. }
  243. .num {
  244. font-size: 26rpx;
  245. color: #999;
  246. }
  247. .info {
  248. font-size: 20rpx;
  249. color: #999;
  250. margin: 10rpx 0 15rpx 0;
  251. }
  252. .money {
  253. font-size: 26rpx;
  254. color: var(--view-theme);
  255. }
  256. }
  257. }
  258. }
  259. .header {
  260. width: 100%;
  261. height: 320rpx;
  262. background-color: var(--view-theme);
  263. text-align: center;
  264. padding-top: 70rpx;
  265. .orderNum {
  266. color: #FFFFFF;
  267. opacity: 0.8;
  268. font-size: 26rpx;
  269. }
  270. .money {
  271. font-size: 42rpx;
  272. font-weight: 500;
  273. color: #fff;
  274. margin-top: 40rpx;
  275. .num {
  276. font-size: 68rpx;
  277. }
  278. }
  279. }
  280. }
  281. </style>