index.vue 4.6 KB

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