index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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" v-for="(item,index) in navList" @click="navTo(item.path)">
  14. <view class="item-top flex">
  15. <image :src="'../../static/index/in' + (index + 1) + '.png'" mode=""></image>
  16. </view>
  17. <view class="">
  18. {{item.tit}}
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. getAed,
  27. getAidList,
  28. getRescuerList,
  29. sos,
  30. } from '@/api/category.js'
  31. import {
  32. loadIndexs,
  33. bannerlist,
  34. getListAED,
  35. getDistance,
  36. getListMechanism,
  37. getdis,
  38. tocall
  39. } from '@/api/index.js';
  40. import {
  41. saveUrl,
  42. interceptor
  43. } from '@/utils/loginUtils.js';
  44. import {
  45. mapState,
  46. mapMutations
  47. } from 'vuex';
  48. import {
  49. userinfo
  50. } from '@/api/user.js';
  51. export default {
  52. data() {
  53. return {
  54. carouselList: [], //轮播
  55. navList: [
  56. {
  57. tit: "爱心捐款",
  58. path: '/pages/applic/love',
  59. img: '',
  60. },
  61. {
  62. tit: "遗体器官捐献",
  63. path: '/pages/form/applicationForm',
  64. img: '',
  65. },
  66. {
  67. tit: "造血干细胞捐献",
  68. path: '/pages/applic/appliSystem',
  69. img: '',
  70. },
  71. {
  72. tit: "红十字志愿者",
  73. path: '/pages/form/tovolApply',
  74. img: '',
  75. },
  76. {
  77. tit: "普及培训报名",
  78. path: '/pages/train/index',
  79. img: '',
  80. },
  81. {
  82. tit: "红十字会员",
  83. path: '/pages/cart/cat1',
  84. img: '',
  85. },
  86. {
  87. tit: "AED智能系统",
  88. path: '/pages/applic/aed',
  89. img: '',
  90. },
  91. {
  92. tit: "关于我们",
  93. path: '/pages/applic/info?id=344',
  94. img: '',
  95. },
  96. {
  97. tit: "红会科普",
  98. path: '/pages/applic/science',
  99. img: '',
  100. }
  101. ]
  102. };
  103. },
  104. onShow() {
  105. saveUrl();
  106. console.log(11, this);
  107. if (!this.hasLogin) {
  108. // 登录拦截
  109. // interceptor();
  110. uni.showModal({
  111. title: '登录',
  112. content: '您未登录,是否马上登陆?',
  113. success: e => {
  114. if (e.confirm) {
  115. interceptor();
  116. }
  117. },
  118. fail: e => {
  119. console.log(e);
  120. }
  121. });
  122. } else {
  123. }
  124. },
  125. onLoad() {
  126. this.loadIndex()
  127. saveUrl();
  128. },
  129. computed: {
  130. ...mapState('user', ['userInfo', 'baseURL', 'hasLogin']),
  131. ...mapState(['baseURL']),
  132. },
  133. methods: {
  134. ...mapMutations('user', ['setUserInfo']),
  135. loadIndex() {
  136. loadIndexs({}).then(({
  137. data
  138. }) => {
  139. console.log(data, 'index')
  140. this.carouselList = data.banner; //轮播图
  141. });
  142. },
  143. open() {
  144. this.$refs.popup.open();
  145. },
  146. close() {
  147. this.$refs.popup.close();
  148. },
  149. navTo(url) {
  150. if(url.indexOf('http') != -1) {
  151. window.location.href = url
  152. }else {
  153. uni.navigateTo({
  154. url,
  155. fail() {
  156. uni.switchTab({
  157. url
  158. })
  159. }
  160. });
  161. }
  162. },
  163. }
  164. };
  165. </script>
  166. <style lang="scss">
  167. .content {
  168. background-color: #fafbfa;
  169. height: 100%;
  170. }
  171. /* 头部 轮播图 */
  172. .carousel-section {
  173. overflow: hidden;
  174. .carousel {
  175. width: 706rpx;
  176. height: 375rpx;
  177. margin: 0 auto;
  178. border-radius: 20rpx;
  179. overflow: hidden;
  180. background-color: #fff;
  181. image {
  182. width: 100%;
  183. height: 375rpx;
  184. border-radius: 20rpx;
  185. }
  186. }
  187. }
  188. // 分类
  189. .cate-section {
  190. justify-content: space-between;
  191. flex-wrap: wrap;
  192. padding: 22rpx;
  193. font-size: 28rpx;
  194. font-weight: 500;
  195. .cate-item {
  196. background: #FFFFFF;
  197. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50,50,52,0.06);
  198. border-radius: 25rpx;
  199. width: 226rpx;
  200. margin-bottom: 22rpx;
  201. text-align: center;
  202. padding-bottom: 50rpx;
  203. .item-top {
  204. padding-top: 20rpx;
  205. height: 207rpx;
  206. align-items: center;
  207. justify-content: center;
  208. image {
  209. width: 112rpx;
  210. height: 112rpx;
  211. }
  212. }
  213. }
  214. }
  215. </style>