index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="疫情服务" type="line">
  12. <view class="card" v-for="(item, index) in list" :key="index" :border="false" @click="illnessBtn(item)">
  13. <image style="width: 100%; height: 90px" :src="item.url"></image>
  14. <text class="title">{{ item.title }}</text>
  15. </view>
  16. </uni-section>
  17. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="办事指南" type="line">
  18. <template v-slot:right>
  19. <text @click="morBtn">更多>></text>
  20. </template>
  21. <uni-card class="card card2" v-for="(item, index) in policyList" :key="index" @click="policyBtn(item)">
  22. <image class="cover" :src="item.url"></image>
  23. <h2>{{ item.title }}</h2>
  24. <text class="cardText">{{ item.text }}</text>
  25. </uni-card>
  26. </uni-section>
  27. </view>
  28. </template>
  29. <script>
  30. import request from '../../api/system.js';
  31. import requestLogin from '../../api/login.js';
  32. const appid = uni.getAccountInfoSync().miniProgram.appId;
  33. export default {
  34. data() {
  35. return {
  36. list: [],
  37. policyList: [],
  38. notice: '通知公告',
  39. autoplay: true,
  40. interval: 3000,
  41. duration: 500,
  42. indicatorDots: false,
  43. bannerList: []
  44. }
  45. },
  46. async mounted() {
  47. const config = await requestLogin.getJson();
  48. const { list, bannerList, policyList } = config.data;
  49. this.list = list;
  50. this.bannerList = bannerList;
  51. this.policyList = policyList;
  52. const _this = this;
  53. wx.login({
  54. success: async ({ code }) => {
  55. const res = await requestLogin.login({ code, appId: appid });
  56. if (res && res.code == 200) {
  57. uni.setStorageSync('token', res.data.token);
  58. uni.setStorageSync('userinfo', res.data.user);
  59. uni.setStorageSync('role', res.data.role);
  60. const notice = await request.getSystemNoticeNew();
  61. _this.notice = notice.data?.noticeTitle;
  62. }
  63. }
  64. })
  65. },
  66. methods: {
  67. morBtn() {
  68. uni.switchTab({ url: '/pages/policy/index' });
  69. },
  70. illnessBtn(e) {
  71. const role = uni.getStorageSync('role');
  72. if (e.isUser && role && role == 'guest') {
  73. uni.navigateTo({
  74. url: `/pages/user/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. .swiper {
  103. height: 150px;
  104. overflow: hidden;
  105. }
  106. .uni-section-content {
  107. display: flex;
  108. flex-wrap: wrap;
  109. }
  110. .card {
  111. margin: 10px;
  112. width: 29%;
  113. margin-right: 1%;
  114. }
  115. .card2 {
  116. width: 29%;
  117. margin-right: 1%;
  118. }
  119. .cover {
  120. display: block;
  121. width: 40px;
  122. height: 40px;
  123. margin: 5px auto;
  124. }
  125. .sectionBox {
  126. margin-bottom: 10px;
  127. display: block;
  128. }
  129. .sectionBox .uni-section-content {
  130. display: flex;
  131. }
  132. .uni-section__content-title {
  133. font-weight: 600;
  134. }
  135. .uni-card {
  136. padding: 0 !important;
  137. margin: 0 !important;
  138. }
  139. .uni-card__content {
  140. padding: 0 !important;
  141. }
  142. h2 {
  143. font-weight: 700;
  144. width: 100%;
  145. text-align: center;
  146. font-size: 16px;
  147. }
  148. .title {
  149. display: block;
  150. margin: 0 auto;
  151. width: 100%;
  152. text-align: center;
  153. font-size: 16px;
  154. }
  155. .cardText {
  156. display: block;
  157. width: 100%;
  158. text-align: center;
  159. font-size: 12px;
  160. margin-bottom: 5px;
  161. color: #999;
  162. }
  163. </style>