index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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="navTo('/pages/form/applicationForm')">
  20. <view class="img-wrapper flex">
  21. <image src="../../static/icon/icon2.png" mode="" class="img2"></image>
  22. </view>
  23. <view class="item-title">遗体器官捐献</view>
  24. </view>
  25. <view class="cate-item flex" @click="navTo('/pages/applic/appliSystem')">
  26. <view class="img-wrapper flex">
  27. <image src="../../static/icon/icon3.png" mode="" class="img3"></image>
  28. </view>
  29. <view class="item-title">造血干细胞捐献</view>
  30. </view>
  31. <view class="cate-item flex" @click="navTo('/pages/form/tovolApply')">
  32. <view class="img-wrapper flex">
  33. <image src="../../static/icon/icon4.png" mode="" class="img4"></image>
  34. </view>
  35. <view class="item-title">红十字志愿者</view>
  36. </view>
  37. </view>
  38. <view class="kp-tit">
  39. <image src="../../static/img/ketit.png" mode="" class="ke-tit-img"></image>
  40. <view class="red-kp">
  41. 红会科普
  42. </view>
  43. </view>
  44. <view class="list-box" v-for="(item,index) in science" :key='index' @click="Jump(item)">
  45. <view class="box-left">
  46. <image :src="$store.state.baseURL + item.image" mode="" class="left-img"></image>
  47. </view>
  48. <view class="box-right">
  49. <view class="right-top word1_ellipsis">
  50. {{item.title}}
  51. </view>
  52. <view class="right-center">
  53. {{item.synopsis}}
  54. </view>
  55. <view class="right-foot">
  56. {{item.releasetime | showTime}}
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. getAed,
  65. getAidList,
  66. getRescuerList,
  67. sos,
  68. } from '@/api/category.js'
  69. import {
  70. loadIndexs,
  71. bannerlist,
  72. getListAED,
  73. getDistance,
  74. getListMechanism,
  75. getdis,
  76. tocall,
  77. getArticList
  78. } from '@/api/index.js';
  79. import {
  80. saveUrl,
  81. interceptor
  82. } from '@/utils/loginUtils.js';
  83. import {
  84. mapState,
  85. mapMutations
  86. } from 'vuex';
  87. import {
  88. userinfo
  89. } from '@/api/user.js';
  90. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  91. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  92. import {
  93. getLoca
  94. } from '@/utils/wxAuthorized.js';
  95. import {
  96. getcomAddress
  97. } from '@/api/index.js';
  98. import topTitle from '../../components/top-title/top-title.vue';
  99. export default {
  100. components: {
  101. uniPopup,
  102. uniLoadMore,
  103. topTitle
  104. },
  105. filters: {
  106. showTime(val) {
  107. let str = ''
  108. if(val) {
  109. let arr = val.split(' ')
  110. str = arr[0]
  111. }
  112. return str
  113. }
  114. },
  115. data() {
  116. return {
  117. carouselList: [], //轮播
  118. science: [], //文章列表
  119. page: 1,
  120. limit: 10,
  121. loadingType: 'more',
  122. };
  123. },
  124. onShow() {
  125. saveUrl();
  126. console.log(11, this);
  127. if (!this.hasLogin) {
  128. // 登录拦截
  129. // interceptor();
  130. uni.showModal({
  131. title: '登录',
  132. content: '您未登录,是否马上登陆?',
  133. success: e => {
  134. if (e.confirm) {
  135. interceptor();
  136. }
  137. },
  138. fail: e => {
  139. console.log(e);
  140. }
  141. });
  142. } else {
  143. // this.loadData();
  144. }
  145. },
  146. onLoad() {
  147. this.loadIndex()
  148. this.getRedKpList()
  149. saveUrl();
  150. },
  151. computed: {
  152. ...mapState('user', ['userInfo', 'baseURL', 'hasLogin']),
  153. ...mapState(['baseURL']),
  154. },
  155. //下拉加载
  156. onReachBottom() {
  157. this.getRedKpList()
  158. },
  159. methods: {
  160. ...mapMutations('user', ['setUserInfo']),
  161. // 获取红会科普
  162. getRedKpList() {
  163. let obj = this
  164. if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  165. return
  166. }
  167. obj.loadingType = 'loading'
  168. getArticList({
  169. page: obj.page,
  170. limit: obj.limit
  171. },61).then(({data}) => {
  172. obj.science = obj.science.concat(data.list);
  173. obj.page++
  174. if(data.list.length == obj.limit) {
  175. obj.loadingType = 'more'
  176. }else {
  177. obj.loadingType = 'noMore'
  178. }
  179. })
  180. },
  181. // 跳转红会科普详情
  182. Jump(item) {
  183. uni.navigateTo({
  184. url:"/pages/applic/info?id="+item.id
  185. })
  186. },
  187. //轮播图
  188. loadIndex() {
  189. loadIndexs({}).then(({
  190. data
  191. }) => {
  192. console.log(data,'index')
  193. this.carouselList = data.banner; //轮播图
  194. });
  195. },
  196. navTo(url) {
  197. uni.navigateTo({
  198. url: url
  199. });
  200. }
  201. }
  202. };
  203. </script>
  204. <style lang="scss">
  205. a {
  206. text-decoration: none;
  207. color: #5f5f5f;
  208. }
  209. .content {
  210. background-color: #f8f8f8;
  211. height: 100%;
  212. /* 头部 轮播图 */
  213. .carousel-section {
  214. // padding-top: 10px;
  215. overflow: hidden;
  216. background-color: #fff;
  217. .carousel {
  218. width: 705rpx;
  219. height: 375rpx;
  220. margin: 0 auto;
  221. border-radius: 20rpx;
  222. overflow: hidden;
  223. .carousel-item {
  224. width: 100%;
  225. height: 100%;
  226. padding-left: 30rpx;
  227. padding-right: 30rpx;
  228. overflow: hidden;
  229. }
  230. image {
  231. width: 100%;
  232. height: 375rpx;
  233. border-radius: 20rpx;
  234. }
  235. }
  236. }
  237. // 分类
  238. .cate-section {
  239. justify-content: space-around;
  240. background-color: #fff;
  241. padding: 46rpx 0 30rpx;
  242. .cate-item {
  243. width: 25%;
  244. flex-direction: column;
  245. text-align: center;
  246. align-items: center;
  247. justify-content: center;
  248. .img-wrapper {
  249. width: 100rpx;
  250. height: 88rpx;
  251. background: #fff;
  252. border-radius: 14rpx;
  253. position: relative;
  254. image {
  255. position: absolute;
  256. left: 50%;
  257. top: 50%;
  258. transform: translate(-50%, -50%);
  259. }
  260. .img1 {
  261. width: 100rpx;
  262. height: 84rpx;
  263. }
  264. .img2 {
  265. width: 100rpx;
  266. height: 85rpx;
  267. }
  268. .img3 {
  269. width: 100rpx;
  270. height: 84rpx;
  271. }
  272. .img4 {
  273. width: 100rpx;
  274. height: 88rpx;
  275. }
  276. }
  277. .item-title {
  278. margin-top: 15rpx;
  279. font-size: 24rpx;
  280. font-family: PingFang SC;
  281. font-weight: 500;
  282. color: #333333;
  283. }
  284. }
  285. }
  286. }
  287. .kp-tit {
  288. margin-top: 20rpx;
  289. position: relative;
  290. height: 100rpx;
  291. background-color: #fff;
  292. .red-kp {
  293. line-height: 100rpx;
  294. text-align: center;
  295. font-size: 33rpx;
  296. font-family: PingFang SC;
  297. font-weight: bold;
  298. color: #CB131C;
  299. }
  300. .ke-tit-img {
  301. position: absolute;
  302. top: 0;
  303. bottom: 0;
  304. right: 0;
  305. left: 0;
  306. margin: auto;
  307. width: 222rpx;
  308. height: 22rpx;
  309. }
  310. }
  311. .list-box{
  312. width: 725rpx;
  313. height: 200rpx;
  314. margin:0 auto 20rpx;
  315. background: #FFFFFF;
  316. box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
  317. border-radius: 7rpx;
  318. padding:0 20rpx;
  319. display: flex;
  320. align-items: center;
  321. .box-left{
  322. width: 230rpx;
  323. height: 145rpx;
  324. margin-right: 20rpx;
  325. .left-img{
  326. width: 230rpx;
  327. height: 145rpx;
  328. }
  329. }
  330. .box-right{
  331. width: 430rpx;
  332. height: 145rpx;
  333. position: relative;
  334. .right-top{
  335. font-size: 25rpx;
  336. font-weight: bold;
  337. color: #333333;
  338. margin-bottom: 24rpx;
  339. }
  340. .right-center{
  341. width: 362rpx;
  342. // height: 53rpx;
  343. font-size: 21rpx;
  344. font-weight: bold;
  345. color: #999999;
  346. line-height: 33rpx;
  347. overflow: hidden;
  348. text-overflow: ellipsis;
  349. display: -webkit-box;
  350. -webkit-line-clamp: 2;//在第几行显示...
  351. -webkit-box-orient: vertical;
  352. }
  353. .right-foot{
  354. font-size: 21rpx;
  355. font-weight: bold;
  356. color: #999999;
  357. line-height: 31rpx;
  358. text-align: right;
  359. // margin-top: 13rpx;
  360. position: absolute;
  361. right: 0;
  362. bottom: -10rpx;
  363. }
  364. }
  365. }
  366. </style>