order-logistics.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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 | dateFormat }} {{ 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/tui-clipboard.js'
  93. import { fetchLogisticsDetail } from '@/services/api/order.js'
  94. import { dateFormat } from '@/common/utils.js'
  95. export default {
  96. filters: {
  97. dateFormat(value) {
  98. if (!value) return '未知'
  99. if (value instanceof Date) {
  100. return dateFormat(value, 'yyyy-MM-dd hh:mm:ss')
  101. } else {
  102. value = new Date(value)
  103. return dateFormat(value, 'yyyy-MM-dd hh:mm:ss')
  104. }
  105. }
  106. },
  107. data() {
  108. return {
  109. orderId: '',
  110. goodsList: []
  111. }
  112. },
  113. onLoad(option) {
  114. //商品数据
  115. this.orderId = option.orderId
  116. this.getData()
  117. },
  118. methods: {
  119. navToListPage(id) {
  120. // this.$router.navigateTo('goods/product')
  121. // this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  122. },
  123. showlogistics(index, loIndex) {
  124. let getGoodsList = this.goodsList[index],
  125. isOpen = getGoodsList.logisticsData[loIndex]['isOpen']
  126. this.goodsList[index].logisticsData[loIndex]['isOpen'] = !isOpen
  127. },
  128. clipboard(data) {
  129. thorui.getClipboardData(data, res => {
  130. if (res) {
  131. this.$toast('复制成功')
  132. } else {
  133. this.$toast('复制失败')
  134. }
  135. })
  136. },
  137. async getData() {
  138. try {
  139. const { data: resData } = await fetchLogisticsDetail({ orderId: this.orderId })
  140. // 添加订单列表信息
  141. let orderListArr = []
  142. resData.forEach((item, index) => {
  143. let logisticsArr = [],
  144. companyList = [],
  145. shopOrderList = item.shopOrderList,
  146. logisticsInfos = item.logisticsInformationList
  147. // 添加物流信息
  148. if (logisticsInfos.length > 0) {
  149. logisticsInfos.forEach((loItem, loIndex) => {
  150. let newRouters = []
  151. logisticsArr.push({
  152. expressname: loItem['logisticsCompanyName'],
  153. expressNumber: loItem['nu'],
  154. expressNewtime: item.deliveryTime,
  155. isOpen: false
  156. })
  157. if (loIndex == 0) {
  158. logisticsArr[loIndex]['isOpen'] = true
  159. }
  160. loItem.routers = JSON.parse(loItem.info)
  161. if (loItem.routers) {
  162. loItem.routers.forEach((rItem, rIndex) => {
  163. newRouters.push({
  164. desc: rItem.context,
  165. time: rItem.time
  166. })
  167. })
  168. logisticsArr[loIndex]['expressRecord'] = [...newRouters]
  169. } else {
  170. logisticsArr[loIndex]['expressRecord'] = []
  171. }
  172. })
  173. }
  174. // 供应商信息
  175. shopOrderList.forEach((shopItem, shopIndex) => {
  176. let prosListArr = [],
  177. cmLogisticsRecords = shopItem.logisticsRecordList
  178. // 商品信息
  179. cmLogisticsRecords.forEach((prosItem, prosIndex) => {
  180. prosListArr.push({
  181. id: prosItem.organizeProductID,
  182. productName: prosItem.productName,
  183. image: prosItem.image,
  184. number: prosItem.buyNum,
  185. logNumber: prosItem.num
  186. })
  187. })
  188. companyList.push({
  189. shopLogo: shopItem.shopLogo,
  190. name: shopItem.shopName,
  191. showGoods: cmLogisticsRecords.length > 0,
  192. productsList: [...prosListArr]
  193. })
  194. })
  195. orderListArr.push({
  196. logisticsData: [...logisticsArr],
  197. companyList: [...companyList]
  198. })
  199. })
  200. this.goodsList = [...orderListArr]
  201. } catch (e) {
  202. console.log('获取物流信息失败')
  203. }
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. page {
  210. height: auto;
  211. }
  212. .logistics-container {
  213. width: 100%;
  214. height: auto;
  215. float: left;
  216. background: #f7f7f7;
  217. border-top: 1px solid #f8f8f8;
  218. .logistics-batch {
  219. display: flex;
  220. flex-direction: column;
  221. margin-bottom: 24rpx;
  222. }
  223. .order-item {
  224. width: 702rpx;
  225. padding: 24rpx 24rpx 12rpx 24rpx;
  226. height: auto;
  227. float: left;
  228. background: #ffffff;
  229. margin-bottom: 20rpx;
  230. .goods-title {
  231. width: 100%;
  232. height: 48rpx;
  233. float: left;
  234. margin-bottom: 12rpx;
  235. .title-logo {
  236. width: 48rpx;
  237. height: 48rpx;
  238. float: left;
  239. border-radius: 8rpx;
  240. border: 1px solid #e1e1e1;
  241. image {
  242. border-radius: 8rpx;
  243. width: 48rpx;
  244. height: 48rpx;
  245. }
  246. }
  247. .title-text {
  248. float: left;
  249. margin-left: 16rpx;
  250. font-size: 28rpx;
  251. color: #333333;
  252. text-align: left;
  253. line-height: 48rpx;
  254. font-weight: bold;
  255. }
  256. }
  257. .goods-item {
  258. width: 100%;
  259. height: auto;
  260. border-bottom: 1px solid #e1e1e1;
  261. &:last-child {
  262. border-bottom: none;
  263. }
  264. }
  265. .goods-pros-t {
  266. display: flex;
  267. align-items: center;
  268. width: 100%;
  269. height: 180rpx;
  270. padding: 20rpx 0;
  271. .pros-img {
  272. width: 180rpx;
  273. height: 180rpx;
  274. border-radius: 10rpx;
  275. margin: 0 26rpx 0 0;
  276. border: 1px solid #f3f3f3;
  277. image {
  278. width: 100%;
  279. height: 100%;
  280. border-radius: 10rpx;
  281. }
  282. }
  283. }
  284. .pros-product {
  285. width: 468rpx;
  286. height: 100%;
  287. line-height: 36rpx;
  288. font-size: 26rpx;
  289. position: relative;
  290. .producttitle {
  291. width: 100%;
  292. display: inline-block;
  293. height: auto;
  294. text-overflow: ellipsis;
  295. display: -webkit-box;
  296. word-break: break-all;
  297. -webkit-box-orient: vertical;
  298. -webkit-line-clamp: 2;
  299. overflow: hidden;
  300. margin-bottom: 28rpx;
  301. }
  302. .productspec {
  303. height: 36rpx;
  304. color: #999999;
  305. line-height: 36rpx;
  306. font-size: 26rpx;
  307. .color {
  308. color: #333333;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. .logistics-template {
  315. width: 702rpx;
  316. height: 100%;
  317. background: #ffffff;
  318. float: left;
  319. padding: 24rpx 24rpx 12rpx 24rpx;
  320. .logistics-content {
  321. width: 100%;
  322. padding: 20rpx 0;
  323. height: auto;
  324. .arrow-showMore {
  325. position: absolute;
  326. right: 24rpx;
  327. z-index: 99;
  328. }
  329. .logistics-top {
  330. width: 100%;
  331. height: 40rpx;
  332. line-height: 40rpx;
  333. font-size: 28rpx;
  334. color: #333;
  335. text-align: left;
  336. padding-bottom: 24rpx;
  337. border-bottom: 1px solid #f8f8f8;
  338. .name {
  339. float: left;
  340. font-weight: bold;
  341. }
  342. .icon-web_xiangxiazhankai {
  343. transform: rotate(0deg);
  344. transform-origin: center center;
  345. float: right;
  346. font-size: 32rpx;
  347. color: #000000;
  348. /* transition: transform 0.3s ease;*/
  349. transition-property: transform;
  350. transition-duration: 0.3s;
  351. transition-timing-function: ease;
  352. }
  353. .icon-web_xiangxiazhankai-active {
  354. transform: rotate(180deg);
  355. }
  356. }
  357. .logistics-warp {
  358. width: 100%;
  359. overflow: hidden;
  360. .table {
  361. height: 76rpx;
  362. line-height: 76rpx;
  363. font-size: 26rpx;
  364. color: #333;
  365. text-align: left;
  366. }
  367. .expressNumber {
  368. width: 250rpx;
  369. display: inline-block;
  370. }
  371. }
  372. .logistics-main-top {
  373. width: 100%;
  374. height: auto;
  375. float: left;
  376. padding-top: 24rpx;
  377. .main-top,
  378. .main-bot {
  379. font-size: 28rpx;
  380. color: #333;
  381. line-height: 40rpx;
  382. margin: 4rpx 0;
  383. }
  384. }
  385. .logistics-main-bot {
  386. position: relative;
  387. width: 100%;
  388. height: auto;
  389. font-size: 24rpx;
  390. color: #333;
  391. line-height: 56rpx;
  392. text-align: justify;
  393. float: left;
  394. padding-left: 40rpx;
  395. margin: 12rpx 0;
  396. &::before {
  397. position: absolute;
  398. left: 0;
  399. top: 18rpx;
  400. content: '';
  401. display: inline-block;
  402. width: 20rpx;
  403. height: 20rpx;
  404. background-color: #555555;
  405. border-radius: 50%;
  406. margin-right: 4rpx;
  407. vertical-align: middle;
  408. }
  409. }
  410. .logistics-animation {
  411. /* transition: transform 0.3s ease;*/
  412. transition-property: transform;
  413. transition-duration: 0.3s;
  414. transition-timing-function: ease;
  415. }
  416. .logistics-warp__wrapper {
  417. /* #ifndef APP-NVUE */
  418. display: flex;
  419. /* #endif */
  420. flex-direction: column;
  421. }
  422. .logistics-warp--hide {
  423. // padding: 0 0;
  424. // height: 0px;
  425. // line-height: 0px;
  426. display: none;
  427. }
  428. .clipboard {
  429. width: 80rpx;
  430. height: 40rpx;
  431. background: #fff8fd;
  432. text-align: center;
  433. font-size: 22rpx;
  434. color: #ff457b;
  435. border-radius: 7rpx;
  436. line-height: 40rpx;
  437. display: inline-block;
  438. }
  439. }
  440. }
  441. </style>