order-pay.vue 11 KB

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