index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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="140" 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. <u-icon :name="item.icon" color="white" size="25" :custom-style="{ margin: '0 auto' }" class="ioc"></u-icon>
  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">更多</text>
  35. <view class="clear"></view>
  36. </view>
  37. <view class="list">
  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/news.jpg" mode="aspectFill" class="img"></image>
  40. <view class="con">
  41. <view class="title ellip">{{ item.title }}</view>
  42. <view class="date">
  43. <text class="icon">&#xe65c;</text>
  44. <text>{{ item.readCount }}</text>
  45. </view>
  46. <text class="releaseTime">{{ item.releaseTime }}</text>
  47. </view>
  48. <view class="clear"></view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. keyword: '',
  60. bannerList: [],
  61. newsList: [],
  62. noticeList: ['边民互市贸易APP上线了', '关于边民互市贸易开通注意事项'],
  63. roleMenu: [],
  64. menuList: []
  65. };
  66. },
  67. onLoad() {
  68. this.getBannerList();
  69. this.getNewsList();
  70. this.getRoleMenu();
  71. //this.getMenu();
  72. },
  73. methods: {
  74. getBannerList() {
  75. this.$api.getBannerList().then(resp => {
  76. this.bannerList = resp.data;
  77. });
  78. },
  79. getRoleMenu() {
  80. let menu = uni.getStorageSync('menu');
  81. this.$api.getRoleMenu().then(res => {
  82. res.data.map((item1, index) => {
  83. menu.map((item2, index1) => {
  84. if (item1.appRoleId == item2) {
  85. this.roleMenu.push(item1.appMenuId);
  86. }
  87. });
  88. });
  89. this.getMenu();
  90. });
  91. },
  92. getMenu() {
  93. this.$api.getMenu().then(res => {
  94. this.roleMenu.map((item2, index1) => {
  95. res.data.map((item1, index) => {
  96. if (parseInt(item1.id) == parseInt(item2)) {
  97. this.menuList.push(item1);
  98. }
  99. });
  100. this.$forceUpdate();
  101. });
  102. });
  103. },
  104. getNewsList() {
  105. this.$api
  106. .getNewestList({
  107. limit: 4
  108. })
  109. .then(resp => {
  110. this.newsList = resp.data;
  111. });
  112. },
  113. navTo(path) {
  114. this.$common.to(path);
  115. }
  116. }
  117. };
  118. </script>
  119. <style lang="scss">
  120. .top {
  121. width: 100%;
  122. position: relative;
  123. }
  124. .cmain {
  125. padding: 10px 15px 10px 15px;
  126. margin-top: -193px;
  127. position: relative;
  128. .vsearch {
  129. margin-bottom: 13px;
  130. position: relative;
  131. .vse {
  132. width: 82% !important;
  133. }
  134. .icon {
  135. position: absolute;
  136. right: 0px;
  137. top: 0px;
  138. color: white;
  139. font-size: 25px;
  140. top: 5px;
  141. }
  142. }
  143. .uni-swiper {
  144. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  145. }
  146. .notice {
  147. margin-top: 10px;
  148. border-radius: 5px !important;
  149. overflow: hidden;
  150. }
  151. .menu {
  152. background-color: white;
  153. padding-top: 3px;
  154. margin-top: 10px;
  155. padding-bottom: 7px;
  156. border-radius: 5px;
  157. .msn {
  158. float: left;
  159. width: 25%;
  160. text-align: center;
  161. .out {
  162. padding: 3px;
  163. .int {
  164. padding: 5px;
  165. animation: bounceIn 1s;
  166. .ioc {
  167. width: 45px;
  168. height: 45px;
  169. background-color: #1c9dff;
  170. border-radius: 50%;
  171. margin: 0 auto;
  172. line-height: 46px;
  173. .icon {
  174. font-size: 23px;
  175. color: white;
  176. }
  177. }
  178. .tit {
  179. font-size: 14px;
  180. margin-top: 5px;
  181. color: $font-c;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. .news {
  188. background-color: white;
  189. margin-top: 10px;
  190. padding: 10px;
  191. }
  192. }
  193. </style>