detail.vue 18 KB

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