index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view>
  3. <view style="width: 100%;text-align: center;position: fixed;height: 96rpx;z-index: 999;">
  4. <u-tabs :list="list" sticky :current="current" @change="change" active-color="#007AFF"></u-tabs>
  5. </view>
  6. <view style="padding: 96rpx 8rpx 96rpx;">
  7. <view v-if="!order.length" class="noData">您暂无相关订单哦~</view>
  8. <template v-else>
  9. <view v-for="(item, index) in order" :key="index" class="lisChild">
  10. <view class="item">
  11. <view class="header" @click="openPopup(index)">
  12. <view>订单编号:{{ item.orderSn }}</view>
  13. <view>{{ $method.timestampToTime(item.createTime) }}</view>
  14. </view>
  15. <u-line color="#D6D6DB" />
  16. <view class="body"
  17. v-for="(items, indexs) in item.orderGoodsList"
  18. :key="indexs" @click="goCourse(items,item.orderStatus)"
  19. >
  20. <view class="body__content">
  21. <image class="goods-img" :src="$method.splitImgHost(items.coverUrl)"></image>
  22. <view class="goods-text">
  23. <view class="goods-name">{{ items.goodsName }}</view>
  24. <view class="goods-price">¥ {{ items.goodsRealPrice }}</view>
  25. </view>
  26. </view>
  27. <view style="display: flex;flex-direction: row-reverse;padding: 10rpx 0;">
  28. <view class="btn2" v-if="items.refundStatus === 0&&item.orderFrom === 2&&(item.orderStatus === 1 || item.orderStatus === 2 || item.orderStatus === 3)&&(items.goodsType == '1' || items.goodsType == '2')" @click.stop="refund(item.orderSn,items.goodsId)">退款</view>
  29. </view>
  30. </view>
  31. <u-line color="#D6D6DB" />
  32. <view class="footer">
  33. <view>
  34. <text style="color:#999;font-size: 24rpx;margin-right: 8rpx;">共{{ item.orderGoodsList.length }}项</text>
  35. <text style="color: #333;font-size: 30rpx;font-weight: bold;">合计</text>
  36. <text style="color:#ff2d55;font-size: 30rpx;font-weight: bold;">¥{{ item.payPrice }}</text>
  37. </view>
  38. <view style="display: flex;align-items: center;">
  39. <view class="btn2" v-if="item.orderStatus === 0&&item.orderFrom === 2" @click="resumeOrder(item)">继续支付</view>
  40. <!-- <view class="btn2" v-if="item.orderStatus === -1 || item.orderStatus === -2" @click="againBuy(item)">重新购买</view> -->
  41. <view class="btn1" v-if="item.orderStatus === -1 || item.orderStatus === -2" @click="delOrder(item)">删除订单</view>
  42. <view class="btn1" @click="closeOrder(item)" v-if="item.orderStatus === 0">取消订单</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <template v-if="current == 1 && order.length">
  49. <view class="apply-invoice" @click="goInvoice">发票申请</view>
  50. </template>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import { mapGetters } from 'vuex';
  56. export default {
  57. components: {},
  58. data() {
  59. return {
  60. list: [
  61. {
  62. name: '待支付'
  63. },
  64. {
  65. name: '已支付'
  66. },
  67. {
  68. name: '已取消'
  69. }
  70. ],
  71. current: 0,
  72. order: [],
  73. formData: {
  74. status: '0,1',
  75. pageNum: 1,
  76. pageSize: 5
  77. },
  78. pageNum1: 0,
  79. pageNum2: 0,
  80. pageNum3: 0
  81. };
  82. },
  83. // onPullDownRefresh() {},
  84. onLoad(option) {
  85. this.current = +option.current || 0;
  86. this.getOrderList();
  87. console.log(this.current)
  88. },
  89. onShow() {
  90. /* if(this.current === 2 && this.$method.isLogin()){
  91. this.$refs.refMy.init();
  92. } */
  93. },
  94. //分享功能
  95. onShareAppMessage(res) {
  96. var self = this;
  97. return {
  98. title: '中正',
  99. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  100. };
  101. },
  102. onReachBottom() {
  103. this.formData.pageNum++;
  104. this.getFY();
  105. },
  106. methods: {
  107. /**
  108. * 跳转发票申请页面
  109. */
  110. goInvoice() {
  111. uni.navigateTo({
  112. url:`/pages2/invoice/index`
  113. })
  114. },
  115. refund(orderSn,goodsId){
  116. uni.showModal({
  117. title:'提示',
  118. content:'确定要退款吗',
  119. success:(res) => {
  120. if(res.confirm) {
  121. let self = this
  122. this.$api.refundSmallOrder({orderSn:orderSn,goodsId:goodsId}).then(res => {
  123. if(res.data.code==200){
  124. if (res.data.code === 200) {
  125. self.$method.showToast('退款成功');
  126. self.getOrderList();
  127. }
  128. } else {
  129. uni.showToast({
  130. icon:'none',
  131. title:'不可以退款哦'
  132. })
  133. }
  134. });
  135. }
  136. }
  137. })
  138. },
  139. /**
  140. * 跳转课程
  141. */
  142. goCourse(item,orderStatus) {
  143. // if(orderStatus == 1 || orderStatus == 2) {
  144. // console.log(item)
  145. // if(item.goodsType == 1) { //网课
  146. // uni.navigateTo({
  147. // url:'/pages2/wd/course?gid='+item.gradeId+'&id='+item.goodsId
  148. // })
  149. // } else if(item.goodsType == 2) { //题库
  150. // uni.navigateTo({
  151. // url:'/pages2/bank/question_detail?id='+item.goodsId
  152. // })
  153. // }
  154. // }
  155. },
  156. resumeOrder(item){
  157. let self = this
  158. uni.login({
  159. provider: 'weixin',
  160. success: function(loginRes) {
  161. console.log(loginRes,69)
  162. self.getOpenid(loginRes.code,item)
  163. }
  164. });
  165. },
  166. getOpenid(code,item){
  167. let self = this
  168. this.$api.wxOpenid({code:code}).then(res => {
  169. if(res.data.code==200){
  170. self.resumeOrderPay(item)
  171. }
  172. });
  173. },
  174. resumeOrderPay(item){
  175. let data = {orderSn:item.orderSn}
  176. this.$api.resumeSmallOrder(data).then(res => {
  177. if(res.data.code==200){
  178. let data = res.data.data
  179. uni.requestPayment({
  180. provider: data.provider,
  181. nonceStr: data.nonceStr,
  182. package: data.package,
  183. signType: data.signType,
  184. paySign: data.sign,
  185. timeStamp: String(data.timeStamp),
  186. success: function (res) {
  187. uni.redirectTo({
  188. url: '/pages2/order/confirm_success?sn='+data.orderSn
  189. });
  190. console.log('success:' + JSON.stringify(res));
  191. },
  192. fail: function (err) {
  193. console.log('fail:' + JSON.stringify(err));
  194. }
  195. });
  196. }else{
  197. uni.showModal({
  198. title: "提示",
  199. content: res.data.msg,
  200. showCancel: false
  201. })
  202. }
  203. });
  204. },
  205. openPopup() {},
  206. //删除订单
  207. delOrder(item) {
  208. var self = this;
  209. uni.showModal({
  210. content: '确定要删除该订单吗',
  211. success: function(res) {
  212. if (res.confirm) {
  213. self.$api
  214. .eddOrder({
  215. orderId: item.orderId,
  216. status: -1
  217. })
  218. .then(res => {
  219. if (res.data.code === 200) {
  220. self.$method.showToast('订单删除成功');
  221. self.getOrderList();
  222. }
  223. });
  224. }
  225. }
  226. });
  227. },
  228. //取消订单
  229. closeOrder(item) {
  230. var self = this;
  231. uni.showModal({
  232. content: '确定要取消该订单吗',
  233. success: function(res) {
  234. if (res.confirm) {
  235. self.$api
  236. .eddOrder({
  237. orderId: item.orderId,
  238. orderStatus: -1
  239. })
  240. .then(res => {
  241. if (res.data.code === 200) {
  242. self.$method.showToast('订单取消成功', 'success');
  243. self.getOrderList();
  244. }
  245. });
  246. }
  247. }
  248. });
  249. },
  250. getFY() {
  251. if (this.current === 0) {
  252. this.formData.orderStatus = '0';
  253. if (this.order.length >= this.pageNum1) {
  254. return;
  255. }
  256. }
  257. if (this.current === 1) {
  258. this.formData.orderStatus = '1,2';
  259. if (this.order.length >= this.pageNum2) {
  260. return;
  261. }
  262. }
  263. if (this.current === 2) {
  264. this.formData.orderStatus = '-1,-2';
  265. if (this.order.length >= this.pageNum3) {
  266. return;
  267. }
  268. }
  269. this.$api.getorderlists(this.formData).then(res => {
  270. if (res.data.code === 200) {
  271. if (res.data.rows.length) {
  272. this.order = this.order.concat(res.data.rows);
  273. }
  274. }
  275. });
  276. },
  277. //获取订单
  278. getOrderList() {
  279. this.formData.pageNum = 1;
  280. if (this.current === 0) {
  281. this.formData.orderStatus = '0';
  282. }
  283. if (this.current === 1) {
  284. this.formData.orderStatus = '1,2,3';
  285. }
  286. if (this.current === 2) {
  287. this.formData.orderStatus = '-1,-2,4';
  288. }
  289. this.$api.getorderlists(this.formData).then(res => {
  290. if (res.data.code === 200) {
  291. if (this.current === 0) {
  292. this.pageNum1 = res.data.total;
  293. }
  294. if (this.current === 1) {
  295. this.pageNum2 = res.data.total;
  296. }
  297. if (this.current === 2) {
  298. this.pageNum3 = res.data.total;
  299. }
  300. this.order = res.data.rows;
  301. }
  302. });
  303. },
  304. change(index) {
  305. if (this.current === index) {
  306. return;
  307. }
  308. this.current = index;
  309. this.getOrderList();
  310. uni.pageScrollTo({
  311. scrollTop: 0
  312. });
  313. }
  314. },
  315. computed: { ...mapGetters(['userInfo']) }
  316. };
  317. </script>
  318. <style>
  319. page {
  320. background: #eaeef1;
  321. }
  322. </style>
  323. <style scoped lang="scss">
  324. .lisChild {
  325. border-radius: 16rpx;
  326. margin-bottom:16rpx;
  327. background:#fff;
  328. .header {
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. height: 80rpx;
  333. padding:0 15rpx;
  334. color: #666666;
  335. font-size: 24rpx;
  336. }
  337. .body {
  338. padding:16rpx;
  339. &__content {
  340. display: flex;
  341. justify-content: space-between;
  342. .goods-img {
  343. height: 134rpx;
  344. width: 278rpx;
  345. border-radius: 16rpx;
  346. flex-shrink: 0;
  347. }
  348. .goods-text {
  349. margin-left: 20rpx;
  350. flex:1;
  351. display: flex;
  352. flex-direction: column;
  353. .goods-name {
  354. color: #333333;
  355. font-size: 30rpx;
  356. font-weight: bold;
  357. flex:1;
  358. }
  359. .goods-price {
  360. font-size: 30rpx;
  361. font-family: PingFang SC;
  362. font-weight: bold;
  363. color: #ff2d55;
  364. display: flex;
  365. flex-direction: row-reverse;
  366. }
  367. }
  368. }
  369. .btn2 {
  370. width: 144rpx;
  371. height: 46rpx;
  372. background: #ffffff;
  373. border: 2rpx solid #007aff;
  374. border-radius: 16rpx;
  375. text-align: center;
  376. line-height: 48rpx;
  377. color: #007aff;
  378. margin: 0 8rpx;
  379. }
  380. }
  381. .footer {
  382. padding:0 24rpx;
  383. height: 80rpx;
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. .btn2 {
  388. width: 144rpx;
  389. height: 46rpx;
  390. background: #ffffff;
  391. border: 2rpx solid #007aff;
  392. border-radius: 16rpx;
  393. text-align: center;
  394. line-height: 48rpx;
  395. color: #007aff;
  396. margin: 0 8rpx;
  397. }
  398. .btn1 {
  399. width: 144rpx;
  400. height: 48rpx;
  401. background: #ffffff;
  402. border: 2rpx solid #999999;
  403. border-radius: 16rpx;
  404. text-align: center;
  405. line-height: 48rpx;
  406. color: #999999;
  407. margin: 0 8rpx;
  408. }
  409. }
  410. }
  411. .lisChild:last-child {
  412. margin-bottom: 34rpx;
  413. }
  414. .noData {
  415. text-align: center;
  416. font-size: 32rpx;
  417. font-family: PingFang SC;
  418. font-weight: 500;
  419. color: #999999;
  420. margin: 160rpx 0;
  421. }
  422. .apply-invoice {
  423. z-index: 100;
  424. position:fixed;
  425. left:0;
  426. right:0;
  427. bottom:40rpx;
  428. margin:0 auto;
  429. width: 526rpx;
  430. height: 80rpx;
  431. text-align: center;
  432. line-height: 80rpx;
  433. color:#fff;
  434. background: #007AFF;
  435. box-shadow: 0rpx 8rpx 7rpx 1rpx rgba(0, 122, 255, 0.1);
  436. border-radius: 40rpx;
  437. }
  438. .bottomBox {
  439. position: fixed;
  440. bottom: 0;
  441. width: 100%;
  442. left: 0;
  443. height: 98rpx;
  444. background-color: #ffffff;
  445. display: flex;
  446. justify-content: space-between;
  447. align-items: center;
  448. padding: 0 30rpx;
  449. }
  450. </style>