order-detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. },
  119. beforeDestroy(){
  120. this.$off('orderAction')
  121. },
  122. methods: {
  123. getOrderDetail() {
  124. this.OrderService.QueryOrderDetails({ orderId: this.orderId })
  125. .then(res => {
  126. this.discernReceiptList = res.data.discernReceiptList
  127. this.shopOrderList = res.data.shopOrderList
  128. this.orderInfo = res.data.order
  129. this.userInfo = res.data.userInfo
  130. this.isRequest = false
  131. })
  132. .catch(err => {
  133. this.$util.modal('提示', '订单查询失败,请稍后重试~', '确定', '', false, () => {
  134. this.$api.switchTabTo('/pages/tabBar/index/index')
  135. })
  136. })
  137. },
  138. getButtonCount(e){
  139. this.buttonCount = e.count
  140. console.log(e.count)
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .order-detail {
  147. min-height: 100vh;
  148. background: #f7f7f7;
  149. padding-top: 138rpx + 60rpx;
  150. box-sizing: border-box;
  151. &.has-bottom {
  152. padding-bottom: 100rpx;
  153. }
  154. .order-status{
  155. height: 60rpx;
  156. font-size: 26rpx;
  157. line-height: 26rpx;
  158. padding: 34rpx 24rpx 0;
  159. box-sizing: border-box;
  160. color: #FF457B;
  161. background: #fff;
  162. }
  163. .detail-top {
  164. height: 134rpx + 60rpx;
  165. position: fixed;
  166. top: 0;
  167. z-index: 999;
  168. }
  169. .grid {
  170. height: 20rpx;
  171. background: #f7f7f7;
  172. }
  173. .shop-section {
  174. background: #fff;
  175. overflow: hidden;
  176. .line {
  177. width: 702rpx;
  178. height: 1px;
  179. background: #f7f7f7;
  180. margin: 0 auto;
  181. }
  182. .origin {
  183. padding: 0 24rpx;
  184. margin-top: 24rpx;
  185. margin-bottom: 16rpx;
  186. display: flex;
  187. justify-content: flex-start;
  188. align-items: center;
  189. .cover {
  190. width: 56rpx;
  191. height: 56rpx;
  192. border-radius: 4rpx;
  193. border: 1px solid #f7f7f7;
  194. box-sizing: border-box;
  195. }
  196. .name {
  197. margin-left: 16rpx;
  198. font-size: 30rpx;
  199. color: #333333;
  200. font-weight: bold;
  201. }
  202. }
  203. .goods-list {
  204. margin-bottom: 32rpx;
  205. .order-goods {
  206. padding-top: 32rpx;
  207. &:first-child {
  208. padding-top: 0;
  209. }
  210. }
  211. }
  212. }
  213. .total {
  214. display: flex;
  215. justify-content: space-between;
  216. align-items: center;
  217. padding: 0 24rpx;
  218. margin: 32rpx 0;
  219. font-size: 26rpx;
  220. color: #333333;
  221. .count {
  222. font-weight: bold;
  223. }
  224. .status {
  225. color: #ff457b;
  226. .label {
  227. color: #333333;
  228. }
  229. }
  230. }
  231. .order-control {
  232. position: fixed;
  233. width: 100%;
  234. box-sizing: border-box;
  235. height: 100rpx;
  236. display: flex;
  237. justify-content: flex-end;
  238. align-items: center;
  239. bottom: 0;
  240. background: #fff;
  241. &.has-bottom{
  242. bottom: 50rpx;
  243. }
  244. }
  245. }
  246. </style>