index.vue 11 KB

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