index.vue 10.0 KB

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