index.vue 6.8 KB

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