index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
  5. indicator-active-color="#ffffff" :autoplay="true" :interval="3000" :duration="1000">
  6. <swiper-item class="list" v-for="(item,index) in imgList" :key="index" @tap="toBanner(item)">
  7. <image class="image" :src="item.url" mode="">
  8. </image>
  9. </swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="two">
  13. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
  14. indicator-active-color="#007AFF" :autoplay="false">
  15. <swiper-item class="swiper-item" v-for="(item,index) in moduleList" :key="index">
  16. <view class="list" v-for="(as,index) in item" :key="indexs" @tap="toChange(as)">
  17. <image class="image" :src="as.url&&as.url.length>0?as.url[0].url:''" mode="aspectFill">
  18. </image>
  19. <text class="text">{{ as.name }}</text>
  20. </view>
  21. </swiper-item>
  22. </swiper>
  23. </view>
  24. <view class="thr">
  25. <uni-notice-bar speed='50' showGetMore='true' moreText='更多' @getmore="toMore" show-icon scrollable
  26. :text="content" />
  27. </view>
  28. <view class="four">
  29. <tabs :tabs="tabs" @tabsChange="tabsChange">
  30. <view class="tabsList">
  31. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  32. <view class="list-scroll-view">
  33. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  34. 1111
  35. <view class="is_bottom" v-if="is_bottom">
  36. <text>{{config.bottom_title}}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </scroll-view>
  41. </view>
  42. </tabs>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import tabs from '../../components/tabs/index.vue';
  48. export default {
  49. components: {
  50. tabs
  51. },
  52. data() {
  53. return {
  54. // 轮播图
  55. imgList: [],
  56. // 模块
  57. moduleList: [],
  58. // 公告内容
  59. content: '',
  60. tabs: {
  61. active: '0',
  62. bgColor: '#ffffff',
  63. menu: []
  64. },
  65. list: [],
  66. total: 0,
  67. skip: 0,
  68. limit: 10,
  69. page: 0,
  70. // 数据是否触底
  71. is_bottom: false,
  72. scrollTop: 0,
  73. }
  74. },
  75. onLoad: async function() {
  76. const that = this;
  77. await that.searchOther();
  78. await that.search();
  79. },
  80. onShow: async function(e) {
  81. const that = this;
  82. },
  83. onPullDownRefresh: async function() {
  84. const that = this;
  85. that.clearPage();
  86. await that.search();
  87. uni.stopPullDownRefresh();
  88. },
  89. methods: {
  90. // 查询
  91. async search() {
  92. const that = this;
  93. let info = {
  94. skip: that.skip,
  95. limit: that.limit,
  96. }
  97. let res;
  98. res = await that.$api(`/article`, 'GET', {
  99. ...info,
  100. });
  101. if (res.errcode == '0') {
  102. let list = [...that.list, ...res.data];
  103. that.$set(that, `list`, list);
  104. that.$set(that, `total`, res.total)
  105. } else {
  106. uni.showToast({
  107. title: res.errmsg,
  108. icon: 'none'
  109. })
  110. }
  111. },
  112. // 点击轮播图图片
  113. toBanner(item) {
  114. console.log(item)
  115. },
  116. // 点击模块
  117. toChange(item) {
  118. console.log(item)
  119. },
  120. // 查看更多公告
  121. toMore() {
  122. console.log('公告')
  123. },
  124. // 查询其他信息
  125. async searchOther() {
  126. const that = this;
  127. let res;
  128. // 基本设置
  129. res = await that.$api(`/config`, 'GET', {});
  130. if (res.errcode == '0') {
  131. that.$set(that, `imgList`, res.data.file);
  132. }
  133. //模块
  134. res = await that.$api(`/module`, 'GET', {
  135. is_use: '0'
  136. });
  137. if (res.errcode == '0') {
  138. const data = res.data.reduce((acc, cur, i) => {
  139. if (i % 10 === 0) acc.push([cur]); // 新增一个小数组
  140. else acc[acc.length - 1].push(cur); // 将当前元素加入最后一个小数组中
  141. return acc;
  142. }, []);
  143. that.$set(that, `moduleList`, data);
  144. }
  145. // 公告
  146. res = await that.$api(`/notice`, 'GET', {
  147. is_use: '0',
  148. limit: 1
  149. });
  150. if (res.errcode == '0') that.$set(that, `content`, res.data[0].name);
  151. // 查询状态
  152. res = await that.$api(`/dictData`, 'GET', {
  153. type: 'home_tabs',
  154. is_use: '0',
  155. })
  156. if (res.errcode == '0') {
  157. const menu = res.data.map((item) => {
  158. return {
  159. title: item.label,
  160. active: item.value
  161. }
  162. })
  163. that.$set(that.tabs, `menu`, menu)
  164. }
  165. },
  166. // 选择选项卡
  167. tabsChange(e) {
  168. const that = this;
  169. that.$set(that.tabs, `active`, e.active)
  170. that.clearPage();
  171. that.search()
  172. },
  173. // 分页
  174. toPage(e) {
  175. const that = this;
  176. let list = that.list;
  177. let limit = that.limit;
  178. if (that.total > list.length) {
  179. uni.showLoading({
  180. title: '加载中',
  181. mask: true
  182. })
  183. let page = that.page + 1;
  184. that.$set(that, `page`, page)
  185. let skip = page * limit;
  186. that.$set(that, `skip`, skip)
  187. that.search();
  188. uni.hideLoading();
  189. } else that.$set(that, `is_bottom`, true)
  190. },
  191. // 触底
  192. toScroll(e) {
  193. const that = this;
  194. let up = that.scrollTop;
  195. that.$set(that, `scrollTop`, e.detail.scrollTop);
  196. let num = Math.sign(up - e.detail.scrollTop);
  197. if (num == 1) that.$set(that, `is_bottom`, false);
  198. },
  199. // 清空列表
  200. clearPage() {
  201. const that = this;
  202. that.$set(that, `list`, [])
  203. that.$set(that, `skip`, 0)
  204. that.$set(that, `limit`, 10)
  205. that.$set(that, `page`, 0)
  206. }
  207. },
  208. }
  209. </script>
  210. <style lang="scss">
  211. .main {
  212. .one {
  213. padding: 0 0 2vw 0;
  214. .swiper {
  215. height: 65vw;
  216. .list {
  217. .image {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. }
  222. }
  223. }
  224. .two {
  225. .swiper {
  226. height: 50vw;
  227. .swiper-item {
  228. display: flex;
  229. flex-direction: column;
  230. flex-wrap: wrap;
  231. .list {
  232. display: flex;
  233. flex-direction: column;
  234. justify-content: space-between;
  235. align-items: center;
  236. width: 20vw;
  237. padding: 1vw 0 0 0;
  238. .image {
  239. width: 15vw;
  240. height: 15vw;
  241. border-radius: 15vw;
  242. box-shadow: 0 0 5px var(--f1Color);
  243. }
  244. .text {
  245. font-size: var(--font14Size);
  246. margin-top: 5px;
  247. color: var(--f85Color);
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .thr {
  254. padding: 0 2vw;
  255. }
  256. .four {
  257. background-color: var(--footColor);
  258. .tabsList {
  259. position: relative;
  260. width: 100vw;
  261. height: 80vh;
  262. .list {
  263. background-color: var(--mainColor);
  264. border: 1px solid var(--f5Color);
  265. padding: 2vw;
  266. margin: 0 2vw 2vw 2vw;
  267. border-radius: 5px;
  268. }
  269. .list:first-child {
  270. margin: 2vw 0 0 0;
  271. }
  272. }
  273. }
  274. }
  275. .scroll-view {
  276. position: absolute;
  277. top: 0;
  278. left: 0;
  279. right: 0;
  280. bottom: 0;
  281. .list-scroll-view {
  282. display: flex;
  283. flex-direction: column;
  284. }
  285. }
  286. .is_bottom {
  287. width: 100%;
  288. text-align: center;
  289. text {
  290. padding: 2vw 0;
  291. display: inline-block;
  292. color: var(--f85Color);
  293. font-size: var(--font14Size);
  294. }
  295. }
  296. </style>