detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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. {{ filterType(info.goodsList[0].goodsState) }}
  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. {{ filterPay(info.payment.paymentWay) || "未支付" }}
  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. },
  259. computed: {
  260. },
  261. methods: {
  262. filterType: function (val) {
  263. if (val == "APPLY_REFUND") {
  264. return "退款审核中";
  265. } else if (val == "CLOSE") {
  266. return "关闭订单";
  267. } else if (val == "REFUNDED") {
  268. return "已退款";
  269. } else if (val == "REFUSAL_REFUND") {
  270. return "拒绝退款";
  271. } else if (val == "USED") {
  272. return "订单已完成";
  273. } else if (val == "WAIT_PAYMENT") {
  274. return "待付款";
  275. } else if (val == "WAIT_USE") {
  276. return "待使用";
  277. }
  278. },
  279. filterPay(val) {
  280. if (val == "wx.unifiedOrder") {
  281. return "微信支付";
  282. } else if (val == "trade.create") {
  283. return "支付宝支付";
  284. } else if (val == "uac.miniOrder") {
  285. return "云闪付支付";
  286. } else {
  287. return "-";
  288. }
  289. },
  290. isRefund() {
  291. if (!this.info.goodsList[0].verifyModel) {
  292. //没核销
  293. return true;
  294. } else if (
  295. this.info.goodsList[0].verifyModel &&
  296. new Date().getTime() <
  297. this.info.goodsList[0].verifyModel.checkTime + 1000 * 60 * 60 * 48
  298. ) {
  299. // 已核销 并且没超过48小时
  300. return true;
  301. } else {
  302. return false;
  303. }
  304. },
  305. finish() {
  306. this.isNotTime = true;
  307. console.log(222222, this.isNotTime);
  308. this.payDetails(this.info.orderNo);
  309. },
  310. refundDetail() {
  311. uni.navigateTo({
  312. url: `/my/order/refundDetail?id=${this.info.orderNo}`,
  313. });
  314. },
  315. checkCode() {
  316. this.codeData = "";
  317. this.$nextTick(() => {
  318. this.show = true;
  319. this.loading = true;
  320. let that = this;
  321. // uni.getScreenBrightness({
  322. // success(res) {
  323. // // 获取用户手机亮度 保存起来
  324. // that.oldBright = res.value
  325. // setTimeout(()=>{
  326. // uni.setScreenBrightness({
  327. // value:1
  328. // })
  329. // },200)
  330. // }
  331. // })
  332. qrCode(this.info.goodsList[0].id).then((res) => {
  333. this.loading = false;
  334. if (res.state == "Success") {
  335. this.codeData = res.content;
  336. }
  337. });
  338. });
  339. },
  340. close() {
  341. this.show = false;
  342. // uni.setScreenBrightness({
  343. // value:this.oldBright
  344. // })
  345. },
  346. apply() {
  347. let that = this;
  348. uni.navigateTo({
  349. url: "./refund",
  350. success: function (res) {
  351. // 通过eventChannel向被打开页面传送数据
  352. res.eventChannel.emit("orderInfo", that.info);
  353. },
  354. });
  355. },
  356. // 获取订单详情
  357. payDetails(orderNo) {
  358. payDetails(orderNo).then((res) => {
  359. this.info = res.content;
  360. try {
  361. let extend = JSON.parse(this.info.extend);
  362. if (extend.account) {
  363. this.isVisual = true;
  364. }
  365. } catch (e) {
  366. //TODO handle the exception
  367. }
  368. // 跳转了但是没支付
  369. if(this.isJumped && this.info.goodsList[0].goodsState == "WAIT_PAYMENT"){
  370. this.btnLoading = false;
  371. uni.showToast({
  372. title: "支付取消",
  373. icon: "warning",
  374. });
  375. }else{
  376. }
  377. });
  378. },
  379. // 支付
  380. pay() {
  381. if (this.btnLoading) return;
  382. this.btnLoading = true;
  383. uni.showLoading({
  384. title: "支付中",
  385. });
  386. let that = this;
  387. let miniPayRequest = this.info.payment.miniPayRequest;
  388. // 打开慧研学
  389. uni.navigateToMiniProgram({
  390. appId: "wx3be1d6d84d46cdf7",
  391. path: "pages/index/index",
  392. success: (res) => {
  393. // 打开成功
  394. // console.log("打开成功", res);
  395. this.isJumped = true;
  396. },
  397. fail: (err) => {
  398. // console.log(err);
  399. uni.hideLoading();
  400. uni.showToast({
  401. title: "支付失败",
  402. icon: "none",
  403. });
  404. that.btnLoading = false
  405. },
  406. });
  407. // uni.requestPayment({
  408. // "provider": "wxpay",
  409. // "orderInfo": miniPayRequest,
  410. // "appid": "wxbc64403830bb13c5", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  411. // "paySign": miniPayRequest.paySign,
  412. // "nonceStr": miniPayRequest.nonceStr, // 随机字符串
  413. // "package": miniPayRequest.package, // 固定值
  414. // // "prepayid": miniPayRequest.package, // 统一下单订单号
  415. // "timeStamp": miniPayRequest.timeStamp, // 时间戳(单位:秒)
  416. // "signType": miniPayRequest.signType, //签名算法
  417. // success(msg) {
  418. // console.log('msg', msg);
  419. // queryPayOrder(that.info.orderNo).then(res1 => {
  420. // if (res1.state == 'Success') {
  421. // uni.hideLoading()
  422. // uni.showToast({
  423. // title: '支付成功',
  424. // icon: 'success'
  425. // })
  426. // that.btnLoading = false
  427. // that.payDetails(that.info.orderNo)
  428. // }
  429. // })
  430. // },
  431. // fail(e) {
  432. // that.btnLoading = false
  433. // uni.hideLoading()
  434. // uni.showToast({
  435. // title: '取消支付',
  436. // icon: 'fail'
  437. // })
  438. // // 取消支付后,获取支付信息以备再次支付
  439. // that.payDetails(that.info.orderNo)
  440. // console.log('err', e,this);
  441. // }
  442. // })
  443. },
  444. // 取消退款申请
  445. cancelReply() {
  446. if (this.btnLoading) return;
  447. this.btnLoading = true;
  448. uni.showLoading({
  449. title: "取消中",
  450. });
  451. unRefund({ id: this.info.goodsList[0].id }).then((res) => {
  452. this.btnLoading = false;
  453. uni.hideLoading();
  454. if (res.state == "Success") {
  455. this.payDetails(this.info.orderNo);
  456. uni.showToast({
  457. title: "取消成功",
  458. icon: "success",
  459. });
  460. }
  461. });
  462. },
  463. },
  464. onReady() {},
  465. onLoad(options) {
  466. this.info.orderNo = options.id;
  467. },
  468. onShow() {
  469. this.payDetails(this.info.orderNo);
  470. },
  471. created() {
  472. // this.info = JSON.parse(uni.getStorageSync('order'))
  473. },
  474. };
  475. </script>
  476. <style lang="scss">
  477. .order-detail {
  478. background: #f9f9f9;
  479. min-height: 100vh;
  480. padding-bottom: 100rpx;
  481. .status-box {
  482. padding: 24rpx 24rpx 4rpx;
  483. display: flex;
  484. justify-content: space-between;
  485. .text-box {
  486. color: #181818;
  487. .status {
  488. font-weight: bold;
  489. font-size: 32rpx;
  490. display: flex;
  491. .u-count-down__text {
  492. color: #ff4d3a !important;
  493. }
  494. }
  495. .notice {
  496. font-size: 24rpx;
  497. margin-top: 20rpx;
  498. }
  499. }
  500. }
  501. .progress {
  502. .progress-title {
  503. font-weight: 600;
  504. font-size: 32rpx;
  505. color: #181818;
  506. }
  507. .progress-desc {
  508. font-weight: 300;
  509. font-size: 24rpx;
  510. color: #aaaaaa;
  511. margin-top: 15rpx;
  512. }
  513. }
  514. .shop-box {
  515. width: 690rpx;
  516. // margin: 0 30rpx;
  517. // padding: 24rpx 24rpx 30rpx;
  518. background: #fff;
  519. border-radius: 16rpx;
  520. margin-top: -30rpx;
  521. box-sizing: border-box;
  522. .shop-name {
  523. font-weight: 600;
  524. font-size: 32rpx;
  525. color: #181818;
  526. width: 100%;
  527. white-space: nowrap;
  528. overflow: hidden;
  529. text-overflow: ellipsis;
  530. }
  531. .address {
  532. font-weight: 300;
  533. font-size: 24rpx;
  534. color: #aaaaaa;
  535. margin-top: 20rpx;
  536. width: 100%;
  537. white-space: nowrap;
  538. overflow: hidden;
  539. text-overflow: ellipsis;
  540. }
  541. }
  542. .black {
  543. color: #222222 !important;
  544. }
  545. .red {
  546. color: red !important;
  547. }
  548. .fs28 {
  549. font-size: 28rpx !important;
  550. font-weight: bold;
  551. }
  552. .code-box {
  553. display: flex;
  554. align-items: center;
  555. justify-content: space-between;
  556. .left {
  557. .title {
  558. font-weight: 500;
  559. font-size: 28rpx;
  560. color: #222222;
  561. }
  562. .codeNum {
  563. font-weight: 300;
  564. font-size: 24rpx;
  565. color: #aaaaaa;
  566. margin-top: 15rpx;
  567. }
  568. }
  569. .code-btn {
  570. display: flex;
  571. align-items: center;
  572. font-weight: 300;
  573. font-size: 24rpx;
  574. color: #aaaaaa;
  575. .jiantou {
  576. width: 24rpx;
  577. height: 24rpx;
  578. }
  579. }
  580. }
  581. .input-box {
  582. margin: 20rpx 30rpx;
  583. padding: 28rpx 24rpx;
  584. background: #ffffff;
  585. border-radius: 16rpx 16rpx 16rpx 16rpx;
  586. display: flex;
  587. align-items: center;
  588. justify-content: space-between;
  589. .label {
  590. color: #222;
  591. font-size: 28rpx;
  592. }
  593. .value {
  594. font-size: 28rpx;
  595. color: #aaaaaa;
  596. }
  597. }
  598. .content {
  599. margin: 20rpx 30rpx;
  600. padding: 28rpx 24rpx;
  601. border-radius: 16rpx;
  602. background: #fff;
  603. .title {
  604. font-weight: 600;
  605. font-size: 28rpx;
  606. color: #222222;
  607. }
  608. .item {
  609. display: flex;
  610. align-items: center;
  611. justify-content: space-between;
  612. margin-top: 28rpx;
  613. .label {
  614. color: #222222;
  615. font-size: 28rpx;
  616. }
  617. .value {
  618. color: #999999;
  619. font-size: 28rpx;
  620. }
  621. }
  622. }
  623. .pay-btn {
  624. background: $uni-color-primary;
  625. width: 688rpx;
  626. height: 80rpx;
  627. line-height: 80rpx;
  628. border-radius: 46rpx;
  629. color: #fff;
  630. margin-top: 50rpx;
  631. }
  632. .refund-box {
  633. .refund-msg {
  634. font-weight: 300;
  635. font-size: 24rpx;
  636. color: #222222;
  637. margin-top: 15rpx;
  638. line-height: 40rpx;
  639. }
  640. }
  641. .apply-box {
  642. position: relative;
  643. .label {
  644. font-weight: 600;
  645. font-size: 28rpx;
  646. color: #222222;
  647. }
  648. .value {
  649. color: #999999;
  650. font-size: 24rpx;
  651. margin-top: 15rpx;
  652. }
  653. .jiantou {
  654. position: absolute;
  655. top: 50%;
  656. right: 24rpx;
  657. transform: translateY(-50%);
  658. width: 24rpx;
  659. height: 24rpx;
  660. }
  661. }
  662. .info {
  663. .order-info {
  664. display: flex;
  665. .icon {
  666. width: 164rpx;
  667. height: 164rpx;
  668. border-radius: 16rpx;
  669. flex-shrink: 0;
  670. }
  671. .shop-info {
  672. display: flex;
  673. flex-direction: column;
  674. justify-content: space-between;
  675. padding-left: 24rpx;
  676. flex: 1;
  677. box-sizing: border-box;
  678. .title {
  679. color: #181818;
  680. font-size: 28rpx;
  681. width: 450rpx;
  682. white-space: nowrap;
  683. overflow: hidden;
  684. text-overflow: ellipsis;
  685. }
  686. .price-box {
  687. display: flex;
  688. align-items: center;
  689. justify-content: space-between;
  690. .price {
  691. color: #181818;
  692. font-size: 32rpx;
  693. font-weight: bold;
  694. }
  695. }
  696. .start-time,
  697. .goods-desc {
  698. font-size: 24rpx;
  699. color: #aaaaaa;
  700. width: 450rpx;
  701. white-space: nowrap;
  702. overflow: hidden;
  703. text-overflow: ellipsis;
  704. }
  705. }
  706. }
  707. }
  708. .wrap {
  709. display: flex;
  710. justify-content: center;
  711. align-items: center;
  712. height: 100vh;
  713. overflow: hidden;
  714. }
  715. }
  716. </style>