order-pay.vue 10 KB

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