order-detail.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="order-detail" :class="{ 'has-bottom': 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 class="remark">
  36. <text class="label">留言:</text>
  37. <text class="content">{{ shopOrder.note }}</text>
  38. </view>
  39. <view class="line"></view>
  40. <view class="description">
  41. <view class="collapse-content" v-if="isCollapse">
  42. <view class="row">
  43. <text class="label">商品总额:</text>
  44. <text class="content">¥{{ shopOrder.needPayAmount | formatPrice }}</text>
  45. </view>
  46. <view class="row">
  47. <text class="label">优惠:</text>
  48. <text class="content">¥{{ shopOrder.eachDiscount | formatPrice }}</text>
  49. </view>
  50. <view class="row">
  51. <text class="label">应付金额:</text>
  52. <text class="content">¥{{ shopOrder.realPay | formatPrice }}</text>
  53. </view>
  54. <view class="row">
  55. <text class="label">已付金额:</text>
  56. <text class="content">¥{{ shopOrder.receiptAmount | formatPrice }}</text>
  57. </view>
  58. </view>
  59. <view class="row">
  60. <text class="label active">待付金额:</text>
  61. <text class="content active">¥{{ shopOrder.restAmount | formatPrice }}</text>
  62. </view>
  63. <view class="collapse" :class="isCollapse ? 'arrowup' : 'arrowdown'" @click="onCollapse">
  64. {{ isCollapse ? '收起' : '展开' }}
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <view class="grid"></view>
  70. <!-- 订单详细信息 -->
  71. <cm-order-information :orderInfo="orderInfo"></cm-order-information>
  72. <!-- 操作 -->
  73. <view class="order-control" v-if="hasControlNav" :class="{ 'has-bottom': isIphoneX }">
  74. <cm-order-control-nav
  75. :orderInfo="orderInfo"
  76. @confirm="handleConfirmClick"
  77. :hasBottom="isIphoneX"
  78. @change="getButtonCount"
  79. ></cm-order-control-nav>
  80. </view>
  81. <!-- 操作弹窗 -->
  82. <tui-modal
  83. :show="modal"
  84. :content="modalText"
  85. :size="32"
  86. :maskClosable="false"
  87. color="#333"
  88. shape="circle"
  89. @click="handleModalConfirm"
  90. ></tui-modal>
  91. <!-- 加载框 -->
  92. <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
  93. <!-- 失效商品列表 -->
  94. <cm-order-invalid-modal
  95. :goodsList="invalidList"
  96. :visible="buyAgainModal"
  97. @confirm="buyAgainModalClick"
  98. @cancel="buyAgainModalHide"
  99. ></cm-order-invalid-modal>
  100. <!-- 底部占位 -->
  101. <view class="reserved" v-if="isIphoneX"></view>
  102. </view>
  103. </template>
  104. <script>
  105. import CmChooseAddress from '@/components/cm-module/cm-choose-address/cm-choose-address.vue' //地址信息
  106. import CmOrderProdcut from '@/components/cm-module/cm-order-prodcut/cm-order-prodcut.vue'
  107. import CmOrderInformation from '@/components/cm-module/cm-order-information/cm-order-information.vue'
  108. import CmOrderControlNav from '@/components/cm-module/cm-order-control-nav/cm-order-control-nav.vue'
  109. import CmOrderInvalidModal from '@/components/cm-module/cm-order-invalid-modal/cm-order-invalid-modal.vue'
  110. import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
  111. import orderList from './mixins/orderList.js'
  112. import wechatPay from './mixins/wechatPay.js'
  113. import { mapGetters } from 'vuex'
  114. export default {
  115. mixins: [wechatPay, orderList],
  116. components: {
  117. CmOrderProdcut,
  118. CmOrderInformation,
  119. CmOrderControlNav,
  120. CmOrderInvalidModal,
  121. CmLoading,
  122. CmChooseAddress
  123. },
  124. data() {
  125. return {
  126. isRequest: true,
  127. orderId: '',
  128. discernReceiptList: [],
  129. shopOrderList: [],
  130. orderInfo: {},
  131. userInfo: {},
  132. isCollapse: false
  133. }
  134. },
  135. computed: {
  136. ...mapGetters(['userId', 'userIdentity', 'isIphoneX']),
  137. // 当前用户是否为协销
  138. isDealer() {
  139. return this.userIdentity === 2
  140. },
  141. hasControlNav() {
  142. return this.orderInfo.buyUserId === this.userId
  143. }
  144. },
  145. onLoad(option) {
  146. this.orderId = option.orderId
  147. this.getOrderDetail()
  148. this.$on('orderAction', () => {
  149. this.getOrderDetail()
  150. })
  151. this.orderPaySuccess()
  152. },
  153. beforeDestroy() {
  154. this.$off('orderAction')
  155. },
  156. methods: {
  157. // 支付回调执行函数
  158. orderPaySuccess() {
  159. this.$on('orderPaySuccess', () => {
  160. const orderInfo = this.hanldOrder.order
  161. this.getOrderDetail()
  162. if (orderInfo.collageFlag) {
  163. uni.navigateTo({ url: `/pages/fight-order/fight-detail?collageId=${orderInfo.collageId}` })
  164. } else {
  165. uni.redirectTo({ url: '/pages/order/success' })
  166. }
  167. })
  168. },
  169. getOrderDetail() {
  170. this.OrderService.QueryOrderDetails({ orderId: this.orderId })
  171. .then(res => {
  172. this.discernReceiptList = res.data.discernReceiptList
  173. this.shopOrderList = res.data.shopOrderList
  174. this.orderInfo = res.data.order
  175. this.userInfo = res.data.userInfo
  176. this.isRequest = false
  177. })
  178. .catch(err => {
  179. this.$util.modal('提示', '订单查询失败,请稍后重试~', '确定', '', false, () => {
  180. this.$api.switchTabTo('/pages/tabBar/index/index')
  181. })
  182. })
  183. },
  184. getButtonCount(e) {
  185. this.buttonCount = e.count
  186. console.log(e.count)
  187. },
  188. onCollapse() {
  189. this.isCollapse = !this.isCollapse
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .order-detail {
  196. min-height: 100vh;
  197. background: #f7f7f7;
  198. padding-top: 138rpx + 60rpx;
  199. box-sizing: border-box;
  200. &.has-bottom {
  201. padding-bottom: 120rpx;
  202. }
  203. .order-status {
  204. height: 60rpx;
  205. font-size: 26rpx;
  206. line-height: 26rpx;
  207. padding: 34rpx 24rpx 0;
  208. box-sizing: border-box;
  209. color: #ff457b;
  210. background: #fff;
  211. }
  212. .detail-top {
  213. height: 134rpx + 60rpx;
  214. position: fixed;
  215. top: 0;
  216. z-index: 999;
  217. }
  218. .grid {
  219. height: 20rpx;
  220. background: #f7f7f7;
  221. }
  222. .shop-section {
  223. background: #fff;
  224. overflow: hidden;
  225. .line {
  226. width: 702rpx;
  227. height: 1px;
  228. background: #f7f7f7;
  229. margin: 0 auto;
  230. }
  231. .origin {
  232. padding: 0 24rpx;
  233. margin-top: 24rpx;
  234. margin-bottom: 16rpx;
  235. display: flex;
  236. justify-content: flex-start;
  237. align-items: center;
  238. .cover {
  239. width: 56rpx;
  240. height: 56rpx;
  241. border-radius: 4rpx;
  242. border: 1px solid #f7f7f7;
  243. box-sizing: border-box;
  244. }
  245. .name {
  246. margin-left: 16rpx;
  247. font-size: 30rpx;
  248. color: #333333;
  249. font-weight: bold;
  250. }
  251. }
  252. .goods-list {
  253. margin-bottom: 32rpx;
  254. .order-goods {
  255. padding-top: 32rpx;
  256. &:first-child {
  257. padding-top: 0;
  258. }
  259. }
  260. }
  261. }
  262. .total {
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. padding: 0 24rpx;
  267. margin: 32rpx 0;
  268. font-size: 26rpx;
  269. color: #333333;
  270. .count {
  271. font-weight: bold;
  272. }
  273. .status {
  274. color: #ff457b;
  275. .label {
  276. color: #333333;
  277. }
  278. }
  279. }
  280. .order-control {
  281. position: fixed;
  282. width: 100%;
  283. box-sizing: border-box;
  284. height: 100rpx;
  285. display: flex;
  286. justify-content: flex-end;
  287. align-items: center;
  288. bottom: 0;
  289. background: #fff;
  290. &.has-bottom {
  291. bottom: 50rpx;
  292. }
  293. }
  294. .remark {
  295. font-size: 26rpx;
  296. color: #333333;
  297. padding: 0 24rpx;
  298. margin: 32rpx 0;
  299. }
  300. .description {
  301. overflow: hidden;
  302. padding: 0 24rpx;
  303. font-size: 26rpx;
  304. .row {
  305. display: flex;
  306. justify-content: space-between;
  307. align-items: center;
  308. margin: 16rpx 0;
  309. .label {
  310. color: #999999;
  311. &.active {
  312. color: #333333;
  313. }
  314. }
  315. .content {
  316. color: #333333;
  317. &.active {
  318. color: #ff457b;
  319. }
  320. }
  321. }
  322. .collapse {
  323. display: flex;
  324. justify-content: center;
  325. align-items: center;
  326. width: 168rpx;
  327. height: 48rpx;
  328. margin: 24rpx auto 40rpx;
  329. border: 1rpx solid #e1e1e1;
  330. border-radius: 8rpx;
  331. font-size: 24rpx;
  332. color: #b2b2b2;
  333. &.arrowdown,
  334. &.arrowup {
  335. &::after {
  336. content: '';
  337. display: block;
  338. width: 30rpx;
  339. height: 30rpx;
  340. margin-left: 6rpx;
  341. background-repeat: no-repeat;
  342. background-size: 30rpx;
  343. background-position: center;
  344. background-image: url(https://static.caimei365.com/app/mini-hehe/icon/icon-arrowdown.png);
  345. }
  346. }
  347. &.arrowup {
  348. &::after {
  349. transform: rotateZ(180deg);
  350. }
  351. }
  352. }
  353. }
  354. }
  355. </style>