index.vue 7.9 KB

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