knowList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div class="bgColor">
  3. <div class="header">常见问题</div>
  4. <div class="search">
  5. <input type="text" placeholder="搜索" v-model="search" @input="searchFn()">
  6. </div>
  7. <div slot="content" class="scroll-wrapper nav">
  8. <div class="demo">
  9. <div class="scroll-list-wrap">
  10. <cube-scroll
  11. ref="scroll"
  12. :data="items"
  13. :options="options"
  14. @pulling-down="onPullingDown"
  15. @pulling-up="onPullingUp"
  16. >
  17. <ul class="foods-wrapper">
  18. <li v-for="data in items" class="food-item border-1px" @click="toKnowDetails(data)">
  19. <div class="food-content">
  20. <div class="title">
  21. <div>
  22. <i class="iconfont icon-changjianwenti1"></i>
  23. </div>
  24. <div>主题:{{data.title}}</div>
  25. </div>
  26. <div
  27. class="content"
  28. v-html="data.content"
  29. style="-webkit-box-orient: vertical !important;"
  30. ></div>
  31. <div class="timeBox">
  32. <div class="time">{{data.createtime.substring(0,data.createtime.length-3)}}</div>
  33. <div class="good">
  34. <i class="iconfont icon-dianzan"></i>&nbsp;&nbsp;
  35. <span>{{data.star}}</span>
  36. 点赞
  37. </div>
  38. </div>
  39. </div>
  40. </li>
  41. <div class="wushuju" v-show="wushuju">
  42. <img src="./../../static/images/wushuju.svg" alt>
  43. <p>暂无常见问题</p>
  44. </div>
  45. </ul>
  46. <template v-if="customPullDown" slot="pulldown" slot-scope="props">
  47. <div
  48. v-if="props.pullDownRefresh"
  49. class="cube-pulldown-wrapper"
  50. :style="props.pullDownStyle"
  51. >
  52. <div
  53. v-show="props.beforePullDown"
  54. class="before-trigger"
  55. :style="{paddingTop: props.bubbleY + 'px'}"
  56. >
  57. <span :class="{rotate: props.bubbleY > pullDownRefreshThreshold - 40}">↓</span>
  58. </div>
  59. <div class="after-trigger" v-show="!props.beforePullDown">
  60. <div v-show="props.isPullingDown" class="loading">
  61. <cube-loading></cube-loading>
  62. </div>
  63. <div v-show="!props.isPullingDown" class="text">
  64. <span class="refresh-text">更新成功</span>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. </cube-scroll>
  70. </div>
  71. </div>
  72. </div>
  73. <load-ing v-show="!items.length&&!wushuju"></load-ing>
  74. </div>
  75. </template>
  76. <script>
  77. import Vue from "vue";
  78. import LoadIng from "./../views/loading.vue";
  79. export default {
  80. data() {
  81. return {
  82. // items: _foods,
  83. items: [],
  84. pullDownRefresh: true,
  85. pullDownRefreshThreshold: 60,
  86. pullDownRefreshStop: 40,
  87. pullDownRefreshTxt: "Refresh success",
  88. pullUpLoad: true,
  89. pullUpLoadThreshold: 0,
  90. pullUpLoadMoreTxt: "加载更多",
  91. pullUpLoadNoMoreTxt: "没有更多数据",
  92. wushuju: false,
  93. customPullDown: true,
  94. search: "",
  95. sum: 10,
  96. idx: 0,
  97. loadShow: true
  98. };
  99. },
  100. components: {
  101. // CubePage,
  102. // SwitchOption,
  103. // InputOption,
  104. // SelectOption,
  105. LoadIng
  106. },
  107. computed: {
  108. options() {
  109. return {
  110. pullDownRefresh: this.pullDownRefreshObj,
  111. pullUpLoad: this.pullUpLoadObj,
  112. scrollbar: true
  113. };
  114. },
  115. pullDownRefreshObj: function() {
  116. return this.pullDownRefresh
  117. ? {
  118. threshold: parseInt(this.pullDownRefreshThreshold),
  119. txt: this.pullDownRefreshTxt
  120. }
  121. : false;
  122. },
  123. pullUpLoadObj: function() {
  124. return this.pullUpLoad
  125. ? {
  126. threshold: parseInt(this.pullUpLoadThreshold),
  127. txt: {
  128. more: this.pullUpLoadMoreTxt,
  129. noMore: this.pullUpLoadNoMoreTxt
  130. }
  131. }
  132. : false;
  133. }
  134. },
  135. methods: {
  136. getParams() {
  137. if (this.$route.params.keword) {
  138. this.search = this.$route.params.keword;
  139. }
  140. },
  141. searchFn() {
  142. var that = this;
  143. that.loadShow = true;
  144. var that = this;
  145. that.idx = 0;
  146. that.sum = 10;
  147. that.items=[];
  148. that.getData();
  149. },
  150. toKnowDetails(data) {
  151. // this.$router.push({path:'/knowDetails'})
  152. this.$router.push({
  153. name: "KnowDetails",
  154. params: {
  155. data: JSON.stringify(data)
  156. }
  157. });
  158. },
  159. getData() {
  160. var that = this;
  161. this.$http
  162. .post("service/solution/fetchDataList/solution", {
  163. idx: that.idx,
  164. solution: {
  165. keywords: that.search,
  166. solutionType: { id: "" },
  167. status: { id: 72 },
  168. createUser: { name: "" }
  169. },
  170. sum: that.sum
  171. })
  172. .then(function(res) {
  173. if (res.data.list.length > 0) {
  174. // that.items = res.data.list;
  175. that.items = that.items.concat(res.data.list);
  176. that.wushuju = false;
  177. } else {
  178. that.wushuju = true;
  179. that.$refs.scroll.forceUpdate()
  180. }
  181. that.loadShow = false;
  182. });
  183. },
  184. onPullingDown() {
  185. var that = this;
  186. that.idx = 0;
  187. that.sum = 10;
  188. that.items = [];
  189. setTimeout(() => {
  190. that.getData();
  191. }, 1000);
  192. },
  193. onPullingUp() {
  194. var that = this;
  195. that.idx += 1;
  196. that.getData();
  197. },
  198. updatePullDownRefresh(val) {
  199. this.pullDownRefresh = val;
  200. },
  201. updatePullDownRefreshThreshold(val) {
  202. this.pullDownRefreshThreshold = val;
  203. },
  204. updatePullDownRefreshTxt(val) {
  205. this.pullDownRefreshTxt = val;
  206. },
  207. updatePullUpLoad(val) {
  208. this.pullUpLoad = val;
  209. },
  210. updatePullUpLoadThreshold(val) {
  211. this.pullUpLoadThreshold = val;
  212. },
  213. updatePullUpLoadMoreTxt(val) {
  214. this.pullUpLoadMoreTxt = val;
  215. },
  216. updatePullUpLoadNoMoreTxt(val) {
  217. this.pullUpLoadNoMoreTxt = val;
  218. },
  219. updateCustomPullDown(val) {
  220. this.customPullDown = val;
  221. },
  222. rebuildScroll() {
  223. Vue.nextTick(() => {
  224. this.$refs.scroll.destroy();
  225. this.$refs.scroll.initScroll();
  226. });
  227. }
  228. },
  229. created() {
  230. this.getParams();
  231. this.getData();
  232. }
  233. };
  234. </script>
  235. <style lang="stylus" rel="stylesheet/stylus" scoped>
  236. .scroll-list-wrap {
  237. /* height: 350px */
  238. height: 90vh;
  239. /* border: 1px solid rgba(0, 0, 0, 0.1) */
  240. border-radius: 5px;
  241. transform: rotate(0deg); // fix 子元素超出边框圆角部分不隐藏的问题
  242. overflow: hidden;
  243. }
  244. .foods-wrapper {
  245. .food-item {
  246. display: flex;
  247. /* min-width: 0 */
  248. /* padding: 18px
  249. border-bottom: 1px solid rgba(7, 17, 27, 0.1) */
  250. &:last-child {
  251. border-none();
  252. margin-bottom: 0;
  253. }
  254. .food-content {
  255. flex: 1;
  256. min-width: 0;
  257. .cartcontrol-wrapper {
  258. position: absolute;
  259. right: 0;
  260. bottom: 12px;
  261. .scroll-wrapper {
  262. .cube-pulldown-wrapper {
  263. .before-trigger {
  264. font-size: 30px;
  265. line-height: 30px;
  266. align-self: flex-end;
  267. span {
  268. display: inline-block;
  269. transition: all 0.3s;
  270. color: #666;
  271. &.rotate {
  272. transform: rotate(180deg);
  273. }
  274. }
  275. }
  276. .after-trigger {
  277. .refresh-text {
  278. color: grey;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>
  288. <style scoped lang='less'>
  289. .bgColor {
  290. background-color: white;
  291. .header {
  292. width: 100%;
  293. height: 0.88rem;
  294. line-height: 0.88rem;
  295. text-align: center;
  296. color: #fff;
  297. font-size: 0.37rem;
  298. background: linear-gradient(#2e2f32, #414246);
  299. position: fixed;
  300. top: 0;
  301. z-index: 6;
  302. }
  303. .search {
  304. width: 100%;
  305. padding: 0.16rem 0.24rem;
  306. box-sizing: border-box;
  307. background-color: #eeeeee;
  308. border-bottom: 0.01rem #b7b7b7 solid;
  309. position: fixed;
  310. top: 0.88rem;
  311. z-index: 6;
  312. input {
  313. width: 100%;
  314. height: 0.56rem;
  315. border-radius: 4px;
  316. text-align: center;
  317. font-size: 0.28rem;
  318. }
  319. &:focus {
  320. outline: none;
  321. }
  322. }
  323. }
  324. .nav {
  325. margin-top: 1.76rem;
  326. }
  327. .food-item {
  328. border-top: 0.16rem rgb(238, 238, 238) solid;
  329. }
  330. .food-content {
  331. border-top: 0.01rem rgb(223, 222, 222) solid;
  332. border-bottom: 0.01rem rgb(223, 222, 222) solid;
  333. }
  334. .title {
  335. display: flex;
  336. min-width: 0;
  337. padding: 0.2rem 0.24rem;
  338. line-height: 0.45rem;
  339. border-bottom: 0.01rem rgb(223, 222, 222) solid;
  340. }
  341. .title div:nth-child(1) {
  342. width: 6%;
  343. }
  344. .title div:nth-child(1) i {
  345. font-size: 0.32rem;
  346. color: #005395;
  347. line-height: 0.49rem;
  348. }
  349. .title div:nth-child(2) {
  350. width: 94%;
  351. font-size: 0.32rem;
  352. overflow: hidden;
  353. white-space: nowrap;
  354. text-overflow: ellipsis;
  355. }
  356. .content {
  357. font-size: 0.28rem;
  358. /* margin-top: .3rem; */
  359. line-height: 0.39rem;
  360. overflow: hidden;
  361. display: -webkit-box;
  362. -webkit-line-clamp: 2;
  363. -webkit-box-orient: vertical;
  364. word-break: break-all;
  365. padding: 0 0.64rem;
  366. width: 83%;
  367. margin: 0.24rem 0;
  368. max-height: 0.8rem;
  369. }
  370. .timeBox {
  371. display: flex;
  372. justify-content: space-between;
  373. /* margin-top: .3rem; */
  374. border-top: 0.01rem rgb(223, 222, 222) solid;
  375. padding: 0.2rem 0.64rem;
  376. }
  377. .timeBox .time {
  378. color: #999999;
  379. font-size: 0.24rem;
  380. }
  381. .timeBox .good {
  382. font-size: 0.3rem;
  383. color: #999;
  384. }
  385. .timeBox .good span {
  386. color: #a37200;
  387. font-size: 0.24rem;
  388. }
  389. .wushuju {
  390. margin-top: 2.4rem;
  391. text-align: center;
  392. color: #999;
  393. }
  394. .wushuju img {
  395. width: 5.12rem;
  396. height: 2.84rem;
  397. }
  398. </style>