material.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="customer-list">
  3. <!-- <u-navbar
  4. :title="$t('mine.mater')"
  5. rightIcon="plus"
  6. :autoBack="true"
  7. @rightClick="onClickRight"
  8. :placeholder="true"
  9. >
  10. </u-navbar> -->
  11. <view class="list-wrap">
  12. <!-- <u-sticky bgColor="#fff" :offset-top="topheight"> -->
  13. <u-sticky bgColor="#fff">
  14. <view class="search-wrap">
  15. <view class="input-wrap">
  16. <u-search
  17. bgColor='#fff'
  18. :showAction='false'
  19. :placeholder="$t('base.common.inputPlaceholder')"
  20. @search="searchList"
  21. @clear='searchList'
  22. v-model="keyword">
  23. </u-search>
  24. <view class="search-btn" @click="searchList">{{$t("customer_meter.search")}}</view>
  25. </view>
  26. <u-icon name="plus" size='22' @click="onClickRight"></u-icon>
  27. </view>
  28. </u-sticky>
  29. <template v-if="materList.length">
  30. <u-list
  31. @scrolltolower="scrolltolower"
  32. >
  33. <u-list-item
  34. v-for="(item, index) in materList"
  35. :key="index"
  36. >
  37. <card :data="item" :path="'material'"></card>
  38. </u-list-item>
  39. </u-list>
  40. </template>
  41. <template v-else>
  42. <u-empty
  43. mode="list"
  44. icon="https://cdn.uviewui.com/uview/empty/list.png"
  45. >
  46. </u-empty>
  47. </template>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import card from '../material/card.vue'
  53. import {getMaterialList} from '../../api/customer'
  54. export default {
  55. data(){
  56. return {
  57. keyword:'',
  58. active:0,
  59. value:'',
  60. materList:[],
  61. topheight:0,
  62. page:{
  63. pages:1,
  64. size:10,
  65. },
  66. total:0,
  67. hasMore:true,
  68. }
  69. },
  70. components:{
  71. card
  72. },
  73. onLoad() {
  74. // this.getTopHeight()
  75. },
  76. onShow(){
  77. this.getMaterialList()
  78. },
  79. methods:{
  80. //搜索列表
  81. searchList(){
  82. this.page.pages = 1
  83. this.hasMore = false
  84. this.getMaterialList()
  85. },
  86. //
  87. scrolltolower() {
  88. console.log(222);
  89. if(this.hasMore){
  90. this.page.pages+=1
  91. this.getMaterialList()
  92. }
  93. },
  94. //适配状态栏高度
  95. // getTopHeight() {
  96. // console.log('123');
  97. // let that = this;
  98. // uni.getSystemInfo({
  99. // success: function (e) {
  100. // //48为自定义导航栏高度,一般为44
  101. // let topPx = e.statusBarHeight + 44 // 顶部状态栏+沉浸式自定义顶部导航
  102. // that.topheight = topPx // px转rpx,这里必须转化为rpx,不然适配失败
  103. // },
  104. // });
  105. // },
  106. getMaterialList(){
  107. let data={
  108. current:this.page.pages,
  109. size:this.page.size,
  110. keywords:this.keyword || '' ,
  111. }
  112. getMaterialList(data).then(res=>{
  113. if(res.statusCode == 200 ){
  114. if(this.hasMore){
  115. this.materList=[...this.materList,...res.data.data.records]
  116. }else{
  117. this.materList=res.data.data.records
  118. }
  119. console.log(this.materList);
  120. this.total=res.data.data.total
  121. if(this.materList.length >= this.total){
  122. this.hasMore=false
  123. }else{
  124. this.hasMore=true
  125. }
  126. }
  127. })
  128. },
  129. onClickRight(){
  130. uni.navigateTo({ url: `/subpages/material/add-edit` })
  131. },
  132. changeTab(item){
  133. this.active=item.index
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="less" scoped>
  139. .customer-list{
  140. background: #f7f8fa;
  141. .list-wrap{
  142. // padding-top: 128rpx;
  143. .top-option{
  144. display: flex;
  145. padding-right: 32rpx;
  146. }
  147. .search-wrap{
  148. padding: 20rpx 32rpx;
  149. background-color: #f2f2f2;
  150. display: flex;
  151. .input-wrap{
  152. flex: 1;
  153. display: flex;
  154. background-color: #fff;
  155. border-radius: 100rpx;
  156. align-items: center;
  157. margin-right: 20rpx;
  158. .search-btn{
  159. align-items: center;
  160. margin-right: 32rpx;
  161. padding-left: 20rpx;
  162. height: 44rpx;
  163. line-height: 44rpx;
  164. color: #333;
  165. border-left: 1px solid #d3d3d3;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. /deep/ .u-tabs__wrapper__nav{
  172. padding: 0 24rpx;
  173. }
  174. // /deep/ .u-search{
  175. // }
  176. /deep/ .u-navbar--fixed{
  177. z-index: 1000;
  178. }
  179. /deep/ .u-empty{
  180. background-color: #fff;
  181. }
  182. </style>