index.vue 7.6 KB

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