integralOrderDetails.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view>
  3. <view class="cont">
  4. <view class="bg"></view>
  5. <view class="inner">
  6. <!-- 订单状态 -->
  7. <view class="order-status">
  8. <!-- 待发货 -->
  9. <view v-if="order.status == 1" class="inner">
  10. <view class="img-box">
  11. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/520e24fba47441b3b0f73b5250bb0b57.png" mode=""></image>
  12. </view>
  13. <view class="status-box">
  14. <text class="status">待发货</text>
  15. <text class="desc">等待后台发货</text>
  16. </view>
  17. </view>
  18. <!-- 已发货、待收货 -->
  19. <view v-if="order.status == 2" class="inner">
  20. <view class="img-box">
  21. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/1e6ba423ff7e4537bef87a022d530015.png" mode=""></image>
  22. </view>
  23. <view class="status-box">
  24. <text class="status">待收货</text>
  25. <text class="desc">运输中</text>
  26. </view>
  27. </view>
  28. <!-- 已完成 -->
  29. <view v-if="order.status == 3" class="inner">
  30. <view class="img-box">
  31. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/0712ba14f3a648afa69c9912fcbf9b61.png" mode=""></image>
  32. </view>
  33. <view class="status-box">
  34. <text class="status">已完成</text>
  35. <text class="desc">订单已确认收货,交易完成</text>
  36. </view>
  37. </view>
  38. <!--交易取消 -->
  39. <view v-if="order.status == -1" class="inner">
  40. <view class="img-box">
  41. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/02f95bd03e854a9c8076aef1e6c05e74.png" mode=""></image>
  42. </view>
  43. <view class="status-box">
  44. <text class="status">交易关闭</text>
  45. <text class="desc">订单已取消</text>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 下单人信息 -->
  50. <view class="order-placer" v-if="order.userName!=null">
  51. <view class="inner">
  52. <image class="location" src="/static/images/location.png" mode=""></image>
  53. <view class="info">
  54. <view class="name-phone">
  55. <text class="text">{{order.userName}}</text>
  56. <text class="text" v-if="order.userPhone!=null">{{order.userPhone}}</text>
  57. </view>
  58. <view class="address ellipsis2">
  59. {{order.userAddress}}
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="content">
  65. <view class="goods-list">
  66. <view class="item" v-for="(item,index) in itemList" :key=index>
  67. <view class="img-box">
  68. <image :src="item.imgUrl==''?'/static/images/drug.svg':item.imgUrl" mode="aspectFill"></image>
  69. </view>
  70. <view class="info-box">
  71. <view>
  72. <view class="name-box ellipsis2">
  73. {{item.goodsName}}
  74. </view>
  75. </view>
  76. <view class="price-num">
  77. <view class="price">
  78. <text class="unit">健康币:</text>
  79. <text class="num" >{{item.integral}}</text>
  80. </view>
  81. <view class="num" >x{{getItemQuantity(order, item, index)}}</view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 订单信息 -->
  87. <view class="order-info">
  88. <view class="title">订单信息</view>
  89. <view class="item">
  90. <text class="label">订单编号</text>
  91. <view class="sn-box">
  92. <text class="text">{{order.orderCode}}</text>
  93. <view class="copy-btn" @click="copyOrderSn(order.orderCode)">复制</view>
  94. </view>
  95. </view>
  96. <view class="item">
  97. <text class="label">下单时间</text>
  98. <text class="text">{{order.createTime}}</text>
  99. </view>
  100. <view class="item">
  101. <text class="label">使用健康币</text>
  102. <text class="text" >¥{{order.integral}}</text>
  103. </view>
  104. <view class="item" v-if="order.deliveryName!=null">
  105. <text class="label">物流公司</text>
  106. <text class="text" >{{order.deliveryName}}</text>
  107. </view>
  108. <view class="item" v-if="order.deliverySn!=null">
  109. <text class="label">物流单号</text>
  110. <text class="text" >{{order.deliverySn}}</text>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- 按钮 -->
  117. <view class="btn-box">
  118. <!-- <view class="btn cancel">
  119. 联系客服
  120. <button class='contact-btn' open-type="contact">
  121. </button>
  122. </view> -->
  123. <view class="btn pay" v-if="order.deliverySn!=null" @click="showDelivery()">查看物流</view>
  124. </view>
  125. </view>
  126. </template>
  127. <script>
  128. import {getIntegralOrderById} from '@/api/integral.js'
  129. export default {
  130. data() {
  131. return {
  132. orderId:null,
  133. order:null,
  134. item:null,
  135. itemList:[]
  136. };
  137. },
  138. onLoad(option) {
  139. this.orderId = option.orderId
  140. },
  141. onShow() {
  142. this.getIntegralOrderById()
  143. },
  144. methods: {
  145. showDelivery() {
  146. uni.navigateTo({
  147. url: '/pages/user/integral/integralOrderDelivery?orderId='+this.orderId
  148. })
  149. },
  150. getIntegralOrderById(){
  151. var data={orderId:this.orderId};
  152. getIntegralOrderById(data).then(res => {
  153. if(res.code==200){
  154. this.order=res.data;
  155. var parsedData=JSON.parse(this.order.itemJson)
  156. if (Array.isArray(parsedData)) {
  157. this.itemList = parsedData;
  158. } else {
  159. this.itemList = [parsedData];
  160. }
  161. // 解析quantityCart字符串为数组,用于匹配每个商品的数量
  162. if (this.order.quantityCart && typeof this.order.quantityCart === 'string') {
  163. this.order.quantityCartArray = this.order.quantityCart.split(',').map(q => q.trim());
  164. } else if (Array.isArray(this.order.quantityCart)) {
  165. this.order.quantityCartArray = this.order.quantityCart;
  166. } else {
  167. this.order.quantityCartArray = [];
  168. }
  169. }else{
  170. uni.showToast({
  171. icon:'none',
  172. title: "请求失败",
  173. });
  174. }
  175. });
  176. },
  177. // 获取商品数量
  178. getItemQuantity(order, item, index) {
  179. // 优先使用商品项自己的quantity字段
  180. if (item && item.quantity !== undefined && item.quantity !== null) {
  181. return item.quantity;
  182. }
  183. // 如果quantityCart是数组,使用对应索引的数量
  184. if (order.quantityCartArray && Array.isArray(order.quantityCartArray) && order.quantityCartArray[index] !== undefined) {
  185. return order.quantityCartArray[index];
  186. }
  187. // 如果quantityCart是字符串,解析后使用对应索引的数量
  188. if (order.quantityCart && typeof order.quantityCart === 'string') {
  189. const quantities = order.quantityCart.split(',').map(q => q.trim());
  190. if (quantities[index] !== undefined) {
  191. return quantities[index];
  192. }
  193. }
  194. // 如果只有一个商品,直接使用quantityCart
  195. if (this.itemList && this.itemList.length === 1 && order.quantityCart) {
  196. if (typeof order.quantityCart === 'string') {
  197. return order.quantityCart.split(',')[0].trim();
  198. }
  199. return order.quantityCart;
  200. }
  201. // 默认返回1
  202. return 1;
  203. },
  204. // 复制订单编号
  205. copyOrderSn(text) {
  206. // 复制方法
  207. uni.setClipboardData({
  208. data:text,
  209. success:()=>{
  210. uni.showToast({
  211. title:'内容已成功复制到剪切板',
  212. icon:'none'
  213. })
  214. }
  215. });
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .cont{
  222. width: 100%;
  223. position: relative;
  224. .bg{
  225. width: 100%;
  226. height: 350upx;
  227. position: absolute;
  228. top: 0;
  229. left: 0;
  230. z-index: 1;
  231. background-color: #FF5030;
  232. background: linear-gradient(#FF5030, #E2C99E);
  233. border-radius: 0rpx 0rpx 100rpx 100rpx;
  234. }
  235. .inner{
  236. position: relative;
  237. padding: 30upx 0rpx;
  238. width: 100%;
  239. height: 100%;
  240. z-index: 999;
  241. .order-status{
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. padding: 0 30upx;
  246. .inner{
  247. display: flex;
  248. align-items: center;
  249. .img-box{
  250. width: 96upx;
  251. height: 96upx;
  252. margin-right: 30upx;
  253. image{
  254. width: 100%;
  255. height: 100%;
  256. }
  257. }
  258. .status-box{
  259. height: 96upx;
  260. display: flex;
  261. flex-direction: column;
  262. justify-content: center;
  263. .status{
  264. font-size: 40upx;
  265. font-family: PingFang SC;
  266. font-weight: bold;
  267. color: #FFFFFF;
  268. line-height: 1;
  269. }
  270. .desc{
  271. font-size: 26upx;
  272. font-family: PingFang SC;
  273. font-weight: 500;
  274. color: #FFFFFF;
  275. line-height: 1;
  276. margin-top: 30upx;
  277. }
  278. }
  279. }
  280. }
  281. .order-placer{
  282. margin-top: 30upx;
  283. padding: 0 20upx;
  284. .inner{
  285. box-sizing: border-box;
  286. border-radius: 16upx;
  287. height: 150upx;
  288. padding: 40upx 30upx;
  289. display: flex;
  290. align-items: center;
  291. background: #FFFFFF;
  292. .location{
  293. width: 24upx;
  294. height: 27upx;
  295. margin-right: 18upx;
  296. flex-shrink: 0;
  297. }
  298. .info{
  299. .name-phone{
  300. display: flex;
  301. align-items: center;
  302. .text{
  303. font-size: 28upx;
  304. font-family: PingFang SC;
  305. font-weight: bold;
  306. color: #333333;
  307. line-height: 1;
  308. margin-right: 20upx;
  309. &:last-child{
  310. margin-right: 0;
  311. }
  312. }
  313. }
  314. .address{
  315. font-size: 26upx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #999999;
  319. line-height: 1.3;
  320. margin-top: 10upx;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. .content{
  328. margin: 20rpx 0rpx;
  329. padding: 0 20upx 140rpx 20upx;
  330. .goods-list{
  331. padding: 0 30upx;
  332. background-color: #FFFFFF;
  333. border-radius: 16upx;
  334. .item{
  335. padding: 30upx 0;
  336. border-bottom: 1px solid #EDEEEF;
  337. display: flex;
  338. align-items: center;
  339. .img-box{
  340. width: 160upx;
  341. height: 160upx;
  342. margin-right: 30upx;
  343. image{
  344. width: 100%;
  345. height: 100%;
  346. }
  347. }
  348. .info-box{
  349. width: calc(100% - 190upx);
  350. height: 160upx;
  351. display: flex;
  352. flex-direction: column;
  353. justify-content: space-between;
  354. .name-box{
  355. font-size: 28upx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #111111;
  359. line-height: 40upx;
  360. .tag{
  361. display: inline-block;
  362. padding: 0 6upx;
  363. height: 30upx;
  364. background: linear-gradient(90deg, #FF5030 0%, #E2C99E 100%);
  365. border-radius: 4upx;
  366. margin-right: 10upx;
  367. font-size: 22upx;
  368. font-family: PingFang SC;
  369. font-weight: bold;
  370. color: #FFFFFF;
  371. line-height: 30upx;
  372. float: left;
  373. margin-top: 7upx;
  374. }
  375. }
  376. .spec{
  377. margin-top: 18upx;
  378. font-size: 24upx;
  379. font-family: PingFang SC;
  380. font-weight: 500;
  381. color: #999999;
  382. line-height: 1;
  383. }
  384. .price-num{
  385. display: flex;
  386. align-items: center;
  387. justify-content: space-between;
  388. .price{
  389. display: flex;
  390. align-items: flex-end;
  391. .unit{
  392. font-size: 24upx;
  393. font-family: PingFang SC;
  394. font-weight: 500;
  395. color: #111111;
  396. line-height: 1.2;
  397. margin-right: 4upx;
  398. }
  399. .num{
  400. font-size: 32upx;
  401. font-family: PingFang SC;
  402. font-weight: 500;
  403. color: #111111;
  404. line-height: 1;
  405. }
  406. }
  407. .num{
  408. font-size: 24upx;
  409. font-family: PingFang SC;
  410. font-weight: 500;
  411. color: #999999;
  412. line-height: 1;
  413. }
  414. }
  415. }
  416. }
  417. .sub-total{
  418. height: 88upx;
  419. display: flex;
  420. align-items: center;
  421. justify-content: flex-end;
  422. .discount{
  423. font-size: 24upx;
  424. font-family: PingFang SC;
  425. font-weight: 500;
  426. color: #999999;
  427. line-height: 1;
  428. margin-right: 30upx;
  429. }
  430. .label{
  431. font-size: 24upx;
  432. font-family: PingFang SC;
  433. font-weight: 500;
  434. color: #999999;
  435. }
  436. .price{
  437. display: flex;
  438. align-items: flex-end;
  439. .unit{
  440. font-size: 24upx;
  441. font-family: PingFang SC;
  442. font-weight: 500;
  443. color: #FF6633;
  444. line-height: 1.2;
  445. margin-right: 4upx;
  446. }
  447. .num{
  448. font-size: 32upx;
  449. font-family: PingFang SC;
  450. font-weight: bold;
  451. color: #FF6633;
  452. line-height: 1;
  453. }
  454. }
  455. }
  456. }
  457. .order-info{
  458. margin-top: 20upx;
  459. background: #FFFFFF;
  460. border-radius: 16upx;
  461. padding: 40upx 30upx;
  462. .title{
  463. font-size: 30upx;
  464. font-family: PingFang SC;
  465. font-weight: bold;
  466. color: #222222;
  467. line-height: 1;
  468. }
  469. .item{
  470. margin-top: 40upx;
  471. display: flex;
  472. align-items: center;
  473. justify-content: space-between;
  474. .label{
  475. font-size: 26upx;
  476. font-family: PingFang SC;
  477. font-weight: 500;
  478. color: #666666;
  479. line-height: 1;
  480. }
  481. .text{
  482. font-size: 26upx;
  483. font-family: PingFang SC;
  484. font-weight: 500;
  485. color: #222222;
  486. line-height: 32upx;
  487. }
  488. .cont-text{
  489. font-size: 26upx;
  490. font-family: PingFang SC;
  491. font-weight: 500;
  492. color: #666666;
  493. .bold{
  494. color: #111111;
  495. }
  496. }
  497. .sn-box{
  498. display: flex;
  499. align-items: center;
  500. .copy-btn{
  501. width: 58upx;
  502. height: 32upx;
  503. line-height: 32upx;
  504. text-align: center;
  505. font-size: 22upx;
  506. font-family: PingFang SC;
  507. font-weight: 500;
  508. color: #222222;
  509. background: #F5F5F5;
  510. border-radius: 4upx;
  511. margin-left: 24upx;
  512. }
  513. }
  514. .check-box{
  515. display: flex;
  516. align-items: center;
  517. image{
  518. width: 14upx;
  519. height: 24upx;
  520. margin-left: 10upx;
  521. }
  522. }
  523. }
  524. .line{
  525. width: 100%;
  526. height: 1px;
  527. background: #F0F0F0;
  528. margin-top: 30upx;
  529. }
  530. }
  531. }
  532. .btn-box{
  533. z-index: 999;
  534. bottom: 0;
  535. width: 100%;
  536. position: fixed;
  537. height: 120upx;
  538. box-sizing: border-box;
  539. background: #FFFFFF;
  540. padding: 0 30upx;
  541. display: flex;
  542. align-items: center;
  543. justify-content: flex-end;
  544. .btn{
  545. position: relative;
  546. width: 155upx;
  547. height: 64upx;
  548. line-height: 64upx;
  549. font-size: 26upx;
  550. font-family: PingFang SC;
  551. font-weight: 500;
  552. text-align: center;
  553. border-radius: 32upx;
  554. margin-left: 15upx;
  555. &.cancel{
  556. border: 1px solid #DDDDDD;
  557. color: #666666;
  558. }
  559. &.pay{
  560. background: #FF5030;
  561. color: #FFFFFF;
  562. }
  563. .contact-btn {
  564. top: 0;
  565. position: absolute;
  566. width:100%;
  567. height:100%;
  568. opacity: 0;
  569. }
  570. }
  571. }
  572. </style>