index.vue 7.8 KB

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