index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view>
  3. <image src="../../static/images/my.png" mode="widthFix" class="top"></image>
  4. <view class="cmain">
  5. <view class="vsearch">
  6. <view class="vse">
  7. <u-search placeholder="搜索资讯" v-model="keyword" @search="search" :actionStyle="{ color: 'white' }" :animation="true" actionText="取消"></u-search>
  8. </view>
  9. <view class="icon" @click="message()">&#xe60d;</view>
  10. <view class="bage" v-if="count > 0"></view>
  11. </view>
  12. <!--轮播图-->
  13. <u-swiper circular :radius="5" :indicator="true" keyName="image" :list="bannerList" :height="110" class="uni-swiper" @click="click"></u-swiper>
  14. <!--通知公告-->
  15. <view class="notice">
  16. <u-notice-bar color="#848484" :text="noticeList" :step="true" direction="column" mode="link" bgColor="white" speed="300" url="/pages/notice/index"></u-notice-bar>
  17. </view>
  18. <!--菜单-->
  19. <view class="menu">
  20. <view class="msn" v-for="(item, index) in menuList" :key="index" @click="navTo(item.path)">
  21. <view class="out">
  22. <view class="int">
  23. <image :src="item.icon" mode="widthFix" style="width: 54px; height: 54px"></image>
  24. <view class="tit">{{ item.menuName }}</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="clear"></view>
  29. </view>
  30. <!--最新资讯-->
  31. <view class="news">
  32. <view class="vlabel">
  33. <view class="tag"></view>
  34. <text class="title">最新资讯</text>
  35. <text class="more" @click="navTo('/pages/news/list')">
  36. <text>更多</text>
  37. <text class="icon">&#xe8f2;</text>
  38. </text>
  39. </view>
  40. <view class="list animated fadeInDown">
  41. <view class="news_item" v-for="(item, index) in newsList" :key="index" @click="go('/pages/news/detail?id=' + item.id)">
  42. <image src="../../static/tp.jpg" mode="aspectFill" class="img"></image>
  43. <view class="con">
  44. <view class="title ellip">{{ item.title }}</view>
  45. <view class="source omit">
  46. <text class="icon">&#xe639;</text>
  47. <text>{{ item.readCount }}</text>
  48. </view>
  49. <view class="releaseTime">{{ item.releaseTime }}</view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. keyword: '',
  62. bannerList: [],
  63. newsList: [],
  64. noticeList: ['边民互市贸易APP上线了', '关于边民互市贸易开通注意事项'],
  65. roleMenu: [],
  66. menuList: [],
  67. count: 0
  68. };
  69. },
  70. onLoad() {
  71. this.getMenu();
  72. this.getBannerList();
  73. this.getNewsList();
  74. },
  75. onShow() {
  76. this.keyword = '';
  77. this.getRead();
  78. },
  79. methods: {
  80. getRead() {
  81. this.http.request({
  82. url: '/sp-admin/app/TbMessage/getRead',
  83. loading: 'false',
  84. success: res => {
  85. if (res.data.data.count > 0) {
  86. this.count = res.data.data.count;
  87. uni.setTabBarBadge({ index: 1, text: res.data.data.count });
  88. } else {
  89. this.count = 0;
  90. }
  91. }
  92. });
  93. },
  94. getBannerList() {
  95. this.http.request({
  96. url: '/level-one-server/app/TbBanner/getList',
  97. success: res => {
  98. this.bannerList = res.data.data;
  99. }
  100. });
  101. },
  102. getMenu() {
  103. this.menuList = [];
  104. let menu = uni.getStorageSync('menu');
  105. this.http.request({
  106. url: '/sp-admin/app/AppMenu/getList',
  107. success: res => {
  108. let data = res.data.data;
  109. menu.map((item2, index1) => {
  110. data.map((item1, index) => {
  111. if (parseInt(item1.id) == parseInt(item2)) {
  112. this.menuList.push(item1);
  113. }
  114. });
  115. });
  116. }
  117. });
  118. },
  119. getNewsList() {
  120. this.http.request({
  121. url: '/level-one-server/app/TbPortNews/getNewestList',
  122. data: { limit: 5 },
  123. success: res => {
  124. this.newsList = res.data.data;
  125. }
  126. });
  127. },
  128. //点击轮播图
  129. click(index) {
  130. uni.navigateTo({ url: '/pages/news/detail?id=8' });
  131. },
  132. message() {
  133. uni.switchTab({ url: '/pages/message/message' });
  134. },
  135. search() {
  136. uni.navigateTo({ url: '/pages/news/list?keyword=' + this.keyword });
  137. },
  138. navTo(url) {
  139. uni.navigateTo({
  140. url: url,
  141. fail: res => {
  142. console.log('zx:' + JSON.stringify(res));
  143. uni.showModal({ content: '功能还在开发中', showCancel: false });
  144. }
  145. });
  146. },
  147. go(url) {
  148. uni.navigateTo({ url: url });
  149. }
  150. },
  151. //下拉刷新
  152. onPullDownRefresh() {
  153. setTimeout(() => {
  154. uni.stopPullDownRefresh();
  155. this.getMenu();
  156. }, 1000);
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. page {
  162. background-color: $pg;
  163. }
  164. .top {
  165. width: 100%;
  166. position: relative;
  167. }
  168. .cmain {
  169. padding: 10px 15px 10px 15px;
  170. margin-top: -193px;
  171. position: relative;
  172. .vsearch {
  173. margin-bottom: 13px;
  174. position: relative;
  175. .vse {
  176. width: 82% !important;
  177. }
  178. .icon {
  179. position: absolute;
  180. right: 0px;
  181. top: 0px;
  182. color: white;
  183. font-size: 25px;
  184. top: 5px;
  185. }
  186. .bage {
  187. width: 8px;
  188. height: 8px;
  189. border-radius: 50%;
  190. background-color: #f44336;
  191. top: 0px;
  192. right: 0px;
  193. position: absolute;
  194. }
  195. }
  196. .uni-swiper {
  197. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  198. }
  199. .notice {
  200. margin-top: 10px;
  201. border-radius: 5px !important;
  202. overflow: hidden;
  203. }
  204. .news {
  205. margin-top: 15px;
  206. }
  207. }
  208. </style>