index.vue 12 KB

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