index.vue 4.5 KB

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