noticeList.vue 9.9 KB

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