自主产品,供应链食堂系统。将两个端拆开了。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
5.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <view class="tabs">
  4. <u-tabs :list="tab_list" :is-scroll="false" :current="current" bg-color="#f6f6f6" active-color="#11D189" @change="tabsChange"></u-tabs>
  5. </view>
  6. <swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '750rpx'}"
  7. :current="current" @change="swiperChange">
  8. <swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
  9. <scroll-view class="lf-w-100 lf-h-100 lf-p-l-32 lf-p-r-32 lf-border-box"
  10. :scroll-y="true" :refresher-enabled="true"
  11. refresher-background="#f6f6f6"
  12. @scrolltolower="scrolltolower"
  13. :refresher-triggered="tabItem.isRefresher"
  14. @refresherrefresh="onRefresherrefresh">
  15. <view class="card" v-for="(item, index) in tabItem.list" :key="item.id" @click="$url('/pages/delivery/detail?id='+ item.o_sn)">
  16. <view class="lf-row-between item">
  17. <view class="lf-color-gray">申请人</view>
  18. <view class="lf-color-black">{{ item.o_name }}</view>
  19. </view>
  20. <view class="lf-row-between item">
  21. <view class="lf-color-gray">申请时间</view>
  22. <!-- todo 申请时间和种类 -->
  23. <view class="lf-color-black">{{ item.o_sn }}</view>
  24. </view>
  25. <view class="lf-row-between item">
  26. <view class="lf-color-gray">商品种类</view>
  27. <view class="lf-color-black">8</view>
  28. </view>
  29. <view class="lf-row-between item">
  30. <view class="lf-color-gray">订单状态</view>
  31. <view class="quoted-price">{{ item.state }}</view>
  32. </view>
  33. </view>
  34. <view class="loading-more">
  35. <text v-if="tabItem.list.length" :class="{'loading-more-text': tabItem.loading_class}">{{ tabItem.loading_text }}</text>
  36. <lf-nocontent v-else class="lf-m-t-50"></lf-nocontent>
  37. </view>
  38. </scroll-view>
  39. </swiper-item>
  40. </swiper>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data(){
  46. let _public = {
  47. loading_class: true,
  48. loading_text: '正在加载中...',
  49. page: 1,
  50. isPage: true,
  51. isRefresher: false
  52. };
  53. return {
  54. current: 0,
  55. tab_list: [{
  56. name: '全部',
  57. list: [],
  58. ..._public
  59. },{
  60. name: '申请中',
  61. list: [],
  62. ..._public
  63. },{
  64. name: '已出库',
  65. list: [],
  66. ..._public
  67. }],
  68. page_size: 10,
  69. windowHeight: 0,
  70. stateText: ''
  71. }
  72. },
  73. computed: {
  74. // TODO 动态设置class,对不同的状态设置不同的展示颜色
  75. stateClass(){
  76. return function(val){
  77. let class_name = {
  78. '等待接单': 'quoted-price',
  79. '等待发货': 'wait',
  80. '已完成': 'passed',
  81. '已退单': 'refuse'
  82. }
  83. return class_name[val];
  84. }
  85. }
  86. },
  87. onLoad(){
  88. this.windowHeight = uni.getSystemInfoSync().windowHeight;
  89. this.getData();
  90. },
  91. methods: {
  92. // 获取数据 TODO 目前接口还没有数据
  93. getData(options){
  94. // if(this.current == 1) {
  95. // this.stateText = '待确认'
  96. // }else if(this.current == 2) {
  97. // this.stateText = '已出库'
  98. // }else {
  99. // this.stateText = ''
  100. // }
  101. let item = this.tab_list[this.current];
  102. this.$http(this.API.API_CANTEEN_WAREHOUSEOUTLIST,{
  103. page: item.page,
  104. pagesize: 10,
  105. state: this.current
  106. }).then(res => {
  107. console.log("getData", res);
  108. this.tab_list[this.current].list = res.data.list || [];
  109. let list = res.data.list || [];
  110. let isPage = res.data.hasmore;
  111. if(!isPage){
  112. item.loading_class = false;
  113. item.loading_text = '已加载全部数据~';
  114. }
  115. item.isPage = isPage;
  116. uni.stopPullDownRefresh()
  117. if(options && options.refresh){
  118. item.isRefresher = false;
  119. }
  120. if(item.page == 1){
  121. item.list = list;
  122. }else{
  123. item.list.push(...list);
  124. }
  125. });
  126. },
  127. // tabs切换
  128. tabsChange(current){
  129. this.current = current;
  130. if(this.tab_list[this.current].list.length <= 0){
  131. this.getData({type: this.current});
  132. }
  133. },
  134. // swiper页面切换
  135. swiperChange(event){
  136. this.current = event.detail.current;
  137. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  138. if(this.tab_list[this.current].list.length <= 0){
  139. this.getData({type: this.current});
  140. }
  141. },
  142. // 页面触底
  143. scrolltolower(){
  144. let item = this.tab_list[this.current];
  145. if(item.isPage){
  146. item.page++;
  147. this.getData({type: this.current});
  148. }
  149. },
  150. // 下拉刷新
  151. onRefresherrefresh(){
  152. this.$u.throttle(() => {
  153. let item = this.tab_list[this.current];
  154. item.isRefresher = true;
  155. item.page = 1;
  156. item.isPage = true;
  157. item.loading_class = true;
  158. item.loading_text = '正在加载中...';
  159. item.list = [];
  160. this.getData({refresh: true,type: this.current});
  161. }, 200);
  162. }
  163. }
  164. }
  165. </script>
  166. <style>
  167. page{
  168. background-color: #f6f6f6;
  169. }
  170. </style>
  171. <style lang="scss" scoped="scoped">
  172. .card{
  173. width: 100%;
  174. height: max-content;
  175. background-color: #FFFFFF;
  176. border-radius: 20rpx;
  177. padding: 0 20rpx;
  178. box-sizing: border-box;
  179. margin-bottom: 30rpx;
  180. .item{
  181. padding: 20rpx 0;
  182. box-sizing: border-box;
  183. width: 100%;
  184. border-bottom: 1rpx solid #E5E5E5;
  185. font-size: 28rpx;
  186. &:last-child{
  187. border-bottom: none;
  188. }
  189. }
  190. // 已报价,等待审核
  191. .quoted-price{
  192. color: #777777;
  193. }
  194. // 等待报价
  195. .wait{
  196. color: #1833F2;
  197. }
  198. // 已通过审核
  199. .passed{
  200. color: #0BCE5F;
  201. }
  202. // 报价被拒绝
  203. .refuse{
  204. color: #FF0000;
  205. }
  206. }
  207. </style>