index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. toLogin();
  117. }
  118. },
  119. methods: {
  120. onLoadFun(){
  121. this.orderList();
  122. this.getUserInfo();
  123. this.isShowAuth = false
  124. },
  125. // 授权关闭
  126. authColse: function(e) {
  127. this.isShowAuth = e
  128. },
  129. orderList() {
  130. payCashier(this.storeId).then(res => {
  131. this.orderInfo = res.data;
  132. this.cartInfo = res.data.cartInfo;
  133. //微信支付是否开启
  134. this.cartArr[0].payStatus = res.data.pay_weixin_open || 0
  135. //支付宝是否开启
  136. this.cartArr[1].payStatus = 0;
  137. //#ifdef MP
  138. this.cartArr[1].payStatus = 0;
  139. //#endif
  140. this.cartArr[2].payStatus = res.data.yue_pay_status == 1?res.data.yue_pay_status:0;
  141. }).catch(err => {
  142. return this.$util.Tips({
  143. title: err
  144. });
  145. })
  146. },
  147. /**
  148. * 事件回调
  149. *
  150. */
  151. onChangeFun: function(e) {
  152. let opt = e;
  153. let action = opt.action || null;
  154. let value = opt.value != undefined ? opt.value : null;
  155. action && this[action] && this[action](value);
  156. },
  157. payClose: function() {
  158. this.pay_close = false;
  159. },
  160. goPay() {
  161. this.pay_close = true;
  162. },
  163. /**
  164. * 支付成功回调
  165. *
  166. */
  167. pay_complete: function() {
  168. this.pay_close = false;
  169. uni.navigateTo({
  170. url: '/pages/goods/order_pay_status/index?order_id=' + this.orderInfo.order_id + '&msg=' +
  171. '支付成功' +
  172. '&type=3' + '&totalPrice=' + this.orderInfo.pay_price
  173. })
  174. },
  175. /**
  176. * 支付失败回调
  177. *
  178. */
  179. pay_fail: function() {
  180. this.pay_close = false;
  181. uni.navigateTo({
  182. url: '/pages/goods/order_pay_status/index?order_id=' + this.orderInfo.order_id + '&msg=' +
  183. '取消支付' +
  184. '&type=3' + '&totalPrice=' + this.orderInfo.pay_price
  185. })
  186. },
  187. /**
  188. * 获取用户信息
  189. *
  190. */
  191. getUserInfo: function() {
  192. let that = this;
  193. getUserInfo().then(res => {
  194. that.cartArr[2].number = res.data.now_money;
  195. that.$set(that, 'cartArr', that.cartArr);
  196. })
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. .orderPay {
  203. .bnt {
  204. width: 690rpx;
  205. height: 86rpx;
  206. border-radius: 43rpx;
  207. background-color: var(--view-theme);
  208. font-size: 32rpx;
  209. color: #fff;
  210. position: fixed;
  211. bottom: 50rpx;
  212. left: 50%;
  213. margin-left: -345rpx;
  214. }
  215. .list {
  216. background-color: #fff;
  217. border-radius: 20rpx 20rpx 0 0;
  218. margin-top: -30rpx;
  219. .title {
  220. height: 99rpx;
  221. font-size: 30rpx;
  222. color: #333;
  223. padding: 0 30rpx;
  224. border-bottom: 1rpx solid #F0F0F0;
  225. .total {
  226. font-size: 30rpx;
  227. color: #999999;
  228. .num {
  229. color: var(--view-theme);
  230. margin: 0 8rpx;
  231. }
  232. }
  233. }
  234. .item {
  235. margin-left: 30rpx;
  236. padding-right: 30rpx;
  237. border-bottom: 1rpx solid #F0F0F0;
  238. height: 180rpx;
  239. .pictrue {
  240. width: 130rpx;
  241. height: 130rpx;
  242. border-radius: 6rpx;
  243. image {
  244. width: 100%;
  245. height: 100%;
  246. border-radius: 6rpx;
  247. }
  248. }
  249. .picTxt {
  250. width: 538rpx;
  251. .name {
  252. width: 490rpx;
  253. font-size: 28rpx;
  254. color: #333;
  255. }
  256. .num {
  257. font-size: 26rpx;
  258. color: #999;
  259. }
  260. .info {
  261. font-size: 20rpx;
  262. color: #999;
  263. margin: 10rpx 0 15rpx 0;
  264. }
  265. .money {
  266. font-size: 26rpx;
  267. color: var(--view-theme);
  268. }
  269. }
  270. }
  271. }
  272. .header {
  273. width: 100%;
  274. height: 320rpx;
  275. background-color: var(--view-theme);
  276. text-align: center;
  277. padding-top: 70rpx;
  278. .orderNum {
  279. color: #FFFFFF;
  280. opacity: 0.8;
  281. font-size: 26rpx;
  282. }
  283. .money {
  284. font-size: 42rpx;
  285. font-weight: 500;
  286. color: #fff;
  287. margin-top: 40rpx;
  288. .num {
  289. font-size: 68rpx;
  290. }
  291. }
  292. }
  293. }
  294. </style>