detail.vue 18 KB

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