126 lines
3.3 KiB
Vue
126 lines
3.3 KiB
Vue
<template>
|
|
<uni-swiper-dot
|
|
:info="props.data.items"
|
|
:current="current"
|
|
field="content"
|
|
mode="round"
|
|
:dots-styles="{
|
|
backgroundColor: '#D6D6D6',
|
|
border: '1px #D6D6D6 solid',
|
|
color: '#fff',
|
|
selectedBackgroundColor: 'var(--color2)',
|
|
selectedBorder: '1px var(--color2) solid',
|
|
selectedWidth: '4',
|
|
selectedHight: '4',
|
|
bottom: '8',
|
|
height: '4',
|
|
}"
|
|
>
|
|
<swiper
|
|
:style="{
|
|
...props.styles,
|
|
overflow: 'hidden',
|
|
}"
|
|
:indicator-dots="props.data.indicatorDots"
|
|
:indicator-color="props.data.indicatorColor"
|
|
:indicator-active-color="props.data.indicatorActiveColor"
|
|
:circular="props.data.circular"
|
|
:interval="props.data.interval"
|
|
:autoplay="props.data.autoplay"
|
|
:duration="props.data.duration"
|
|
@change="change"
|
|
>
|
|
<swiper-item v-for="(item, index) in props.data.items" :key="index" @click="go(item.url)">
|
|
<image style="width: 100%; height: 100%" :src="item.picUrl" mode="aspectFill"></image>
|
|
</swiper-item>
|
|
</swiper>
|
|
</uni-swiper-dot>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue';
|
|
import * as AiApi from '@/sheep/api/ai/index';
|
|
let current = ref(0);
|
|
// 轮播图
|
|
const props = defineProps({
|
|
data: {
|
|
type: Object,
|
|
default: () => ({
|
|
indicatorColor: '#D6D6D6', //点颜色
|
|
indicatorActiveColor: '#FE4246', //当前点颜色
|
|
autoplay: true, //是否自动切换
|
|
interval: 3000, //自动切换时间间隔
|
|
circular: true, //是否衔接滑动
|
|
indicatorDots: true, //是否显示面板指示点
|
|
}),
|
|
},
|
|
styles: {
|
|
type: Object,
|
|
default: () => ({}),
|
|
},
|
|
});
|
|
const change = (e) => {
|
|
current.value = e.detail.current;
|
|
};
|
|
|
|
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
|
|
|
|
const parsePath = (raw) => {
|
|
const s = typeof raw === 'string' ? raw : '';
|
|
const [p] = s.split('?');
|
|
return p;
|
|
};
|
|
|
|
const go = async (url, obj = {}) => {
|
|
if (!url) {
|
|
// uni.showToast({
|
|
// title: '功能开发中, 敬请期待',
|
|
// icon: 'none',
|
|
// });
|
|
return;
|
|
}
|
|
|
|
const path = parsePath(url);
|
|
if (path === '/pages/index/aiStore') {
|
|
try {
|
|
const res = await AiApi.checkShopStatus({});
|
|
const opened = res?.code === 0 ? Boolean(res?.data) : false;
|
|
if (!opened) {
|
|
const message =
|
|
'您尚未开通AI店铺,无法查看购物车。请先开通AI店铺后再进行购买。';
|
|
uni.setStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY, '会员优选');
|
|
uni.showToast({
|
|
title: message,
|
|
icon: 'none',
|
|
duration: 2500,
|
|
});
|
|
setTimeout(() => {
|
|
uni.switchTab({
|
|
url: '/pages/index/index',
|
|
fail: () => {
|
|
uni.reLaunch({ url: '/pages/index/index' });
|
|
},
|
|
});
|
|
}, 1000);
|
|
return;
|
|
}
|
|
} catch (e) {
|
|
uni.showToast({
|
|
title: '系统繁忙,请稍后重试',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
|
|
uni.switchTab({ url: '/pages/index/aiStore' });
|
|
return;
|
|
}
|
|
|
|
uni.navigateTo({
|
|
url: url,
|
|
data: obj,
|
|
});
|
|
};
|
|
</script>
|
|
<style scoped lang="scss"></style>
|