index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. console.log(this.current)
  78. },
  79. onShow() {
  80. this.getOrderList();
  81. /* if(this.current === 2 && this.$method.isLogin()){
  82. this.$refs.refMy.init();
  83. } */
  84. },
  85. //分享功能
  86. onShareAppMessage(res) {
  87. var self = this;
  88. return {
  89. title: '中正',
  90. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  91. };
  92. },
  93. onReachBottom() {
  94. this.formData.pageNum++;
  95. this.getFY();
  96. },
  97. methods: {
  98. /**
  99. * 跳转课程
  100. */
  101. goCourse(item,orderStatus) {
  102. if(orderStatus == 1 || orderStatus == 2) {
  103. uni.navigateTo({
  104. url:'/pages2/wd/course?id='+item.goodsId
  105. })
  106. }
  107. },
  108. resumeOrder(item){
  109. let self = this
  110. uni.login({
  111. provider: 'weixin',
  112. success: function(loginRes) {
  113. console.log(loginRes,69)
  114. self.getOpenid(loginRes.code,item)
  115. }
  116. });
  117. },
  118. getOpenid(code,item){
  119. let self = this
  120. this.$api.wxOpenid({code:code}).then(res => {
  121. if(res.data.code==200){
  122. self.resumeOrderPay(item)
  123. }
  124. });
  125. },
  126. resumeOrderPay(item){
  127. let data = {orderSn:item.orderSn}
  128. this.$api.resumeSmallOrder(data).then(res => {
  129. if(res.data.code==200){
  130. let data = res.data.data
  131. uni.requestPayment({
  132. provider: data.provider,
  133. nonceStr: data.nonceStr,
  134. package: data.package,
  135. signType: data.signType,
  136. paySign: data.sign,
  137. timeStamp: String(data.timeStamp),
  138. success: function (res) {
  139. uni.redirectTo({
  140. url: '/pages2/order/confirm_success?sn='+data.orderSn
  141. });
  142. console.log('success:' + JSON.stringify(res));
  143. },
  144. fail: function (err) {
  145. console.log('fail:' + JSON.stringify(err));
  146. }
  147. });
  148. }else{
  149. uni.showModal({
  150. title: "提示",
  151. content: res.data.msg,
  152. showCancel: false
  153. })
  154. }
  155. });
  156. },
  157. openPopup() {},
  158. //删除订单
  159. delOrder(item) {
  160. var self = this;
  161. uni.showModal({
  162. content: '确定要删除该订单吗',
  163. success: function(res) {
  164. if (res.confirm) {
  165. self.$api
  166. .eddOrder({
  167. orderId: item.orderId,
  168. status: -1
  169. })
  170. .then(res => {
  171. if (res.data.code === 200) {
  172. self.$method.showToast('订单删除成功');
  173. self.getOrderList();
  174. }
  175. });
  176. }
  177. }
  178. });
  179. },
  180. //取消订单
  181. closeOrder(item) {
  182. var self = this;
  183. uni.showModal({
  184. content: '确定要取消该订单吗',
  185. success: function(res) {
  186. if (res.confirm) {
  187. self.$api
  188. .eddOrder({
  189. orderId: item.orderId,
  190. orderStatus: -1
  191. })
  192. .then(res => {
  193. if (res.data.code === 200) {
  194. self.$method.showToast('订单取消成功', 'success');
  195. self.getOrderList();
  196. }
  197. });
  198. }
  199. }
  200. });
  201. },
  202. getFY() {
  203. if (this.current === 0) {
  204. this.formData.orderStatus = '0';
  205. if (this.order.length >= this.pageNum1) {
  206. return;
  207. }
  208. }
  209. if (this.current === 1) {
  210. this.formData.orderStatus = '1,2';
  211. if (this.order.length >= this.pageNum2) {
  212. return;
  213. }
  214. }
  215. if (this.current === 2) {
  216. this.formData.orderStatus = '-1,-2';
  217. if (this.order.length >= this.pageNum3) {
  218. return;
  219. }
  220. }
  221. this.$api.getorderlists(this.formData).then(res => {
  222. if (res.data.code === 200) {
  223. if (res.data.rows.length) {
  224. this.order = this.order.concat(res.data.rows);
  225. }
  226. }
  227. });
  228. },
  229. //获取订单
  230. getOrderList() {
  231. this.formData.pageNum = 1;
  232. if (this.current === 0) {
  233. this.formData.orderStatus = '0';
  234. }
  235. if (this.current === 1) {
  236. this.formData.orderStatus = '1,2';
  237. }
  238. if (this.current === 2) {
  239. this.formData.orderStatus = '-1,-2';
  240. }
  241. this.$api.getorderlists(this.formData).then(res => {
  242. if (res.data.code === 200) {
  243. if (this.current === 0) {
  244. this.pageNum1 = res.data.total;
  245. }
  246. if (this.current === 1) {
  247. this.pageNum2 = res.data.total;
  248. }
  249. if (this.current === 2) {
  250. this.pageNum3 = res.data.total;
  251. }
  252. this.order = res.data.rows;
  253. }
  254. });
  255. },
  256. change(index) {
  257. if (this.current === index) {
  258. return;
  259. }
  260. this.current = index;
  261. this.getOrderList();
  262. uni.pageScrollTo({
  263. scrollTop: 0
  264. });
  265. }
  266. },
  267. computed: { ...mapGetters(['userInfo']) }
  268. };
  269. </script>
  270. <style>
  271. page {
  272. background: #eaeef1;
  273. }
  274. </style>
  275. <style scoped>
  276. .lisChild:last-child {
  277. margin-bottom: 34rpx;
  278. }
  279. .noData {
  280. text-align: center;
  281. font-size: 32rpx;
  282. font-family: PingFang SC;
  283. font-weight: 500;
  284. color: #999999;
  285. margin: 160rpx 0;
  286. }
  287. .btn2 {
  288. width: 144rpx;
  289. height: 46rpx;
  290. background: #ffffff;
  291. border: 2rpx solid #007aff;
  292. border-radius: 16rpx;
  293. text-align: center;
  294. line-height: 48rpx;
  295. color: #007aff;
  296. margin: 0 8rpx;
  297. }
  298. .btn1 {
  299. width: 144rpx;
  300. height: 48rpx;
  301. background: #ffffff;
  302. border: 2rpx solid #999999;
  303. border-radius: 16rpx;
  304. text-align: center;
  305. line-height: 48rpx;
  306. color: #999999;
  307. margin: 0 8rpx;
  308. }
  309. .item {
  310. width: 100%;
  311. background: #ffffff;
  312. border-radius: 16rpx;
  313. /* margin-bottom: 20rpx; */
  314. padding: 15rpx;
  315. }
  316. .priceTag {
  317. font-size: 30rpx;
  318. font-family: PingFang SC;
  319. font-weight: bold;
  320. color: #ff2d55;
  321. display: flex;
  322. flex-direction: row-reverse;
  323. }
  324. .bottomBox {
  325. position: fixed;
  326. bottom: 0;
  327. width: 100%;
  328. left: 0;
  329. height: 98rpx;
  330. background-color: #ffffff;
  331. display: flex;
  332. justify-content: space-between;
  333. align-items: center;
  334. padding: 0 30rpx;
  335. }
  336. </style>