index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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" @click.stop="goDetail(item.id)">
  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. goDetail(id) {
  209. uni.navigateTo({
  210. url: "/pages/orders/detail?order_id=" + id,
  211. });
  212. },
  213. },
  214. };
  215. </script>
  216. <style lang="less">
  217. .order_status_list {
  218. display: block;
  219. height: 60rpx;
  220. color: #666666;
  221. line-height: 60rpx;
  222. background: #ffffff;
  223. padding: 10rpx 35rpx;
  224. .order_status_item {
  225. float: left;
  226. font-size: 28rpx;
  227. padding: 0rpx 20rpx;
  228. }
  229. .order_status_item.active {
  230. color: #000000;
  231. font-weight: bold;
  232. }
  233. }
  234. .order_list {
  235. display: block;
  236. overflow: hidden;
  237. margin: 0rpx auto;
  238. .order_item {
  239. display: block;
  240. background: #ffffff;
  241. margin: 0rpx auto;
  242. padding: 0rpx 35rpx;
  243. margin-bottom: 10rpx;
  244. .order_title {
  245. width: 100%;
  246. height: 60rpx;
  247. display: block;
  248. overflow: hidden;
  249. line-height: 60rpx;
  250. .business_name {
  251. float: left;
  252. font-size: 32rpx;
  253. }
  254. .order_status {
  255. float: right;
  256. color: #999999;
  257. font-size: 24rpx;
  258. }
  259. }
  260. .product_list {
  261. display: block;
  262. height: 100rpx;
  263. overflow: hidden;
  264. margin: 15rpx auto;
  265. transition: all 1s ease-out; /* 添加过渡效果 */
  266. .product_item {
  267. display: block;
  268. height: 100rpx;
  269. overflow: hidden;
  270. .product_img {
  271. float: left;
  272. width: 80rpx;
  273. height: 80rpx;
  274. display: block;
  275. margin-top: 10rpx;
  276. margin-right: 30rpx;
  277. }
  278. .product_info {
  279. float: left;
  280. width: 480rpx;
  281. height: 100rpx;
  282. display: block;
  283. overflow: hidden;
  284. .product_name {
  285. display: block;
  286. height: 60rpx;
  287. display: block;
  288. font-size: 28rpx;
  289. line-height: 60rpx;
  290. overflow: hidden;
  291. }
  292. .product_spec {
  293. color: #999999;
  294. height: 40rpx;
  295. display: block;
  296. font-size: 24rpx;
  297. line-height: 40rpx;
  298. overflow: hidden;
  299. }
  300. }
  301. .buy_num {
  302. float: right;
  303. height: 100rpx;
  304. color: #999999;
  305. font-size: 26rpx;
  306. text-align: right;
  307. position: relative;
  308. line-height: 100rpx;
  309. }
  310. }
  311. }
  312. .product_list.active {
  313. height: auto !important;
  314. }
  315. .order_price {
  316. display: block;
  317. height: 60rpx;
  318. overflow: hidden;
  319. line-height: 60rpx;
  320. .pay_total {
  321. float: right;
  322. height: 60rpx;
  323. color: #e03519;
  324. font-size: 28rpx;
  325. line-height: 60rpx;
  326. }
  327. }
  328. .show_more {
  329. width: 100%;
  330. height: 30rpx;
  331. display: block;
  332. font-size: 20rpx !important;
  333. margin-top: -30rpx;
  334. text-align: center;
  335. position: relative;
  336. background-color: rgba(0, 0, 0, 0.05);
  337. }
  338. .order_btn {
  339. display: block;
  340. height: 60rpx;
  341. overflow: hidden;
  342. .order_cancel {
  343. float: left;
  344. height: 50rpx;
  345. color: #999999;
  346. font-size: 24rpx;
  347. padding: 0rpx 10rpx;
  348. line-height: 50rpx;
  349. margin-left: 10rpx;
  350. border-radius: 25rpx;
  351. border: 2rpx solid #999999;
  352. background-color: transparent;
  353. }
  354. .order_cancel::after {
  355. border: none;
  356. }
  357. .order_share {
  358. float: right;
  359. height: 50rpx;
  360. color: #e03519;
  361. font-size: 24rpx;
  362. padding: 0rpx 10rpx;
  363. line-height: 50rpx;
  364. margin-left: 10rpx;
  365. border-radius: 25rpx;
  366. border: 2rpx solid #e03519;
  367. background-color: transparent;
  368. }
  369. .order_share::after {
  370. border: none;
  371. }
  372. }
  373. }
  374. }
  375. </style>