faq.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="container">
  3. <uv-navbar title="常见问题" placeholder autoBack></uv-navbar>
  4. <uv-sticky :offsetTop="0" :customNavHeight="44">
  5. <view class="topsearch u-p30s">
  6. <uv-search
  7. v-model="parmas.problemTitle"
  8. :showAction="true"
  9. actionText="搜索"
  10. clearabled
  11. @search="searchBtn"
  12. @custom="searchBtn"
  13. ></uv-search>
  14. </view>
  15. </uv-sticky>
  16. <view class="topsbox">
  17. <view
  18. class="u-flex-column-start"
  19. v-for="(item, i) in balance"
  20. :key="item.id"
  21. @click="listText(i, item.id)"
  22. >
  23. <view class="uptop u-border-one-one u-flex-center-sb">
  24. <view class="u-text1">
  25. {{ item.problemTitle }}
  26. </view>
  27. <text class="iconfont u-font28 u-333 icons">&#xe6c7;</text>
  28. </view>
  29. <view class="u-font26 u-999 u-mt10 ql-editor-box" v-if="item.show">
  30. <view v-html="item.replyContent"></view>
  31. </view>
  32. </view>
  33. </view>
  34. <noData v-if="noDatas" :config="{ top: 20, content: '暂无数据~' }"></noData>
  35. <loadMore v-if="balance.length > 0" :status="status"></loadMore>
  36. </view>
  37. </template>
  38. <script setup>
  39. import { problemPage, problemInfo } from "@/api/index.js";
  40. import { ref } from "vue";
  41. import { onReachBottom, onPullDownRefresh, onLoad } from "@dcloudio/uni-app";
  42. const balance = ref([]);
  43. const parmas = ref({
  44. page: 1,
  45. limit: 20,
  46. title: "",
  47. });
  48. const noDatas = ref(false);
  49. const status = ref("more");
  50. function searchBtn() {
  51. rest();
  52. accountInfo();
  53. }
  54. function accountInfo() {
  55. problemPage(parmas.value).then((res) => {
  56. if (res && res.code == 200) {
  57. let list = res.rows;
  58. if (list.length > 0) {
  59. list = list.map((keys) => {
  60. keys.show = false;
  61. keys.replyContentShow = false;
  62. return keys;
  63. });
  64. }
  65. uni.stopPullDownRefresh();
  66. balance.value = balance.value.concat(res.rows);
  67. if (balance.value.length == 0) {
  68. noDatas.value = true;
  69. } else {
  70. noDatas.value = false;
  71. }
  72. if (balance.value.length >= res.total) {
  73. status.value = "noMore";
  74. } else {
  75. status.value = "more";
  76. }
  77. } else {
  78. uni.stopPullDownRefresh();
  79. }
  80. });
  81. }
  82. function listText(i, id) {
  83. if (!balance.value[i].replyContentShow) {
  84. problemInfo(id).then((res) => {
  85. if (res.code == 200) {
  86. balance.value[i].replyContent = res.data.replyContent;
  87. balance.value[i].replyContentShow = true;
  88. balance.value[i].show = true;
  89. }
  90. });
  91. } else {
  92. balance.value[i].show = !balance.value[i].show;
  93. }
  94. }
  95. function rest() {
  96. parmas.value.page = 1;
  97. balance.value = [];
  98. }
  99. onLoad(() => {
  100. accountInfo();
  101. });
  102. onPullDownRefresh(() => {
  103. rest();
  104. accountInfo();
  105. });
  106. onReachBottom(() => {
  107. if (status.value == "noMore") return;
  108. status.value = "loading";
  109. parmas.value.page++;
  110. accountInfo();
  111. });
  112. </script>
  113. <style>
  114. .topsearch {
  115. /* position: fixed;
  116. left: 0; */
  117. width: 100%;
  118. /* z-index: 2; */
  119. box-sizing: border-box;
  120. background-color: #fff;
  121. }
  122. .topsbox {
  123. padding: 20rpx 30rpx 20rpx;
  124. }
  125. .leftbox {
  126. height: 60rpx;
  127. line-height: 60rpx;
  128. background-color: #e6e6e6;
  129. border-radius: 30rpx;
  130. }
  131. .u-p30s {
  132. padding: 10rpx 30rpx;
  133. }
  134. .uptop {
  135. padding: 30rpx 0;
  136. width: 100%;
  137. position: relative;
  138. }
  139. .turn {
  140. transform: rotate(90deg);
  141. }
  142. </style>