index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <view>
  3. <nav-bar title="我的订单"></nav-bar>
  4. <view style="width: 100%;text-align: center;position: fixed;height: 96rpx;z-index: 999;" >
  5. <u-tabs :list="list" sticky :current="current" @change="change" active-color="#007AFF" :offset="[-1,0]"></u-tabs>
  6. </view>
  7. <view style="padding: 96rpx 8rpx 130rpx;">
  8. <view v-if="!order.length" class="noData">您暂无相关订单哦~</view>
  9. <template v-else>
  10. <view v-for="(item, index) in order" :key="index" class="lisChild">
  11. <view class="item">
  12. <view class="header" @click="openPopup(index)">
  13. <view>订单编号:{{ item.orderSn }}</view>
  14. <view>{{ $method.timestampToTime(item.createTime) }}</view>
  15. </view>
  16. <u-line color="#D6D6DB" />
  17. <view v-if="current == 3">
  18. <view class="body"
  19. >
  20. <view class="body__content">
  21. <image class="goods-img" :src="$method.splitImgHost(item.coverUrl)"></image>
  22. <view class="goods-text">
  23. <view class="goods-name">{{ item.goodsName }}</view>
  24. <!-- <view class="goods-price">¥ {{ items.goodsRealPrice }}</view> -->
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view v-else >
  30. <view class="body"
  31. v-for="(items, indexs) in item.orderGoodsList"
  32. :key="indexs" @click="goCourse(items,item.orderStatus)"
  33. >
  34. <view class="body__content">
  35. <image class="goods-img" :src="$method.splitImgHost(items.coverUrl)"></image>
  36. <view class="goods-text">
  37. <view class="goods-name">{{ items.goodsName }}</view>
  38. <view v-if="item.orderFrom !== 6" class="goods-price">¥ {{ items.goodsRealPrice }}</view>
  39. </view>
  40. </view>
  41. <view style="display: flex;flex-direction: row-reverse;padding: 10rpx 0;">
  42. <view class="btn2" v-if="items.refundStatus === 0&&(item.orderFrom === 2 || item.orderFrom === 3)&&(item.orderStatus === 1 || item.orderStatus === 2 || item.orderStatus === 3)&&(items.goodsType == '1' || items.goodsType == '2' || items.goodsType == '6') && items.goodsPrice > 0" @click.stop="refund(item.orderSn,items.goodsId)">退款</view>
  43. <view v-if="items.refundStatus == 2"> 已退款</view>
  44. </view>
  45. </view>
  46. </view>
  47. <u-line color="#D6D6DB" />
  48. <view class="footer" v-if="current == 3">
  49. <view>
  50. <text style="color:#999;font-size: 24rpx;margin-right: 8rpx;">退款金额</text>
  51. <text style="color:#ff2d55;font-size: 30rpx;font-weight: bold;">¥{{ item.refundFee }}</text>
  52. </view>
  53. </view>
  54. <view class="footer" v-else>
  55. <view>
  56. <text style="color:#999;font-size: 24rpx;margin-right: 8rpx;">共{{ item.orderGoodsList.length }}项</text>
  57. <!-- 业务系统下单的需要隐藏价格 -->
  58. <!-- 订单来源:1业务员普通单,2祥粤云学堂小程序,3祥粤云学堂网站,4祥粤e管证小程序,5业务员录单,6业务系统下单 -->
  59. <text v-if="item.orderFrom !== 6">
  60. <text style="color: #333;font-size: 30rpx;font-weight: bold;">合计</text>
  61. <text style="color:#ff2d55;font-size: 30rpx;font-weight: bold;">¥{{ item.payPrice }}</text>
  62. </text>
  63. </view>
  64. <view style="display: flex;align-items: center;">
  65. <view class="btn2" v-if="item.orderStatus === 0&&(item.orderFrom === 2 || item.orderFrom === 3)" @click="resumeOrder(item)">继续支付</view>
  66. <!-- <view class="btn2" v-if="item.orderStatus === -1 || item.orderStatus === -2" @click="againBuy(item)">重新购买</view> -->
  67. <view class="btn1" v-if="(item.orderStatus === -1 || item.orderStatus === -2)&&(item.orderFrom === 2 || item.orderFrom === 3)" @click="delOrder(item)">删除订单</view>
  68. <view class="btn1" @click="closeOrder(item)" v-if="item.orderStatus === 0 &&(item.orderFrom === 2 || item.orderFrom === 3)">取消订单</view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <template v-if="current == 1 && order.length">
  75. <view class="apply_btn">
  76. <view class="apply-invoice" @click="goInvoice">发票申请</view>
  77. </view>
  78. </template>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import { mapGetters } from 'vuex';
  84. export default {
  85. components: {},
  86. data() {
  87. return {
  88. list: [
  89. {
  90. name: '待支付',
  91. count: 0
  92. },
  93. {
  94. name: '已支付',
  95. count: 0
  96. },
  97. {
  98. name: '已取消',
  99. count: 0
  100. },
  101. {
  102. name: '已退款',
  103. count: 0
  104. }
  105. ],
  106. current: 0,
  107. order: [],
  108. formData: {
  109. status: '0,1',
  110. pageNum: 1,
  111. pageSize: 10
  112. },
  113. pageNum1: 0,
  114. pageNum2: 0,
  115. pageNum3: 0,
  116. pageNum4: 0
  117. };
  118. },
  119. // onPullDownRefresh() {},
  120. onLoad(option) {
  121. this.current = +option.current || 0;
  122. this.getOrderList();
  123. this.getOrderNum();
  124. console.log(this.current)
  125. },
  126. onShow() {
  127. /* if(this.current === 2 && this.$method.isLogin()){
  128. this.$refs.refMy.init();
  129. } */
  130. },
  131. //分享功能
  132. onShareAppMessage(res) {
  133. var self = this;
  134. return {
  135. title: '中正',
  136. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  137. };
  138. },
  139. onReachBottom() {
  140. this.formData.pageNum++;
  141. this.getFY();
  142. },
  143. methods: {
  144. getOrderNum() {
  145. this.$api.getorderlists({
  146. status: '0,1',
  147. pageNum: 1,
  148. pageSize: 1,
  149. orderStatus:'0'
  150. }).then(res => {
  151. if (res.data.code === 200) {
  152. this.list[0].count = res.data.total;
  153. }
  154. });
  155. this.$api.getorderlists({
  156. status: '0,1',
  157. pageNum: 1,
  158. pageSize: 1,
  159. orderStatus:'1,2,3,4'
  160. }).then(res => {
  161. if (res.data.code === 200) {
  162. this.list[1].count = res.data.total;
  163. }
  164. });
  165. this.$api.getorderlists({
  166. status: '0,1',
  167. pageNum: 1,
  168. pageSize: 1,
  169. orderStatus:'-1,-2'
  170. }).then(res => {
  171. if (res.data.code === 200) {
  172. this.list[2].count = res.data.total;
  173. }
  174. });
  175. },
  176. /**
  177. * 跳转发票申请页面
  178. */
  179. goInvoice() {
  180. uni.navigateTo({
  181. url:`/pages2/invoice/index`
  182. })
  183. },
  184. refund(orderSn,goodsId){
  185. uni.showModal({
  186. title:'提示',
  187. content:'确定要退款吗',
  188. success:(res) => {
  189. if(res.confirm) {
  190. let self = this
  191. this.$api.refundSmallOrder({orderSn:orderSn,goodsId:goodsId}).then(res => {
  192. if(res.data.code==200){
  193. if (res.data.code === 200) {
  194. self.$method.showToast('退款成功');
  195. self.getOrderList();
  196. }
  197. } else {
  198. uni.showToast({
  199. icon:'none',
  200. title:'不可以退款哦'
  201. })
  202. }
  203. });
  204. }
  205. }
  206. })
  207. },
  208. /**
  209. * 跳转课程
  210. */
  211. goCourse(item,orderStatus) {
  212. // if(orderStatus == 1 || orderStatus == 2) {
  213. // console.log(item)
  214. // if(item.goodsType == 1) { //网课
  215. // uni.navigateTo({
  216. // url:'/pages2/wd/course?gid='+item.gradeId+'&id='+item.goodsId
  217. // })
  218. // } else if(item.goodsType == 2) { //题库
  219. // uni.navigateTo({
  220. // url:'/pages2/bank/question_detail?id='+item.goodsId
  221. // })
  222. // }
  223. // }
  224. },
  225. resumeOrder(item){
  226. let self = this
  227. // #ifdef MP-WEIXIN
  228. uni.login({
  229. provider: 'weixin',
  230. success: function(loginRes) {
  231. console.log(loginRes,69)
  232. self.getOpenid(loginRes.code,item)
  233. }
  234. });
  235. // #endif
  236. // #ifdef H5
  237. location.replace(
  238. "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6f48f721d18244eb" +
  239. "&redirect_uri=" +
  240. encodeURIComponent('https://www.xyyxt.net') +
  241. "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
  242. )
  243. // #endif
  244. },
  245. getOpenid(code,item){
  246. let self = this
  247. this.$api.wxOpenid({code:code}).then(res => {
  248. if(res.data.code==200){
  249. self.resumeOrderPay(item)
  250. }
  251. });
  252. },
  253. resumeOrderPay(item){
  254. let data = {orderSn:item.orderSn}
  255. this.$api.resumeSmallOrder(data).then(res => {
  256. if(res.data.code==200){
  257. let data = res.data.data
  258. uni.requestPayment({
  259. provider: data.provider,
  260. nonceStr: data.nonceStr,
  261. package: data.package,
  262. signType: data.signType,
  263. paySign: data.sign,
  264. timeStamp: String(data.timeStamp),
  265. success: function (res) {
  266. uni.redirectTo({
  267. url: '/pages2/order/confirm_success?sn='+data.orderSn
  268. });
  269. console.log('success:' + JSON.stringify(res));
  270. },
  271. fail: function (err) {
  272. console.log('fail:' + JSON.stringify(err));
  273. }
  274. });
  275. }else{
  276. uni.showModal({
  277. title: "提示",
  278. content: res.data.msg,
  279. showCancel: false
  280. })
  281. }
  282. });
  283. },
  284. openPopup() {},
  285. //删除订单
  286. delOrder(item) {
  287. var self = this;
  288. uni.showModal({
  289. content: '确定要删除该订单吗',
  290. success: function(res) {
  291. if (res.confirm) {
  292. self.$api
  293. .eddOrder({
  294. orderId: item.orderId,
  295. status: -1
  296. })
  297. .then(res => {
  298. if (res.data.code === 200) {
  299. self.$method.showToast('订单删除成功');
  300. self.getOrderList();
  301. }
  302. });
  303. }
  304. }
  305. });
  306. },
  307. //取消订单
  308. closeOrder(item) {
  309. var self = this;
  310. uni.showModal({
  311. content: '确定要取消该订单吗',
  312. success: function(res) {
  313. if (res.confirm) {
  314. self.$api
  315. .eddOrder({
  316. orderId: item.orderId,
  317. orderStatus: -1
  318. })
  319. .then(res => {
  320. if (res.data.code === 200) {
  321. self.$method.showToast('订单取消成功', 'success');
  322. self.getOrderList();
  323. }
  324. });
  325. }
  326. }
  327. });
  328. },
  329. getFY() {
  330. if (this.current === 0) {
  331. this.formData.orderStatus = '0';
  332. if (this.order.length >= this.pageNum1) {
  333. return;
  334. }
  335. }
  336. if (this.current === 1) {
  337. this.formData.orderStatus = '1,2,3,4';
  338. if (this.order.length >= this.pageNum2) {
  339. return;
  340. }
  341. }
  342. if (this.current === 2) {
  343. this.formData.orderStatus = '-1,-2';
  344. if (this.order.length >= this.pageNum3) {
  345. return;
  346. }
  347. }
  348. if(this.current == 3) {
  349. if(this.order.length >= this.pageNum4) {
  350. return;
  351. }
  352. this.formData.orderStatus = '';
  353. this.$api.orderRefundList(this.formData).then(res => {
  354. if(res.data.code == 200) {
  355. this.order = this.order.concat(res.data.rows);
  356. }
  357. })
  358. return;
  359. }
  360. this.$api.getorderlists(this.formData).then(res => {
  361. if (res.data.code === 200) {
  362. if (res.data.rows.length) {
  363. this.order = this.order.concat(res.data.rows);
  364. }
  365. }
  366. });
  367. },
  368. //获取订单
  369. getOrderList() {
  370. this.formData.pageNum = 1;
  371. if (this.current === 0) {
  372. this.formData.orderStatus = '0';
  373. }
  374. if (this.current === 1) {
  375. this.formData.orderStatus = '1,2,3,4';
  376. }
  377. if (this.current === 2) {
  378. this.formData.orderStatus = '-1,-2';
  379. }
  380. this.order = [];
  381. this.$api.getorderlists(this.formData).then(res => {
  382. if (res.data.code === 200) {
  383. if (this.current === 0) {
  384. this.list[0].count = res.data.total;
  385. this.pageNum1 = res.data.total;
  386. }
  387. if (this.current === 1) {
  388. this.list[1].count = res.data.total;
  389. this.pageNum2 = res.data.total;
  390. }
  391. if (this.current === 2) {
  392. this.list[2].count = res.data.total;
  393. this.pageNum3 = res.data.total;
  394. }
  395. this.order = res.data.rows;
  396. console.log('订单列表this.order', this.order)
  397. }
  398. });
  399. },
  400. orderRefundList() {
  401. this.order = [];
  402. this.formData.pageNum = 1;
  403. this.formData.orderStatus = ''
  404. this.$api.orderRefundList(this.formData).then(res => {
  405. if(res.data.code == 200) {
  406. this.order = res.data.rows;
  407. }
  408. })
  409. },
  410. change(index) {
  411. if (this.current === index) {
  412. return;
  413. }
  414. this.current = index;
  415. console.log('this.current', this.current)
  416. if(this.current == 3) { //退款订单
  417. this.formData.status = '';
  418. this.orderRefundList()
  419. } else { //其他订单
  420. this.formData.status = '0,1';
  421. this.getOrderList();
  422. }
  423. uni.pageScrollTo({
  424. scrollTop: 0
  425. });
  426. }
  427. },
  428. computed: { ...mapGetters(['userInfo']) }
  429. };
  430. </script>
  431. <style>
  432. page {
  433. background: #eaeef1;
  434. }
  435. </style>
  436. <style scoped lang="scss">
  437. .lisChild {
  438. border-radius: 16rpx;
  439. margin-bottom:16rpx;
  440. background:#fff;
  441. .header {
  442. display: flex;
  443. justify-content: space-between;
  444. align-items: center;
  445. height: 80rpx;
  446. padding:0 15rpx;
  447. color: #666666;
  448. font-size: 24rpx;
  449. }
  450. .body {
  451. padding:16rpx;
  452. &__content {
  453. display: flex;
  454. justify-content: space-between;
  455. .goods-img {
  456. height: 156rpx;
  457. width: 278rpx;
  458. border-radius: 16rpx;
  459. flex-shrink: 0;
  460. }
  461. .goods-text {
  462. margin-left: 20rpx;
  463. flex:1;
  464. display: flex;
  465. flex-direction: column;
  466. .goods-name {
  467. color: #333333;
  468. font-size: 30rpx;
  469. font-weight: bold;
  470. flex:1;
  471. }
  472. .goods-price {
  473. font-size: 30rpx;
  474. font-family: PingFang SC;
  475. font-weight: bold;
  476. color: #ff2d55;
  477. display: flex;
  478. flex-direction: row-reverse;
  479. }
  480. }
  481. }
  482. .btn2 {
  483. width: 144rpx;
  484. height: 46rpx;
  485. background: #ffffff;
  486. border: 2rpx solid #007aff;
  487. border-radius: 16rpx;
  488. text-align: center;
  489. line-height: 48rpx;
  490. color: #007aff;
  491. margin: 0 8rpx;
  492. }
  493. }
  494. .footer {
  495. padding:0 24rpx;
  496. height: 80rpx;
  497. display: flex;
  498. justify-content: space-between;
  499. align-items: center;
  500. .btn2 {
  501. width: 144rpx;
  502. height: 46rpx;
  503. background: #ffffff;
  504. border: 2rpx solid #007aff;
  505. border-radius: 16rpx;
  506. text-align: center;
  507. line-height: 48rpx;
  508. color: #007aff;
  509. margin: 0 8rpx;
  510. }
  511. .btn1 {
  512. width: 144rpx;
  513. height: 48rpx;
  514. background: #ffffff;
  515. border: 2rpx solid #999999;
  516. border-radius: 16rpx;
  517. text-align: center;
  518. line-height: 48rpx;
  519. color: #999999;
  520. margin: 0 8rpx;
  521. }
  522. }
  523. }
  524. .lisChild:last-child {
  525. margin-bottom: 34rpx;
  526. }
  527. .noData {
  528. text-align: center;
  529. font-size: 32rpx;
  530. font-family: PingFang SC;
  531. font-weight: 500;
  532. color: #999999;
  533. margin: 160rpx 0;
  534. }
  535. .apply_btn {
  536. width: 100%;
  537. height: 124rpx;
  538. background: #FFFFFF;
  539. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0,0,0,0.1000);
  540. z-index: 100;
  541. position:fixed;
  542. left:0;
  543. right:0;
  544. bottom: 0rpx;
  545. }
  546. .apply-invoice {
  547. margin:0 auto;
  548. width: 686rpx;
  549. height: 84rpx;
  550. line-height: 84rpx;
  551. text-align: center;
  552. font-size: 32rpx;
  553. color:#fff;
  554. background: #0080FF;
  555. margin-top: 20rpx;
  556. border-radius: 120rpx;
  557. }
  558. .bottomBox {
  559. position: fixed;
  560. bottom: 0;
  561. width: 100%;
  562. left: 0;
  563. height: 98rpx;
  564. background-color: #ffffff;
  565. display: flex;
  566. justify-content: space-between;
  567. align-items: center;
  568. padding: 0 30rpx;
  569. }
  570. </style>