index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="container">
  3. <view class="banner">
  4. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  5. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item">
  6. <image src="../../static/img/banner.png" />
  7. </swiper-item>
  8. </swiper>
  9. <view class="swiper-dots">
  10. <view class="swiper-dots-item" :class="{ current: swiperCurrent + 1 === index }"
  11. v-for="(item, index) in swiperLength"></view>
  12. </view>
  13. </view>
  14. <view class="swiper-btm flex">
  15. <view class="btm-item flex">
  16. <image class="image1" src="../../static/icon/index1.png" mode=""></image>
  17. <view class="">实名认证</view>
  18. </view>
  19. <view class="btm-item flex">
  20. <image class="image2" src="../../static/icon/index2.png" mode=""></image>
  21. <view class="">专业培训</view>
  22. </view>
  23. <view class="btm-item flex">
  24. <image class="image3" src="../../static/icon/index3.png" mode=""></image>
  25. <view class="">代办问诊</view>
  26. </view>
  27. </view>
  28. <view class="main flex">
  29. <view class="main-item" v-for="(item, index) in pzlist" @click="navTo('/pages/index/yypz?type=' + item.id)">
  30. <view class="main-image">
  31. <image :src="item.image" mode=""></image>
  32. </view>
  33. <view class="main-font">{{ item.name }}</view>
  34. </view>
  35. </view>
  36. <view class="title">
  37. <view class="xian"></view>
  38. <view class="title-font">代办服务</view>
  39. </view>
  40. <view class="dbfw flex">
  41. <view class="dbfw-item" v-for="(item, index) in dblist" @click="navTo('/pages/index/yydb?type=' + item.id)">
  42. <view class="dbfw-left">
  43. <image :src="item.image" mode=""></image>
  44. </view>
  45. <view class="dbfw-right">
  46. <view class="dbfw-title">{{ item.name }}</view>
  47. <view class="dbfw-tip">{{ item.info }}</view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- <view class="title">
  52. <view class="xian"></view>
  53. <view class="title-font">关于我们</view>
  54. </view>
  55. <view class="dbfw flex">
  56. <view class="dbfw-item" @click="navTo('/pages/index/info?id=3')">
  57. <view class="dbfw-left"><image src="../../static/img/gsjs.png" mode=""></image></view>
  58. <view class="dbfw-right">
  59. <view class="dbfw-title">公司介绍</view>
  60. <view class="dbfw-tip">专业创造价值</view>
  61. </view>
  62. </view>
  63. <view class="dbfw-item" @click="navTo('/pages/index/info?id=2')">
  64. <view class="dbfw-left"><image src="../../static/img/xgsm.png" mode=""></image></view>
  65. <view class="dbfw-right">
  66. <view class="dbfw-title">相关说明</view>
  67. <view class="dbfw-tip">服务使用指南</view>
  68. </view>
  69. </view>
  70. </view> -->
  71. <view class="card" @click="navTo('/pages/index/card')">
  72. <image src="../../static/img/index11.png" mode=""></image>
  73. </view>
  74. <view class="title">
  75. <view class="xian"></view>
  76. <view class="title-font">新闻资讯</view>
  77. </view>
  78. <view v-for="(item, index) in dataList" :key="index" class="list" @click="navto(item)">
  79. <view class="img">
  80. <image :src="item.image_input[0]" mode=""></image>
  81. </view>
  82. <view class="right">
  83. <view class="r-title clamp2">{{ item.title }}</view>
  84. <view class="time">{{ item.add_time }}</view>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. loadIndexs,
  92. cate,
  93. articleList
  94. } from '@/api/index.js';
  95. import {
  96. getUserInfo
  97. } from '@/api/user.js';
  98. import {
  99. mapState
  100. } from 'vuex';
  101. import {
  102. saveUrl,
  103. interceptor
  104. } from '@/utils/loginUtils.js';
  105. export default {
  106. data() {
  107. return {
  108. carouselList: [''], //轮播图列表
  109. height: '',
  110. swiperCurrent: 0, //当前几张图
  111. swiperLength: 1, //轮播图总数
  112. dataList: [], //文章列表
  113. dblist: [], //代办列表
  114. pzlist: [] //陪诊列表
  115. };
  116. },
  117. computed: {
  118. ...mapState(['loginInterceptor']),
  119. ...mapState('user', ['hasLogin', 'userInfo'])
  120. },
  121. onLoad: function(option) {
  122. // #ifndef MP
  123. if (option.spread) {
  124. // 存储其他邀请人
  125. uni.setStorageSync('spread', option.spread);
  126. }
  127. // #endif
  128. // #ifdef MP
  129. if (option.scene) {
  130. // 存储小程序邀请人
  131. uni.setStorage({
  132. key: 'spread_code',
  133. data: option.scene
  134. });
  135. }
  136. // #endif
  137. },
  138. onShow: function() {
  139. // 判断是否强制登录
  140. if (this.loginInterceptor && !this.hasLogin) {
  141. // 登录拦截
  142. interceptor();
  143. } else {
  144. this.loadData();
  145. }
  146. },
  147. //下拉刷新
  148. onPullDownRefresh() {
  149. this.loadData();
  150. },
  151. methods: {
  152. // 请求载入数据
  153. async loadData() {
  154. loadIndexs({})
  155. .then(({
  156. data
  157. }) => {
  158. this.carouselList = data.banner;
  159. })
  160. .catch(e => {});
  161. cate({
  162. type: 1
  163. }).then(({
  164. data
  165. }) => {
  166. this.pzlist = data;
  167. });
  168. cate({
  169. type: 2
  170. }).then(({
  171. data
  172. }) => {
  173. this.dblist = data;
  174. });
  175. articleList({
  176. page: 1,
  177. limit: 10000
  178. }, 1).then(({
  179. data
  180. }) => {
  181. this.dataList = data;
  182. console.log(data, '123456');
  183. });
  184. },
  185. //轮播图切换修改背景色
  186. swiperChange(e) {
  187. const index = e.detail.current;
  188. this.swiperCurrent = index;
  189. },
  190. navTo(url) {
  191. if (!this.hasLogin) {
  192. // 保存地址
  193. saveUrl();
  194. // 登录拦截
  195. interceptor();
  196. } else {
  197. uni.navigateTo({
  198. url
  199. });
  200. }
  201. },
  202. navto(item) {
  203. uni.navigateTo({
  204. url: '/pages/index/info?id=' + item.id
  205. });
  206. }
  207. }
  208. };
  209. </script>
  210. <style lang="scss">
  211. page,
  212. .container {
  213. min-height: 100%;
  214. height: auto;
  215. background: #ffffff;
  216. }
  217. image {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. .banner {
  222. width: 750rpx;
  223. height: 375rpx;
  224. position: relative;
  225. .carousel {
  226. width: 750rpx;
  227. height: 375rpx;
  228. .carousel-item {
  229. width: 100%;
  230. height: 100%;
  231. }
  232. }
  233. .swiper-dots {
  234. position: absolute;
  235. bottom: 16rpx;
  236. left: 0;
  237. right: 0;
  238. display: flex;
  239. justify-content: center;
  240. .swiper-dots-item {
  241. margin: 0 5rpx;
  242. width: 10rpx;
  243. height: 10rpx;
  244. background: #ffffff;
  245. border-radius: 50%;
  246. }
  247. .current {
  248. opacity: 0.71;
  249. }
  250. }
  251. }
  252. .swiper-btm {
  253. height: 60rpx;
  254. width: 750rpx;
  255. background-color: #ebf7f5;
  256. margin-bottom: 20rpx;
  257. font-size: 21rpx;
  258. font-weight: 500;
  259. color: #7c8584;
  260. .btm-item {
  261. flex-grow: 1;
  262. justify-content: center;
  263. .image1 {
  264. width: 28rpx;
  265. height: 24rpx;
  266. margin-right: 14rpx;
  267. }
  268. .image2 {
  269. width: 24rpx;
  270. height: 24rpx;
  271. margin-right: 14rpx;
  272. }
  273. .image3 {
  274. width: 28rpx;
  275. height: 24rpx;
  276. margin-right: 14rpx;
  277. }
  278. }
  279. }
  280. .main {
  281. margin: 30rpx auto 0;
  282. width: 702rpx;
  283. background: #ffffff;
  284. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  285. border-radius: 10rpx;
  286. padding: 30rpx 0 33rpx;
  287. .main-item {
  288. width: 33%;
  289. display: flex;
  290. flex-direction: column;
  291. align-items: center;
  292. .main-image {
  293. width: 82rpx;
  294. height: 82rpx;
  295. }
  296. .main-font {
  297. margin-top: 8rpx;
  298. font-size: 28rpx;
  299. font-family: PingFang SC;
  300. font-weight: bold;
  301. color: #262626;
  302. }
  303. }
  304. }
  305. .title {
  306. margin: 40rpx 0 0 24rpx;
  307. display: flex;
  308. align-items: center;
  309. .xian {
  310. width: 9rpx;
  311. height: 30rpx;
  312. background: #45bc9a;
  313. border-radius: 5rpx;
  314. }
  315. .title-font {
  316. margin-left: 20rpx;
  317. font-size: 30rpx;
  318. font-family: PingFang SC;
  319. font-weight: bold;
  320. color: #262626;
  321. }
  322. }
  323. .dbfw {
  324. margin-top: 34rpx;
  325. flex-wrap: wrap;
  326. justify-content: space-around;
  327. .dbfw-item {
  328. margin-top: 28rpx;
  329. width: 340rpx;
  330. height: 116rpx;
  331. background: #ffffff;
  332. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  333. border-radius: 15rpx;
  334. padding: 20rpx 18rpx;
  335. display: flex;
  336. align-items: center;
  337. .dbfw-left {
  338. width: 76rpx;
  339. height: 76rpx;
  340. }
  341. .dbfw-right {
  342. margin-left: 18rpx;
  343. line-height: 1;
  344. .dbfw-title {
  345. font-size: 30rpx;
  346. font-family: PingFang SC;
  347. font-weight: bold;
  348. color: #000000;
  349. }
  350. .dbfw-tip {
  351. margin-top: 10rpx;
  352. font-size: 22rpx;
  353. font-family: PingFang SC;
  354. font-weight: 500;
  355. color: #999999;
  356. }
  357. }
  358. }
  359. }
  360. .card {
  361. margin: 18rpx auto 0;
  362. width: 750rpx;
  363. height: 210rpx;
  364. }
  365. .listBox {
  366. margin-top: 28rpx;
  367. }
  368. .list {
  369. margin-top: 20rpx;
  370. margin-bottom: 50rpx;
  371. padding-left: 34rpx;
  372. padding-right: 40rpx;
  373. display: flex;
  374. .img {
  375. background-color: #ffffff;
  376. width: 200rpx;
  377. height: 160rpx;
  378. flex-shrink: 0;
  379. image {
  380. width: 100%;
  381. height: 100%;
  382. }
  383. }
  384. .right {
  385. text-align: left;
  386. width: 476rpx;
  387. padding-left: 20rpx;
  388. display: flex;
  389. flex-direction: column;
  390. justify-content: space-between;
  391. .r-title {
  392. font-size: 32rpx;
  393. font-weight: 400;
  394. color: #333333;
  395. }
  396. .time {
  397. font-size: 26rpx;
  398. font-weight: 400;
  399. color: #999999;
  400. }
  401. }
  402. }
  403. </style>