index.vue 8.3 KB

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