123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <view class="section_page_main clearfix">
- <view class="recommend-list">
- <swiper
- class="tui-banner-swiper"
- :autoplay="true"
- :interval="5000"
- :duration="500"
- :circular="true"
- @change="swiperChange"
- >
- <swiper-item class="clearfix" v-for="(list,index1) in productList" :key="index1">
- <view class="img-box" v-for="(product,index2) in list" :key="index2" @click="navigaitionTo(product)">
- <image :src="product.appletsImage" ></image>
- </view>
- </swiper-item>
- </swiper>
- <view class="swiper__recommenddots-box" v-if="productList.length > 1">
- <view
- v-for="(item, idx) in productList"
- :key="idx"
- :class="[idx === swiperCurrent ? 'swiper__dots-long' : 'none']"
- :data-index="swiperCurrent"
- class="swiper__dots-item"
- >
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { mapState, mapMutations } from 'vuex'
- import uniGrader from '@/components/uni-grade/uni-grade.vue'
- import caimeiApi from '@/common/config/caimeiApi.js'
- export default {
- name: 'templateH',
- components: {
- uniGrader
- },
- props: {
- pageData: {
- type: Object
- },
- userIdentity: {
- type: Number
- }
- },
- data() {
- return {
- productList: [],
- swiperCurrent: 0,
- pageSize: 8,
- }
- },
- created() {
- this.initData(this.pageData)
- },
- watch: {
- pageData: {
- handler: function(el) {
- //监听对象的变换使用 function,箭头函数容易出现this指向不正确
- this.pageData = el
- this.initData(this.pageData)
- },
- deep: true
- }
- },
- methods: {
- initData(data) {
- while(data.floorImageList.length > 0){
- this.productList.push(data.floorImageList.splice(0,this.pageSize))
- }
- },
- swiperChange(e) {
- //轮播切换
- const index = e.detail.current
- this.swiperCurrent = index
- },
- navigaitionTo(item){
- if (item.adsImage === '' && item.linkType === -1) {
- return
- }else if(item.linkType === -1){
- uni.navigateTo({
- url:`/h5/pages/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
- })
- }else{
- caimeiApi.FlooryNavigateTo(item)
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .section_page_main {
- width: 100%;
- height: auto;
- box-sizing: border-box;
- .recommend-list {
- width: 100%;
- height: 390rpx;
- position: relative;
- padding-bottom: 20rpx;
- .tui-banner-swiper {
- width: 100%;
- margin: 0 auto;
- background: #f7f7f7;
- height: 350rpx;
- overflow: hidden;
- transform: translateY(0);
- .img-box {
- width: 164rpx;
- height: 164rpx;
- float: left;
- margin: 15rpx 15rpx 0 0;
- overflow: hidden;
- border-radius: 8rpx;
- image {
- width: 164rpx;
- height: 164rpx;
- }
- &:nth-child(4n) {
- margin-right: 0;
- }
- &:nth-child(1),
- &:nth-child(2),
- &:nth-child(3),
- &:nth-child(4) {
- margin-top: 0;
- }
- }
- }
- }
- .swiper__recommenddots-box {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex: 1;
- flex-direction: row;
- justify-content: center;
- align-items: center;
- height: 60rpx;
- .swiper__dots-item {
- width: 8rpx;
- height: 8rpx;
- border-radius: 100%;
- margin-left: 6px;
- background-color: rgba(225, 86, 22, 0.3);
- }
- .swiper__dots-long {
- width: 32rpx;
- height: 8rpx;
- border-radius: 4rpx;
- background-color: #e15616;
- transition: all 0.4s;
- }
- }
- }
- </style>
|