index.vue 9.1 KB

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