index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view>
  3. <orderGoods
  4. :productType="orderInfo.type"
  5. :orderId="orderId"
  6. :cartInfo="orderInfo.items"
  7. :jump="false"
  8. />
  9. <view class='logistics'>
  10. <view class='logisticsCon'>
  11. <view class='company acea-row row-between-wrapper'>
  12. <view class='picTxt acea-row row-between-wrapper'>
  13. <view class='iconfont icon-wuliu'></view>
  14. <view class='text'>
  15. <view><text class='name line1'>物流公司:</text> {{ orderInfo.logisticsName }}</view>
  16. <view class='express line1'><text class='name'>快递单号:</text> {{ orderInfo.logisticsNo }}</view>
  17. </view>
  18. </view>
  19. <!-- #ifndef H5 -->
  20. <view class='copy' @tap='copyOrderId'>复制单号</view>
  21. <!-- #endif -->
  22. <!-- #ifdef H5 -->
  23. <view class='copy copy-data' :data-clipboard-text="orderInfo.logisticsNo">复制单号</view>
  24. <!-- #endif -->
  25. </view>
  26. <!-- 物流轨迹 -->
  27. <view class='item' v-for="(item,index) in expressTracks" :key="index">
  28. <view class='circular' :class='index === 0 ? "on":""'></view>
  29. <view class='text' :class='index===0 ? "on-font on":""'>
  30. <view>{{item.content}}</view>
  31. <view class='data' :class='index===0 ? "on-font on":""'>{{ formatDate(item.time) }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. <recommend :hostProduct='hostProduct' v-if="hostProduct.length" />
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import ClipboardJS from "@/plugin/clipboard/clipboard.js";
  41. import { toLogin } from '@/libs/login.js';
  42. import { mapGetters } from "vuex";
  43. import recommend from '@/components/recommend';
  44. import * as OrderApi from '@/api/trade/order.js';
  45. import dayjs from '@/plugin/dayjs/dayjs.min.js';
  46. import orderGoods from "@/components/orderGoods";
  47. import * as ProductSpuApi from '@/api/product/spu.js';
  48. import * as PromotionActivityApi from '@/api/promotion/activity.js';
  49. import * as ProductUtil from '@/utils/product.js'
  50. export default {
  51. components: {
  52. recommend,
  53. orderGoods
  54. },
  55. data() {
  56. return {
  57. orderId: '',
  58. product: {
  59. productInfo: {}
  60. },
  61. orderInfo: {},
  62. expressTracks: [],
  63. hostProduct: [],
  64. loading: false,
  65. goodScroll: true,
  66. params: { // 精品推荐分页
  67. page: 1,
  68. limit: 10,
  69. },
  70. };
  71. },
  72. computed: mapGetters(['isLogin']),
  73. watch:{
  74. isLogin:{
  75. handler:function(newV, oldV) {
  76. if (newV) {
  77. this.getExpress();
  78. this.get_host_product();
  79. }
  80. },
  81. deep:true
  82. }
  83. },
  84. onLoad: function (options) {
  85. if (!this.isLogin) {
  86. toLogin();
  87. return
  88. }
  89. // 解析参数
  90. if (!options.orderId) {
  91. return this.$util.Tips({title:'缺少订单号'});
  92. }
  93. this.orderId = options.orderId;
  94. this.getExpress();
  95. this.get_host_product();
  96. },
  97. onReady: function() {
  98. // #ifdef H5
  99. this.$nextTick(function() {
  100. const clipboard = new ClipboardJS(".copy-data");
  101. clipboard.on("success", () => {
  102. this.$util.Tips({
  103. title: '复制成功'
  104. });
  105. });
  106. });
  107. // #endif
  108. },
  109. methods: {
  110. copyOrderId: function() {
  111. uni.setClipboardData({ data: this.orderInfo.deliveryId });
  112. },
  113. getExpress: function() {
  114. OrderApi.getOrderExpressTrackList(this.orderId).then(res => {
  115. this.$set(this, 'expressTracks', (res.data || []).reverse());
  116. });
  117. OrderApi.getOrderDetail(this.orderId).then(res => {
  118. this.$set(this, 'orderInfo', res.data);
  119. })
  120. },
  121. get_host_product: function () {
  122. this.loading = true
  123. if (!this.goodScroll) {
  124. return
  125. }
  126. ProductSpuApi.getSpuPage({
  127. recommendType: 'hot',
  128. pageNo: this.params.page,
  129. pageSize: this.params.limit
  130. }).then(res => {
  131. this.loading = false
  132. const good_list = res.data.list;
  133. this.params.page++
  134. this.goodScroll = res.data.list.length >= this.params.limit
  135. // 设置营销活动
  136. const spuIds = good_list.map(item => item.id);
  137. if (spuIds.length > 0) {
  138. PromotionActivityApi.getActivityListBySpuIds(spuIds).then(res => {
  139. ProductUtil.setActivityList(good_list, res.data);
  140. this.hostProduct = this.hostProduct.concat(good_list) // 放在此处,避免 Vue 监控不到数组里的元素变化
  141. });
  142. }
  143. });
  144. },
  145. formatDate: function(date) {
  146. return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
  147. }
  148. },
  149. // 滚动到底部
  150. onReachBottom() {
  151. if (this.params.page !== 1) {
  152. this.get_host_product();
  153. }
  154. },
  155. }
  156. </script>
  157. <style scoped lang="scss">
  158. .logistics .header {
  159. padding: 23rpx 30rpx;
  160. background-color: #fff;
  161. height: 166rpx;
  162. box-sizing: border-box;
  163. }
  164. .logistics .header .pictrue {
  165. width: 120rpx;
  166. height: 120rpx;
  167. }
  168. .logistics .header .pictrue image {
  169. width: 100%;
  170. height: 100%;
  171. border-radius: 6rpx;
  172. }
  173. .logistics .header .text {
  174. width: 540rpx;
  175. font-size: 28rpx;
  176. color: #999;
  177. margin-top: 6rpx;
  178. }
  179. .logistics .header .text .name {
  180. width: 365rpx;
  181. color: #282828;
  182. }
  183. .logistics .header .text .money {
  184. text-align: right;
  185. }
  186. .logistics .logisticsCon {
  187. background-color: #fff;
  188. margin: 12rpx 0;
  189. }
  190. .logistics .logisticsCon .company {
  191. height: 120rpx;
  192. margin: 0 0 45rpx 30rpx;
  193. padding-right: 30rpx;
  194. border-bottom: 1rpx solid #f5f5f5;
  195. }
  196. .logistics .logisticsCon .company .picTxt {
  197. width: 520rpx;
  198. }
  199. .logistics .logisticsCon .company .picTxt .iconfont {
  200. width: 50rpx;
  201. height: 50rpx;
  202. background-color: #666;
  203. text-align: center;
  204. line-height: 50rpx;
  205. color: #fff;
  206. font-size: 35rpx;
  207. }
  208. .logistics .logisticsCon .company .picTxt .text {
  209. width: 450rpx;
  210. font-size: 26rpx;
  211. color: #282828;
  212. }
  213. .logistics .logisticsCon .company .picTxt .text .name {
  214. color: #999;
  215. }
  216. .logistics .logisticsCon .company .picTxt .text .express {
  217. margin-top: 5rpx;
  218. }
  219. .logistics .logisticsCon .company .copy {
  220. font-size: 20rpx;
  221. width: 106rpx;
  222. height: 40rpx;
  223. text-align: center;
  224. line-height: 40rpx;
  225. border-radius: 20rpx;
  226. border: 1rpx solid #999;
  227. }
  228. .logistics .logisticsCon .item {
  229. padding: 0 40rpx;
  230. position: relative;
  231. }
  232. .logistics .logisticsCon .item .circular {
  233. width: 20rpx;
  234. height: 20rpx;
  235. border-radius: 50%;
  236. position: absolute;
  237. top: -1rpx;
  238. left: 31.5rpx;
  239. background-color: #ddd;
  240. }
  241. .logistics .logisticsCon .item .circular.on {
  242. background-color: $theme-color;
  243. }
  244. .logistics .logisticsCon .item .text.on-font {
  245. color: $theme-color;
  246. }
  247. .logistics .logisticsCon .item .text .data.on-font {
  248. color: $theme-color;
  249. }
  250. .logistics .logisticsCon .item .text {
  251. font-size: 26rpx;
  252. color: #666;
  253. width: 615rpx;
  254. border-left: 1rpx solid #e6e6e6;
  255. padding: 0 0 60rpx 38rpx;
  256. }
  257. .logistics .logisticsCon .item .text.on {
  258. border-left-color: #f8c1bd;
  259. }
  260. .logistics .logisticsCon .item .text .data {
  261. font-size: 24rpx;
  262. color: #999;
  263. margin-top: 10rpx;
  264. }
  265. .logistics .logisticsCon .item .text .data .time {
  266. margin-left: 15rpx;
  267. }
  268. </style>