guide.vue 8.6 KB

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