order-detail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="order-detail" :class="{ hasBottom: hasControlNav }">
  3. <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
  4. <view class="detail-top">
  5. <!-- 订单状态 -->
  6. <view class="order-status">{{ stateExpFormat(orderInfo.status) }}</view>
  7. <!-- 收货地址 -->
  8. <cm-choose-address :addressData="userInfo" disabled></cm-choose-address>
  9. </view>
  10. <!-- 订单商品列表 -->
  11. <template v-for="(shopOrder, shopOrderIndex) in shopOrderList">
  12. <view class="grid" :key="shopOrderIndex"></view>
  13. <view class="shop-section" :key="shopOrderIndex">
  14. <!-- 供应商 -->
  15. <view class="origin">
  16. <image class="cover" :src="shopOrder.shopLogo"></image>
  17. <view class="name">{{ shopOrder.shopName }}</view>
  18. </view>
  19. <!-- 商品列表 -->
  20. <view class="goods-list">
  21. <!-- 商品信息 -->
  22. <view class="order-goods" v-for="goods in shopOrder.orderProductList" :key="goods.productId">
  23. <cm-order-prodcut :goods-data="goods"></cm-order-prodcut>
  24. </view>
  25. </view>
  26. <view class="line"></view>
  27. <!-- 统计 -->
  28. <view class="total">
  29. <view class="count">共{{ shopOrder.itemCount }}件商品</view>
  30. <view class="status">
  31. <text class="label">商品总额:</text>
  32. <text>¥{{ shopOrder.totalAmount | formatPrice }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <view class="grid"></view>
  38. <!-- 订单详细信息 -->
  39. <cm-order-information :orderInfo="orderInfo"></cm-order-information>
  40. <!-- 操作 -->
  41. <view class="order-control" v-if="hasControlNav" :class="{'has-bottom': isIphoneX}">
  42. <cm-order-control-nav
  43. :orderInfo="orderInfo"
  44. @confirm="handleConfirmClick"
  45. :hasBottom="isIphoneX"
  46. @change="getButtonCount"
  47. ></cm-order-control-nav>
  48. </view>
  49. <!-- 操作弹窗 -->
  50. <tui-modal
  51. :show="modal"
  52. :content="modalText"
  53. :size="32"
  54. :maskClosable="false"
  55. color="#333"
  56. shape="circle"
  57. @click="handleModalConfirm"
  58. ></tui-modal>
  59. <!-- 加载框 -->
  60. <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
  61. <!-- 失效商品列表 -->
  62. <cm-order-invalid-modal
  63. :goodsList="invalidList"
  64. :visible="buyAgainModal"
  65. @confirm="buyAgainModalClick"
  66. @cancel="buyAgainModalHide"
  67. ></cm-order-invalid-modal>
  68. <!-- 底部占位 -->
  69. <view class="reserved" v-if="isIphoneX"></view>
  70. </view>
  71. </template>
  72. <script>
  73. import CmChooseAddress from '@/components/cm-module/cm-choose-address/cm-choose-address.vue' //地址信息
  74. import CmOrderProdcut from '@/components/cm-module/cm-order-prodcut/cm-order-prodcut.vue'
  75. import CmOrderInformation from '@/components/cm-module/cm-order-information/cm-order-information.vue'
  76. import CmOrderControlNav from '@/components/cm-module/cm-order-control-nav/cm-order-control-nav.vue'
  77. import CmOrderInvalidModal from '@/components/cm-module/cm-order-invalid-modal/cm-order-invalid-modal.vue'
  78. import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
  79. import orderList from './mixins/orderList.js'
  80. import wechatPay from './mixins/wechatPay.js'
  81. import { mapGetters } from 'vuex'
  82. export default {
  83. mixins: [wechatPay, orderList],
  84. components: {
  85. CmOrderProdcut,
  86. CmOrderInformation,
  87. CmOrderControlNav,
  88. CmOrderInvalidModal,
  89. CmLoading,
  90. CmChooseAddress
  91. },
  92. data() {
  93. return {
  94. isRequest: false,
  95. orderId: '',
  96. discernReceiptList: [],
  97. shopOrderList: [],
  98. orderInfo: {},
  99. userInfo: {},
  100. }
  101. },
  102. computed: {
  103. ...mapGetters(['userId', 'userIdentity', 'isIphoneX']),
  104. // 当前用户是否为协销
  105. isDealer() {
  106. return this.userIdentity === 2
  107. },
  108. hasControlNav() {
  109. return this.orderInfo.buyUserId === this.userId
  110. },
  111. },
  112. onLoad(option) {
  113. this.orderId = option.orderId
  114. this.getOrderDetail()
  115. this.$on('orderAction', () => {
  116. this.getOrderDetail()
  117. })
  118. this.orderPaySuccess()
  119. },
  120. beforeDestroy(){
  121. this.$off('orderAction')
  122. },
  123. methods: {
  124. // 支付回调执行函数
  125. orderPaySuccess(){
  126. this.$on('orderPaySuccess', ()=>{
  127. const orderInfo = this.hanldOrder.order
  128. this.getOrderDetail()
  129. if(orderInfo.collageFlag){
  130. uni.navigateTo({ url: `/pages/fight-order/fight-detail?collageId=${orderInfo.collageId}` })
  131. }else{
  132. uni.redirectTo({ url: '/pages/order/success' })
  133. }
  134. })
  135. },
  136. getOrderDetail() {
  137. this.OrderService.QueryOrderDetails({ orderId: this.orderId })
  138. .then(res => {
  139. this.discernReceiptList = res.data.discernReceiptList
  140. this.shopOrderList = res.data.shopOrderList
  141. this.orderInfo = res.data.order
  142. this.userInfo = res.data.userInfo
  143. this.isRequest = false
  144. })
  145. .catch(err => {
  146. this.$util.modal('提示', '订单查询失败,请稍后重试~', '确定', '', false, () => {
  147. this.$api.switchTabTo('/pages/tabBar/index/index')
  148. })
  149. })
  150. },
  151. getButtonCount(e){
  152. this.buttonCount = e.count
  153. console.log(e.count)
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .order-detail {
  160. min-height: 100vh;
  161. background: #f7f7f7;
  162. padding-top: 138rpx + 60rpx;
  163. box-sizing: border-box;
  164. &.has-bottom {
  165. padding-bottom: 100rpx;
  166. }
  167. .order-status{
  168. height: 60rpx;
  169. font-size: 26rpx;
  170. line-height: 26rpx;
  171. padding: 34rpx 24rpx 0;
  172. box-sizing: border-box;
  173. color: #FF457B;
  174. background: #fff;
  175. }
  176. .detail-top {
  177. height: 134rpx + 60rpx;
  178. position: fixed;
  179. top: 0;
  180. z-index: 999;
  181. }
  182. .grid {
  183. height: 20rpx;
  184. background: #f7f7f7;
  185. }
  186. .shop-section {
  187. background: #fff;
  188. overflow: hidden;
  189. .line {
  190. width: 702rpx;
  191. height: 1px;
  192. background: #f7f7f7;
  193. margin: 0 auto;
  194. }
  195. .origin {
  196. padding: 0 24rpx;
  197. margin-top: 24rpx;
  198. margin-bottom: 16rpx;
  199. display: flex;
  200. justify-content: flex-start;
  201. align-items: center;
  202. .cover {
  203. width: 56rpx;
  204. height: 56rpx;
  205. border-radius: 4rpx;
  206. border: 1px solid #f7f7f7;
  207. box-sizing: border-box;
  208. }
  209. .name {
  210. margin-left: 16rpx;
  211. font-size: 30rpx;
  212. color: #333333;
  213. font-weight: bold;
  214. }
  215. }
  216. .goods-list {
  217. margin-bottom: 32rpx;
  218. .order-goods {
  219. padding-top: 32rpx;
  220. &:first-child {
  221. padding-top: 0;
  222. }
  223. }
  224. }
  225. }
  226. .total {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. padding: 0 24rpx;
  231. margin: 32rpx 0;
  232. font-size: 26rpx;
  233. color: #333333;
  234. .count {
  235. font-weight: bold;
  236. }
  237. .status {
  238. color: #ff457b;
  239. .label {
  240. color: #333333;
  241. }
  242. }
  243. }
  244. .order-control {
  245. position: fixed;
  246. width: 100%;
  247. box-sizing: border-box;
  248. height: 100rpx;
  249. display: flex;
  250. justify-content: flex-end;
  251. align-items: center;
  252. bottom: 0;
  253. background: #fff;
  254. &.has-bottom{
  255. bottom: 50rpx;
  256. }
  257. }
  258. }
  259. </style>