index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. if (e.isUser && role && role == 'guest') {
  72. uni.navigateTo({
  73. url: `/pages/register/index?path=${e.path}`
  74. })
  75. return;
  76. }
  77. if (!e.path) {
  78. uni.showToast({
  79. title: '敬请期待',
  80. icon: 'error',
  81. duration: 2000,
  82. });
  83. return;
  84. }
  85. uni.navigateTo({ url: e.path });
  86. },
  87. policyBtn(e) {
  88. uni.navigateTo({ url: e.path });
  89. },
  90. // 查看更多
  91. getMore() {
  92. uni.navigateTo({ url: `/pages/notice/index` });
  93. }
  94. },
  95. onShow:function(){
  96. uni.removeStorageSync('policyItem')
  97. }
  98. }
  99. </script>
  100. <style>
  101. .container {
  102. background: #fff;
  103. }
  104. .swiper {
  105. height: 45vw;
  106. overflow: hidden;
  107. }
  108. .uni-section-content {
  109. display: flex;
  110. flex-wrap: wrap;
  111. }
  112. .card {
  113. margin: 10px;
  114. width: 29%;
  115. margin-right: 1%;
  116. }
  117. .card2 {
  118. width: 29%;
  119. margin-right: 1%;
  120. }
  121. .cover {
  122. display: block;
  123. width: 40px;
  124. height: 40px;
  125. margin: 5px auto;
  126. }
  127. .sectionBox {
  128. margin-bottom: 10px;
  129. display: block;
  130. }
  131. .sectionBox .uni-section-content {
  132. display: flex;
  133. }
  134. .uni-section__content-title {
  135. font-weight: 600;
  136. }
  137. .uni-card {
  138. padding: 0 !important;
  139. margin: 0 !important;
  140. }
  141. .uni-card__content {
  142. /* padding: 0 !important; */
  143. }
  144. h2 {
  145. font-weight: 700;
  146. width: 100%;
  147. text-align: center;
  148. font-size: 16px;
  149. }
  150. .title {
  151. display: block;
  152. margin: 0 auto;
  153. width: 100%;
  154. text-align: center;
  155. font-size: 16px;
  156. }
  157. .cardText {
  158. display: block;
  159. width: 100%;
  160. text-align: center;
  161. font-size: 12px;
  162. margin-bottom: 5px;
  163. color: #999;
  164. }
  165. </style>