index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="container">
  3. <view class="page-section page-section-spacing swiper">
  4. <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
  5. <swiper-item v-for="(item, index) in bannerList" :key="index">
  6. <image style="width: 100%; height: 100%;" :src="item"></image>
  7. </swiper-item>
  8. </swiper>
  9. </view>
  10. <uni-notice-bar moreColor="#000" scrollable show-get-more show-icon :text="notice" more-text="更多>>" @getmore="getMore" />
  11. <!-- 治理 -->
  12. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="精细治理" type="line">
  13. <view class="card" v-for="(item, index) in govern" :key="index" :border="false" @click="illnessBtn(item)">
  14. <image style="width: 50%; height: 55px; margin: 0 auto; display: block;" :src="item.url"></image>
  15. <text class="title">{{ item.title }}</text>
  16. </view>
  17. </uni-section>
  18. <!-- 疫情 -->
  19. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="疫情防控" type="line">
  20. <uni-card class="card card2" v-for="(item, index) in list" :key="index" :border="false" @click="illnessBtn(item)">
  21. <text class="title">{{ item.title }}</text>
  22. <image style="width: 60%; height: 70px; margin-left: 40%; display: block;" :src="item.url"></image>
  23. </uni-card>
  24. </uni-section>
  25. </view>
  26. </template>
  27. <script>
  28. import request from '../../api/system.js';
  29. import requestLogin from '../../api/login.js';
  30. const appid = uni.getAccountInfoSync().miniProgram.appId;
  31. export default {
  32. data() {
  33. return {
  34. list: [],
  35. policyList: [],
  36. notice: '通知公告',
  37. autoplay: true,
  38. interval: 3000,
  39. duration: 500,
  40. indicatorDots: false,
  41. bannerList: [],
  42. govern: []
  43. }
  44. },
  45. async mounted() {
  46. const config = await requestLogin.getJson();
  47. const { list, bannerList, governList } = config.data;
  48. this.list = list;
  49. this.bannerList = bannerList;
  50. this.govern = governList;
  51. const _this = this;
  52. wx.login({
  53. success: async ({ code }) => {
  54. const res = await requestLogin.login({ code, appId: appid });
  55. if (res && res.code == 200) {
  56. uni.setStorageSync('token', res.data.token);
  57. uni.setStorageSync('userinfo', res.data.user);
  58. uni.setStorageSync('role', res.data.role);
  59. const notice = await request.getSystemNoticeNew();
  60. _this.notice = notice.data?.noticeTitle;
  61. }
  62. }
  63. })
  64. },
  65. methods: {
  66. morBtn() {
  67. uni.switchTab({ url: '/pages/policy/index' });
  68. },
  69. illnessBtn(e) {
  70. const role = uni.getStorageSync('role');
  71. console.log(role, 'role')
  72. if (e.isUser && role && role == 'guest') {
  73. uni.navigateTo({
  74. url: `/pages/register/index?path=${e.path}`
  75. })
  76. return;
  77. }
  78. if (!e.path) {
  79. uni.showToast({
  80. title: '敬请期待',
  81. icon: 'error',
  82. duration: 2000,
  83. });
  84. return;
  85. }
  86. uni.navigateTo({ url: e.path });
  87. },
  88. policyBtn(e) {
  89. uni.navigateTo({ url: e.path });
  90. },
  91. // 查看更多
  92. getMore() {
  93. uni.navigateTo({ url: `/pages/notice/index` });
  94. }
  95. },
  96. onShow:function(){
  97. uni.removeStorageSync('policyItem')
  98. }
  99. }
  100. </script>
  101. <style>
  102. .container {
  103. background: #fff;
  104. }
  105. .swiper {
  106. height: 45vw;
  107. overflow: hidden;
  108. }
  109. .uni-section-content {
  110. display: flex;
  111. flex-wrap: wrap;
  112. }
  113. .card {
  114. margin: 10px;
  115. width: 29%;
  116. margin-right: 1%;
  117. }
  118. .card2 {
  119. width: 29%;
  120. margin-right: 1%;
  121. }
  122. .cover {
  123. display: block;
  124. width: 40px;
  125. height: 40px;
  126. margin: 5px auto;
  127. }
  128. .sectionBox {
  129. margin-bottom: 10px;
  130. display: block;
  131. }
  132. .sectionBox .uni-section-content {
  133. display: flex;
  134. }
  135. .uni-section__content-title {
  136. font-weight: 600;
  137. }
  138. .uni-card {
  139. padding: 0 !important;
  140. margin: 0 !important;
  141. }
  142. .uni-card__content {
  143. /* padding: 0 !important; */
  144. }
  145. h2 {
  146. font-weight: 700;
  147. width: 100%;
  148. text-align: center;
  149. font-size: 16px;
  150. }
  151. .title {
  152. display: block;
  153. margin: 0 auto;
  154. width: 100%;
  155. text-align: center;
  156. font-size: 16px;
  157. }
  158. .cardText {
  159. display: block;
  160. width: 100%;
  161. text-align: center;
  162. font-size: 12px;
  163. margin-bottom: 5px;
  164. color: #999;
  165. }
  166. </style>