index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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')">更多</text>
  36. </view>
  37. <view class="list animated fadeInDown">
  38. <view class="news_item" v-for="(item, index) in newsList" :key="index" @click="go('/pages/news/detail?id=' + item.id)">
  39. <image src="../../static/tp.jpg" mode="aspectFill" class="img"></image>
  40. <view class="con">
  41. <view class="title ellip">{{ item.title }}</view>
  42. <view class="source omit">
  43. <text class="icon">&#xe639;</text>
  44. <text>{{ item.readCount }}</text>
  45. </view>
  46. <view class="releaseTime">{{ item.releaseTime }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. keyword: '',
  59. bannerList: [],
  60. newsList: [],
  61. noticeList: ['边民互市贸易APP上线了', '关于边民互市贸易开通注意事项'],
  62. roleMenu: [],
  63. menuList: [],
  64. count: 0
  65. };
  66. },
  67. onLoad() {
  68. this.getBannerList();
  69. this.getNewsList();
  70. this.getMenu();
  71. },
  72. onShow() {
  73. this.keyword = '';
  74. this.getRead();
  75. },
  76. methods: {
  77. getRead() {
  78. this.http.request({
  79. url: '/sp-admin/app/TbMessage/getRead',
  80. loading: 'false',
  81. success: res => {
  82. if (res.data.data.count > 0) {
  83. this.count = res.data.data.count;
  84. uni.setTabBarBadge({ index: 1, text: res.data.data.count });
  85. }
  86. }
  87. });
  88. },
  89. getBannerList() {
  90. this.http.request({
  91. url: '/level-one-server/app/TbBanner/getList',
  92. success: res => {
  93. this.bannerList = res.data.data;
  94. }
  95. });
  96. },
  97. getMenu() {
  98. let menu = uni.getStorageSync('menu');
  99. this.http.request({
  100. url: '/sp-admin/app/AppMenu/getList',
  101. success: res => {
  102. let data = res.data.data;
  103. menu.map((item2, index1) => {
  104. data.map((item1, index) => {
  105. if (parseInt(item1.id) == parseInt(item2)) {
  106. this.menuList.push(item1);
  107. }
  108. });
  109. });
  110. }
  111. });
  112. },
  113. getNewsList() {
  114. this.http.request({
  115. url: '/level-one-server/app/TbPortNews/getNewestList',
  116. data: { limit: 5 },
  117. success: res => {
  118. this.newsList = res.data.data;
  119. }
  120. });
  121. },
  122. //点击轮播图
  123. click(index) {
  124. uni.navigateTo({ url: '/pages/news/detail?id=8' });
  125. },
  126. message() {
  127. uni.switchTab({ url: '/pages/message/message' });
  128. },
  129. search() {
  130. uni.navigateTo({ url: '/pages/news/list?keyword=' + this.keyword });
  131. },
  132. navTo(url) {
  133. uni.navigateTo({
  134. url: url,
  135. fail: res => {
  136. console.log('zx:' + JSON.stringify(res));
  137. uni.showModal({ content: '功能还在开发中', showCancel: false });
  138. }
  139. });
  140. },
  141. go(url) {
  142. uni.navigateTo({ url: url });
  143. }
  144. }
  145. };
  146. </script>
  147. <style lang="scss">
  148. page {
  149. background-color: $pg;
  150. }
  151. .top {
  152. width: 100%;
  153. position: relative;
  154. }
  155. .cmain {
  156. padding: 10px 15px 10px 15px;
  157. margin-top: -193px;
  158. position: relative;
  159. .vsearch {
  160. margin-bottom: 13px;
  161. position: relative;
  162. .vse {
  163. width: 82% !important;
  164. }
  165. .icon {
  166. position: absolute;
  167. right: 0px;
  168. top: 0px;
  169. color: white;
  170. font-size: 25px;
  171. top: 5px;
  172. }
  173. .bage {
  174. width: 8px;
  175. height: 8px;
  176. border-radius: 50%;
  177. background-color: #f44336;
  178. top: 0px;
  179. right: 0px;
  180. position: absolute;
  181. }
  182. }
  183. .uni-swiper {
  184. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  185. }
  186. .notice {
  187. margin-top: 10px;
  188. border-radius: 5px !important;
  189. overflow: hidden;
  190. }
  191. .news {
  192. margin-top: 15px;
  193. }
  194. }
  195. </style>