index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view class="content">
  3. <!-- 轮播 -->
  4. <view class="carousel-section">
  5. <swiper class="carousel" :autoplay="true" :interval="3000" :duration="1000">
  6. <swiper-item v-for="item in carouselList" :key="item.id">
  7. <image :src="baseURL + item.image"></image>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <!-- 分类 -->
  12. <view class="cate-section flex">
  13. <view class="cate-item flex" @click="navTo('/pages/applic/love')">
  14. <view class="img-wrapper flex">
  15. <image src="../../static/icon/icon1.png" mode="" class="img1"></image>
  16. </view>
  17. <view class="item-title">爱心捐款</view>
  18. </view>
  19. <view class="cate-item flex" @click="tocontribution">
  20. <view class="img-wrapper flex">
  21. <image src="../../static/icon/icon2.png" mode="" class="img1"></image>
  22. </view>
  23. <view class="item-title">遗体器官捐献</view>
  24. </view>
  25. <view class="cate-item flex" @click="toapplic">
  26. <view class="img-wrapper flex">
  27. <image src="../../static/icon/icon3.png" mode="" class="img1"></image>
  28. </view>
  29. <view class="item-title">造血干细胞捐献</view>
  30. </view>
  31. <view class="cate-item flex" @click="navTo('/pages/fu/axjz')">
  32. <view class="img-wrapper flex">
  33. <image src="../../static/icon/icon4.png" mode="" class="img1"></image>
  34. </view>
  35. <view class="item-title">爱心帮扶</view>
  36. </view>
  37. </view>
  38. <!-- 加入红十字 -->
  39. <view class="join-red">
  40. <image src="../../static/img/join-banner.png" mode="" @click="navTo('/pages/cart/cart')"></image>
  41. </view>
  42. <!-- 就在身边 -->
  43. <view class="jzsb-wrap">
  44. <!-- 附近救护员 -->
  45. <view class="wrap-tit">
  46. 就在身边
  47. <view class="tit-bg"></view>
  48. </view>
  49. <view class="fjjhy-wrap" @click="navTo('/pages/applic/location')">
  50. <image src="../../static/img/jzsb-bg.png" mode=""></image>
  51. </view>
  52. <!-- 救护站 and Aed -->
  53. <view class="jhz-aed-wrap flex">
  54. <!-- 救护站 -->
  55. <view class="jhz-wrap" @click="navTo('/pages/applic/aid')">
  56. <image src="../../static/img/jhz-bg.png" mode=""></image>
  57. </view>
  58. <!-- aed -->
  59. <view class="aed-wrap" @click="navTo('/pages/applic/aed')">
  60. <image src="../../static/img/aed-bg.png" mode=""></image>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 红会科普 -->
  65. <view class="kp-wrap" v-if="(science.length != 0) && loaded">
  66. <view class="wrap-tit">
  67. 红会科普
  68. <view class="tit-bg"></view>
  69. </view>
  70. <view class="readmore" @click="navTo('/pages/applic/science')">
  71. 更多<image src="../../static/icon/next.png" mode="widthFix"></image>
  72. </view>
  73. <scroll-view scroll-x="true" class="kp-scroll flex">
  74. <view class="kp-item" v-for="sitem in science" @click="navTo('/pages/applic/info?id=' + sitem.id)">
  75. <view class="kp-item-img">
  76. <image src="../../static/img/002.png" mode="heightFix" ></image>
  77. </view>
  78. <view class="kp-item-tit clamp">
  79. {{sitem.title}}
  80. </view>
  81. </view>
  82. </scroll-view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import {
  88. loadIndexs,
  89. } from '@/api/index.js';
  90. import { getArticList} from '@/api/index.js';
  91. import {
  92. saveUrl,
  93. interceptor
  94. } from '@/utils/loginUtils.js';
  95. import {
  96. mapState,
  97. mapMutations
  98. } from 'vuex';
  99. import {
  100. userinfo
  101. } from '@/api/user.js';
  102. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  103. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  104. export default {
  105. components: {
  106. uniPopup,
  107. uniLoadMore
  108. },
  109. data() {
  110. return {
  111. carouselList: [], //轮播
  112. science: [], //文章列表
  113. page: 1,
  114. limit: 10,
  115. loaded: false
  116. };
  117. },
  118. onShow() {
  119. saveUrl();
  120. if (!this.hasLogin) {
  121. // 登录拦截
  122. // interceptor();
  123. uni.showModal({
  124. title: '登录',
  125. content: '您未登录,是否马上登陆?',
  126. success: e => {
  127. if (e.confirm) {
  128. interceptor();
  129. }
  130. },
  131. fail: e => {
  132. console.log(e);
  133. }
  134. });
  135. } else {
  136. }
  137. },
  138. onLoad() {
  139. this.getPkList()
  140. this.loadIndex()
  141. saveUrl();
  142. },
  143. computed: {
  144. ...mapState('user', ['userInfo', 'hasLogin']),
  145. ...mapState('info',['kpCid']),
  146. ...mapState(['baseURL']),
  147. },
  148. methods: {
  149. ...mapMutations('user', ['setUserInfo']),
  150. loadIndex() {
  151. let obj = this;
  152. loadIndexs({}).then(({
  153. data
  154. }) => {
  155. console.log(data, 'index')
  156. //轮播图
  157. this.carouselList = data.banner
  158. });
  159. },
  160. loadData() {
  161. let obj = this;
  162. userinfo({}).then(({
  163. data
  164. }) => {
  165. obj.setUserInfo(data);
  166. });
  167. },
  168. // 处理跳转
  169. navTo(url) {
  170. uni.navigateTo({
  171. url:url,
  172. fail() {
  173. uni.switchTab({
  174. url:url
  175. })
  176. }
  177. });
  178. },
  179. // 获取科普文章列表
  180. getPkList() {
  181. let obj = this
  182. getArticList({
  183. page: obj.page,
  184. limit: obj.limit,
  185. ifyid: obj.kpCid
  186. }).then(res => {
  187. obj.loaded = true
  188. console.log(res,'获取科普文章列表')
  189. obj.science = res.data.list
  190. })
  191. }
  192. }
  193. };
  194. </script>
  195. <style lang="scss">
  196. a {
  197. text-decoration: none;
  198. color: #5f5f5f;
  199. }
  200. .content {
  201. background-color: #ffabab;
  202. }
  203. .content {
  204. background-color: #f8f8f8;
  205. height: 100%;
  206. /* 头部 轮播图 */
  207. .carousel-section {
  208. // padding-top: 10px;
  209. overflow: hidden;
  210. background-color: #fff;
  211. .carousel {
  212. width: 750rpx;
  213. height: 547rpx;
  214. margin: 0 auto;
  215. overflow: hidden;
  216. .carousel-item {
  217. width: 100%;
  218. height: 100%;
  219. padding-left: 30rpx;
  220. padding-right: 30rpx;
  221. overflow: hidden;
  222. }
  223. image {
  224. width: 100%;
  225. height: 547rpx;
  226. }
  227. }
  228. }
  229. // 分类
  230. .cate-section {
  231. justify-content: space-around;
  232. background-color: #fff;
  233. padding: 46rpx 0 30rpx;
  234. .cate-item {
  235. width: 25%;
  236. flex-direction: column;
  237. text-align: center;
  238. align-items: center;
  239. justify-content: center;
  240. .img-wrapper {
  241. width: 100rpx;
  242. height: 120rpx;
  243. border-radius: 14rpx;
  244. position: relative;
  245. image {
  246. position: absolute;
  247. left: 50%;
  248. top: 50%;
  249. transform: translate(-50%, -50%);
  250. }
  251. .img1 {
  252. width: 120rpx;
  253. height: 120rpx;
  254. }
  255. }
  256. .item-title {
  257. margin-top: 15rpx;
  258. font-size: 24rpx;
  259. font-family: PingFang SC;
  260. font-weight: 500;
  261. color: #333333;
  262. }
  263. }
  264. }
  265. }
  266. .join-red {
  267. width: 750rpx;
  268. height: 279rpx;
  269. background-color: #fff;
  270. margin: 20rpx 0;
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. image {
  275. width: 710rpx;
  276. height: 203rpx;
  277. }
  278. }
  279. .jzsb-wrap {
  280. width: 750rpx;
  281. height: 812rpx;
  282. background-color: #fff;
  283. margin: 20rpx 0;
  284. image {
  285. width: 100%;
  286. height: 100%;
  287. }
  288. .fjjhy-wrap {
  289. width: 694rpx;
  290. height: 417rpx;
  291. margin: 0 auto 20rpx;
  292. border-radius: 20rpx;
  293. }
  294. .jhz-aed-wrap {
  295. width: 694rpx;
  296. height: 210rpx;
  297. margin: 20rpx auto;
  298. justify-content: space-between;
  299. .jhz-wrap {
  300. width: 334rpx;
  301. height: 208rpx;
  302. border-radius: 28rpx;
  303. }
  304. .aed-wrap {
  305. width: 334rpx;
  306. height: 208rpx;
  307. border-radius: 28rpx;
  308. }
  309. }
  310. }
  311. .kp-wrap {
  312. width: 750rpx;
  313. height: 353rpx;
  314. background-color: #fff;
  315. margin: 20rpx auto;
  316. position: relative;
  317. .kp-scroll {
  318. height: 200rpx;
  319. width: 750rpx;
  320. // background-color: red;
  321. // justify-content: ;
  322. padding-left: 23rpx;
  323. white-space: nowrap;
  324. .kp-item {
  325. display: inline-block;
  326. width: 286rpx;
  327. height: 200rpx;
  328. background: #FFFFFF;
  329. border: 1px solid #F5F5F5;
  330. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  331. border-radius: 15rpx;
  332. margin-right:15rpx;
  333. .kp-item-img {
  334. height: 155rpx;
  335. margin-bottom: 5rpx;
  336. image {
  337. display: block;
  338. margin: auto;
  339. height: 155rpx;
  340. max-width: 286rpx;
  341. }
  342. }
  343. .kp-item-tit {
  344. width: 246rpx;
  345. height: 33rpx;
  346. background: #a1a1a1;
  347. border-radius: 17rpx;
  348. color: #fff;
  349. margin: auto;
  350. position: relative;
  351. font-size: 24rpx;
  352. font-weight: 500;
  353. color: #FEFEFE;
  354. line-height: 33rpx;
  355. padding-left: 23rpx;
  356. &::before {
  357. content: '';
  358. width: 4rpx;
  359. height: 4rpx;
  360. background: #F3392C;
  361. border-radius: 50%;
  362. position: absolute;
  363. top: 0;
  364. bottom: 0;
  365. left: 12rpx;
  366. margin: auto;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. .wrap-tit {
  373. display: inline-block;
  374. line-height: 115rpx;
  375. font-size: 40rpx;
  376. font-weight:600;
  377. color: #666666;
  378. padding-left: 24rpx;
  379. position: relative;
  380. .tit-bg {
  381. width: 160rpx;
  382. height: 22rpx;
  383. background: linear-gradient(-330deg, #FFE88B, #FFBA00);
  384. opacity: 0.4;
  385. position: absolute;
  386. bottom: 40rpx;
  387. margin: auto;
  388. }
  389. }
  390. .readmore {
  391. width: 150rpx;
  392. padding-right: 27rpx;
  393. font-size: 28rpx;
  394. font-weight: 500;
  395. color: #999999;
  396. position: absolute;
  397. text-align: right;
  398. top: 0;
  399. right: 0;
  400. line-height: 110rpx;
  401. image {
  402. width: 35rpx;
  403. vertical-align: text-bottom;
  404. }
  405. }
  406. </style>