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