home.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view>
  3. <!-- 使用自定义的搜索组件 -->
  4. <view class="search-box">
  5. <uni-row>
  6. <uni-col :span="4">
  7. <view class="my-location" @click="getLocations">
  8. <view class="location-text">位置</view>
  9. <uni-icons type="location-filled" size="20">位置</uni-icons>
  10. </view>
  11. </uni-col>
  12. <uni-col :span="20">
  13. <my-search @click="gotoSearch" bgcolor="#F5F5F5"></my-search>
  14. </uni-col>
  15. </uni-row>
  16. </view>
  17. <uni-swiper-dot :info="info" :current="current">
  18. <swiper class="swiper-box" autoplay circular @change="change">
  19. <swiper-item v-for="(item ,index) in info" :key="index">
  20. <view class="swiper-item">
  21. <image :src="item.url"></image>
  22. </view>
  23. </swiper-item>
  24. </swiper>
  25. </uni-swiper-dot>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. info: [],
  33. current: 0
  34. }
  35. },
  36. created() {
  37. this.getSwiperList()
  38. },
  39. methods: {
  40. submit() {
  41. this.$refs.form.validate().then(res => {
  42. console.log('表单数据信息:', res);
  43. }).catch(err => {
  44. console.log('表单错误信息:', err);
  45. })
  46. },
  47. gotoSearch() {
  48. uni.navigateTo({
  49. url: '/subpkg/search/search'
  50. })
  51. },
  52. // 获取轮播图列表
  53. async getSwiperList() {
  54. const {
  55. data: result
  56. } = await uni.$http.get('/education/swiper/getSwiperList')
  57. this.info = result.data.list
  58. },
  59. // 滑动轮播图触发
  60. change(e) {
  61. this.current = e.detail.current
  62. },
  63. getLocations() {
  64. console.log("hhh")
  65. wx.choosePoi({
  66. success(res) {
  67. console.log(res)
  68. }
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .search-box {
  76. // 设置定位效果为“吸顶”
  77. position: sticky;
  78. // 吸顶的“位置”
  79. top: 0;
  80. // 提高层级,防止被轮播图覆盖
  81. z-index: 999;
  82. }
  83. .my-location {
  84. display: flex;
  85. justify-content: center;
  86. align-items: center;
  87. height: 50px;
  88. }
  89. .swiper-box {
  90. height: 350rpx;
  91. }
  92. .swiper-item {
  93. display: block;
  94. height: 350rpx;
  95. line-height: 350rpx;
  96. text-align: center;
  97. image {
  98. width: 100%;
  99. height: 100%;
  100. display: block;
  101. }
  102. }
  103. </style>