orders.vue 7.6 KB

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