index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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 96rpx;">
  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 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-invoice" @click="goInvoice">发票申请</view>
  76. </template>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { mapGetters } from 'vuex';
  82. export default {
  83. components: {},
  84. data() {
  85. return {
  86. list: [
  87. {
  88. name: '待支付',
  89. count: 0
  90. },
  91. {
  92. name: '已支付',
  93. count: 0
  94. },
  95. {
  96. name: '已取消',
  97. count: 0
  98. },
  99. {
  100. name: '已退款',
  101. count: 0
  102. }
  103. ],
  104. current: 0,
  105. order: [],
  106. formData: {
  107. status: '0,1',
  108. pageNum: 1,
  109. pageSize: 10
  110. },
  111. pageNum1: 0,
  112. pageNum2: 0,
  113. pageNum3: 0,
  114. pageNum4: 0
  115. };
  116. },
  117. // onPullDownRefresh() {},
  118. onLoad(option) {
  119. this.current = +option.current || 0;
  120. this.getOrderList();
  121. this.getOrderNum();
  122. console.log(this.current)
  123. },
  124. onShow() {
  125. /* if(this.current === 2 && this.$method.isLogin()){
  126. this.$refs.refMy.init();
  127. } */
  128. },
  129. //分享功能
  130. onShareAppMessage(res) {
  131. var self = this;
  132. return {
  133. title: '中正',
  134. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  135. };
  136. },
  137. onReachBottom() {
  138. this.formData.pageNum++;
  139. this.getFY();
  140. },
  141. methods: {
  142. getOrderNum() {
  143. this.$api.getorderlists({
  144. status: '0,1',
  145. pageNum: 1,
  146. pageSize: 1,
  147. orderStatus:'0'
  148. }).then(res => {
  149. if (res.data.code === 200) {
  150. this.list[0].count = res.data.total;
  151. }
  152. });
  153. this.$api.getorderlists({
  154. status: '0,1',
  155. pageNum: 1,
  156. pageSize: 1,
  157. orderStatus:'1,2,3,4'
  158. }).then(res => {
  159. if (res.data.code === 200) {
  160. this.list[1].count = res.data.total;
  161. }
  162. });
  163. this.$api.getorderlists({
  164. status: '0,1',
  165. pageNum: 1,
  166. pageSize: 1,
  167. orderStatus:'-1,-2'
  168. }).then(res => {
  169. if (res.data.code === 200) {
  170. this.list[2].count = res.data.total;
  171. }
  172. });
  173. },
  174. /**
  175. * 跳转发票申请页面
  176. */
  177. goInvoice() {
  178. uni.navigateTo({
  179. url:`/pages2/invoice/index`
  180. })
  181. },
  182. refund(orderSn,goodsId){
  183. uni.showModal({
  184. title:'提示',
  185. content:'确定要退款吗',
  186. success:(res) => {
  187. if(res.confirm) {
  188. let self = this
  189. this.$api.refundSmallOrder({orderSn:orderSn,goodsId:goodsId}).then(res => {
  190. if(res.data.code==200){
  191. if (res.data.code === 200) {
  192. self.$method.showToast('退款成功');
  193. self.getOrderList();
  194. }
  195. } else {
  196. uni.showToast({
  197. icon:'none',
  198. title:'不可以退款哦'
  199. })
  200. }
  201. });
  202. }
  203. }
  204. })
  205. },
  206. /**
  207. * 跳转课程
  208. */
  209. goCourse(item,orderStatus) {
  210. // if(orderStatus == 1 || orderStatus == 2) {
  211. // console.log(item)
  212. // if(item.goodsType == 1) { //网课
  213. // uni.navigateTo({
  214. // url:'/pages2/wd/course?gid='+item.gradeId+'&id='+item.goodsId
  215. // })
  216. // } else if(item.goodsType == 2) { //题库
  217. // uni.navigateTo({
  218. // url:'/pages2/bank/question_detail?id='+item.goodsId
  219. // })
  220. // }
  221. // }
  222. },
  223. resumeOrder(item){
  224. let self = this
  225. uni.login({
  226. provider: 'weixin',
  227. success: function(loginRes) {
  228. console.log(loginRes,69)
  229. self.getOpenid(loginRes.code,item)
  230. }
  231. });
  232. },
  233. getOpenid(code,item){
  234. let self = this
  235. this.$api.wxOpenid({code:code}).then(res => {
  236. if(res.data.code==200){
  237. self.resumeOrderPay(item)
  238. }
  239. });
  240. },
  241. resumeOrderPay(item){
  242. let data = {orderSn:item.orderSn}
  243. this.$api.resumeSmallOrder(data).then(res => {
  244. if(res.data.code==200){
  245. let data = res.data.data
  246. uni.requestPayment({
  247. provider: data.provider,
  248. nonceStr: data.nonceStr,
  249. package: data.package,
  250. signType: data.signType,
  251. paySign: data.sign,
  252. timeStamp: String(data.timeStamp),
  253. success: function (res) {
  254. uni.redirectTo({
  255. url: '/pages2/order/confirm_success?sn='+data.orderSn
  256. });
  257. console.log('success:' + JSON.stringify(res));
  258. },
  259. fail: function (err) {
  260. console.log('fail:' + JSON.stringify(err));
  261. }
  262. });
  263. }else{
  264. uni.showModal({
  265. title: "提示",
  266. content: res.data.msg,
  267. showCancel: false
  268. })
  269. }
  270. });
  271. },
  272. openPopup() {},
  273. //删除订单
  274. delOrder(item) {
  275. var self = this;
  276. uni.showModal({
  277. content: '确定要删除该订单吗',
  278. success: function(res) {
  279. if (res.confirm) {
  280. self.$api
  281. .eddOrder({
  282. orderId: item.orderId,
  283. status: -1
  284. })
  285. .then(res => {
  286. if (res.data.code === 200) {
  287. self.$method.showToast('订单删除成功');
  288. self.getOrderList();
  289. }
  290. });
  291. }
  292. }
  293. });
  294. },
  295. //取消订单
  296. closeOrder(item) {
  297. var self = this;
  298. uni.showModal({
  299. content: '确定要取消该订单吗',
  300. success: function(res) {
  301. if (res.confirm) {
  302. self.$api
  303. .eddOrder({
  304. orderId: item.orderId,
  305. orderStatus: -1
  306. })
  307. .then(res => {
  308. if (res.data.code === 200) {
  309. self.$method.showToast('订单取消成功', 'success');
  310. self.getOrderList();
  311. }
  312. });
  313. }
  314. }
  315. });
  316. },
  317. getFY() {
  318. if (this.current === 0) {
  319. this.formData.orderStatus = '0';
  320. if (this.order.length >= this.pageNum1) {
  321. return;
  322. }
  323. }
  324. if (this.current === 1) {
  325. this.formData.orderStatus = '1,2,3,4';
  326. if (this.order.length >= this.pageNum2) {
  327. return;
  328. }
  329. }
  330. if (this.current === 2) {
  331. this.formData.orderStatus = '-1,-2';
  332. if (this.order.length >= this.pageNum3) {
  333. return;
  334. }
  335. }
  336. if(this.current == 3) {
  337. if(this.order.length >= this.pageNum4) {
  338. return;
  339. }
  340. this.formData.orderStatus = '';
  341. this.$api.orderRefundList(this.formData).then(res => {
  342. if(res.data.code == 200) {
  343. this.order = this.order.concat(res.data.rows);
  344. }
  345. })
  346. return;
  347. }
  348. this.$api.getorderlists(this.formData).then(res => {
  349. if (res.data.code === 200) {
  350. if (res.data.rows.length) {
  351. this.order = this.order.concat(res.data.rows);
  352. }
  353. }
  354. });
  355. },
  356. //获取订单
  357. getOrderList() {
  358. this.formData.pageNum = 1;
  359. if (this.current === 0) {
  360. this.formData.orderStatus = '0';
  361. }
  362. if (this.current === 1) {
  363. this.formData.orderStatus = '1,2,3,4';
  364. }
  365. if (this.current === 2) {
  366. this.formData.orderStatus = '-1,-2';
  367. }
  368. this.order = [];
  369. this.$api.getorderlists(this.formData).then(res => {
  370. if (res.data.code === 200) {
  371. if (this.current === 0) {
  372. this.list[0].count = res.data.total;
  373. this.pageNum1 = res.data.total;
  374. }
  375. if (this.current === 1) {
  376. this.list[1].count = res.data.total;
  377. this.pageNum2 = res.data.total;
  378. }
  379. if (this.current === 2) {
  380. this.list[2].count = res.data.total;
  381. this.pageNum3 = res.data.total;
  382. }
  383. this.order = res.data.rows;
  384. }
  385. });
  386. },
  387. orderRefundList() {
  388. this.order = [];
  389. this.formData.pageNum = 1;
  390. this.formData.orderStatus = ''
  391. this.$api.orderRefundList(this.formData).then(res => {
  392. if(res.data.code == 200) {
  393. this.order = res.data.rows;
  394. }
  395. })
  396. },
  397. change(index) {
  398. if (this.current === index) {
  399. return;
  400. }
  401. this.current = index;
  402. console.log('this.current', this.current)
  403. if(this.current == 3) { //退款订单
  404. this.formData.status = '';
  405. this.orderRefundList()
  406. } else { //其他订单
  407. this.formData.status = '0,1';
  408. this.getOrderList();
  409. }
  410. uni.pageScrollTo({
  411. scrollTop: 0
  412. });
  413. }
  414. },
  415. computed: { ...mapGetters(['userInfo']) }
  416. };
  417. </script>
  418. <style>
  419. page {
  420. background: #eaeef1;
  421. }
  422. </style>
  423. <style scoped lang="scss">
  424. .lisChild {
  425. border-radius: 16rpx;
  426. margin-bottom:16rpx;
  427. background:#fff;
  428. .header {
  429. display: flex;
  430. justify-content: space-between;
  431. align-items: center;
  432. height: 80rpx;
  433. padding:0 15rpx;
  434. color: #666666;
  435. font-size: 24rpx;
  436. }
  437. .body {
  438. padding:16rpx;
  439. &__content {
  440. display: flex;
  441. justify-content: space-between;
  442. .goods-img {
  443. height: 156rpx;
  444. width: 278rpx;
  445. border-radius: 16rpx;
  446. flex-shrink: 0;
  447. }
  448. .goods-text {
  449. margin-left: 20rpx;
  450. flex:1;
  451. display: flex;
  452. flex-direction: column;
  453. .goods-name {
  454. color: #333333;
  455. font-size: 30rpx;
  456. font-weight: bold;
  457. flex:1;
  458. }
  459. .goods-price {
  460. font-size: 30rpx;
  461. font-family: PingFang SC;
  462. font-weight: bold;
  463. color: #ff2d55;
  464. display: flex;
  465. flex-direction: row-reverse;
  466. }
  467. }
  468. }
  469. .btn2 {
  470. width: 144rpx;
  471. height: 46rpx;
  472. background: #ffffff;
  473. border: 2rpx solid #007aff;
  474. border-radius: 16rpx;
  475. text-align: center;
  476. line-height: 48rpx;
  477. color: #007aff;
  478. margin: 0 8rpx;
  479. }
  480. }
  481. .footer {
  482. padding:0 24rpx;
  483. height: 80rpx;
  484. display: flex;
  485. justify-content: space-between;
  486. align-items: center;
  487. .btn2 {
  488. width: 144rpx;
  489. height: 46rpx;
  490. background: #ffffff;
  491. border: 2rpx solid #007aff;
  492. border-radius: 16rpx;
  493. text-align: center;
  494. line-height: 48rpx;
  495. color: #007aff;
  496. margin: 0 8rpx;
  497. }
  498. .btn1 {
  499. width: 144rpx;
  500. height: 48rpx;
  501. background: #ffffff;
  502. border: 2rpx solid #999999;
  503. border-radius: 16rpx;
  504. text-align: center;
  505. line-height: 48rpx;
  506. color: #999999;
  507. margin: 0 8rpx;
  508. }
  509. }
  510. }
  511. .lisChild:last-child {
  512. margin-bottom: 34rpx;
  513. }
  514. .noData {
  515. text-align: center;
  516. font-size: 32rpx;
  517. font-family: PingFang SC;
  518. font-weight: 500;
  519. color: #999999;
  520. margin: 160rpx 0;
  521. }
  522. .apply-invoice {
  523. z-index: 100;
  524. position:fixed;
  525. left:0;
  526. right:0;
  527. bottom:40rpx;
  528. margin:0 auto;
  529. width: 526rpx;
  530. height: 80rpx;
  531. text-align: center;
  532. line-height: 80rpx;
  533. color:#fff;
  534. background: #007AFF;
  535. box-shadow: 0rpx 8rpx 7rpx 1rpx rgba(0, 122, 255, 0.1);
  536. border-radius: 40rpx;
  537. }
  538. .bottomBox {
  539. position: fixed;
  540. bottom: 0;
  541. width: 100%;
  542. left: 0;
  543. height: 98rpx;
  544. background-color: #ffffff;
  545. display: flex;
  546. justify-content: space-between;
  547. align-items: center;
  548. padding: 0 30rpx;
  549. }
  550. </style>