orderDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view>
  3. <view class="cont">
  4. <view class="bg"></view>
  5. <view class="inner">
  6. <!-- 订单状态 -->
  7. <!-- 1待支付2已支付 3已发货 4已完成-1已取消 -->
  8. <view class="order-status">
  9. <!-- 待支付 -->
  10. <view v-if="order.status == 1" class="inner">
  11. <view class="img-box">
  12. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/67eda0644e5847008096525b04cd12ca.png" mode=""></image>
  13. </view>
  14. <view class="status-box">
  15. <text class="status">待付款</text>
  16. <text class="desc">请在{{order.expiredTime}}前完成支付</text>
  17. </view>
  18. </view>
  19. <!-- 待发货 -->
  20. <view v-if="order.status == 2" class="inner">
  21. <view class="img-box">
  22. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/520e24fba47441b3b0f73b5250bb0b57.png" mode=""></image>
  23. </view>
  24. <view class="status-box">
  25. <text class="status">待发货</text>
  26. <text class="desc">等待后台发货</text>
  27. </view>
  28. </view>
  29. <!-- 已发货、待收货 -->
  30. <view v-if="order.status == 3" class="inner">
  31. <view class="img-box">
  32. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/1e6ba423ff7e4537bef87a022d530015.png" mode=""></image>
  33. </view>
  34. <view class="status-box">
  35. <text class="status">待收货</text>
  36. <text class="desc">运输中</text>
  37. </view>
  38. </view>
  39. <!-- 已完成 -->
  40. <view v-if="order.status == 4" class="inner">
  41. <view class="img-box">
  42. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/0712ba14f3a648afa69c9912fcbf9b61.png" mode=""></image>
  43. </view>
  44. <view class="status-box">
  45. <text class="status">已完成</text>
  46. <text class="desc">订单已确认收货,交易完成</text>
  47. </view>
  48. </view>
  49. <!--交易取消 -->
  50. <view v-if="order.status == -1" class="inner">
  51. <view class="img-box">
  52. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/02f95bd03e854a9c8076aef1e6c05e74.png" mode=""></image>
  53. </view>
  54. <view class="status-box">
  55. <text class="status">交易关闭</text>
  56. <text class="desc">订单已取消</text>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="content">
  61. <view class="goods-list">
  62. <view class="item">
  63. <view class="img-box">
  64. <image :src="goods.goodsImg==''?'/static/images/drug.svg':goods.goodsImg" mode="aspectFill"></image>
  65. </view>
  66. <view class="info-box">
  67. <view>
  68. <view class="name-box ellipsis2">
  69. {{goods.goodsName}}
  70. </view>
  71. </view>
  72. <view class="price-num">
  73. <view class="price">
  74. <text class="num">¥{{goods.opPrice}}</text>
  75. </view>
  76. <view class="num">x1</view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 订单信息 -->
  82. <view class="order-info">
  83. <view class="title">订单信息</view>
  84. <view class="item">
  85. <text class="label">订单编号</text>
  86. <view class="sn-box">
  87. <text class="text">{{order.orderSn}}</text>
  88. <view class="copy-btn" @click="copyOrderSn(order.orderSn)">复制</view>
  89. </view>
  90. </view>
  91. <view class="item">
  92. <text class="label">下单时间</text>
  93. <text class="text">{{order.createTime}}</text>
  94. </view>
  95. <view class="item">
  96. <text class="label">支付方式</text>
  97. <!-- 支付类型 1-微信 2-微信H5 3-微信APP 4-支付宝 5-支付宝H5 -->
  98. <text class="text" v-if="order.payType==1">微信</text>
  99. <text class="text" v-if="order.payType==4">支付宝</text>
  100. </view>
  101. <view class="item">
  102. <text class="label">订单金额</text>
  103. <text class="text" v-if="order.orderMoney!=null">¥{{order.orderMoney.toFixed(2)}}</text>
  104. </view>
  105. <view class="item">
  106. <text class="label">支付金额</text>
  107. <text class="text" v-if="order.payMoney!=null">¥{{order.payMoney.toFixed(2)}}</text>
  108. </view>
  109. <view class="item">
  110. <text class="label">支付时间</text>
  111. <text class="text">{{order.payTime}}</text>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 按钮 -->
  118. <view class="btn-box">
  119. <!-- <view class="btn cancel" v-if="order.status==1" @click="cancelOrder()">取消订单</view> -->
  120. <view class="btn pay" v-if="order.status==1" @click="pay()">支付</view>
  121. <view class="btn pay" v-if="order.deliverySn!=null" @click="showDelivery()">查看物流</view>
  122. </view>
  123. </view>
  124. </template>
  125. <script>
  126. import{orderDetail}from '@/api/courseAnswer.js'
  127. import {cancelOrder,getPackageOrderById,pay} from '@/api/packageOrder'
  128. export default {
  129. data() {
  130. return {
  131. orderId:null,
  132. order:{},
  133. package:null,
  134. goods:{},
  135. };
  136. },
  137. onLoad(option) {
  138. this.orderId = option.orderId
  139. this.getOrderDetail();
  140. },
  141. onShow() {
  142. },
  143. methods: {
  144. showDelivery() {
  145. uni.navigateTo({
  146. url: '/pages/courseAnswer/orderDelivery?orderId='+this.orderId
  147. })
  148. },
  149. cancelOrder(){
  150. var that=this;
  151. uni.showModal({
  152. title:"提示",
  153. content:"确认取消订单吗?",
  154. showCancel:true,
  155. cancelText:'取消',
  156. confirmText:'确定',
  157. success:res=>{
  158. if(res.confirm){
  159. // 用户点击确定
  160. var data={orderId:that.orderId}
  161. cancelOrder(data).then(
  162. res => {
  163. if(res.code==200){
  164. uni.$emit('refreshPackageOrder');
  165. that.getPackageOrderById()
  166. uni.showToast({
  167. icon:'success',
  168. title: "操作成功",
  169. });
  170. }else{
  171. uni.showToast({
  172. icon:'none',
  173. title: res.msg,
  174. });
  175. }
  176. },
  177. rej => {}
  178. );
  179. }else{
  180. // 否则点击了取消
  181. }
  182. }
  183. })
  184. },
  185. getOrderDetail(){
  186. var data={orderId:this.orderId};
  187. orderDetail(data).then(res => {
  188. if(res.code==200){
  189. this.order=res.data;
  190. this.goods=JSON.parse(res.data.goodsJson)
  191. }else{
  192. uni.showToast({
  193. icon:'none',
  194. title: "请求失败",
  195. });
  196. }
  197. });
  198. },
  199. pay() {
  200. uni.navigateTo({
  201. url: '/pages/courseAnswer/orderPay?orderId='+this.orderId
  202. })
  203. },
  204. // 返回上一页
  205. back() {
  206. let pages = getCurrentPages();
  207. console.log(pages.length);
  208. if(pages.length>1){
  209. uni.navigateBack()
  210. }
  211. else{
  212. uni.reLaunch({
  213. url:"/pages/common/launch"
  214. })
  215. }
  216. },
  217. // 复制订单编号
  218. copyOrderSn(text) {
  219. // 复制方法
  220. uni.setClipboardData({
  221. data:text,
  222. success:()=>{
  223. uni.showToast({
  224. title:'内容已成功复制到剪切板',
  225. icon:'none'
  226. })
  227. }
  228. });
  229. },
  230. }
  231. }
  232. </script>
  233. <style lang="scss">
  234. .goods-list{
  235. margin-top: 20upx;
  236. padding: 0 30upx;
  237. background-color: #FFFFFF;
  238. border-radius: 16upx;
  239. .item{
  240. padding: 30upx 0;
  241. border-bottom: 1px solid #EDEEEF;
  242. display: flex;
  243. align-items: center;
  244. .img-box{
  245. width: 160upx;
  246. height: 160upx;
  247. margin-right: 30upx;
  248. image{
  249. width: 100%;
  250. height: 100%;
  251. }
  252. }
  253. .info-box{
  254. width: calc(100% - 190upx);
  255. height: 160upx;
  256. display: flex;
  257. flex-direction: column;
  258. justify-content: space-between;
  259. .name-box{
  260. font-size: 28upx;
  261. font-family: PingFang SC;
  262. font-weight: 500;
  263. color: #111111;
  264. line-height: 40upx;
  265. .tag{
  266. display: inline-block;
  267. padding: 0 6upx;
  268. height: 30upx;
  269. background: linear-gradient(90deg, #C39A58 0%, #E2C99E 100%);
  270. border-radius: 4upx;
  271. margin-right: 10upx;
  272. font-size: 22upx;
  273. font-family: PingFang SC;
  274. font-weight: bold;
  275. color: #FFFFFF;
  276. line-height: 30upx;
  277. float: left;
  278. margin-top: 7upx;
  279. }
  280. }
  281. .spec{
  282. margin-top: 10upx;
  283. font-size: 24upx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #999999;
  287. line-height: 1;
  288. }
  289. .price-num{
  290. display: flex;
  291. align-items: center;
  292. justify-content: space-between;
  293. .price{
  294. display: flex;
  295. align-items: flex-end;
  296. .unit{
  297. font-size: 24upx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #111111;
  301. line-height: 1.2;
  302. margin-right: 4upx;
  303. }
  304. .num{
  305. font-size: 32upx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #111111;
  309. line-height: 1;
  310. }
  311. }
  312. .num{
  313. font-size: 24upx;
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. color: #999999;
  317. line-height: 1;
  318. }
  319. }
  320. }
  321. }
  322. }
  323. .cont{
  324. width: 100%;
  325. position: relative;
  326. .bg{
  327. width: 100%;
  328. height: 350upx;
  329. position: absolute;
  330. top: 0;
  331. left: 0;
  332. z-index: 1;
  333. background-color: #FF5C03;
  334. background: linear-gradient(#FF5C03, #E2C99E);
  335. border-radius: 0rpx 0rpx 100rpx 100rpx;
  336. }
  337. .inner{
  338. position: relative;
  339. padding: 30upx 0rpx;
  340. width: 100%;
  341. height: 100%;
  342. z-index: 99;
  343. .order-status{
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-between;
  347. padding: 0 30upx;
  348. .inner{
  349. display: flex;
  350. align-items: center;
  351. .img-box{
  352. width: 96upx;
  353. height: 96upx;
  354. margin-right: 30upx;
  355. image{
  356. width: 100%;
  357. height: 100%;
  358. }
  359. }
  360. .status-box{
  361. height: 96upx;
  362. display: flex;
  363. flex-direction: column;
  364. justify-content: center;
  365. .status{
  366. font-size: 40upx;
  367. font-family: PingFang SC;
  368. font-weight: bold;
  369. color: #FFFFFF;
  370. line-height: 1;
  371. }
  372. .desc{
  373. font-size: 26upx;
  374. font-family: PingFang SC;
  375. font-weight: 500;
  376. color: #FFFFFF;
  377. line-height: 1;
  378. margin-top: 30upx;
  379. }
  380. }
  381. }
  382. }
  383. }
  384. }
  385. .content{
  386. margin: 20rpx 0rpx;
  387. padding: 0 20upx 140rpx 20upx;
  388. .order-info{
  389. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  390. margin-top: 20upx;
  391. background: #FFFFFF;
  392. border-radius: 16upx;
  393. padding: 40upx 30upx;
  394. .title{
  395. font-size: 30upx;
  396. font-family: PingFang SC;
  397. font-weight: bold;
  398. color: #222222;
  399. line-height: 1;
  400. }
  401. .item{
  402. margin-top: 40upx;
  403. display: flex;
  404. align-items: center;
  405. justify-content: space-between;
  406. .label{
  407. font-size: 26upx;
  408. font-family: PingFang SC;
  409. font-weight: 500;
  410. color: #666666;
  411. line-height: 1;
  412. }
  413. .text{
  414. font-size: 26upx;
  415. font-family: PingFang SC;
  416. font-weight: 500;
  417. color: #222222;
  418. line-height: 32upx;
  419. }
  420. .cont-text{
  421. font-size: 26upx;
  422. font-family: PingFang SC;
  423. font-weight: 500;
  424. color: #666666;
  425. .bold{
  426. color: #111111;
  427. }
  428. }
  429. .sn-box{
  430. display: flex;
  431. align-items: center;
  432. .copy-btn{
  433. width: 58upx;
  434. height: 32upx;
  435. line-height: 32upx;
  436. text-align: center;
  437. font-size: 22upx;
  438. font-family: PingFang SC;
  439. font-weight: 500;
  440. color: #222222;
  441. background: #F5F5F5;
  442. border-radius: 4upx;
  443. margin-left: 24upx;
  444. }
  445. }
  446. .check-box{
  447. display: flex;
  448. align-items: center;
  449. image{
  450. width: 14upx;
  451. height: 24upx;
  452. margin-left: 10upx;
  453. }
  454. }
  455. }
  456. .line{
  457. width: 100%;
  458. height: 1px;
  459. background: #F0F0F0;
  460. margin-top: 30upx;
  461. }
  462. }
  463. }
  464. .btn-box{
  465. z-index: 99;
  466. bottom: 0;
  467. width: 100%;
  468. position: fixed;
  469. height: 120upx;
  470. box-sizing: border-box;
  471. background: #FFFFFF;
  472. padding: 0 30upx;
  473. display: flex;
  474. align-items: center;
  475. justify-content: flex-end;
  476. .btn{
  477. width: 155upx;
  478. height: 64upx;
  479. line-height: 64upx;
  480. font-size: 26upx;
  481. font-family: PingFang SC;
  482. font-weight: 500;
  483. text-align: center;
  484. border-radius: 32upx;
  485. margin-left: 15upx;
  486. &.cancel{
  487. border: 1px solid #DDDDDD;
  488. color: #666666;
  489. }
  490. &.pay{
  491. background: #FF5C03;
  492. color: #FFFFFF;
  493. }
  494. }
  495. }
  496. </style>