knowList.vue 11 KB

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