orderDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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>
  122. </view>
  123. </template>
  124. <script>
  125. import{orderDetail}from '@/api/courseAnswer.js'
  126. import {cancelOrder,getPackageOrderById,pay} from '@/api/packageOrder'
  127. export default {
  128. data() {
  129. return {
  130. orderId:null,
  131. order:{},
  132. package:null,
  133. goods:{},
  134. };
  135. },
  136. onLoad(option) {
  137. this.orderId = option.orderId
  138. this.getOrderDetail();
  139. },
  140. onShow() {
  141. },
  142. methods: {
  143. cancelOrder(){
  144. var that=this;
  145. uni.showModal({
  146. title:"提示",
  147. content:"确认取消订单吗?",
  148. showCancel:true,
  149. cancelText:'取消',
  150. confirmText:'确定',
  151. success:res=>{
  152. if(res.confirm){
  153. // 用户点击确定
  154. var data={orderId:that.orderId}
  155. cancelOrder(data).then(
  156. res => {
  157. if(res.code==200){
  158. uni.$emit('refreshPackageOrder');
  159. that.getPackageOrderById()
  160. uni.showToast({
  161. icon:'success',
  162. title: "操作成功",
  163. });
  164. }else{
  165. uni.showToast({
  166. icon:'none',
  167. title: res.msg,
  168. });
  169. }
  170. },
  171. rej => {}
  172. );
  173. }else{
  174. // 否则点击了取消
  175. }
  176. }
  177. })
  178. },
  179. getOrderDetail(){
  180. var data={orderId:this.orderId};
  181. orderDetail(data).then(res => {
  182. if(res.code==200){
  183. this.order=res.data;
  184. this.goods=JSON.parse(res.data.goodsJson)
  185. }else{
  186. uni.showToast({
  187. icon:'none',
  188. title: "请求失败",
  189. });
  190. }
  191. });
  192. },
  193. pay() {
  194. uni.navigateTo({
  195. url: '/pages/courseAnswer/orderPay?orderId='+this.orderId
  196. })
  197. },
  198. // 返回上一页
  199. back() {
  200. let pages = getCurrentPages();
  201. console.log(pages.length);
  202. if(pages.length>1){
  203. uni.navigateBack()
  204. }
  205. else{
  206. uni.reLaunch({
  207. url:"/pages/common/launch"
  208. })
  209. }
  210. },
  211. // 复制订单编号
  212. copyOrderSn(text) {
  213. // 复制方法
  214. uni.setClipboardData({
  215. data:text,
  216. success:()=>{
  217. uni.showToast({
  218. title:'内容已成功复制到剪切板',
  219. icon:'none'
  220. })
  221. }
  222. });
  223. },
  224. }
  225. }
  226. </script>
  227. <style lang="scss">
  228. .goods-list{
  229. margin-top: 20upx;
  230. padding: 0 30upx;
  231. background-color: #FFFFFF;
  232. border-radius: 16upx;
  233. .item{
  234. padding: 30upx 0;
  235. border-bottom: 1px solid #EDEEEF;
  236. display: flex;
  237. align-items: center;
  238. .img-box{
  239. width: 160upx;
  240. height: 160upx;
  241. margin-right: 30upx;
  242. image{
  243. width: 100%;
  244. height: 100%;
  245. }
  246. }
  247. .info-box{
  248. width: calc(100% - 190upx);
  249. height: 160upx;
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: space-between;
  253. .name-box{
  254. font-size: 28upx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #111111;
  258. line-height: 40upx;
  259. .tag{
  260. display: inline-block;
  261. padding: 0 6upx;
  262. height: 30upx;
  263. background: linear-gradient(90deg, #C39A58 0%, #E2C99E 100%);
  264. border-radius: 4upx;
  265. margin-right: 10upx;
  266. font-size: 22upx;
  267. font-family: PingFang SC;
  268. font-weight: bold;
  269. color: #FFFFFF;
  270. line-height: 30upx;
  271. float: left;
  272. margin-top: 7upx;
  273. }
  274. }
  275. .spec{
  276. margin-top: 10upx;
  277. font-size: 24upx;
  278. font-family: PingFang SC;
  279. font-weight: 500;
  280. color: #999999;
  281. line-height: 1;
  282. }
  283. .price-num{
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-between;
  287. .price{
  288. display: flex;
  289. align-items: flex-end;
  290. .unit{
  291. font-size: 24upx;
  292. font-family: PingFang SC;
  293. font-weight: 500;
  294. color: #111111;
  295. line-height: 1.2;
  296. margin-right: 4upx;
  297. }
  298. .num{
  299. font-size: 32upx;
  300. font-family: PingFang SC;
  301. font-weight: 500;
  302. color: #111111;
  303. line-height: 1;
  304. }
  305. }
  306. .num{
  307. font-size: 24upx;
  308. font-family: PingFang SC;
  309. font-weight: 500;
  310. color: #999999;
  311. line-height: 1;
  312. }
  313. }
  314. }
  315. }
  316. }
  317. .cont{
  318. width: 100%;
  319. position: relative;
  320. .bg{
  321. width: 100%;
  322. height: 350upx;
  323. position: absolute;
  324. top: 0;
  325. left: 0;
  326. z-index: 1;
  327. background-color: #FF5C03;
  328. background: linear-gradient(#FF5C03, #E2C99E);
  329. border-radius: 0rpx 0rpx 100rpx 100rpx;
  330. }
  331. .inner{
  332. position: relative;
  333. padding: 30upx 0rpx;
  334. width: 100%;
  335. height: 100%;
  336. z-index: 99;
  337. .order-status{
  338. display: flex;
  339. align-items: center;
  340. justify-content: space-between;
  341. padding: 0 30upx;
  342. .inner{
  343. display: flex;
  344. align-items: center;
  345. .img-box{
  346. width: 96upx;
  347. height: 96upx;
  348. margin-right: 30upx;
  349. image{
  350. width: 100%;
  351. height: 100%;
  352. }
  353. }
  354. .status-box{
  355. height: 96upx;
  356. display: flex;
  357. flex-direction: column;
  358. justify-content: center;
  359. .status{
  360. font-size: 40upx;
  361. font-family: PingFang SC;
  362. font-weight: bold;
  363. color: #FFFFFF;
  364. line-height: 1;
  365. }
  366. .desc{
  367. font-size: 26upx;
  368. font-family: PingFang SC;
  369. font-weight: 500;
  370. color: #FFFFFF;
  371. line-height: 1;
  372. margin-top: 30upx;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. }
  379. .content{
  380. margin: 20rpx 0rpx;
  381. padding: 0 20upx 140rpx 20upx;
  382. .order-info{
  383. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  384. margin-top: 20upx;
  385. background: #FFFFFF;
  386. border-radius: 16upx;
  387. padding: 40upx 30upx;
  388. .title{
  389. font-size: 30upx;
  390. font-family: PingFang SC;
  391. font-weight: bold;
  392. color: #222222;
  393. line-height: 1;
  394. }
  395. .item{
  396. margin-top: 40upx;
  397. display: flex;
  398. align-items: center;
  399. justify-content: space-between;
  400. .label{
  401. font-size: 26upx;
  402. font-family: PingFang SC;
  403. font-weight: 500;
  404. color: #666666;
  405. line-height: 1;
  406. }
  407. .text{
  408. font-size: 26upx;
  409. font-family: PingFang SC;
  410. font-weight: 500;
  411. color: #222222;
  412. line-height: 32upx;
  413. }
  414. .cont-text{
  415. font-size: 26upx;
  416. font-family: PingFang SC;
  417. font-weight: 500;
  418. color: #666666;
  419. .bold{
  420. color: #111111;
  421. }
  422. }
  423. .sn-box{
  424. display: flex;
  425. align-items: center;
  426. .copy-btn{
  427. width: 58upx;
  428. height: 32upx;
  429. line-height: 32upx;
  430. text-align: center;
  431. font-size: 22upx;
  432. font-family: PingFang SC;
  433. font-weight: 500;
  434. color: #222222;
  435. background: #F5F5F5;
  436. border-radius: 4upx;
  437. margin-left: 24upx;
  438. }
  439. }
  440. .check-box{
  441. display: flex;
  442. align-items: center;
  443. image{
  444. width: 14upx;
  445. height: 24upx;
  446. margin-left: 10upx;
  447. }
  448. }
  449. }
  450. .line{
  451. width: 100%;
  452. height: 1px;
  453. background: #F0F0F0;
  454. margin-top: 30upx;
  455. }
  456. }
  457. }
  458. .btn-box{
  459. z-index: 99;
  460. bottom: 0;
  461. width: 100%;
  462. position: fixed;
  463. height: 120upx;
  464. box-sizing: border-box;
  465. background: #FFFFFF;
  466. padding: 0 30upx;
  467. display: flex;
  468. align-items: center;
  469. justify-content: flex-end;
  470. .btn{
  471. width: 155upx;
  472. height: 64upx;
  473. line-height: 64upx;
  474. font-size: 26upx;
  475. font-family: PingFang SC;
  476. font-weight: 500;
  477. text-align: center;
  478. border-radius: 32upx;
  479. margin-left: 15upx;
  480. &.cancel{
  481. border: 1px solid #DDDDDD;
  482. color: #666666;
  483. }
  484. &.pay{
  485. background: #FF5C03;
  486. color: #FFFFFF;
  487. }
  488. }
  489. }
  490. </style>