index.vue 6.9 KB

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