index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="container">
  3. <!-- 动画 -->
  4. <uni-transition ref="ani" class="dhbox" custom-class="transition" :mode-class="modeClass" v-if="dhshow" :show="dhshow" :styles="styles">
  5. <img src="https://fuyu.scapp.cn/static/wxa/dh.jpg" class="dhimg">
  6. <view class="to" @click="show">
  7. 跳过
  8. </view>
  9. </uni-transition>
  10. <view v-else>
  11. <view class="page-section page-section-spacing swiper">
  12. <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
  13. <swiper-item v-for="(item, index) in bannerList" :key="index">
  14. <image style="width: 100%; height: 100%;" :src="item"></image>
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. <uni-notice-bar :speed="50" moreColor="#000" scrollable show-get-more show-icon :text="notice" more-text="更多>>" @getmore="getMore" />
  19. <!-- 党建 -->
  20. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="党建引领" type="line">
  21. <view class="card" v-for="(item, index) in construct" :key="index" :border="false" @click="illnessBtn(item)">
  22. <image style="width: 50%; height: 55px; margin: 0 auto; display: block;" :src="item.url"></image>
  23. <text class="title">{{ item.title }}</text>
  24. </view>
  25. </uni-section>
  26. <!-- 治理 -->
  27. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="精细治理" type="line">
  28. <view class="card" v-for="(item, index) in govern" :key="index" :border="false" @click="illnessBtn(item)">
  29. <image style="width: 50%; height: 55px; margin: 0 auto; display: block;" :src="item.url"></image>
  30. <text class="title">{{ item.title }}</text>
  31. </view>
  32. </uni-section>
  33. <!-- 疫情 -->
  34. <uni-section titleFontSize="16px" class="mb-10 sectionBox" title="便民服务" type="line">
  35. <view class="card" v-for="(item, index) in list" :key="index" :border="false" @click="illnessBtn(item)">
  36. <image style="width: 50%; height: 55px; margin: 0 auto; display: block;" :src="item.url"></image>
  37. <text class="title">{{ item.title }}</text>
  38. </view>
  39. </uni-section>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import request from '../../api/system.js';
  45. import requestLogin from '../../api/login.js';
  46. const appid = uni.getAccountInfoSync().miniProgram.appId;
  47. export default {
  48. data() {
  49. return {
  50. styles: {
  51. width: '100vw',
  52. height: '100vh',
  53. },
  54. modeClass: ['fade', 'zoom-in'],
  55. dhshow: true,
  56. list: [],
  57. policyList: [],
  58. notice: '',
  59. autoplay: true,
  60. interval: 3000,
  61. duration: 500,
  62. indicatorDots: false,
  63. bannerList: [],
  64. govern: [],
  65. construct: [],
  66. timeout: null
  67. }
  68. },
  69. async mounted() {
  70. wx.hideTabBar();
  71. this.timeout = setTimeout(() => {
  72. this.show();
  73. }, 3000)
  74. const config = await requestLogin.getJson();
  75. const { list, bannerList, governList, construct } = config.data;
  76. this.list = list;
  77. this.bannerList = bannerList;
  78. this.govern = governList;
  79. this.construct = construct;
  80. const _this = this;
  81. wx.login({
  82. success: async ({ code }) => {
  83. const res = await requestLogin.login({ code, appId: appid });
  84. if (res && res.code == 200) {
  85. uni.setStorageSync('token', res.data.token);
  86. uni.setStorageSync('userinfo', res.data.user);
  87. uni.setStorageSync('role', res.data.role);
  88. const notice = await request.getSystemNoticeNew();
  89. _this.notice = notice.data?.status == '0' ? notice.data?.noticeTitle : '';
  90. }
  91. }
  92. })
  93. },
  94. methods: {
  95. show() {
  96. clearTimeout(this.timeout);
  97. this.dhshow = !this.dhshow;
  98. wx.showTabBar();
  99. },
  100. morBtn() {
  101. uni.switchTab({ url: '/pages/policy/index' });
  102. },
  103. illnessBtn(e) {
  104. const role = uni.getStorageSync('role');
  105. if (e.isUser && role && role == 'guest') {
  106. uni.navigateTo({
  107. url: `/pages/register/index?path=${e.path}`
  108. })
  109. return;
  110. }
  111. if (e.appId) {
  112. this.toMiniProgram(e.appId, e.appPath);
  113. return;
  114. }
  115. if (!e.path) {
  116. uni.showToast({
  117. title: '敬请期待',
  118. icon: 'error',
  119. duration: 2000,
  120. });
  121. return;
  122. }
  123. uni.navigateTo({ url: e.path });
  124. },
  125. policyBtn(e) {
  126. uni.navigateTo({ url: e.path });
  127. },
  128. // 查看更多
  129. getMore() {
  130. uni.navigateTo({ url: `/pages/notice/index` });
  131. },
  132. toMiniProgram(miniId, miniPath) {
  133. uni.navigateToMiniProgram({
  134. appId: miniId,
  135. path: miniPath,
  136. success(res) {
  137. return true
  138. },
  139. fail(res){
  140. uni.showToast({
  141. title:'跳转小程序失败',
  142. icon:'none',
  143. duration:3000
  144. })
  145. console.log('跳转小程序失败',res)
  146. return false;
  147. }
  148. })
  149. }
  150. },
  151. onShow:function(){
  152. uni.removeStorageSync('policyItem')
  153. }
  154. }
  155. </script>
  156. <style>
  157. .container {
  158. background: #fff;
  159. }
  160. .swiper {
  161. height: 45vw;
  162. overflow: hidden;
  163. }
  164. .uni-section-content {
  165. display: flex;
  166. flex-wrap: wrap;
  167. }
  168. .card {
  169. margin: 10px;
  170. width: 29%;
  171. margin-right: 1%;
  172. }
  173. .card2 {
  174. width: 29%;
  175. margin-right: 1%;
  176. }
  177. .cover {
  178. display: block;
  179. width: 40px;
  180. height: 40px;
  181. margin: 5px auto;
  182. }
  183. .sectionBox {
  184. margin-bottom: 10px;
  185. display: block;
  186. }
  187. .sectionBox .uni-section-content {
  188. display: flex;
  189. }
  190. .uni-section__content-title {
  191. font-weight: 600;
  192. }
  193. .uni-card {
  194. padding: 0 !important;
  195. margin: 0 !important;
  196. }
  197. .uni-card__content {
  198. /* padding: 0 !important; */
  199. }
  200. h2 {
  201. font-weight: 700;
  202. width: 100%;
  203. text-align: center;
  204. font-size: 16px;
  205. }
  206. .title {
  207. display: block;
  208. margin: 0 auto;
  209. width: 100%;
  210. text-align: center;
  211. font-size: 14px;
  212. }
  213. .cardText {
  214. display: block;
  215. width: 100%;
  216. text-align: center;
  217. font-size: 12px;
  218. margin-bottom: 5px;
  219. color: #999;
  220. }
  221. .dhbox {
  222. position: fixed;
  223. z-index: 999;
  224. width: 100vw;
  225. height: 100vh;
  226. }
  227. .dhimg {
  228. width: 100%;
  229. height: 100%;
  230. display: block;
  231. }
  232. .to {
  233. width: 60px;
  234. height: 20px;
  235. opacity: 0.8;
  236. background-color: #000;
  237. color: #fff;
  238. position: absolute;
  239. top: 10px;
  240. right: 10px;
  241. text-align: center;
  242. border-radius: 12px;
  243. font-size: 12px;
  244. line-height: 20px;
  245. }
  246. </style>