orders.vue 7.1 KB

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