order-pay.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 (orderInfo.collageFlag) {
  103. this.$router.redirectTo(`share-buy/share-buy-detail?collageId=${orderInfo.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. // 如果该订单为拼团订单
  127. if (data.order.collageFlag) {
  128. this.orderList = data.shopOrderList.map(order => {
  129. order.collageFlag = data.order.collageFlag
  130. order.collageId = data.order.collageId
  131. order.collageStatus = data.order.collageStatus
  132. order.collageEndTime = data.order.collageEndTime
  133. return order
  134. })
  135. } else {
  136. this.orderList = data.shopOrderList.map(order => {
  137. order.shareFlag = data.order.shareFlag
  138. return order
  139. })
  140. }
  141. } catch (e) {
  142. console.log('获取订单信息失败')
  143. console.log(e)
  144. }
  145. },
  146. // 活动价
  147. isActivityPrice(product) {
  148. return product.activeStatus > 0 || product.actProduct === '1'
  149. },
  150. // 拼团价
  151. isCollagePrice(product) {
  152. return product.collageStatus > 0 || product.actProduct === '2'
  153. },
  154. // 限时特价
  155. isDiscountPrice(product) {
  156. return product.discountStatus > 0 || product.actProduct === '3'
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .order-pay {
  163. min-height: 100vh;
  164. background: #f7f7f7;
  165. .top-tip {
  166. position: sticky;
  167. top: 0;
  168. z-index: 99;
  169. width: 750rpx;
  170. height: 80rpx;
  171. line-height: 80rpx;
  172. padding: 0 24rpx;
  173. background: #fff3f7;
  174. color: #ff457b;
  175. font-size: 26rpx;
  176. box-sizing: border-box;
  177. }
  178. .shop-info {
  179. padding: 32rpx 24rpx;
  180. background-color: #fff;
  181. margin-bottom: 20rpx;
  182. .shop-name {
  183. font-size: 30rpx;
  184. color: #333333;
  185. font-weight: bold;
  186. }
  187. .product-list {
  188. .product {
  189. display: flex;
  190. margin: 20rpx 0;
  191. .cover {
  192. width: 180rpx;
  193. height: 180rpx;
  194. border-radius: 8rpx;
  195. background-color: #f7f7f7;
  196. }
  197. .content {
  198. position: relative;
  199. width: 500rpx;
  200. margin-left: 16rpx;
  201. .count {
  202. position: absolute;
  203. bottom: 0;
  204. right: 0;
  205. font-size: 26rpx;
  206. color: #666;
  207. }
  208. &.between {
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: space-between;
  212. }
  213. .title {
  214. font-size: 28rpx;
  215. color: #333333;
  216. text-align: justify;
  217. height: 72rpx;
  218. line-height: 36rpx;
  219. }
  220. .unit {
  221. font-size: 20rpx;
  222. color: #999999;
  223. margin: 8rpx 0;
  224. }
  225. }
  226. .price {
  227. font-size: 26rpx;
  228. .active {
  229. color: #ff457b;
  230. }
  231. .deleted {
  232. margin-left: 24rpx;
  233. font-size: 24rpx;
  234. color: #999;
  235. text-decoration: line-through;
  236. }
  237. }
  238. }
  239. }
  240. .total {
  241. padding-left: 220rpx - 24rpx;
  242. margin: 16rpx 0 20rpx;
  243. font-size: 26rpx;
  244. color: #333;
  245. text {
  246. &:nth-child(2) {
  247. margin-left: 56rpx;
  248. }
  249. }
  250. }
  251. .foot {
  252. display: flex;
  253. justify-content: flex-end;
  254. align-items: center;
  255. .price {
  256. font-size: 26rpx;
  257. color: #333333;
  258. .active {
  259. color: #ff457b;
  260. }
  261. }
  262. .submit {
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. width: 160rpx;
  267. height: 64rpx;
  268. margin-left: 40rpx;
  269. background: linear-gradient(90deg, #fa55bf 0%, #f83c6c 100%);
  270. color: #ffffff;
  271. border-radius: 32rpx;
  272. font-size: 26rpx;
  273. }
  274. }
  275. }
  276. }
  277. </style>