index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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. uni.login({
  228. provider: 'weixin',
  229. success: function(loginRes) {
  230. console.log(loginRes,69)
  231. self.getOpenid(loginRes.code,item)
  232. }
  233. });
  234. },
  235. getOpenid(code,item){
  236. let self = this
  237. this.$api.wxOpenid({code:code}).then(res => {
  238. if(res.data.code==200){
  239. self.resumeOrderPay(item)
  240. }
  241. });
  242. },
  243. resumeOrderPay(item){
  244. let data = {orderSn:item.orderSn}
  245. this.$api.resumeSmallOrder(data).then(res => {
  246. if(res.data.code==200){
  247. let data = res.data.data
  248. uni.requestPayment({
  249. provider: data.provider,
  250. nonceStr: data.nonceStr,
  251. package: data.package,
  252. signType: data.signType,
  253. paySign: data.sign,
  254. timeStamp: String(data.timeStamp),
  255. success: function (res) {
  256. uni.redirectTo({
  257. url: '/pages2/order/confirm_success?sn='+data.orderSn
  258. });
  259. console.log('success:' + JSON.stringify(res));
  260. },
  261. fail: function (err) {
  262. console.log('fail:' + JSON.stringify(err));
  263. }
  264. });
  265. }else{
  266. uni.showModal({
  267. title: "提示",
  268. content: res.data.msg,
  269. showCancel: false
  270. })
  271. }
  272. });
  273. },
  274. openPopup() {},
  275. //删除订单
  276. delOrder(item) {
  277. var self = this;
  278. uni.showModal({
  279. content: '确定要删除该订单吗',
  280. success: function(res) {
  281. if (res.confirm) {
  282. self.$api
  283. .eddOrder({
  284. orderId: item.orderId,
  285. status: -1
  286. })
  287. .then(res => {
  288. if (res.data.code === 200) {
  289. self.$method.showToast('订单删除成功');
  290. self.getOrderList();
  291. }
  292. });
  293. }
  294. }
  295. });
  296. },
  297. //取消订单
  298. closeOrder(item) {
  299. var self = this;
  300. uni.showModal({
  301. content: '确定要取消该订单吗',
  302. success: function(res) {
  303. if (res.confirm) {
  304. self.$api
  305. .eddOrder({
  306. orderId: item.orderId,
  307. orderStatus: -1
  308. })
  309. .then(res => {
  310. if (res.data.code === 200) {
  311. self.$method.showToast('订单取消成功', 'success');
  312. self.getOrderList();
  313. }
  314. });
  315. }
  316. }
  317. });
  318. },
  319. getFY() {
  320. if (this.current === 0) {
  321. this.formData.orderStatus = '0';
  322. if (this.order.length >= this.pageNum1) {
  323. return;
  324. }
  325. }
  326. if (this.current === 1) {
  327. this.formData.orderStatus = '1,2,3,4';
  328. if (this.order.length >= this.pageNum2) {
  329. return;
  330. }
  331. }
  332. if (this.current === 2) {
  333. this.formData.orderStatus = '-1,-2';
  334. if (this.order.length >= this.pageNum3) {
  335. return;
  336. }
  337. }
  338. if(this.current == 3) {
  339. if(this.order.length >= this.pageNum4) {
  340. return;
  341. }
  342. this.formData.orderStatus = '';
  343. this.$api.orderRefundList(this.formData).then(res => {
  344. if(res.data.code == 200) {
  345. this.order = this.order.concat(res.data.rows);
  346. }
  347. })
  348. return;
  349. }
  350. this.$api.getorderlists(this.formData).then(res => {
  351. if (res.data.code === 200) {
  352. if (res.data.rows.length) {
  353. this.order = this.order.concat(res.data.rows);
  354. }
  355. }
  356. });
  357. },
  358. //获取订单
  359. getOrderList() {
  360. this.formData.pageNum = 1;
  361. if (this.current === 0) {
  362. this.formData.orderStatus = '0';
  363. }
  364. if (this.current === 1) {
  365. this.formData.orderStatus = '1,2,3,4';
  366. }
  367. if (this.current === 2) {
  368. this.formData.orderStatus = '-1,-2';
  369. }
  370. this.order = [];
  371. this.$api.getorderlists(this.formData).then(res => {
  372. if (res.data.code === 200) {
  373. if (this.current === 0) {
  374. this.list[0].count = res.data.total;
  375. this.pageNum1 = res.data.total;
  376. }
  377. if (this.current === 1) {
  378. this.list[1].count = res.data.total;
  379. this.pageNum2 = res.data.total;
  380. }
  381. if (this.current === 2) {
  382. this.list[2].count = res.data.total;
  383. this.pageNum3 = res.data.total;
  384. }
  385. this.order = res.data.rows;
  386. console.log('订单列表this.order', this.order)
  387. }
  388. });
  389. },
  390. orderRefundList() {
  391. this.order = [];
  392. this.formData.pageNum = 1;
  393. this.formData.orderStatus = ''
  394. this.$api.orderRefundList(this.formData).then(res => {
  395. if(res.data.code == 200) {
  396. this.order = res.data.rows;
  397. }
  398. })
  399. },
  400. change(index) {
  401. if (this.current === index) {
  402. return;
  403. }
  404. this.current = index;
  405. console.log('this.current', this.current)
  406. if(this.current == 3) { //退款订单
  407. this.formData.status = '';
  408. this.orderRefundList()
  409. } else { //其他订单
  410. this.formData.status = '0,1';
  411. this.getOrderList();
  412. }
  413. uni.pageScrollTo({
  414. scrollTop: 0
  415. });
  416. }
  417. },
  418. computed: { ...mapGetters(['userInfo']) }
  419. };
  420. </script>
  421. <style>
  422. page {
  423. background: #eaeef1;
  424. }
  425. </style>
  426. <style scoped lang="scss">
  427. .lisChild {
  428. border-radius: 16rpx;
  429. margin-bottom:16rpx;
  430. background:#fff;
  431. .header {
  432. display: flex;
  433. justify-content: space-between;
  434. align-items: center;
  435. height: 80rpx;
  436. padding:0 15rpx;
  437. color: #666666;
  438. font-size: 24rpx;
  439. }
  440. .body {
  441. padding:16rpx;
  442. &__content {
  443. display: flex;
  444. justify-content: space-between;
  445. .goods-img {
  446. height: 156rpx;
  447. width: 278rpx;
  448. border-radius: 16rpx;
  449. flex-shrink: 0;
  450. }
  451. .goods-text {
  452. margin-left: 20rpx;
  453. flex:1;
  454. display: flex;
  455. flex-direction: column;
  456. .goods-name {
  457. color: #333333;
  458. font-size: 30rpx;
  459. font-weight: bold;
  460. flex:1;
  461. }
  462. .goods-price {
  463. font-size: 30rpx;
  464. font-family: PingFang SC;
  465. font-weight: bold;
  466. color: #ff2d55;
  467. display: flex;
  468. flex-direction: row-reverse;
  469. }
  470. }
  471. }
  472. .btn2 {
  473. width: 144rpx;
  474. height: 46rpx;
  475. background: #ffffff;
  476. border: 2rpx solid #007aff;
  477. border-radius: 16rpx;
  478. text-align: center;
  479. line-height: 48rpx;
  480. color: #007aff;
  481. margin: 0 8rpx;
  482. }
  483. }
  484. .footer {
  485. padding:0 24rpx;
  486. height: 80rpx;
  487. display: flex;
  488. justify-content: space-between;
  489. align-items: center;
  490. .btn2 {
  491. width: 144rpx;
  492. height: 46rpx;
  493. background: #ffffff;
  494. border: 2rpx solid #007aff;
  495. border-radius: 16rpx;
  496. text-align: center;
  497. line-height: 48rpx;
  498. color: #007aff;
  499. margin: 0 8rpx;
  500. }
  501. .btn1 {
  502. width: 144rpx;
  503. height: 48rpx;
  504. background: #ffffff;
  505. border: 2rpx solid #999999;
  506. border-radius: 16rpx;
  507. text-align: center;
  508. line-height: 48rpx;
  509. color: #999999;
  510. margin: 0 8rpx;
  511. }
  512. }
  513. }
  514. .lisChild:last-child {
  515. margin-bottom: 34rpx;
  516. }
  517. .noData {
  518. text-align: center;
  519. font-size: 32rpx;
  520. font-family: PingFang SC;
  521. font-weight: 500;
  522. color: #999999;
  523. margin: 160rpx 0;
  524. }
  525. .apply_btn {
  526. width: 100%;
  527. height: 124rpx;
  528. background: #FFFFFF;
  529. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0,0,0,0.1000);
  530. z-index: 100;
  531. position:fixed;
  532. left:0;
  533. right:0;
  534. bottom: 0rpx;
  535. }
  536. .apply-invoice {
  537. margin:0 auto;
  538. width: 686rpx;
  539. height: 84rpx;
  540. line-height: 84rpx;
  541. text-align: center;
  542. font-size: 32rpx;
  543. color:#fff;
  544. background: #0080FF;
  545. margin-top: 20rpx;
  546. border-radius: 120rpx;
  547. }
  548. .bottomBox {
  549. position: fixed;
  550. bottom: 0;
  551. width: 100%;
  552. left: 0;
  553. height: 98rpx;
  554. background-color: #ffffff;
  555. display: flex;
  556. justify-content: space-between;
  557. align-items: center;
  558. padding: 0 30rpx;
  559. }
  560. </style>