faq.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="topsearch u-p30s u-flex-center-sb" :style="{top:tabTop+'px'}">
  5. <view class="u-flex1 u-flex-center leftbox">
  6. <text class="iconfont u-font30 u-666 u-ml30">&#xe650;</text>
  7. <input class="u-font22 u-CCC u-ml20 u-flex1" style="color: #333;" type="text" value="" @confirm="submit" @input="valSearch" placeholder="请输入搜索关键字" />
  8. </view>
  9. <text class="u-font28 u-1A1A1A u-ml30" @click="searchBtn" >搜索</text>
  10. </view>
  11. <view class="topsbox">
  12. <view class="u-flex-column-start " v-for="(item,index) in balance" :key="item.id" @click="listText(item.id)">
  13. <view class="uptop u-border-one-one u-flex-center-sb ">
  14. <view class="u-text1">
  15. {{item.title}}
  16. </view>
  17. <text class="iconfont u-font28 u-333 icons" :class="item.show?'turn':''">&#xe6c7;</text>
  18. </view>
  19. <view class="u-font26 u-999 u-mt10" v-if="item.show">{{item.content}}</view>
  20. </view>
  21. </view>
  22. <nodata v-if="noData" :config="{top:20,content:'暂无数据~'}"></nodata>
  23. <loadMore v-if="balance.length>0" :status="status" ></loadMore>
  24. </view>
  25. </template>
  26. <script>
  27. var app = getApp()
  28. export default {
  29. data() {
  30. return {
  31. config: {
  32. back: true, //false是tolbar页面 是则不写
  33. title: '常见问题',
  34. color: '#1A1A1A',
  35. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  36. backgroundColor: [1, "#FFFFFF"],
  37. statusBarFontColor: '#1A1A1A',
  38. },
  39. balance:[],
  40. parmas:{
  41. page:1,
  42. limit:20,
  43. title:''
  44. },
  45. noData:false,
  46. tabTop:0,
  47. status:'more',//more|loading|noMore
  48. }
  49. },
  50. onReachBottom(e) {
  51. this.status='loading'
  52. this.parmas.page++
  53. this.accountInfo()
  54. },
  55. onPullDownRefresh() {
  56. this.rest()
  57. this.accountInfo()
  58. },
  59. onLoad(){
  60. this.accountInfo()
  61. this.tabTop=app.globalData.barHeight+44;
  62. },
  63. methods:{
  64. submit(e){
  65. if(e){
  66. this.rest()
  67. this.parmas.title=e.detail.value
  68. this.accountInfo()
  69. }
  70. },
  71. // 点击搜索
  72. searchBtn(){
  73. this.rest()
  74. this.accountInfo()
  75. },
  76. //监听input值
  77. valSearch(e){
  78. if(e){
  79. this.parmas.title =e.detail.value
  80. }
  81. },
  82. accountInfo(){
  83. this.$http.get('/sys/faq/pages',this.parmas)
  84. .then(res => {
  85. if(res&&res.code==200){
  86. uni.stopPullDownRefresh()
  87. if(res.page.list.length >0){
  88. res.page.list.forEach(keys=>{
  89. keys.show = false
  90. })
  91. }
  92. this.balance = this.balance.concat(res.page.list)
  93. if(this.balance.length==0){
  94. this.noData=true
  95. }else{
  96. this.noData=false
  97. }
  98. if(res.page.totalPage <= res.page.currPage){
  99. this.status='noMore'
  100. }else{
  101. this.status='more'
  102. }
  103. }else{
  104. uni.stopPullDownRefresh()
  105. }
  106. })
  107. },
  108. listText(id){
  109. this.balance.forEach(key=>{
  110. if(key.id == id){
  111. key.show =!key.show
  112. }
  113. })
  114. },
  115. rest(){
  116. this.parmas.page=1
  117. this.balance=[]
  118. },
  119. }
  120. }
  121. </script>
  122. <style>
  123. .topsearch{
  124. position: fixed;
  125. left: 0;
  126. width: 100%;
  127. z-index: 2;
  128. box-sizing: border-box;
  129. background-color: #fff;
  130. }
  131. .topsbox{
  132. padding: 80rpx 30rpx 0;
  133. }
  134. .leftbox{
  135. height: 60rpx;
  136. line-height: 60rpx;
  137. background-color: #E6E6E6;
  138. border-radius: 30rpx;
  139. }
  140. .u-p30s{
  141. padding: 10rpx 30rpx;
  142. }
  143. .uptop{
  144. padding:30rpx 0 ;
  145. width: 100%;
  146. position: relative;
  147. }
  148. .turn{
  149. transform:rotate(90deg);
  150. }
  151. </style>