index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 @click.stop="goDetail(item.id)">
  12. <view class="order_title">
  13. <view class="business_name">{{ item.business_name }}</view>
  14. <view class="order_status">{{ item.state }}</view>
  15. </view>
  16. <view class="product_list" :class="item.contents_class ? 'active' : ''">
  17. <view class="product_item" v-for="(product_info, k) in item.product_list" :key="k">
  18. <image class="product_img" :src="product_info.product_thumb" mode=""></image>
  19. <view class="product_info">
  20. <view class="product_name"> <text v-if="product_info.is_rebate">【赠】</text> {{ product_info.product_name }} </view>
  21. <view class="product_spec">
  22. {{ product_info.product_spec }}
  23. </view>
  24. </view>
  25. <view class="buy_num"> x{{ product_info.buy_num }} </view>
  26. </view>
  27. </view>
  28. <view class="show_more" v-if="item.product_list.length > 1" @click.stop="changeHeight(index)">
  29. <uni-icons :type="item.contents_class ? 'up' : 'down'"></uni-icons>
  30. </view>
  31. <view class="order_price">
  32. <view class="pay_total">¥{{ item.pay_total }}</view>
  33. </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. </view>
  39. <view class="order_btn" v-if="item.status == 10">
  40. <button class="order_cancel" @click="cancelOrderRegiment(index)">取消拼团</button>
  41. </view>
  42. </view>
  43. </view>
  44. <Empty text="----- 还没有订单 -----" v-if="!orderList.length" />
  45. <view class="to_bottom" v-if="isLast && orderList.length"> -----到底啦-----</view>
  46. </view>
  47. </template>
  48. <script>
  49. import Empty from "@/components/Empty/Empty.vue";
  50. export default {
  51. components: {
  52. Empty,
  53. },
  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. setStatus(status) {
  142. // 登录提示
  143. if (!this.$checkAccess.alterLogin()) return;
  144. // 请求中,不再请求
  145. if (this.isReqing) return;
  146. // 初始化页码为1
  147. this.requestParam.page = 1;
  148. // 是否是最后一页
  149. this.isLast = false;
  150. // 状态变更
  151. this.requestParam.status = status;
  152. // 设置请求中
  153. this.isReqing = true;
  154. // 请求列表
  155. this.$http.request("api/orders/get_list", this.requestParam).then((re) => {
  156. // 设置非请求中
  157. this.isReqing = false;
  158. // 成功结果
  159. if (re.code == "success") {
  160. if (re.data.last_page >= this.requestParam.page) this.isLast = true;
  161. this.orderList = re.data.data;
  162. }
  163. });
  164. },
  165. changeHeight(index) {
  166. this.orderList[index].contents_class = this.orderList[index].contents_class ? 0 : 1;
  167. },
  168. // 取消订单
  169. cancelOrder(index) {
  170. uni.showModal({
  171. title: "确认取消该订单?",
  172. success: (res) => {
  173. if (res.confirm) {
  174. // 请求列表
  175. this.$http.request("api/orders/cancel", { id: this.orderList[index].id }).then((re) => {
  176. this.orderList[index].state = "已取消";
  177. this.orderList[index].status = 4;
  178. });
  179. }
  180. },
  181. });
  182. },
  183. // 取消拼团
  184. cancelOrderRegiment(index) {
  185. uni.showModal({
  186. title: "确认取消该订单?",
  187. success: (res) => {
  188. if (res.confirm) {
  189. // 请求列表
  190. this.$http.request("api/orders/cancel_regiment", { id: this.orderList[index].id }).then((re) => {
  191. this.orderList[index].state = "已取消";
  192. this.orderList[index].status = 4;
  193. });
  194. }
  195. },
  196. });
  197. },
  198. navToProduct(id) {
  199. if (id) {
  200. uni.navigateTo({
  201. url: "/pages/product/index?product_id=" + id,
  202. });
  203. }
  204. },
  205. toReceipt(item) {
  206. uni.navigateTo({
  207. url: "/pages/orders/receipt?order_id=" + item.id,
  208. });
  209. },
  210. goDetail(id) {
  211. uni.navigateTo({
  212. url: "/pages/orders/detail?order_id=" + id,
  213. });
  214. },
  215. },
  216. };
  217. </script>
  218. <style lang="less">
  219. .order_status_list {
  220. display: block;
  221. height: 60rpx;
  222. color: #666666;
  223. line-height: 60rpx;
  224. background: #ffffff;
  225. padding: 10rpx 35rpx;
  226. .order_status_item {
  227. float: left;
  228. font-size: 28rpx;
  229. padding: 0rpx 20rpx;
  230. }
  231. .order_status_item.active {
  232. color: #000000;
  233. font-weight: bold;
  234. }
  235. }
  236. .order_list {
  237. display: block;
  238. overflow: hidden;
  239. margin: 0rpx auto;
  240. .order_item {
  241. display: block;
  242. background: #ffffff;
  243. margin: 0rpx auto;
  244. padding: 0rpx 35rpx;
  245. margin-bottom: 10rpx;
  246. .order_title {
  247. width: 100%;
  248. height: 60rpx;
  249. display: block;
  250. overflow: hidden;
  251. line-height: 60rpx;
  252. display: flex;
  253. align-items: center;
  254. justify-content: space-between;
  255. .business_name {
  256. float: left;
  257. font-size: 32rpx;
  258. display: flex;
  259. align-items: center;
  260. .business_icon {
  261. width: 48rpx;
  262. height: 48rpx;
  263. margin-right: 10rpx;
  264. }
  265. }
  266. .order_status {
  267. float: right;
  268. color: #999999;
  269. font-size: 24rpx;
  270. }
  271. }
  272. .product_list {
  273. display: block;
  274. height: 100rpx;
  275. overflow: hidden;
  276. margin: 15rpx auto;
  277. transition: all 1s ease-out; /* 添加过渡效果 */
  278. .product_item {
  279. display: block;
  280. height: 100rpx;
  281. overflow: hidden;
  282. .product_img {
  283. float: left;
  284. width: 80rpx;
  285. height: 80rpx;
  286. display: block;
  287. margin-top: 10rpx;
  288. margin-right: 30rpx;
  289. }
  290. .product_info {
  291. float: left;
  292. width: 480rpx;
  293. height: 100rpx;
  294. display: block;
  295. overflow: hidden;
  296. .product_name {
  297. display: block;
  298. height: 60rpx;
  299. display: block;
  300. font-size: 28rpx;
  301. line-height: 60rpx;
  302. overflow: hidden;
  303. }
  304. .product_spec {
  305. color: #999999;
  306. height: 40rpx;
  307. display: block;
  308. font-size: 24rpx;
  309. line-height: 40rpx;
  310. overflow: hidden;
  311. }
  312. }
  313. .buy_num {
  314. float: right;
  315. height: 100rpx;
  316. color: #999999;
  317. font-size: 26rpx;
  318. text-align: right;
  319. position: relative;
  320. line-height: 100rpx;
  321. }
  322. }
  323. }
  324. .product_list.active {
  325. height: auto !important;
  326. }
  327. .order_price {
  328. display: block;
  329. height: 60rpx;
  330. overflow: hidden;
  331. line-height: 60rpx;
  332. .pay_total {
  333. float: right;
  334. height: 60rpx;
  335. color: #e03519;
  336. font-size: 28rpx;
  337. line-height: 60rpx;
  338. }
  339. }
  340. .show_more {
  341. width: 100%;
  342. height: 30rpx;
  343. display: block;
  344. font-size: 20rpx !important;
  345. margin-top: -30rpx;
  346. text-align: center;
  347. position: relative;
  348. background-color: rgba(0, 0, 0, 0.05);
  349. }
  350. .order_btn {
  351. display: block;
  352. height: 60rpx;
  353. overflow: hidden;
  354. .order_cancel {
  355. float: left;
  356. height: 50rpx;
  357. color: #999999;
  358. font-size: 24rpx;
  359. padding: 0rpx 10rpx;
  360. line-height: 50rpx;
  361. margin-left: 10rpx;
  362. border-radius: 25rpx;
  363. border: 2rpx solid #999999;
  364. background-color: transparent;
  365. }
  366. .order_cancel::after {
  367. border: none;
  368. }
  369. .order_share {
  370. float: right;
  371. height: 50rpx;
  372. color: #e03519;
  373. font-size: 24rpx;
  374. padding: 0rpx 10rpx;
  375. line-height: 50rpx;
  376. margin-left: 10rpx;
  377. border-radius: 25rpx;
  378. border: 2rpx solid #e03519;
  379. background-color: transparent;
  380. }
  381. .order_share::after {
  382. border: none;
  383. }
  384. }
  385. }
  386. }
  387. </style>