index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view v-if="!isLoading && express.length" class="container">
  3. <!-- 标签栏 -->
  4. <u-tabs v-if="tabs.length > 1" :list="tabs" :isScroll="true" v-model="curTab" :active-color="appTheme.mainBg" :duration="0.2" bar-width="60"
  5. @change="onChangeTab"></u-tabs>
  6. <!-- 商品列表 -->
  7. <view v-show="tabs.length > 1" class="deliver-goods-list i-card clearfix">
  8. <view class="goods-item" v-for="(goods, idx) in express[curTab].goods" :key="idx">
  9. <image class="goods-img" :src="goods.goods.goods_image" alt="商品图片" />
  10. <view class="title">共{{ goods.delivery_num }}件</view>
  11. </view>
  12. </view>
  13. <!-- 物流信息 -->
  14. <view class="express i-card">
  15. <view class="info-item">
  16. <view class="item-lable">物流公司:</view>
  17. <view class="item-content">
  18. <text v-if="express[curTab].delivery_method == 20">无需物流</text>
  19. <text v-else>{{ express[curTab].express ? express[curTab].express.express_name : '--' }}</text>
  20. </view>
  21. </view>
  22. <view class="info-item">
  23. <view class="item-lable">物流单号:</view>
  24. <view class="item-content">
  25. <text>{{ express[curTab].express_no ? express[curTab].express_no : '--' }}</text>
  26. <view v-show="express[curTab].express_no" class="act-copy" @click.stop="handleCopy(express[curTab].express_no)">
  27. <text>复制</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 物流轨迹 -->
  33. <view class="logis-detail" v-if="express[curTab].traces && express[curTab].traces.length">
  34. <view class="logis-item" :class="{ first: index === 0 }" v-for="(item, index) in express[curTab].traces" :key="index">
  35. <view class="logis-item-content">
  36. <view class="logis-item-content__describe">
  37. <text class="f-26">{{ item.context }}</text>
  38. </view>
  39. <view class="logis-item-content__time">
  40. <text class="f-22">{{ item.time }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import * as OrderApi from '@/api/order'
  49. export default {
  50. data() {
  51. return {
  52. // 正在加载
  53. isLoading: true,
  54. // 当前标签索引
  55. curTab: 0,
  56. // 当前订单ID
  57. orderId: null,
  58. // 物流信息
  59. express: {}
  60. }
  61. },
  62. computed: {
  63. tabs() {
  64. if (this.express && this.express.length) {
  65. const test = this.express.map((item, index) => {
  66. return { name: `包裹${index + 1}` }
  67. })
  68. console.log('test', test)
  69. return this.express.map((item, index) => {
  70. return { name: `包裹${index + 1}` }
  71. })
  72. }
  73. return []
  74. }
  75. },
  76. /**
  77. * 生命周期函数--监听页面加载
  78. */
  79. onLoad({ orderId }) {
  80. this.orderId = orderId
  81. // 获取当前订单的物流信息
  82. this.getExpress()
  83. },
  84. methods: {
  85. // 获取当前订单的物流信息
  86. getExpress() {
  87. const app = this
  88. app.isLoading = true
  89. OrderApi.express(app.orderId)
  90. .then(result => {
  91. app.express = result.data.express
  92. app.isLoading = false
  93. })
  94. },
  95. // 复制指定内容
  96. handleCopy(value) {
  97. const app = this
  98. uni.setClipboardData({
  99. data: value,
  100. success: () => app.$toast('复制成功'),
  101. fail: ({ errMsg }) => app.$toast('复制失败 ' + errMsg)
  102. })
  103. },
  104. // 切换标签项
  105. onChangeTab(index) {
  106. this.curTab = index
  107. },
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. // 通栏卡片
  113. .i-card {
  114. background: #fff;
  115. padding: 24rpx 24rpx;
  116. }
  117. // 物流公司
  118. .express {
  119. margin-bottom: 20rpx;
  120. .info-item {
  121. display: flex;
  122. margin-bottom: 24rpx;
  123. &:last-child {
  124. margin-bottom: 0;
  125. }
  126. .item-lable {
  127. display: flex;
  128. align-items: center;
  129. font-size: 24rpx;
  130. color: #999;
  131. margin-right: 6rpx;
  132. }
  133. .item-content {
  134. flex: 1;
  135. display: flex;
  136. align-items: center;
  137. font-size: 26rpx;
  138. color: #333;
  139. .act-copy {
  140. margin-left: 20rpx;
  141. padding: 2rpx 20rpx;
  142. font-size: 22rpx;
  143. color: #666;
  144. border: 1rpx solid #c1c1c1;
  145. border-radius: 16rpx;
  146. }
  147. }
  148. }
  149. }
  150. // 商品列表
  151. .deliver-goods-list {
  152. margin-top: 20rpx;
  153. margin-bottom: -30rpx;
  154. .goods-item {
  155. position: relative;
  156. border-radius: 8rpx;
  157. overflow: hidden;
  158. width: 130rpx;
  159. height: 130rpx;
  160. float: left;
  161. margin-right: 30rpx;
  162. margin-bottom: 30rpx;
  163. }
  164. .goods-img {
  165. display: block;
  166. width: 100%;
  167. height: 100%;
  168. }
  169. .title {
  170. position: absolute;
  171. bottom: 0;
  172. width: 100%;
  173. text-align: center;
  174. background: rgba(0, 0, 0, 0.6);
  175. color: #fff;
  176. padding: 4rpx 0;
  177. font-size: 24rpx;
  178. }
  179. }
  180. // 物流轨迹
  181. .logis-detail {
  182. padding: 30rpx;
  183. background-color: #fff;
  184. .logis-item {
  185. position: relative;
  186. padding: 10px 0 10px 25px;
  187. box-sizing: border-box;
  188. border-left: 2px solid #ccc;
  189. &.first {
  190. border-left: 2px solid #f40;
  191. &:after {
  192. background: #f40;
  193. }
  194. .logis-item-content {
  195. background: #ff6e39;
  196. color: #fff;
  197. &:after {
  198. border-bottom-color: #ff6e39;
  199. }
  200. }
  201. }
  202. &:after {
  203. content: ' ';
  204. display: inline-block;
  205. position: absolute;
  206. left: -6px;
  207. top: 30px;
  208. width: 6px;
  209. height: 6px;
  210. border-radius: 10px;
  211. background: #bdbdbd;
  212. border: 2px solid #fff;
  213. }
  214. .logis-item-content {
  215. position: relative;
  216. background: #f9f9f9;
  217. padding: 10rpx 20rpx;
  218. box-sizing: border-box;
  219. color: #666;
  220. &:after {
  221. content: '';
  222. display: inline-block;
  223. position: absolute;
  224. left: -10px;
  225. top: 18px;
  226. border-left: 10px solid #fff;
  227. border-bottom: 10px solid #f3f3f3;
  228. }
  229. }
  230. }
  231. }
  232. </style>