index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <template>
  2. <view>
  3. <nav-bar title="我的订单"></nav-bar>
  4. <view style="
  5. width: 100%;
  6. text-align: center;
  7. position: fixed;
  8. height: 96rpx;
  9. z-index: 999;
  10. ">
  11. <u-tabs :list="list" sticky :current="current" @change="change" active-color="#007AFF"
  12. :offset="[-1, 0]"></u-tabs>
  13. </view>
  14. <view style="padding: 96rpx 8rpx 130rpx">
  15. <view v-if="!order.length" class="noData">您暂无相关订单哦~</view>
  16. <template v-else>
  17. <view v-for="(item, index) in order" :key="index" class="lisChild">
  18. <view class="item">
  19. <view class="header" @click="openPopup(index)">
  20. <view>订单编号:{{ item.orderSn }}</view>
  21. <view>{{ $method.timestampToTime(item.createTime) }}</view>
  22. </view>
  23. <u-line color="#D6D6DB" />
  24. <view v-if="current == 3">
  25. <view class="body">
  26. <view class="body__content">
  27. <image class="goods-img" :src="$method.splitImgHost(item.coverUrl)"></image>
  28. <view class="goods-text">
  29. <view class="goods-name">{{ item.goodsName }}</view>
  30. <!-- <view class="goods-price">¥ {{ items.goodsRealPrice }}</view> -->
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-else>
  36. <view class="body" v-for="(items, indexs) in item.orderGoodsList" :key="indexs"
  37. @click="goCourse(items, item.orderStatus)">
  38. <view class="body__content">
  39. <image class="goods-img" :src="$method.splitImgHost(items.coverUrl)"></image>
  40. <view class="goods-text">
  41. <view class="goods-name">{{ items.goodsName }}</view>
  42. <view class="goods-name" v-if="items.sevenYear">{{
  43. items.sevenYear
  44. }}</view>
  45. <view v-if="item.orderFrom !== 6" class="goods-price">¥
  46. {{ items.goodsRealPrice }}</view>
  47. </view>
  48. </view>
  49. <view style="
  50. display: flex;
  51. flex-direction: row-reverse;
  52. padding: 10rpx 0;
  53. ">
  54. <view v-if="
  55. items.refundStatus === 0 &&
  56. (item.orderFrom === 2 || item.orderFrom === 3) &&
  57. (item.orderStatus === 1 ||
  58. item.orderStatus === 2 ||
  59. item.orderStatus === 3) &&
  60. (items.goodsType == '1' ||
  61. items.goodsType == '2' ||
  62. items.goodsType == '6') &&
  63. items.goodsPrice > 0
  64. " class="btn2" @click.stop="handelRefund(item.orderSn, items)">申请退款</view>
  65. <!-- <view v-if="items.refundStatus == 2"> 已退款</view> -->
  66. <view v-if="items.periodStatus !== null">{{
  67. [
  68. "复审不通过",
  69. "初审不通过",
  70. "待审核",
  71. "初审通过",
  72. "复审通过待退款",
  73. "已退款",
  74. ][items.periodStatus + 2]
  75. }}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <u-line color="#D6D6DB" />
  80. <view class="footer" v-if="current == 3">
  81. <view>
  82. <text style="color: #999; font-size: 24rpx; margin-right: 8rpx">退款金额</text>
  83. <text
  84. style="color: #ff2d55; font-size: 30rpx; font-weight: bold">¥{{ item.refundFee }}</text>
  85. </view>
  86. </view>
  87. <view class="footer" v-else>
  88. <view>
  89. <text
  90. style="color: #999; font-size: 24rpx; margin-right: 8rpx">共{{ item.orderGoodsList.length }}项</text>
  91. <!-- 业务系统下单的需要隐藏价格 -->
  92. <!-- 订单来源:1业务员普通单,2祥粤云学堂小程序,3祥粤云学堂网站,4祥粤e管证小程序,5业务员录单,6业务系统下单 -->
  93. <text v-if="item.orderFrom !== 6">
  94. <text style="color: #333; font-size: 30rpx; font-weight: bold">合计</text>
  95. <text
  96. style="color: #ff2d55; font-size: 30rpx; font-weight: bold">¥{{ item.payPrice }}</text>
  97. </text>
  98. </view>
  99. <view style="display: flex; align-items: center">
  100. <view class="btn2" v-if="
  101. item.orderStatus === 0 &&
  102. (item.orderFrom === 2 || item.orderFrom === 3)
  103. " @click="resumeOrder(item)">继续支付</view>
  104. <!-- <view class="btn2" v-if="item.orderStatus === -1 || item.orderStatus === -2" @click="againBuy(item)">重新购买</view> -->
  105. <view class="btn1" v-if="
  106. (item.orderStatus === -1 || item.orderStatus === -2) &&
  107. (item.orderFrom === 2 || item.orderFrom === 3)
  108. " @click="delOrder(item)">删除订单</view>
  109. <view class="btn1" @click="closeOrder(item)" v-if="
  110. item.orderStatus === 0 &&
  111. (item.orderFrom === 2 || item.orderFrom === 3)
  112. ">取消订单</view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. </template>
  118. <template v-if="current == 1 && order.length">
  119. <view class="apply_btn">
  120. <view class="apply-invoice" @click="goInvoice">发票申请</view>
  121. </view>
  122. </template>
  123. </view>
  124. <!-- 退款弹窗 -->
  125. <u-popup v-model="show" :mask-close-able="false" closeable mode="center" width="80%" border-radius="24">
  126. <view class="rf-popup-main">
  127. <view class="title">提示</view>
  128. <view class="tip">确认要退款吗</view>
  129. <u-input v-model="refundForm.applyReason" placeholder-style="color:#999999" type="textarea"
  130. placeholder="请输入退款原因" />
  131. <u-button type="primary" style="border-radius: 60rpx" @click="refund">确定</u-button>
  132. </view>
  133. </u-popup>
  134. </view>
  135. </template>
  136. <script>
  137. import {
  138. mapGetters
  139. } from "vuex";
  140. export default {
  141. components: {},
  142. data() {
  143. return {
  144. list: [{
  145. name: "待支付",
  146. count: 0,
  147. },
  148. {
  149. name: "已支付",
  150. count: 0,
  151. },
  152. {
  153. name: "已取消",
  154. count: 0,
  155. },
  156. {
  157. name: "已退款",
  158. count: 0,
  159. },
  160. ],
  161. current: 0,
  162. order: [],
  163. formData: {
  164. status: "0,1",
  165. pageNum: 1,
  166. pageSize: 10,
  167. },
  168. pageNum1: 0,
  169. pageNum2: 0,
  170. pageNum3: 0,
  171. pageNum4: 0,
  172. refundForm: {},
  173. show: false,
  174. value: "",
  175. };
  176. },
  177. // onPullDownRefresh() {},
  178. onLoad(option) {
  179. this.current = +option.current || 0;
  180. this.getOrderList();
  181. this.getOrderNum();
  182. },
  183. onShow() {
  184. /* if(this.current === 2 && this.$method.isLogin()){
  185. this.$refs.refMy.init();
  186. } */
  187. },
  188. //分享功能
  189. onShareAppMessage(res) {
  190. var self = this;
  191. return {
  192. title: "中正",
  193. path: `/pages/index/index?inviteCode=` + userInfo == null ?
  194. "" :
  195. userInfo.userAccount,
  196. };
  197. },
  198. onReachBottom() {
  199. this.formData.pageNum++;
  200. this.getFY();
  201. },
  202. methods: {
  203. getOrderNum() {
  204. this.$api
  205. .getorderlists({
  206. status: "0,1",
  207. pageNum: 1,
  208. pageSize: 1,
  209. orderStatus: "0",
  210. })
  211. .then((res) => {
  212. if (res.data.code === 200) {
  213. this.list[0].count = res.data.total;
  214. }
  215. });
  216. this.$api
  217. .getorderlists({
  218. status: "0,1",
  219. pageNum: 1,
  220. pageSize: 1,
  221. orderStatus: "1,2,3,4",
  222. })
  223. .then((res) => {
  224. if (res.data.code === 200) {
  225. this.list[1].count = res.data.total;
  226. }
  227. });
  228. this.$api
  229. .getorderlists({
  230. status: "0,1",
  231. pageNum: 1,
  232. pageSize: 1,
  233. orderStatus: "-1,-2",
  234. })
  235. .then((res) => {
  236. if (res.data.code === 200) {
  237. this.list[2].count = res.data.total;
  238. }
  239. });
  240. },
  241. /**
  242. * 跳转发票申请页面
  243. */
  244. goInvoice() {
  245. uni.navigateTo({
  246. url: `/pages2/invoice/index`,
  247. });
  248. },
  249. confirm() {},
  250. handelRefund(orderSn, item) {
  251. this.refundForm = {
  252. orderSn: orderSn,
  253. goodsId: item.goodsId,
  254. orderGoodsId: item.orderGoodsId,
  255. applyReason: ""
  256. };
  257. this.show = true;
  258. },
  259. refund() {
  260. this.$api.refundSmallOrder(this.refundForm).then((res) => {
  261. this.show = false;
  262. if (res.data.code == 200) {
  263. this.$method.showToast(res.data.msg);
  264. this.getOrderList();
  265. } else {
  266. uni.showToast({
  267. icon: "none",
  268. title: res.data.msg,
  269. });
  270. }
  271. });
  272. },
  273. /**
  274. * 跳转课程
  275. */
  276. goCourse(item, orderStatus) {
  277. // if(orderStatus == 1 || orderStatus == 2) {
  278. // console.log(item)
  279. // if(item.goodsType == 1) { //网课
  280. // uni.navigateTo({
  281. // url:'/pages2/wd/course?gid='+item.gradeId+'&id='+item.goodsId
  282. // })
  283. // } else if(item.goodsType == 2) { //题库
  284. // uni.navigateTo({
  285. // url:'/pages2/bank/question_detail?id='+item.goodsId
  286. // })
  287. // }
  288. // }
  289. },
  290. resumeOrder(item) {
  291. let self = this;
  292. // #ifdef MP-WEIXIN
  293. uni.login({
  294. provider: "weixin",
  295. success: function(loginRes) {
  296. console.log(loginRes, 69);
  297. self.getOpenid(loginRes.code, item);
  298. },
  299. });
  300. // #endif
  301. // #ifdef H5
  302. // 在首页已经请求过接口/gzh_login 提交code了
  303. this.resumeOrderPay(item);
  304. // #endif
  305. },
  306. getOpenid(code, item) {
  307. let self = this;
  308. this.$api.wxOpenid({
  309. code: code
  310. }).then((res) => {
  311. if (res.data.code == 200) {
  312. self.resumeOrderPay(item);
  313. }
  314. });
  315. },
  316. resumeOrderPay(item) {
  317. let data = {
  318. orderSn: item.orderSn
  319. };
  320. // #ifdef MP-WEIXIN
  321. this.$api.resumeSmallOrder(data).then((res) => {
  322. if (res.data.code == 200) {
  323. let data = res.data.data;
  324. uni.requestPayment({
  325. provider: data.provider,
  326. nonceStr: data.nonceStr,
  327. package: data.package,
  328. signType: data.signType,
  329. paySign: data.sign,
  330. timeStamp: String(data.timeStamp),
  331. success: function(res) {
  332. uni.redirectTo({
  333. url: "/pages2/order/confirm_success?sn=" + data.orderSn,
  334. });
  335. console.log("success:" + JSON.stringify(res));
  336. },
  337. fail: function(err) {
  338. console.log("fail:" + JSON.stringify(err));
  339. },
  340. });
  341. } else {
  342. uni.showModal({
  343. title: "提示",
  344. content: res.data.msg,
  345. showCancel: false,
  346. });
  347. }
  348. });
  349. // #endif
  350. // #ifdef H5
  351. data["url"] = location.href;
  352. this.$api.resumePlaceGzhOrder(data).then((res) => {
  353. console.log(res, "继续支付res");
  354. if (res.data.code == 200) {
  355. this.h5_wxpay(res.data.data);
  356. } else {
  357. uni.showModal({
  358. title: "提示",
  359. content: res.data.msg,
  360. showCancel: false,
  361. });
  362. }
  363. });
  364. // #endif
  365. },
  366. h5_wxpay(data) {
  367. console.log("调起支付状态1", data);
  368. let self = this;
  369. function onBridgeReady() {
  370. // 加载框
  371. WeixinJSBridge.invoke(
  372. "getBrandWCPayRequest", {
  373. appId: data.appId, // 公众号名称,由商户传入
  374. timeStamp: data.timeStamp, // 时间戳,自1970年以来的秒数
  375. nonceStr: data.nonceStr, // 随机串
  376. package: data.package,
  377. signType: data.signType, // 微信签名方式:
  378. paySign: data.paySign, // 微信签名
  379. },
  380. function(res) {
  381. // 判断支付状态
  382. console.log("支付状态", res, "this:", this, self);
  383. if (res.err_msg === "get_brand_wcpay_request:ok") {
  384. self.$u.toast("支付成功");
  385. uni.redirectTo({
  386. url: "/pages2/order/confirm_success?sn=" + data.orderSn,
  387. });
  388. } else if (res.err_msg === "get_brand_wcpay_request:cancel") {
  389. self.$u.toast("取消支付");
  390. } else {
  391. self.$u.toast("支付失败");
  392. }
  393. }
  394. );
  395. }
  396. if (typeof WeixinJSBridge === "undefined") {
  397. if (document.addEventListener) {
  398. document.addEventListener(
  399. "WeixinJSBridgeReady",
  400. onBridgeReady,
  401. false
  402. );
  403. } else if (document.attachEvent) {
  404. document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
  405. document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
  406. }
  407. } else {
  408. onBridgeReady();
  409. }
  410. },
  411. openPopup() {},
  412. //删除订单
  413. delOrder(item) {
  414. var self = this;
  415. uni.showModal({
  416. content: "确定要删除该订单吗",
  417. success: function(res) {
  418. if (res.confirm) {
  419. self.$api
  420. .eddOrder({
  421. orderId: item.orderId,
  422. status: -1,
  423. })
  424. .then((res) => {
  425. if (res.data.code === 200) {
  426. self.$method.showToast("订单删除成功");
  427. self.getOrderList();
  428. }
  429. });
  430. }
  431. },
  432. });
  433. },
  434. //取消订单
  435. closeOrder(item) {
  436. var self = this;
  437. uni.showModal({
  438. content: "确定要取消该订单吗",
  439. success: function(res) {
  440. if (res.confirm) {
  441. self.$api
  442. .eddOrder({
  443. orderId: item.orderId,
  444. orderStatus: -1,
  445. })
  446. .then((res) => {
  447. if (res.data.code === 200) {
  448. self.$method.showToast("订单取消成功", "success");
  449. self.getOrderList();
  450. }
  451. });
  452. }
  453. },
  454. });
  455. },
  456. getFY() {
  457. if (this.current === 0) {
  458. this.formData.orderStatus = "0";
  459. if (this.order.length >= this.pageNum1) {
  460. return;
  461. }
  462. }
  463. if (this.current === 1) {
  464. this.formData.orderStatus = "1,2,3,4";
  465. if (this.order.length >= this.pageNum2) {
  466. return;
  467. }
  468. }
  469. if (this.current === 2) {
  470. this.formData.orderStatus = "-1,-2";
  471. if (this.order.length >= this.pageNum3) {
  472. return;
  473. }
  474. }
  475. if (this.current == 3) {
  476. if (this.order.length >= this.pageNum4) {
  477. return;
  478. }
  479. this.formData.orderStatus = "";
  480. this.$api.orderRefundList(this.formData).then((res) => {
  481. if (res.data.code == 200) {
  482. this.order = this.order.concat(res.data.rows);
  483. }
  484. });
  485. return;
  486. }
  487. this.$api.getorderlists(this.formData).then((res) => {
  488. if (res.data.code === 200) {
  489. if (res.data.rows.length) {
  490. this.order = this.order.concat(res.data.rows);
  491. }
  492. }
  493. });
  494. },
  495. //获取订单
  496. getOrderList() {
  497. this.formData.pageNum = 1;
  498. if (this.current === 0) {
  499. this.formData.orderStatus = "0";
  500. }
  501. if (this.current === 1) {
  502. this.formData.orderStatus = "1,2,3,4";
  503. }
  504. if (this.current === 2) {
  505. this.formData.orderStatus = "-1,-2";
  506. }
  507. this.order = [];
  508. this.$api.getorderlists(this.formData).then((res) => {
  509. if (res.data.code === 200) {
  510. if (this.current === 0) {
  511. this.list[0].count = res.data.total;
  512. this.pageNum1 = res.data.total;
  513. }
  514. if (this.current === 1) {
  515. this.list[1].count = res.data.total;
  516. this.pageNum2 = res.data.total;
  517. }
  518. if (this.current === 2) {
  519. this.list[2].count = res.data.total;
  520. this.pageNum3 = res.data.total;
  521. }
  522. this.order = res.data.rows;
  523. console.log("订单列表this.order", this.order);
  524. }
  525. });
  526. },
  527. orderRefundList() {
  528. this.order = [];
  529. this.formData.pageNum = 1;
  530. this.formData.orderStatus = "";
  531. this.$api.orderRefundList(this.formData).then((res) => {
  532. if (res.data.code == 200) {
  533. this.order = res.data.rows;
  534. }
  535. });
  536. },
  537. change(index) {
  538. if (this.current === index) {
  539. return;
  540. }
  541. this.current = index;
  542. console.log("this.current", this.current);
  543. if (this.current == 3) {
  544. //退款订单
  545. this.formData.status = "";
  546. this.orderRefundList();
  547. } else {
  548. //其他订单
  549. this.formData.status = "0,1";
  550. this.getOrderList();
  551. }
  552. uni.pageScrollTo({
  553. scrollTop: 0,
  554. });
  555. },
  556. },
  557. computed: {
  558. ...mapGetters(["userInfo"])
  559. },
  560. };
  561. </script>
  562. <style>
  563. page {
  564. background: #eaeef1;
  565. }
  566. </style>
  567. <style scoped lang="scss">
  568. .lisChild {
  569. border-radius: 16rpx;
  570. margin-bottom: 16rpx;
  571. background: #fff;
  572. .header {
  573. display: flex;
  574. justify-content: space-between;
  575. align-items: center;
  576. height: 80rpx;
  577. padding: 0 15rpx;
  578. color: #666666;
  579. font-size: 24rpx;
  580. }
  581. .body {
  582. padding: 16rpx;
  583. &__content {
  584. display: flex;
  585. justify-content: space-between;
  586. .goods-img {
  587. height: 156rpx;
  588. width: 278rpx;
  589. border-radius: 16rpx;
  590. flex-shrink: 0;
  591. }
  592. .goods-text {
  593. margin-left: 20rpx;
  594. flex: 1;
  595. display: flex;
  596. flex-direction: column;
  597. .goods-name {
  598. color: #333333;
  599. font-size: 30rpx;
  600. font-weight: bold;
  601. flex: 1;
  602. }
  603. .goods-price {
  604. font-size: 30rpx;
  605. font-family: PingFang SC;
  606. font-weight: bold;
  607. color: #ff2d55;
  608. display: flex;
  609. flex-direction: row-reverse;
  610. }
  611. }
  612. }
  613. .btn2 {
  614. width: 144rpx;
  615. height: 46rpx;
  616. background: #ffffff;
  617. border: 2rpx solid #007aff;
  618. border-radius: 16rpx;
  619. text-align: center;
  620. line-height: 48rpx;
  621. color: #007aff;
  622. margin: 0 8rpx;
  623. }
  624. }
  625. .footer {
  626. padding: 0 24rpx;
  627. height: 80rpx;
  628. display: flex;
  629. justify-content: space-between;
  630. align-items: center;
  631. .btn2 {
  632. width: 144rpx;
  633. height: 46rpx;
  634. background: #ffffff;
  635. border: 2rpx solid #007aff;
  636. border-radius: 16rpx;
  637. text-align: center;
  638. line-height: 48rpx;
  639. color: #007aff;
  640. margin: 0 8rpx;
  641. }
  642. .btn1 {
  643. width: 144rpx;
  644. height: 48rpx;
  645. background: #ffffff;
  646. border: 2rpx solid #999999;
  647. border-radius: 16rpx;
  648. text-align: center;
  649. line-height: 48rpx;
  650. color: #999999;
  651. margin: 0 8rpx;
  652. }
  653. }
  654. }
  655. .lisChild:last-child {
  656. margin-bottom: 34rpx;
  657. }
  658. .noData {
  659. text-align: center;
  660. font-size: 32rpx;
  661. font-family: PingFang SC;
  662. font-weight: 500;
  663. color: #999999;
  664. margin: 160rpx 0;
  665. }
  666. .apply_btn {
  667. width: 100%;
  668. height: 124rpx;
  669. background: #ffffff;
  670. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1);
  671. z-index: 100;
  672. position: fixed;
  673. left: 0;
  674. right: 0;
  675. bottom: 0rpx;
  676. }
  677. .apply-invoice {
  678. margin: 0 auto;
  679. width: 686rpx;
  680. height: 84rpx;
  681. line-height: 84rpx;
  682. text-align: center;
  683. font-size: 32rpx;
  684. color: #fff;
  685. background: #0080ff;
  686. margin-top: 20rpx;
  687. border-radius: 120rpx;
  688. }
  689. .bottomBox {
  690. position: fixed;
  691. bottom: 0;
  692. width: 100%;
  693. left: 0;
  694. height: 98rpx;
  695. background-color: #ffffff;
  696. display: flex;
  697. justify-content: space-between;
  698. align-items: center;
  699. padding: 0 30rpx;
  700. }
  701. .rf-popup-main {
  702. text-align: center;
  703. padding: 40rpx;
  704. .title {
  705. font-size: 40rpx;
  706. font-weight: 600;
  707. }
  708. .tip {
  709. margin: 30rpx 0 40rpx;
  710. font-size: 32rpx;
  711. }
  712. .u-input {
  713. border-radius: 20rpx;
  714. background: #eee;
  715. padding-left: 20rpx !important;
  716. margin-bottom: 40rpx;
  717. }
  718. .u-button {
  719. border-radius: 60rpx !important;
  720. }
  721. }
  722. </style>