orders.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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==8?'active':''" @click="setStatus(8)"> 已完成 </view>
  7. </view> -->
  8. <view class="order_list" v-if="orderList.length">
  9. <view class="order_item" v-for="(item, index) in orderList" :key="index">
  10. <view class="box_left">
  11. <image class="product_image" :src="item.product_thumb" mode=""></image>
  12. </view>
  13. <view class="box_right">
  14. <view class="product_title">
  15. <view class="product_name">{{ item.product_name }}</view>
  16. <view class="order_status">
  17. {{ item.state }}
  18. </view>
  19. </view>
  20. <view class="spec_number">
  21. <view class="product_spec">{{ item.product_spec }}</view>
  22. <view class="buy_num">共{{ item.buy_num }}件</view>
  23. </view>
  24. <view class="pay_info">
  25. <!-- 赠品信息 -->
  26. <view class="coupon_info" v-if="item.is_rebate">赠品</view>
  27. <view class="pay_total">{{ item.score_total }} 积分</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <Empty v-if="!orderList.length" text="----- 还没有记录啦 -----" />
  33. <view class="to_bottom" v-if="isLast && orderList.length"> -----到底啦-----</view>
  34. </view>
  35. </template>
  36. <script>
  37. import Empty from "@/components/Empty/Empty.vue";
  38. export default {
  39. components: {
  40. Empty,
  41. },
  42. data() {
  43. return {
  44. // 产品列表
  45. orderList: [],
  46. // 请求参数
  47. requestParam: {
  48. page: 1,
  49. status: 0,
  50. },
  51. // 是否最后一页
  52. isLast: false,
  53. // 是否请求中
  54. isReqing: false,
  55. };
  56. },
  57. onLoad() {
  58. // 初始化页码为1
  59. this.requestParam.page = 1;
  60. // 是否是最后一页
  61. this.isLast = false;
  62. // 设置请求中
  63. this.isReqing = true;
  64. // 登录提示
  65. if (!this.$checkAccess.alterLogin()) return;
  66. // 请求列表
  67. this.$http.request("api/score_orders/get_list", this.requestParam).then((re) => {
  68. // 设置非请求中
  69. this.isReqing = false;
  70. // 成功结果
  71. if (re.code == "success") {
  72. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  73. this.orderList = re.data.data;
  74. }
  75. });
  76. },
  77. onShow() {
  78. // 登录提示
  79. if (!this.$checkAccess.alterLogin()) return;
  80. // 没有数据的话,或者请求中,不允许刷新
  81. if (this.orderList.length > 0 || this.isReqing) return;
  82. // 设置请求中
  83. this.isReqing = true;
  84. // 请求列表
  85. this.$http.request("api/score_orders/get_list", this.requestParam).then((re) => {
  86. // 设置非请求中
  87. this.isReqing = false;
  88. // 成功结果
  89. if (re.code == "success") {
  90. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  91. this.orderList = re.data.data;
  92. }
  93. });
  94. },
  95. onPullDownRefresh() {
  96. // 登录提示
  97. if (!this.$checkAccess.alterLogin()) return;
  98. // 如果请求中,不允许请求,
  99. if (this.isReqing) return false;
  100. // 初始化页码为1
  101. this.requestParam.page = 1;
  102. // 是否是最后一页
  103. this.isLast = false;
  104. // 设置请求中
  105. this.isReqing = true;
  106. // 请求列表
  107. this.$http.request("api/score_orders/get_list", this.requestParam).then((re) => {
  108. // 设置非请求中
  109. this.isReqing = false;
  110. // 成功结果
  111. if (re.code == "success") {
  112. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  113. this.orderList = re.data.data;
  114. }
  115. });
  116. uni.stopPullDownRefresh();
  117. },
  118. onReachBottom() {
  119. // 登录提示
  120. if (!this.$checkAccess.alterLogin()) return;
  121. // 如果页码是0,避免第一页重复
  122. if (this.requestParam.page < 1) return;
  123. // 最后一页不请求
  124. if (this.isLast) return;
  125. // 请求中,不再请求
  126. if (this.isReqing) return;
  127. // 增加一页
  128. this.requestParam.page = this.requestParam.page + 1;
  129. // 设置请求中
  130. this.isReqing = true;
  131. // 请求列表
  132. this.$http.request("api/score_orders/get_list", this.requestParam).then((re) => {
  133. // 设置非请求中
  134. this.isReqing = false;
  135. // 成功结果
  136. if (re.code == "success") {
  137. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  138. // 追加数据
  139. this.orderList.push(...re.data.data);
  140. }
  141. });
  142. },
  143. methods: {
  144. setStatus(status) {
  145. // 登录提示
  146. if (!this.$checkAccess.alterLogin()) return;
  147. // 请求中,不再请求
  148. if (this.isReqing) return;
  149. // 初始化页码为1
  150. this.requestParam.page = 1;
  151. // 是否是最后一页
  152. this.isLast = false;
  153. // 状态变更
  154. this.requestParam.status = status;
  155. // 设置请求中
  156. this.isReqing = true;
  157. // 请求列表
  158. this.$http.request("api/score_orders/get_list", this.requestParam).then((re) => {
  159. // 设置非请求中
  160. this.isReqing = false;
  161. // 成功结果
  162. if (re.code == "success") {
  163. if (re.data.last_page >= this.requestParam.page) this.isLast = true;
  164. this.orderList = re.data.data;
  165. }
  166. });
  167. },
  168. },
  169. };
  170. </script>
  171. <style lang="less">
  172. .order_status_list {
  173. display: block;
  174. height: 60rpx;
  175. color: #666666;
  176. line-height: 60rpx;
  177. background: #ffffff;
  178. padding: 10rpx 35rpx;
  179. .order_status_item {
  180. float: left;
  181. font-size: 28rpx;
  182. padding: 0rpx 20rpx;
  183. }
  184. .order_status_item.active {
  185. color: #000000;
  186. font-weight: bold;
  187. }
  188. }
  189. .order_list {
  190. display: block;
  191. overflow: hidden;
  192. margin: 10rpx auto;
  193. .order_item {
  194. height: 200rpx;
  195. display: block;
  196. background: #ffffff;
  197. margin: 10rpx auto;
  198. .box_left {
  199. float: left;
  200. width: 160rpx;
  201. height: 200rpx;
  202. margin-left: 35rpx;
  203. .product_image {
  204. width: 160rpx;
  205. height: 160rpx;
  206. margin: 20rpx 0rpx;
  207. border-radius: 5rpx;
  208. }
  209. }
  210. .box_right {
  211. float: left;
  212. width: 485rpx;
  213. margin-left: 35rpx;
  214. padding-top: 20rpx;
  215. .product_title {
  216. width: 485rpx;
  217. max-height: 80rpx;
  218. font-size: 30rpx;
  219. overflow: hidden;
  220. line-height: 40rpx;
  221. padding: 0rpx 0rpx;
  222. .product_name {
  223. float: left;
  224. height: 40rpx;
  225. width: 380rpx;
  226. }
  227. .order_status {
  228. width: 85rpx;
  229. float: right;
  230. color: #999999;
  231. font-size: 24rpx;
  232. }
  233. }
  234. .spec_number {
  235. color: #999999;
  236. height: 60rpx;
  237. font-size: 24rpx;
  238. overflow: hidden;
  239. margin: 10rpx auto;
  240. line-height: 60rpx;
  241. .product_spec {
  242. float: left;
  243. color: #999999;
  244. }
  245. .buy_num {
  246. float: right;
  247. height: 40rpx;
  248. color: #333333;
  249. font-size: 20rpx;
  250. text-align: right;
  251. }
  252. }
  253. .pay_info {
  254. width: 485rpx;
  255. max-height: 80rpx;
  256. font-size: 30rpx;
  257. overflow: hidden;
  258. line-height: 40rpx;
  259. padding: 0rpx 0rpx;
  260. .coupon_info {
  261. color: gold;
  262. float: left;
  263. font-size: 20rpx;
  264. }
  265. .pay_total {
  266. color: red;
  267. width: 200rpx;
  268. float: right;
  269. text-align: right;
  270. font-size: 30rpx;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. </style>