index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <page title="物流包裹" ref="pageRef" nav-color="#fff">
  3. <view v-if="data">
  4. <view>
  5. <view v-for="item in data" class="cell" :key="item.id">
  6. <view class="top flex-align-between" v-if="item.expressNo">
  7. <view class="font4">{{ item.expressCompany }}</view>
  8. <view class="flex-align">
  9. <view class="font4">{{ item.expressNo }}</view>
  10. <button
  11. class="btn-clear copy marginL5 flex-shrink0"
  12. @click.stop="$common.copy(item.tradeNo)"
  13. >
  14. 复制
  15. </button>
  16. </view>
  17. </view>
  18. <view class="top" v-else>
  19. <view class="font4">待揽收</view>
  20. </view>
  21. <view class="font4 paddingT8 text-center color-theme">
  22. 共{{ item.num }}种商品
  23. </view>
  24. <view class="itemListBox">
  25. <scroll-view
  26. scroll-x
  27. class="scroll-wrapper itemList"
  28. v-if="item.list.length > 4"
  29. >
  30. <view class="item" v-for="(goods, index) in item.list" :key="index">
  31. <image
  32. class="super"
  33. :src="LEVEL_MAP[goods.data.level].bg"
  34. mode="scaleToFill"
  35. />
  36. <image
  37. class="super-image translateX"
  38. mode="aspectFit"
  39. :src="goods.data.cover"
  40. />
  41. <view
  42. class="bg-title bold"
  43. :style="
  44. 'background-image:url(' + ossurl.welfare.detail.numBg + ')'
  45. "
  46. >
  47. x {{ goods.data.quantity ? goods.data.quantity : goods.total }}
  48. </view>
  49. </view>
  50. </scroll-view>
  51. <view v-else class="flex-align-around padding15 itemList">
  52. <view class="item" v-for="(goods, index) in item.list" :key="index">
  53. <image
  54. class="super"
  55. :src="LEVEL_MAP[goods.data.level].bg"
  56. mode="scaleToFill"
  57. />
  58. <image
  59. class="super-image translateX"
  60. mode="aspectFit"
  61. :src="goods.data.cover"
  62. />
  63. <view
  64. class="bg-title bold"
  65. :style="
  66. 'background-image:url(' + ossurl.welfare.detail.numBg + ')'
  67. "
  68. >
  69. x {{ goods.data.quantity ? goods.data.quantity : goods.total }}
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view v-if="item.expressNo" class="flex-align-end paddingX15 paddingY15">
  75. <view>
  76. <button class="btn marginL15" @click="showExpress(item)">
  77. 查看物流信息
  78. </button>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <empty v-if="isEmpty" :top="200" />
  84. </view>
  85. </page>
  86. </template>
  87. <script>
  88. import empty from '@/components/empty'
  89. import { LEVEL_MAP } from '@/utils/config'
  90. import ossurl from '@/utils/ossurl'
  91. export default {
  92. components: { empty },
  93. data() {
  94. return {
  95. LEVEL_MAP,
  96. data: null,
  97. isEmpty: false,
  98. type: 1,
  99. ossurl
  100. }
  101. },
  102. onLoad(options) {
  103. this.tradeNo = options.tradeNo
  104. this.type = options.type
  105. },
  106. mounted() {
  107. this.getData(true)
  108. },
  109. onPullDownRefresh() {
  110. this.getData()
  111. },
  112. methods: {
  113. async getData(loading = false) {
  114. let res = null
  115. if (this.type == 1) {
  116. res = await this.$service.mall.packages(this.tradeNo, loading)
  117. } else {
  118. res = await this.$service.award.packages(this.tradeNo, loading)
  119. }
  120. this.isEmpty = res && res.length === 0
  121. if (res && res.length > 0) {
  122. res = this.changeData(res)
  123. }
  124. this.data = res
  125. console.log(this.data)
  126. uni.stopPullDownRefresh()
  127. },
  128. showExpress(item) {
  129. this.$router.push('express', {
  130. tradeNo: this.tradeNo,
  131. packageId: item.id,
  132. type: this.type
  133. })
  134. },
  135. changeData(res) {
  136. if (!res) return false
  137. res.forEach((item) => {
  138. item.num = item.itemList.length
  139. let goods = item.itemList
  140. let goodsMap = {}
  141. goods.forEach((item) => {
  142. let key = item.spuId + '_' + item.level
  143. let obj = goodsMap[key]
  144. if (obj) {
  145. goodsMap[key] = {
  146. total: obj.total + 1,
  147. data: obj.data
  148. }
  149. } else {
  150. goodsMap[key] = {
  151. total: 1,
  152. data: item
  153. }
  154. }
  155. })
  156. item.list = Object.values(goodsMap)
  157. })
  158. return res
  159. }
  160. }
  161. }
  162. </script>
  163. <style></style>
  164. <style lang="scss" scoped>
  165. .bg {
  166. position: fixed;
  167. z-index: -1;
  168. left: 0;
  169. right: 0;
  170. top: 0;
  171. width: 100%;
  172. height: 100%;
  173. }
  174. .cell {
  175. margin: 24rpx 28rpx;
  176. background: #fff;
  177. overflow: hidden;
  178. border-radius: 16rpx;
  179. .top {
  180. margin: 0 30rpx;
  181. padding: 20rpx 0;
  182. border-bottom: 2rpx solid rgba(0, 0, 0, 0.05);
  183. }
  184. .copy {
  185. padding: 0 6rpx;
  186. height: 32rpx;
  187. line-height: 32rpx;
  188. border-radius: 8rpx;
  189. text-align: center;
  190. font-size: 24rpx;
  191. background-color: #fec433;
  192. color: #000;
  193. }
  194. .scroll-wrapper {
  195. overflow: hidden;
  196. white-space: nowrap;
  197. width: 100%;
  198. .item {
  199. display: inline-block;
  200. margin-right: 20rpx;
  201. }
  202. }
  203. .item {
  204. width: 158rpx;
  205. height: 206rpx;
  206. position: relative;
  207. background: #ffffff;
  208. border-radius: 12rpx 12rpx 12rpx 12rpx;
  209. margin-right: 12rpx;
  210. .super {
  211. position: absolute;
  212. z-index: 0;
  213. left: 0;
  214. top: 0;
  215. width: 120rpx;
  216. height: 182rpx;
  217. }
  218. .super-image {
  219. width: 158rpx;
  220. height: 206rpx;
  221. border-radius: 6rpx 6rpx 6rpx 6rpx;
  222. background-color: #fff;
  223. }
  224. .bg-title {
  225. width: 36rpx;
  226. height: 32rpx;
  227. background-size: 100% 100%;
  228. font-size: 20rpx;
  229. font-family: Arial, Arial;
  230. font-weight: 400;
  231. color: #ffffff;
  232. line-height: 32rpx;
  233. text-align: center;
  234. position: absolute;
  235. right: 0;
  236. top: 0;
  237. }
  238. }
  239. .btn {
  240. height: 48rpx;
  241. line-height: 48rpx;
  242. text-align: center;
  243. padding: 0 20rpx;
  244. background-color: #fec433;
  245. color: #000;
  246. font-size: 28rpx;
  247. border-radius: 24rpx;
  248. border: none;
  249. box-shadow: none;
  250. ::after {
  251. display: none !important;
  252. }
  253. }
  254. .border-top {
  255. border-top: 2rpx solid rgba(0, 0, 0, 0.05);
  256. }
  257. }
  258. .itemListBox {
  259. padding: 20rpx 28rpx;
  260. }
  261. .itemList {
  262. background: #f8f8f8;
  263. border-radius: 12rpx;
  264. padding: 12rpx;
  265. }
  266. </style>