orders.vue 6.9 KB

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