index.vue 9.4 KB

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