integralOrderDetails.vue 14 KB

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