detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <template>
  2. <view class="order-detail">
  3. <view class="status-box">
  4. <view class="text-box">
  5. <view class="status" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT' && !isNotTime">
  6. 等待支付,剩余<u-count-down :time="closeTime" format="mm:ss" @finish="finish"></u-count-down>
  7. </view>
  8. <view
  9. v-else
  10. class="status">
  11. {{ filterType(info.goodsList[0].goodsState) || "订单错误" }}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="content progress" v-if="
  16. info.goodsList[0].goodsState == 'APPLY_REFUND' ||
  17. info.goodsList[0].goodsState == 'REFUNDED'
  18. " @click="refundDetail">
  19. <view class="progress-title"> 退款进度 </view>
  20. <view class="progress-desc"> 查看退款详情 </view>
  21. </view>
  22. <view class="content info">
  23. <view class="order-info">
  24. <image class="icon" :src="info.goodsList[0].goodsInfo.goodsPath" mode=""></image>
  25. <view class="shop-info">
  26. <view class="title">
  27. {{ info.goodsList[0].goodsInfo.goodsName }}
  28. </view>
  29. <view class="goods-desc">
  30. {{ info.goodsList[0].goodsInfo.goodsDescribe }}
  31. </view>
  32. <view class="price-box">
  33. <view class="price">
  34. ¥{{ info.goodsList[0].goodsInfo.realPrice }}
  35. </view>
  36. </view>
  37. <!-- 有extend并且不是虚拟商品 -->
  38. <!-- <view class="start-time" v-if="info.extend&&!isVisual">
  39. 出发时间:{{info.extend}}
  40. </view> -->
  41. </view>
  42. </view>
  43. </view>
  44. <view class="input-box-address" @click="toMap()">
  45. <view class="label"> 到店自取地址 </view>
  46. <view class="value">
  47. <!-- {{ info.address }} -->
  48. 印象贵大文创店
  49. </view>
  50. <view class="label"> 贵州大学西校区西一区体育场楼下</view>
  51. </view>
  52. <view class="content code-box" v-if="
  53. info.goodsList[0].goodsState == 'WAIT_USE' &&
  54. info.goodsList[0].goodsName != '二维码支付'
  55. ">
  56. <view class="left">
  57. <view class="title"> 券码信息 </view>
  58. <view class="codeNum"> </view>
  59. </view>
  60. <view class="code-btn" @click="checkCode">
  61. 查看券码
  62. <image class="jiantou" src="../../static/jiantou-icon.png" mode=""></image>
  63. </view>
  64. </view>
  65. <view class="content" v-if="info.goodsList[0].goodsState == 'USED'">
  66. <view class="title"> 消费记录 </view>
  67. <view class="item">
  68. <view class="label"> 消费时间 </view>
  69. <view class="value">
  70. {{
  71. $u.timeFormat(
  72. info.goodsList[0].verifyModel.checkTime,
  73. "yyyy-mm-dd hh:MM:ss"
  74. )
  75. }}
  76. </view>
  77. </view>
  78. <view class="item">
  79. <view class="label"> 消费门店 </view>
  80. <view class="value">
  81. {{ info.goodsList[0].verifyModel.shopName }}
  82. </view>
  83. </view>
  84. </view>
  85. <view class="content">
  86. <view class="title"> 订单信息 </view>
  87. <view class="item">
  88. <view class="label"> 订单编号 </view>
  89. <view class="value">
  90. {{ info.orderNo }}
  91. </view>
  92. </view>
  93. <view class="item">
  94. <view class="label"> 付款方式 </view>
  95. <view class="value">
  96. {{ info.payment.pay ? filterPay(info.payment.paymentWay) : "未支付" }}
  97. </view>
  98. </view>
  99. <view class="item">
  100. <view class="label"> 下单时间 </view>
  101. <view class="value">
  102. {{
  103. $u.timeFormat(info.createTime, "yyyy-mm-dd hh:MM:ss") || "未支付"
  104. }}
  105. </view>
  106. </view>
  107. <view class="item" v-if="
  108. info.goodsList[0].goodsState != 'WAIT_PAYMENT' &&
  109. info.goodsList[0].goodsState != 'CLOSE'
  110. ">
  111. <view class="label"> 支付时间 </view>
  112. <view class="value">
  113. {{ $u.timeFormat(info.payment.paymentTime, "yyyy-mm-dd hh:MM:ss") }}
  114. </view>
  115. </view>
  116. <view class="item">
  117. <view class="label" style="word-break: keep-all; margin-right: 20rpx;"> 订单备注 </view>
  118. <view class="value" style="word-break: break-word;">
  119. {{
  120. info.extend.remark || "无"
  121. }}
  122. </view>
  123. </view>
  124. </view>
  125. <view class="content">
  126. <view class="title"> 交易信息 </view>
  127. <view class="item">
  128. <view class="label"> 商品金额 </view>
  129. <view class="value black">
  130. ¥{{ info.goodsList[0].goodsInfo.realPrice }}
  131. </view>
  132. </view>
  133. <view class="item">
  134. <view class="label"> 优惠券 </view>
  135. <view class="value red"> -¥{{ info.discountAmount }} </view>
  136. </view>
  137. <view class="item">
  138. <view class="label"> 合计 </view>
  139. <view class="value">
  140. <text class="red fs28">¥{{ info.payAmount }}</text>
  141. </view>
  142. </view>
  143. </view>
  144. <view class="input-box" v-if="isVisual">
  145. <view class="label"> 充值账号 </view>
  146. <view class="value">
  147. {{ JSON.parse(info.extend).account }}
  148. </view>
  149. </view>
  150. <template v-if="info.goodsList[0].goodsState == 'APPLY_REFUND'">
  151. <view class="content refund-box">
  152. <view class="title"> 退款原因 </view>
  153. <view class="refund-msg">
  154. {{ info.goodsList[0].refundLog.remark }}
  155. </view>
  156. </view>
  157. <button type="default" :loading="btnLoading" v-if="!info.payment.transferAll" class="pay-btn"
  158. @click="cancelReply">
  159. 取消退款
  160. </button>
  161. </template>
  162. <button type="default" :loading="btnLoading" class="pay-btn" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'"
  163. @click="pay">
  164. 立即支付
  165. </button>
  166. <view class="content apply-box" v-else-if="
  167. (info.goodsList[0].goodsState == 'WAIT_USE' ||
  168. info.goodsList[0].goodsState == 'USED') &&
  169. isRefund()
  170. " @click="apply">
  171. <view class="label"> 退款申请 </view>
  172. <view class="value"> 如引发商品争议,可申请平台介入处理 </view>
  173. <image class="jiantou" src="../../static/jiantou-icon.png" mode=""></image>
  174. </view>
  175. <!-- 二维码 -->
  176. <u-overlay :show="show" v-if="show" :opacity="0.6">
  177. <view class="wrap" @click.stop="close">
  178. <uqrcode ref="uqrcode" type="2d" auto canvas-id="qrcode" :value="codeData" :loading="loading"
  179. :options="{ margin: 20 }">
  180. <template v-slot:loading>
  181. <text style="color: black">拼命加载中...</text>
  182. </template>
  183. </uqrcode>
  184. </view>
  185. </u-overlay>
  186. </view>
  187. </template>
  188. <script>
  189. import { qrCode } from "@/api/order.js";
  190. import { payDetails, queryPayOrder, unRefund } from "@/api/payment.js";
  191. export default {
  192. data() {
  193. return {
  194. isVisual: false, //是否是虚拟商品
  195. codeData: "123",
  196. show: false,
  197. isJumped: false,
  198. loading: false,
  199. btnLoading: false,
  200. oldBright: 0,
  201. info: {
  202. goodsList: [{ goodsState: "" }],
  203. payment: {
  204. paymentWay: "",
  205. pay: false
  206. },
  207. extend: "",
  208. },
  209. isNotTime: false,
  210. };
  211. },
  212. watch: {
  213. // isNotTime(val) {
  214. // if(this.isNotTime){
  215. // this.payDetails(this.info.orderNo)
  216. // }
  217. // }
  218. },
  219. filters: {
  220. },
  221. computed: {
  222. closeTime() {
  223. // if((this.info.createTime + 1000*60*15) - new Date().getTime()){
  224. // this.isNotTime = false
  225. // }else{
  226. // this.isNotTime = true
  227. // }
  228. return (this.info.createTime + 1000 * 60 * 30) - new Date().getTime()
  229. },
  230. },
  231. methods: {
  232. filterType: function (val) {
  233. if (val == "APPLY_REFUND") {
  234. return "退款审核中";
  235. } else if (val == "CLOSE") {
  236. return "关闭订单";
  237. } else if (val == "REFUNDED") {
  238. return "已退款";
  239. } else if (val == "REFUSAL_REFUND") {
  240. return "拒绝退款";
  241. } else if (val == "USED") {
  242. return "订单已完成";
  243. } else if (val == "WAIT_PAYMENT") {
  244. return "待付款";
  245. } else if (val == "HAVE_PAID") {
  246. return "待使用";
  247. } else if (val == "WAIT_USE") {
  248. return "待使用";
  249. }
  250. },
  251. filterPay(val) {
  252. if (val == "wx.unifiedOrder") {
  253. return "微信支付";
  254. } else if (val == "trade.create") {
  255. return "支付宝支付";
  256. } else if (val == "uac.miniOrder") {
  257. return "云闪付支付";
  258. } else if (val == "wx.miniPreOrder") {
  259. return "银联支付"
  260. } else {
  261. return "-";
  262. }
  263. },
  264. isRefund() {
  265. if (!this.info.goodsList[0].verifyModel) {
  266. //没核销
  267. return true;
  268. } else if (
  269. this.info.goodsList[0].verifyModel &&
  270. new Date().getTime() <
  271. this.info.goodsList[0].verifyModel.checkTime + 1000 * 60 * 60 * 48
  272. ) {
  273. // 已核销 并且没超过48小时
  274. return true;
  275. } else {
  276. return false;
  277. }
  278. },
  279. finish() {
  280. this.isNotTime = true;
  281. console.log(222222, this.isNotTime);
  282. this.payDetails(this.info.orderNo);
  283. },
  284. refundDetail() {
  285. uni.navigateTo({
  286. url: `/my/order/refundDetail?id=${this.info.orderNo}`,
  287. });
  288. },
  289. checkCode() {
  290. this.codeData = "";
  291. this.$nextTick(() => {
  292. this.show = true;
  293. this.loading = true;
  294. let that = this;
  295. // uni.getScreenBrightness({
  296. // success(res) {
  297. // // 获取用户手机亮度 保存起来
  298. // that.oldBright = res.value
  299. // setTimeout(()=>{
  300. // uni.setScreenBrightness({
  301. // value:1
  302. // })
  303. // },200)
  304. // }
  305. // })
  306. qrCode(this.info.goodsList[0].id).then((res) => {
  307. this.loading = false;
  308. if (res.state == "Success") {
  309. this.codeData = res.content;
  310. }
  311. });
  312. });
  313. },
  314. close() {
  315. this.show = false;
  316. // uni.setScreenBrightness({
  317. // value:this.oldBright
  318. // })
  319. },
  320. apply() {
  321. let that = this;
  322. uni.navigateTo({
  323. url: "./refund",
  324. success: function (res) {
  325. // 通过eventChannel向被打开页面传送数据
  326. res.eventChannel.emit("orderInfo", that.info);
  327. },
  328. });
  329. },
  330. // 获取订单详情
  331. payDetails(orderNo) {
  332. payDetails(orderNo).then((res) => {
  333. this.info = res.content;
  334. if (!this.info.payment) {
  335. this.info.payment = {
  336. paymentWay: "",
  337. pay: false
  338. }
  339. }
  340. queryPayOrder(this.info.orderNo).then(res => {
  341. // console.log('res111',res);
  342. if (res.state == "Fail") {
  343. uni.showToast({
  344. title: "支付信息获取失败,请稍后再试.",
  345. icon: "none",
  346. });
  347. }
  348. })
  349. this.info.extend = JSON.parse(this.info.goodsList[0].extend);
  350. if (this.isJumped) {
  351. this.isJumped = false;
  352. const that = this;
  353. let checkTime = 0;
  354. uni.showLoading({
  355. title: "支付中",
  356. });
  357. const checkOrder = setInterval(() => {
  358. queryPayOrder(that.info.orderNo)
  359. .then((res1) => {
  360. // 支付成功
  361. if (res1.content.status == "TRADE_SUCCESS") {
  362. that.payDetails(that.info.orderNo);
  363. uni.showToast({
  364. title: "支付成功!",
  365. icon: "none",
  366. });
  367. clearInterval(checkOrder)
  368. uni.hideLoading();
  369. that.btnLoading = false;
  370. } else {
  371. checkTime++;
  372. }
  373. if (checkTime > 5) {
  374. clearInterval(checkOrder)
  375. that.btnLoading = false;
  376. uni.showToast({
  377. title: "订单查询失败",
  378. icon: "none",
  379. });
  380. uni.hideLoading();
  381. }
  382. }).catch(() => {
  383. if (checkOrder) {
  384. clearInterval(checkOrder)
  385. checkOrder = null
  386. }
  387. that.btnLoading = false;
  388. uni.showToast({
  389. title: "订单查询失败",
  390. icon: "none",
  391. });
  392. uni.hideLoading();
  393. })
  394. }, 1000);
  395. }
  396. });
  397. },
  398. toMap() {
  399. uni.openLocation({
  400. latitude: 26.4401,
  401. longitude: 106.664,
  402. name: "印象贵大文创店",
  403. address: "贵州大学西校区西一区体育场楼下",
  404. });
  405. },
  406. // 支付
  407. pay() {
  408. if (this.btnLoading) return;
  409. this.btnLoading = true;
  410. uni.showLoading({
  411. title: "支付中",
  412. });
  413. let that = this;
  414. let miniPayRequest = this.info.payment.miniPayRequest;
  415. miniPayRequest = JSON.parse(miniPayRequest);
  416. let query = encodeURIComponent(JSON.stringify({
  417. sign: miniPayRequest.sign,
  418. prepayid: miniPayRequest.prepayid,
  419. }))
  420. // 打开银联小程序
  421. uni.navigateToMiniProgram({
  422. appId: miniPayRequest.miniuser,
  423. path: `${miniPayRequest.minipath}?appPayRequest=${query}`,
  424. success: (res) => {
  425. // 打开成功
  426. this.isJumped = true;
  427. },
  428. fail: (err) => {
  429. // console.log(err);
  430. uni.hideLoading();
  431. uni.showToast({
  432. title: "取消支付",
  433. icon: "none",
  434. });
  435. that.btnLoading = false
  436. },
  437. });
  438. },
  439. // 取消退款申请
  440. cancelReply() {
  441. if (this.btnLoading) return;
  442. this.btnLoading = true;
  443. uni.showLoading({
  444. title: "取消中",
  445. });
  446. unRefund({ id: this.info.goodsList[0].id }).then((res) => {
  447. this.btnLoading = false;
  448. uni.hideLoading();
  449. if (res.state == "Success") {
  450. this.payDetails(this.info.orderNo);
  451. uni.showToast({
  452. title: "取消成功",
  453. icon: "success",
  454. });
  455. }
  456. });
  457. },
  458. },
  459. onReady() { },
  460. onLoad(options) {
  461. this.info.orderNo = options.id;
  462. },
  463. onShow() {
  464. this.payDetails(this.info.orderNo);
  465. },
  466. created() {
  467. // this.info = JSON.parse(uni.getStorageSync('order'))
  468. },
  469. };
  470. </script>
  471. <style lang="scss">
  472. .order-detail {
  473. background: #f9f9f9;
  474. min-height: 100vh;
  475. // padding-bottom: 100rpx;
  476. .status-box {
  477. padding: 24rpx 24rpx 4rpx;
  478. display: flex;
  479. justify-content: space-between;
  480. .text-box {
  481. color: #181818;
  482. .status {
  483. font-weight: bold;
  484. font-size: 32rpx;
  485. display: flex;
  486. .u-count-down__text {
  487. color: #ff4d3a !important;
  488. }
  489. }
  490. .notice {
  491. font-size: 24rpx;
  492. margin-top: 20rpx;
  493. }
  494. }
  495. }
  496. .progress {
  497. .progress-title {
  498. font-weight: 600;
  499. font-size: 32rpx;
  500. color: #181818;
  501. }
  502. .progress-desc {
  503. font-weight: 300;
  504. font-size: 24rpx;
  505. color: #aaaaaa;
  506. margin-top: 15rpx;
  507. }
  508. }
  509. .shop-box {
  510. width: 690rpx;
  511. // margin: 0 30rpx;
  512. // padding: 24rpx 24rpx 30rpx;
  513. background: #fff;
  514. border-radius: 16rpx;
  515. margin-top: -30rpx;
  516. box-sizing: border-box;
  517. .shop-name {
  518. font-weight: 600;
  519. font-size: 32rpx;
  520. color: #181818;
  521. width: 100%;
  522. white-space: nowrap;
  523. overflow: hidden;
  524. text-overflow: ellipsis;
  525. }
  526. .address {
  527. font-weight: 300;
  528. font-size: 24rpx;
  529. color: #aaaaaa;
  530. margin-top: 20rpx;
  531. width: 100%;
  532. white-space: nowrap;
  533. overflow: hidden;
  534. text-overflow: ellipsis;
  535. }
  536. }
  537. .black {
  538. color: #222222 !important;
  539. }
  540. .red {
  541. color: red !important;
  542. }
  543. .fs28 {
  544. font-size: 28rpx !important;
  545. font-weight: bold;
  546. }
  547. .code-box {
  548. display: flex;
  549. align-items: center;
  550. justify-content: space-between;
  551. .left {
  552. .title {
  553. font-weight: 500;
  554. font-size: 28rpx;
  555. color: #222222;
  556. }
  557. .codeNum {
  558. font-weight: 300;
  559. font-size: 24rpx;
  560. color: #aaaaaa;
  561. margin-top: 15rpx;
  562. }
  563. }
  564. .code-btn {
  565. display: flex;
  566. align-items: center;
  567. font-weight: 300;
  568. font-size: 24rpx;
  569. color: #aaaaaa;
  570. .jiantou {
  571. width: 24rpx;
  572. height: 24rpx;
  573. }
  574. }
  575. }
  576. .input-box {
  577. margin: 20rpx 30rpx;
  578. padding: 28rpx 24rpx;
  579. background: #ffffff;
  580. border-radius: 16rpx 16rpx 16rpx 16rpx;
  581. display: flex;
  582. align-items: center;
  583. justify-content: space-between;
  584. .label {
  585. color: #222;
  586. font-size: 28rpx;
  587. }
  588. .value {
  589. font-size: 28rpx;
  590. color: #aaaaaa;
  591. }
  592. }
  593. .input-box-address {
  594. margin: 20rpx 30rpx;
  595. padding: 28rpx 24rpx;
  596. background: #ffffff;
  597. border-radius: 16rpx 16rpx 16rpx 16rpx;
  598. // display: flex;
  599. // align-items: center;
  600. // justify-content: space-between;
  601. .value {
  602. color: #222;
  603. font-size: 28rpx;
  604. }
  605. .label {
  606. font-size: 28rpx;
  607. margin: 10rpx 0;
  608. color: #aaaaaa;
  609. }
  610. }
  611. .content {
  612. margin: 20rpx 30rpx;
  613. padding: 28rpx 24rpx;
  614. border-radius: 16rpx;
  615. background: #fff;
  616. .title {
  617. font-weight: 600;
  618. font-size: 28rpx;
  619. color: #222222;
  620. }
  621. .item {
  622. display: flex;
  623. align-items: center;
  624. justify-content: space-between;
  625. margin-top: 28rpx;
  626. .label {
  627. color: #222222;
  628. font-size: 28rpx;
  629. }
  630. .value {
  631. color: #999999;
  632. font-size: 28rpx;
  633. }
  634. }
  635. }
  636. .pay-btn {
  637. background: $uni-color-primary;
  638. width: 688rpx;
  639. height: 80rpx;
  640. line-height: 80rpx;
  641. border-radius: 46rpx;
  642. color: #fff;
  643. margin-top: 50rpx;
  644. }
  645. .refund-box {
  646. .refund-msg {
  647. font-weight: 300;
  648. font-size: 24rpx;
  649. color: #222222;
  650. margin-top: 15rpx;
  651. line-height: 40rpx;
  652. }
  653. }
  654. .apply-box {
  655. position: relative;
  656. .label {
  657. font-weight: 600;
  658. font-size: 28rpx;
  659. color: #222222;
  660. }
  661. .value {
  662. color: #999999;
  663. font-size: 24rpx;
  664. margin-top: 15rpx;
  665. }
  666. .jiantou {
  667. position: absolute;
  668. top: 50%;
  669. right: 24rpx;
  670. transform: translateY(-50%);
  671. width: 24rpx;
  672. height: 24rpx;
  673. }
  674. }
  675. .info {
  676. .order-info {
  677. display: flex;
  678. .icon {
  679. width: 164rpx;
  680. height: 164rpx;
  681. border-radius: 16rpx;
  682. flex-shrink: 0;
  683. }
  684. .shop-info {
  685. display: flex;
  686. flex-direction: column;
  687. justify-content: space-between;
  688. padding-left: 24rpx;
  689. flex: 1;
  690. box-sizing: border-box;
  691. .title {
  692. color: #181818;
  693. font-size: 28rpx;
  694. width: 450rpx;
  695. white-space: nowrap;
  696. overflow: hidden;
  697. text-overflow: ellipsis;
  698. }
  699. .price-box {
  700. display: flex;
  701. align-items: center;
  702. justify-content: space-between;
  703. .price {
  704. color: #181818;
  705. font-size: 32rpx;
  706. font-weight: bold;
  707. }
  708. }
  709. .start-time,
  710. .goods-desc {
  711. font-size: 24rpx;
  712. color: #aaaaaa;
  713. width: 450rpx;
  714. white-space: nowrap;
  715. overflow: hidden;
  716. text-overflow: ellipsis;
  717. }
  718. }
  719. }
  720. }
  721. .wrap {
  722. display: flex;
  723. justify-content: center;
  724. align-items: center;
  725. height: 100vh;
  726. overflow: hidden;
  727. }
  728. }
  729. </style>