index.vue 4.3 KB

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