index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view>
  3. <view class="order_status_list">
  4. <view class="order_status_item" :class="requestParam.status == 0 ? 'active' : ''" @click="setStatus(0)"> 全部 </view>
  5. <view class="order_status_item" :class="requestParam.status == 1 ? 'active' : ''" @click="setStatus(1)"> 待支付 </view>
  6. <view class="order_status_item" :class="requestParam.status == 2 ? 'active' : ''" @click="setStatus(2)"> 已支付 </view>
  7. <view class="order_status_item" :class="requestParam.status == 4 ? 'active' : ''" @click="setStatus(4)"> 已取消 </view>
  8. <view class="order_status_item" :class="requestParam.status == 6 ? 'active' : ''" @click="setStatus(6)"> 已退款 </view>
  9. </view>
  10. <view class="to_bottom" v-if="!orderList.length"> -----还没有订单-----</view>
  11. <view class="order_list">
  12. <view class="order_item" v-for="(item, index) in orderList" :key="index">
  13. <view @click.stop="goDetail(item.id)">
  14. <view class="order_title">
  15. <view class="business_name">{{ item.business_name }}</view>
  16. <view class="order_status">{{ item.state }}</view>
  17. </view>
  18. <view class="product_list" :class="item.contents_class ? 'active' : ''">
  19. <view class="product_item" v-for="(product_info, k) in item.product_list" :key="k">
  20. <image class="product_img" :src="product_info.product_thumb" mode=""></image>
  21. <view class="product_info">
  22. <view class="product_name"> <text v-if="product_info.is_rebate">【赠】</text> {{ product_info.product_name }} </view>
  23. <view class="product_spec">
  24. {{ product_info.product_spec }}
  25. </view>
  26. </view>
  27. <view class="buy_num"> x{{ product_info.buy_num }} </view>
  28. </view>
  29. </view>
  30. <view class="show_more" v-if="item.product_list.length > 1" @click.stop="changeHeight(index)">
  31. <uni-icons :type="item.contents_class ? 'up' : 'down'"></uni-icons>
  32. </view>
  33. <view class="order_price">
  34. <view class="pay_total">¥{{ item.pay_total }}</view>
  35. </view>
  36. <view class="order_btn" v-if="item.status == 1">
  37. <!-- <button class="order_cancel" @click="cancelOrder(index)">取消订单</button> -->
  38. <!-- <button class="order_share" @click="toReceipt(item)">我已收货</button>-->
  39. <button class="order_share" @click="toPay(item)">去付款</button>
  40. </view>
  41. <!-- <view class="order_btn" v-if="item.status == 10">
  42. <button class="order_cancel" @click="cancelOrderRegiment(index)">取消拼团</button>
  43. </view> -->
  44. <!-- <view class="order_btn"v-if="item.status == 2">
  45. <button class="order_share" @click="toCourse(index)">去上课</button>
  46. </view> -->
  47. </view>
  48. </view>
  49. </view>
  50. <view class="to_bottom" v-if="isLast"> -----到底啦-----</view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. // 产品列表
  58. orderList: [],
  59. // 请求参数
  60. requestParam: {
  61. page: 1,
  62. status: 0,
  63. },
  64. // 是否最后一页
  65. isLast: false,
  66. // 是否请求中
  67. isReqing: false,
  68. };
  69. },
  70. onLoad() {},
  71. onShow() {
  72. // 登录提示
  73. if (!this.$checkAccess.alterLogin()) return;
  74. // 没有数据的话,或者请求中,不允许刷新
  75. if (this.isReqing) return;
  76. // 初始化页码为1
  77. this.requestParam.page = 1;
  78. // 是否是最后一页
  79. this.isLast = false;
  80. // 设置请求中
  81. this.isReqing = true;
  82. // 请求列表
  83. this.$http.request("api/orders/get_list", this.requestParam).then((re) => {
  84. // 设置非请求中
  85. this.isReqing = false;
  86. // 成功结果
  87. if (re.code == "success") {
  88. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  89. this.orderList = re.data.data;
  90. }
  91. });
  92. },
  93. onPullDownRefresh() {
  94. // 登录提示
  95. if (!this.$checkAccess.alterLogin()) return;
  96. // 如果请求中,不允许请求,
  97. if (this.isReqing) return false;
  98. // 初始化页码为1
  99. this.requestParam.page = 1;
  100. // 是否是最后一页
  101. this.isLast = false;
  102. // 设置请求中
  103. this.isReqing = true;
  104. // 请求列表
  105. this.$http.request("api/orders/get_list", this.requestParam).then((re) => {
  106. // 设置非请求中
  107. this.isReqing = false;
  108. // 成功结果
  109. if (re.code == "success") {
  110. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  111. this.orderList = re.data.data;
  112. }
  113. });
  114. uni.stopPullDownRefresh();
  115. },
  116. onReachBottom() {
  117. // 登录提示
  118. if (!this.$checkAccess.alterLogin()) return;
  119. // 如果页码是0,避免第一页重复
  120. if (this.requestParam.page < 1) return;
  121. // 最后一页不请求
  122. if (this.isLast) return;
  123. // 请求中,不再请求
  124. if (this.isReqing) return;
  125. // 增加一页
  126. this.requestParam.page = this.requestParam.page + 1;
  127. // 设置请求中
  128. this.isReqing = true;
  129. // 请求列表
  130. this.$http.request("api/orders/get_list", this.requestParam).then((re) => {
  131. // 设置非请求中
  132. this.isReqing = false;
  133. // 成功结果
  134. if (re.code == "success") {
  135. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  136. // 追加数据
  137. this.orderList.push(...re.data.data);
  138. }
  139. });
  140. },
  141. methods: {
  142. goDetail(id) {
  143. uni.navigateTo({
  144. url: "/pages/orders/detail?order_id=" + id,
  145. });
  146. },
  147. setStatus(status) {
  148. // 登录提示
  149. if (!this.$checkAccess.alterLogin()) return;
  150. // 请求中,不再请求
  151. if (this.isReqing) return;
  152. // 初始化页码为1
  153. this.requestParam.page = 1;
  154. // 是否是最后一页
  155. this.isLast = false;
  156. // 状态变更
  157. this.requestParam.status = status;
  158. // 设置请求中
  159. this.isReqing = true;
  160. // 请求列表
  161. this.$http.request("api/orders/get_list", this.requestParam).then((re) => {
  162. // 设置非请求中
  163. this.isReqing = false;
  164. // 成功结果
  165. if (re.code == "success") {
  166. if (re.data.last_page >= this.requestParam.page) this.isLast = true;
  167. this.orderList = re.data.data;
  168. }
  169. });
  170. },
  171. changeHeight(index) {
  172. this.orderList[index].contents_class = this.orderList[index].contents_class ? 0 : 1;
  173. },
  174. // 取消订单
  175. cancelOrder(index) {
  176. uni.showModal({
  177. title: "确认取消该订单?",
  178. success: (res) => {
  179. if (res.confirm) {
  180. // 请求列表
  181. this.$http.request("api/orders/cancel", { id: this.orderList[index].id }).then((re) => {
  182. this.orderList[index].state = "已取消";
  183. this.orderList[index].status = 4;
  184. });
  185. }
  186. },
  187. });
  188. },
  189. // 取消拼团
  190. cancelOrderRegiment(index) {
  191. uni.showModal({
  192. title: "确认取消该订单?",
  193. success: (res) => {
  194. if (res.confirm) {
  195. // 请求列表
  196. this.$http.request("api/orders/cancel_regiment", { id: this.orderList[index].id }).then((re) => {
  197. this.orderList[index].state = "已取消";
  198. this.orderList[index].status = 4;
  199. });
  200. }
  201. },
  202. });
  203. },
  204. navToProduct(id) {
  205. if (id) {
  206. uni.navigateTo({
  207. url: "/pages/product/index?product_id=" + id,
  208. });
  209. }
  210. },
  211. toReceipt(item) {
  212. uni.navigateTo({
  213. url: "/pages/orders/receipt?order_id=" + item.id,
  214. });
  215. },
  216. toPay(item) {
  217. if (item) {
  218. let orderInfo = {
  219. snowflake_id: item.snowflake_id,
  220. pay_total: item.pay_total,
  221. order_id: item.id,
  222. };
  223. orderInfo = JSON.stringify(orderInfo);
  224. let params = encodeURIComponent(orderInfo);
  225. // 跳转到确认支付页面
  226. uni.navigateTo({ url: `/pages/orders/confirm?params=${params}` });
  227. } else {
  228. uni.showToast({
  229. title: "订单数据错误",
  230. icon: "none",
  231. });
  232. return;
  233. }
  234. },
  235. toCourse(item) {
  236. uni.switchTab({
  237. url: "/pages/course/index?order_id=" + item.id,
  238. });
  239. },
  240. },
  241. };
  242. </script>
  243. <style lang="less">
  244. .order_status_list {
  245. display: block;
  246. height: 60rpx;
  247. color: #666666;
  248. line-height: 60rpx;
  249. background: #ffffff;
  250. padding: 10rpx 35rpx;
  251. .order_status_item {
  252. float: left;
  253. font-size: 28rpx;
  254. padding: 0rpx 10rpx;
  255. }
  256. .order_status_item.active {
  257. color: #000000;
  258. font-weight: bold;
  259. }
  260. }
  261. .order_list {
  262. display: block;
  263. overflow: hidden;
  264. margin: 0rpx auto;
  265. .order_item {
  266. display: block;
  267. background: #ffffff;
  268. margin: 0rpx auto;
  269. padding: 0rpx 35rpx;
  270. margin-bottom: 10rpx;
  271. .order_title {
  272. width: 100%;
  273. height: 60rpx;
  274. display: block;
  275. overflow: hidden;
  276. line-height: 60rpx;
  277. .business_name {
  278. float: left;
  279. font-size: 32rpx;
  280. }
  281. .order_status {
  282. float: right;
  283. color: #999999;
  284. font-size: 24rpx;
  285. }
  286. }
  287. .product_list {
  288. display: block;
  289. height: 100rpx;
  290. overflow: hidden;
  291. margin: 15rpx auto;
  292. .product_item {
  293. display: block;
  294. height: 100rpx;
  295. overflow: hidden;
  296. .product_img {
  297. float: left;
  298. width: 80rpx;
  299. height: 80rpx;
  300. display: block;
  301. margin-top: 10rpx;
  302. margin-right: 30rpx;
  303. }
  304. .product_info {
  305. float: left;
  306. width: 480rpx;
  307. height: 100rpx;
  308. display: block;
  309. overflow: hidden;
  310. .product_name {
  311. display: block;
  312. height: 60rpx;
  313. display: block;
  314. font-size: 28rpx;
  315. line-height: 60rpx;
  316. overflow: hidden;
  317. }
  318. .product_spec {
  319. color: #999999;
  320. height: 40rpx;
  321. display: block;
  322. font-size: 24rpx;
  323. line-height: 40rpx;
  324. overflow: hidden;
  325. }
  326. }
  327. .buy_num {
  328. float: right;
  329. height: 100rpx;
  330. color: #999999;
  331. font-size: 26rpx;
  332. text-align: right;
  333. position: relative;
  334. line-height: 100rpx;
  335. }
  336. }
  337. }
  338. .product_list.active {
  339. height: auto !important;
  340. }
  341. .order_price {
  342. display: block;
  343. height: 60rpx;
  344. overflow: hidden;
  345. line-height: 60rpx;
  346. .pay_total {
  347. float: right;
  348. height: 60rpx;
  349. color: #e03519;
  350. font-size: 28rpx;
  351. line-height: 60rpx;
  352. }
  353. }
  354. .show_more {
  355. width: 100%;
  356. height: 30rpx;
  357. display: block;
  358. font-size: 20rpx !important;
  359. margin-top: -30rpx;
  360. text-align: center;
  361. position: relative;
  362. background-color: rgba(0, 0, 0, 0.05);
  363. }
  364. .order_btn {
  365. display: block;
  366. height: 60rpx;
  367. overflow: hidden;
  368. .order_cancel {
  369. float: left;
  370. height: 50rpx;
  371. color: #999999;
  372. font-size: 24rpx;
  373. padding: 0rpx 10rpx;
  374. line-height: 50rpx;
  375. margin-left: 10rpx;
  376. border-radius: 25rpx;
  377. border: 2rpx solid #999999;
  378. background-color: transparent;
  379. }
  380. .order_cancel::after {
  381. border: none;
  382. }
  383. .order_share {
  384. float: right;
  385. height: 50rpx;
  386. color: #e03519;
  387. font-size: 24rpx;
  388. padding: 0rpx 10rpx;
  389. line-height: 50rpx;
  390. margin-left: 10rpx;
  391. border-radius: 25rpx;
  392. border: 2rpx solid #e03519;
  393. background-color: transparent;
  394. }
  395. .order_share::after {
  396. border: none;
  397. }
  398. }
  399. }
  400. }
  401. </style>