order-logistics.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view class="container logistics clearfix">
  3. <!-- 商品 -->
  4. <view class="logistics-container">
  5. <view class="logistics-batch" v-for="(item, index) in goodsList" :key="index">
  6. <view class="order-item" v-for="(comItem, comIndex) in item.companyList" :key="comIndex">
  7. <view class="goods-title">
  8. <view class="title-logo"><image :src="comItem.shopLogo" mode=""></image></view>
  9. <view class="title-text">{{ comItem.name }}</view>
  10. </view>
  11. <view class="goods-item" v-for="(pros, prosIndex) in comItem.productsList" :key="prosIndex">
  12. <view class="goods-pros-t">
  13. <view class="pros-img"><image :src="pros.image" alt="" /></view>
  14. <view class="pros-product">
  15. <view class="producttitle">{{ pros.productName }}</view>
  16. <view class="productspec">
  17. 购买数量:
  18. <text class="color">{{ pros.number }}</text>
  19. </view>
  20. <view class="productspec">
  21. 已发货数量:
  22. <text class="color">{{ pros.logNumber }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="logistics-template">
  29. <!-- 物流信息 -->
  30. <view
  31. class="logistics-content"
  32. v-if="item.logisticsData.length > 0"
  33. v-for="(logItem, loIndex) in item.logisticsData"
  34. :key="loIndex"
  35. >
  36. <view class="logistics-top"><text class="name">物流信息</text></view>
  37. <view class="logistics-warp">
  38. <view class="logistics-warp__wrapper">
  39. <view class="logistics-main">
  40. <view class="logistics-main-top">
  41. <view class="main-top" @click="showlogistics(index, loIndex)">
  42. {{ logItem.expressname }}:
  43. <text class="expressNumber">{{ logItem.expressNumber }}</text>
  44. <text class="clipboard" @click.stop="clipboard(logItem.expressNumber)">
  45. 复制
  46. </text>
  47. <text
  48. class="arrow-showMore iconfont icon-web_xiangxiazhankai"
  49. :style="{
  50. transform: logItem.isOpen ? 'rotate(180deg)' : 'rotate(0)',
  51. transition: 'transform 0.3s ease'
  52. }"
  53. ></text>
  54. </view>
  55. <view class="main-bot">发货时间:{{ logItem.expressNewtime }}</view>
  56. </view>
  57. <view
  58. v-if="logItem.expressRecord.length > 0"
  59. v-for="(infoItem, infoIndex) in logItem.expressRecord"
  60. :key="infoIndex"
  61. :class="{ 'logistics-warp--hide': !logItem.isOpen }"
  62. class="logistics-main-bot logistics-animation"
  63. :style="{
  64. transform: logItem.isOpen ? 'translateY(0)' : 'translateY(-50%)',
  65. '-webkit-transform': logItem.isOpen ? 'translateY(0)' : 'translateY(-50%)'
  66. }"
  67. >
  68. {{ infoItem.time }} {{ infoItem.desc }}
  69. </view>
  70. <view
  71. v-if="logItem.expressRecord.length < 1"
  72. :class="{ 'logistics-warp--hide': !logItem.isOpen }"
  73. class="logistics-main-bot logistics-animation"
  74. :style="{
  75. transform: logItem.isOpen ? 'translateY(0)' : 'translateY(-50%)',
  76. '-webkit-transform': logItem.isOpen ? 'translateY(0)' : 'translateY(-50%)'
  77. }"
  78. >
  79. 暂无物流信息
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="logistics-content" v-else>暂无物流信息</view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import thorui from '@/components/common/tui-clipboard/clipboard.min.js'
  93. import { fetchLogisticsDetail } from '@/services/api/order.js'
  94. export default {
  95. data() {
  96. return {
  97. orderId: '',
  98. goodsList: []
  99. }
  100. },
  101. onLoad(option) {
  102. //商品数据
  103. this.orderId = option.orderId
  104. this.getData()
  105. },
  106. methods: {
  107. navToListPage(id) {
  108. // this.$router.navigateTo('goods/product')
  109. // this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  110. },
  111. showlogistics(index, loIndex) {
  112. let getGoodsList = this.goodsList[index],
  113. isOpen = getGoodsList.logisticsData[loIndex]['isOpen']
  114. this.goodsList[index].logisticsData[loIndex]['isOpen'] = !isOpen
  115. },
  116. clipboard(data) {
  117. thorui.getClipboardData(data, res => {
  118. if (res) {
  119. this.$toast('复制成功')
  120. } else {
  121. this.$toast('复制失败')
  122. }
  123. })
  124. },
  125. async getData() {
  126. try {
  127. const { data: resData } = fetchLogisticsDetail({ orderId: this.orderId })
  128. // 添加订单列表信息
  129. let orderListArr = []
  130. resData.forEach((item, index) => {
  131. let logisticsArr = [],
  132. companyList = [],
  133. shopOrderList = item.shopOrderList,
  134. logisticsInfos = item.logisticsInformationList
  135. // 添加物流信息
  136. if (logisticsInfos.length > 0) {
  137. logisticsInfos.forEach((loItem, loIndex) => {
  138. let newRouters = []
  139. logisticsArr.push({
  140. expressname: loItem['logisticsCompanyName'],
  141. expressNumber: loItem['nu'],
  142. expressNewtime: item.deliveryTime,
  143. isOpen: false
  144. })
  145. if (loIndex == 0) {
  146. logisticsArr[loIndex]['isOpen'] = true
  147. }
  148. if (loItem.routers) {
  149. loItem.routers.forEach((rItem, rIndex) => {
  150. newRouters.push({
  151. desc: rItem.desc,
  152. time: this.$api.timestampToTime(rItem.time)
  153. })
  154. })
  155. logisticsArr[loIndex]['expressRecord'] = [...newRouters]
  156. } else {
  157. logisticsArr[loIndex]['expressRecord'] = []
  158. }
  159. })
  160. }
  161. // 供应商信息
  162. shopOrderList.forEach((shopItem, shopIndex) => {
  163. let prosListArr = [],
  164. cmLogisticsRecords = shopItem.logisticsRecordList
  165. // 商品信息
  166. cmLogisticsRecords.forEach((prosItem, prosIndex) => {
  167. prosListArr.push({
  168. id: prosItem.organizeProductID,
  169. productName: prosItem.productName,
  170. image: prosItem.image,
  171. number: prosItem.buyNum,
  172. logNumber: prosItem.num
  173. })
  174. })
  175. companyList.push({
  176. shopLogo: shopItem.shopLogo,
  177. name: shopItem.shopName,
  178. showGoods: cmLogisticsRecords.length > 0,
  179. productsList: [...prosListArr]
  180. })
  181. })
  182. orderListArr.push({
  183. logisticsData: [...logisticsArr],
  184. companyList: [...companyList]
  185. })
  186. })
  187. this.goodsList = [...orderListArr]
  188. } catch (e) {
  189. console.log('获取物流信息失败')
  190. }
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. page {
  197. height: auto;
  198. }
  199. .logistics-container {
  200. width: 100%;
  201. height: auto;
  202. float: left;
  203. background: #f7f7f7;
  204. border-top: 1px solid #f8f8f8;
  205. .logistics-batch {
  206. display: flex;
  207. flex-direction: column;
  208. margin-bottom: 24rpx;
  209. }
  210. .order-item {
  211. width: 702rpx;
  212. padding: 24rpx 24rpx 12rpx 24rpx;
  213. height: auto;
  214. float: left;
  215. background: #ffffff;
  216. margin-bottom: 20rpx;
  217. .goods-title {
  218. width: 100%;
  219. height: 48rpx;
  220. float: left;
  221. margin-bottom: 12rpx;
  222. .title-logo {
  223. width: 48rpx;
  224. height: 48rpx;
  225. float: left;
  226. border-radius: 8rpx;
  227. border: 1px solid #e1e1e1;
  228. image {
  229. border-radius: 8rpx;
  230. width: 48rpx;
  231. height: 48rpx;
  232. }
  233. }
  234. .title-text {
  235. float: left;
  236. margin-left: 16rpx;
  237. font-size: 28rpx;
  238. color: #333333;
  239. text-align: left;
  240. line-height: 48rpx;
  241. font-weight: bold;
  242. }
  243. }
  244. .goods-item {
  245. width: 100%;
  246. height: auto;
  247. border-bottom: 1px solid #e1e1e1;
  248. &:last-child {
  249. border-bottom: none;
  250. }
  251. }
  252. .goods-pros-t {
  253. display: flex;
  254. align-items: center;
  255. width: 100%;
  256. height: 180rpx;
  257. padding: 20rpx 0;
  258. .pros-img {
  259. width: 180rpx;
  260. height: 180rpx;
  261. border-radius: 10rpx;
  262. margin: 0 26rpx 0 0;
  263. border: 1px solid #f3f3f3;
  264. image {
  265. width: 100%;
  266. height: 100%;
  267. border-radius: 10rpx;
  268. }
  269. }
  270. }
  271. .pros-product {
  272. width: 468rpx;
  273. height: 100%;
  274. line-height: 36rpx;
  275. font-size: 26rpx;
  276. position: relative;
  277. .producttitle {
  278. width: 100%;
  279. display: inline-block;
  280. height: auto;
  281. text-overflow: ellipsis;
  282. display: -webkit-box;
  283. word-break: break-all;
  284. -webkit-box-orient: vertical;
  285. -webkit-line-clamp: 2;
  286. overflow: hidden;
  287. margin-bottom: 28rpx;
  288. }
  289. .productspec {
  290. height: 36rpx;
  291. color: #999999;
  292. line-height: 36rpx;
  293. font-size: 26rpx;
  294. .color {
  295. color: #333333;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. .logistics-template {
  302. width: 702rpx;
  303. height: 100%;
  304. background: #ffffff;
  305. float: left;
  306. padding: 24rpx 24rpx 12rpx 24rpx;
  307. .logistics-content {
  308. width: 100%;
  309. padding: 20rpx 0;
  310. height: auto;
  311. .arrow-showMore {
  312. position: absolute;
  313. right: 24rpx;
  314. z-index: 99;
  315. }
  316. .logistics-top {
  317. width: 100%;
  318. height: 40rpx;
  319. line-height: 40rpx;
  320. font-size: 28rpx;
  321. color: #333;
  322. text-align: left;
  323. padding-bottom: 24rpx;
  324. border-bottom: 1px solid #f8f8f8;
  325. .name {
  326. float: left;
  327. font-weight: bold;
  328. }
  329. .icon-web_xiangxiazhankai {
  330. transform: rotate(0deg);
  331. transform-origin: center center;
  332. float: right;
  333. font-size: 32rpx;
  334. color: #000000;
  335. /* transition: transform 0.3s ease;*/
  336. transition-property: transform;
  337. transition-duration: 0.3s;
  338. transition-timing-function: ease;
  339. }
  340. .icon-web_xiangxiazhankai-active {
  341. transform: rotate(180deg);
  342. }
  343. }
  344. .logistics-warp {
  345. width: 100%;
  346. overflow: hidden;
  347. .table {
  348. height: 76rpx;
  349. line-height: 76rpx;
  350. font-size: 26rpx;
  351. color: #333;
  352. text-align: left;
  353. }
  354. .expressNumber {
  355. width: 250rpx;
  356. display: inline-block;
  357. }
  358. }
  359. .logistics-main-top {
  360. width: 100%;
  361. height: auto;
  362. float: left;
  363. padding-top: 24rpx;
  364. .main-top,
  365. .main-bot {
  366. font-size: 28rpx;
  367. color: #333;
  368. line-height: 40rpx;
  369. margin: 4rpx 0;
  370. }
  371. }
  372. .logistics-main-bot {
  373. width: 100%;
  374. height: auto;
  375. font-size: 24rpx;
  376. color: #333;
  377. line-height: 56rpx;
  378. text-align: justify;
  379. float: left;
  380. }
  381. .logistics-animation {
  382. /* transition: transform 0.3s ease;*/
  383. transition-property: transform;
  384. transition-duration: 0.3s;
  385. transition-timing-function: ease;
  386. }
  387. .logistics-warp__wrapper {
  388. /* #ifndef APP-NVUE */
  389. display: flex;
  390. /* #endif */
  391. flex-direction: column;
  392. }
  393. .logistics-warp--hide {
  394. // padding: 0 0;
  395. // height: 0px;
  396. // line-height: 0px;
  397. display: none;
  398. }
  399. .clipboard {
  400. width: 80rpx;
  401. height: 40rpx;
  402. background: #fff8fd;
  403. text-align: center;
  404. font-size: 22rpx;
  405. color: #ff457b;
  406. border-radius: 7rpx;
  407. line-height: 40rpx;
  408. display: inline-block;
  409. }
  410. }
  411. }
  412. </style>