index.vue 21 KB

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