index.vue 11 KB

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