order-pay.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view class="order-pay">
  3. <view class="top-tip">请对每家店铺分别进行付款</view>
  4. <template v-for="order in orderList">
  5. <view class="shop-info" :key="order.shopId">
  6. <view class="shop-name">{{ order.shopName }}</view>
  7. <view class="product-list">
  8. <template v-for="product in order.orderProductList">
  9. <view class="product" :key="product.orderProductId">
  10. <image class="cover" :src="product.productImage" mode="widthFix"></image>
  11. <view class="content">
  12. <view class="count">×{{ product.num }}</view>
  13. <view class="title">{{ product.name }}</view>
  14. <view class="unit">规格:{{ product.productUnit }}</view>
  15. <view class="tags">
  16. <!-- 促销 自营 -->
  17. <view class="tag cx" v-if="userId === product.heUserId">促销</view>
  18. <view class="tag cx" v-else>自营</view>
  19. <!-- 拼团价 活动价 限时特价 券后价 -->
  20. <view class="tag pt" v-if="isCollagePrice(product)">拼团价</view>
  21. <view class="tag hd" v-else-if="isActivityPrice(product)">活动价</view>
  22. <view class="tag other" v-else-if="isDiscountPrice(product)">限时特价</view>
  23. <view class="tag other" v-else-if="product.couponStatus > 1">
  24. {{ product.couponInfo }}
  25. </view>
  26. <view class="tag other" v-else-if="product.couponStatus > 0">券后价</view>
  27. </view>
  28. <view class="price">
  29. <text class="active">¥{{ product.price | priceFormat }}</text>
  30. <text class="deleted">¥{{ product.normalPrice | priceFormat }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. </view>
  36. <view class="total">
  37. <text>优惠:¥{{ order.eachDiscount | priceFormat }}</text>
  38. <text>已付:¥{{ order.receiptAmount | priceFormat }}</text>
  39. </view>
  40. <view class="foot" v-if="order.receiptStatus !== 3">
  41. <view class="price">
  42. <text>待付:</text>
  43. <text class="active">¥{{ order.restAmount | priceFormat }}</text>
  44. </view>
  45. <view class="submit" @click="onPayOrder(order)">付款</view>
  46. </view>
  47. </view>
  48. </template>
  49. <!-- <view class="shop-info">
  50. <view class="shop-name">采美快递物流商</view>
  51. <view class="product-list">
  52. <view class="product">
  53. <image
  54. class="cover"
  55. src="https://static.caimei365.com/app/mini-hehe/icon/icon-logistics.png"
  56. mode="widthFix"
  57. ></image>
  58. <view class="content between">
  59. <view class="title">运费</view>
  60. <view class="price"><text>¥0</text></view>
  61. <view class="count">×1</view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="foot">
  66. <view class="price">
  67. <text>待付:</text>
  68. <text class="active">¥0</text>
  69. </view>
  70. </view>
  71. </view> -->
  72. <!-- 操作弹窗 -->
  73. <tui-modal :show="modal" content="确认支付?" :maskClosable="false" @click="handleModalConfirm"></tui-modal>
  74. </view>
  75. </template>
  76. <script>
  77. import { mapGetters } from 'vuex'
  78. import wechatPay from './mixins/wechatPay.js'
  79. import { fetchOrderDetail } from '@/services/api/order.js'
  80. export default {
  81. mixins: [wechatPay],
  82. data() {
  83. return {
  84. orderId: '',
  85. modal: false,
  86. orderList: [],
  87. orderInfo: {}
  88. }
  89. },
  90. computed: {
  91. ...mapGetters(['userId'])
  92. },
  93. onLoad(option) {
  94. this.orderId = option.orderId
  95. this.getOrderDetail() // 获取订单支付列表
  96. this.orderPaySuccess() // 支付回调执行函数
  97. },
  98. methods: {
  99. // 支付成功回调
  100. orderPaySuccess() {
  101. this.$on('orderPaySuccess', orderInfo => {
  102. if (this.collageFlag === 1) {
  103. uni.redirectTo({ url: `share-buy/share-buy-detail?collageId=${this.collageId}` })
  104. } else {
  105. uni.setStorageSync('PAY_ORDER_INFO', orderInfo)
  106. this.$router.redirectTo('order/pay-success')
  107. }
  108. })
  109. },
  110. // 确认支付
  111. handleModalConfirm(e) {
  112. this.modal = false
  113. if (!e.index) return
  114. this.miniWxPayFor(this.orderInfo)
  115. },
  116. // 子订单支付
  117. onPayOrder(orderInfo) {
  118. orderInfo.payableAmount = orderInfo.restAmount
  119. this.orderInfo = orderInfo
  120. this.modal = true
  121. },
  122. // 获取订单支付列表
  123. async getOrderDetail() {
  124. try {
  125. const { data } = await fetchOrderDetail({ orderId: this.orderId })
  126. this.orderList = data.shopOrderList
  127. } catch (e) {
  128. console.log('获取订单信息失败')
  129. console.log(e)
  130. }
  131. },
  132. // 活动价
  133. isActivityPrice(product) {
  134. return product.activeStatus > 0 || product.actProduct === '1'
  135. },
  136. // 拼团价
  137. isCollagePrice(product) {
  138. return product.collageStatus > 0 || product.actProduct === '2'
  139. },
  140. // 限时特价
  141. isDiscountPrice(product) {
  142. return product.discountStatus > 0 || product.actProduct === '3'
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .order-pay {
  149. min-height: 100vh;
  150. background: #f7f7f7;
  151. .top-tip {
  152. position: sticky;
  153. top: 0;
  154. z-index: 99;
  155. width: 750rpx;
  156. height: 80rpx;
  157. line-height: 80rpx;
  158. padding: 0 24rpx;
  159. background: #fff3f7;
  160. color: #ff457b;
  161. font-size: 26rpx;
  162. box-sizing: border-box;
  163. }
  164. .shop-info {
  165. padding: 32rpx 24rpx;
  166. background-color: #fff;
  167. margin-bottom: 20rpx;
  168. .shop-name {
  169. font-size: 30rpx;
  170. color: #333333;
  171. font-weight: bold;
  172. }
  173. .product-list {
  174. .product {
  175. display: flex;
  176. margin: 20rpx 0;
  177. .cover {
  178. width: 180rpx;
  179. height: 180rpx;
  180. border-radius: 8rpx;
  181. background-color: #f7f7f7;
  182. }
  183. .content {
  184. position: relative;
  185. width: 500rpx;
  186. margin-left: 16rpx;
  187. .count {
  188. position: absolute;
  189. bottom: 0;
  190. right: 0;
  191. font-size: 26rpx;
  192. color: #666;
  193. }
  194. &.between {
  195. display: flex;
  196. flex-direction: column;
  197. justify-content: space-between;
  198. }
  199. .title {
  200. font-size: 28rpx;
  201. color: #333333;
  202. text-align: justify;
  203. height: 72rpx;
  204. line-height: 36rpx;
  205. }
  206. .unit {
  207. font-size: 20rpx;
  208. color: #999999;
  209. margin: 8rpx 0;
  210. }
  211. }
  212. .price {
  213. font-size: 26rpx;
  214. .active {
  215. color: #ff457b;
  216. }
  217. .deleted {
  218. margin-left: 24rpx;
  219. font-size: 24rpx;
  220. color: #999;
  221. text-decoration: line-through;
  222. }
  223. }
  224. }
  225. }
  226. .total {
  227. padding-left: 220rpx - 24rpx;
  228. margin: 16rpx 0 20rpx;
  229. font-size: 26rpx;
  230. color: #333;
  231. text {
  232. &:nth-child(2) {
  233. margin-left: 56rpx;
  234. }
  235. }
  236. }
  237. .foot {
  238. display: flex;
  239. justify-content: flex-end;
  240. align-items: center;
  241. .price {
  242. font-size: 26rpx;
  243. color: #333333;
  244. .active {
  245. color: #ff457b;
  246. }
  247. }
  248. .submit {
  249. display: flex;
  250. justify-content: center;
  251. align-items: center;
  252. width: 160rpx;
  253. height: 64rpx;
  254. margin-left: 40rpx;
  255. background: linear-gradient(90deg, #fa55bf 0%, #f83c6c 100%);
  256. color: #ffffff;
  257. border-radius: 32rpx;
  258. font-size: 26rpx;
  259. }
  260. }
  261. }
  262. }
  263. </style>