init
This commit is contained in:
@@ -0,0 +1,353 @@
|
||||
<template>
|
||||
<s-pages tabbar="/pages/cart/cart" title="购物车" :showLeftButton="false">
|
||||
<s-empty
|
||||
v-if="state.list.length === 0"
|
||||
icon="/static/cart-empty.png"
|
||||
text="购物车空空如也,快去逛逛吧~"
|
||||
/>
|
||||
|
||||
<!-- 头部 -->
|
||||
<view v-if="state.list.length" class="cart-box ss-flex ss-flex-col ss-row-between">
|
||||
<view class="cart-header ss-flex ss-col-center ss-row-between ss-p-x-30">
|
||||
<view></view>
|
||||
<view class="header-right">
|
||||
<view v-if="state.editMode" class="c0" @tap="onChangeEditMode(false)"> 取消 </view>
|
||||
<view v-else class="f500" @tap="onChangeEditMode(true)"> 管理 </view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 内容 -->
|
||||
<view class="cart-content ss-flex-1 ss-p-x-30 ss-m-b-40 m-b-100">
|
||||
<view
|
||||
v-for="item in state.list"
|
||||
:key="item.id"
|
||||
class="goods-box ss-r-10"
|
||||
@click="goInfo(item.spu.id)"
|
||||
>
|
||||
<view class="ss-flex ss-col-center">
|
||||
<label
|
||||
class="check-box ss-flex ss-col-center ss-p-l-10"
|
||||
@tap.stop="onSelectSingle(item.id)"
|
||||
>
|
||||
<radio
|
||||
:checked="state.selectedIds.includes(item.id)"
|
||||
color="var(--color32)"
|
||||
style="transform: scale(0.8)"
|
||||
backgroundColor="var(--color31)"
|
||||
@tap.stop="onSelectSingle(item.id)"
|
||||
/>
|
||||
</label>
|
||||
<view v-if="item.spu?.status !== 1 && !state.editMode" class="down-box">
|
||||
该商品已下架
|
||||
</view>
|
||||
<view v-else-if="item.spu?.stock <= 0 && !state.editMode" class="down-box">
|
||||
该商品无库存
|
||||
</view>
|
||||
<s-goods-item
|
||||
:img="item.spu.picUrl || item.goods.image"
|
||||
:price="item.sku?.price || 0"
|
||||
:skuText="
|
||||
item.sku?.properties.length > 1
|
||||
? item.sku?.properties.reduce(
|
||||
(items2, items) => items2.valueName + ' ' + items.valueName,
|
||||
)
|
||||
: item.sku?.properties[0].valueName
|
||||
"
|
||||
:title="item.spu.name"
|
||||
:titleWidth="400"
|
||||
priceColor="#FF3000"
|
||||
>
|
||||
<template v-if="!state.editMode" v-slot:tool>
|
||||
<su-number-box
|
||||
v-model="item.count"
|
||||
:max="item.sku?.stock"
|
||||
:min="0"
|
||||
:step="1"
|
||||
@change="onNumberChange($event, item)"
|
||||
background="var(--color18)"
|
||||
color="var(--color34)"
|
||||
/>
|
||||
</template>
|
||||
</s-goods-item>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部 -->
|
||||
<su-fixed v-if="state.list.length > 0" :isInset="false" :val="valNum" bottom placeholder>
|
||||
<view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom">
|
||||
<view class="ss-flex ss-col-center flex1">
|
||||
<label class="check-box ss-flex ss-col-center ss-p-r-30 flex1" @tap="onSelectAll">
|
||||
<radio
|
||||
:checked="state.isAllSelected"
|
||||
color="var(--color32)"
|
||||
style="transform: scale(0.8)"
|
||||
backgroundColor="var(--color31)"
|
||||
@tap.stop="onSelectAll"
|
||||
/>
|
||||
<view class="ss-m-l-8 c0"> 全选</view>
|
||||
</label>
|
||||
<view class="flex-center" style="margin-right: 14rpx">
|
||||
<text class="size26 c0">总计:</text>
|
||||
|
||||
<view class="price-text c13">
|
||||
<span class="f500">¥</span>
|
||||
<span class="priceNum">
|
||||
{{ fen2yuan(state.totalPriceSelected) }}
|
||||
</span>
|
||||
</view>
|
||||
<!-- <view class="text-price price-text size34" style="color: #ee0a24">
|
||||
{{ fen2yuan(state.totalPriceSelected) }}
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="footer-right">
|
||||
<button
|
||||
v-if="state.editMode"
|
||||
class="ss-reset-button pay-btn ui-Shadow-Main"
|
||||
@tap="onDelete"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
<button v-else class="ss-reset-button pay-btn ui-Shadow-Main" @tap="onConfirm">
|
||||
去结算
|
||||
{{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</su-fixed>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import { onShow, onLoad } from '@dcloudio/uni-app';
|
||||
import SpuApi from '@/sheep/api/product/spu';
|
||||
import { computed, reactive } from 'vue';
|
||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||
import { isEmpty } from '@/sheep/helper/utils';
|
||||
onLoad(() => {
|
||||
uni.hideNavigationBarLoading();
|
||||
});
|
||||
// 隐藏原生tabBar
|
||||
// uni.hideTabBar({
|
||||
// fail: () => {},
|
||||
// });
|
||||
|
||||
const sys_navBar = sheep.$platform.navbar;
|
||||
const cart = sheep.$store('cart');
|
||||
|
||||
const state = reactive({
|
||||
editMode: computed(() => cart.editMode),
|
||||
list: computed(() => cart.list),
|
||||
selectedList: [],
|
||||
selectedIds: computed(() => cart.selectedIds),
|
||||
isAllSelected: computed(() => cart.isAllSelected),
|
||||
totalPriceSelected: computed(() => cart.totalPriceSelected),
|
||||
});
|
||||
|
||||
// 单选选中
|
||||
function onSelectSingle(id) {
|
||||
cart.selectSingle(id);
|
||||
}
|
||||
|
||||
// 编辑、取消
|
||||
function onChangeEditMode(flag) {
|
||||
cart.onChangeEditMode(flag);
|
||||
}
|
||||
|
||||
// 全选
|
||||
function onSelectAll() {
|
||||
cart.selectAll(!state.isAllSelected);
|
||||
}
|
||||
|
||||
// 结算
|
||||
async function onConfirm() {
|
||||
const items = [];
|
||||
state.selectedList = state.list.filter((item) => state.selectedIds.includes(item.id));
|
||||
state.selectedList.map((item) => {
|
||||
// 此处前端做出修改
|
||||
items.push({
|
||||
skuId: item.sku?.id,
|
||||
count: item.count,
|
||||
cartId: item.id,
|
||||
categoryId: item.spu.categoryId,
|
||||
});
|
||||
});
|
||||
if (isEmpty(items)) {
|
||||
sheep.$helper.toast('请先选择商品');
|
||||
return;
|
||||
}
|
||||
await validateDeliveryType(state.selectedList.map((item) => item.spu).map((spu) => spu.id));
|
||||
sheep.$router.go('/pages/order/confirm', {
|
||||
data: JSON.stringify({
|
||||
items,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验配送方式冲突
|
||||
*
|
||||
* @param {string[]} spuIds - 商品ID数组
|
||||
* @returns {Promise<void>}
|
||||
* @throws {Error} 当配送方式冲突或获取商品信息失败时抛出错误
|
||||
*/
|
||||
async function validateDeliveryType(spuIds) {
|
||||
// 获取商品信息
|
||||
const { data: spuList } = await SpuApi.getSpuListByIds(spuIds.join(','));
|
||||
if (isEmpty(spuList)) {
|
||||
sheep.$helper.toast('未找到商品信息');
|
||||
throw new Error('未找到商品信息');
|
||||
}
|
||||
// 获取所有商品的配送方式列表
|
||||
const deliveryTypesList = spuList.map((item) => item.deliveryTypes);
|
||||
// 检查配送方式冲突
|
||||
const hasConflict = checkDeliveryConflicts(deliveryTypesList);
|
||||
if (hasConflict) {
|
||||
sheep.$helper.toast('选中商品支持的配送方式冲突,不允许提交');
|
||||
throw new Error('选中商品支持的配送方式冲突,不允许提交');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配送方式列表中是否存在冲突
|
||||
* @description
|
||||
* 示例场景:
|
||||
* A 商品支持:[快递, 自提]
|
||||
* B 商品支持:[快递]
|
||||
* C 商品支持:[自提]
|
||||
*
|
||||
* 对比结果:
|
||||
* A 和 B:不冲突 (有交集:快递)
|
||||
* A 和 C:不冲突 (有交集:自提)
|
||||
* B 和 C:冲突 (无交集)
|
||||
* @param {Array<Array<number>>} deliveryTypesList - 配送方式列表的数组
|
||||
* @returns {boolean} 是否存在冲突
|
||||
*/
|
||||
function checkDeliveryConflicts(deliveryTypesList) {
|
||||
for (let i = 0; i < deliveryTypesList.length - 1; i++) {
|
||||
const currentTypes = deliveryTypesList[i];
|
||||
for (let j = i + 1; j < deliveryTypesList.length; j++) {
|
||||
const nextTypes = deliveryTypesList[j];
|
||||
// 检查是否没有交集(即冲突)
|
||||
const hasNoIntersection = !currentTypes.some((type) => nextTypes.includes(type));
|
||||
if (hasNoIntersection) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onNumberChange(e, cartItem) {
|
||||
//console.log(e);
|
||||
if (e === 0) {
|
||||
cart.delete(cartItem.id);
|
||||
return;
|
||||
}
|
||||
if (cartItem.goods_num === e) return;
|
||||
cartItem.goods_num = e;
|
||||
cart.update({
|
||||
goods_id: cartItem.id,
|
||||
goods_num: e,
|
||||
goods_sku_price_id: cartItem.goods_sku_price_id,
|
||||
});
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
cart.delete(state.selectedIds);
|
||||
}
|
||||
|
||||
function getCartList() {
|
||||
cart.getList();
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getCartList();
|
||||
});
|
||||
const goInfo = (id) => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/goods/info?id=' + id,
|
||||
});
|
||||
};
|
||||
let valNum = ref(0);
|
||||
// #ifdef APP-PLUS
|
||||
valNum.value = 0;
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
valNum.value = 50;
|
||||
// #endif
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.ui-fixed) {
|
||||
height: 72rpx;
|
||||
}
|
||||
|
||||
.cart-box {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border-radius: 0 0 16rpx 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.cart-header {
|
||||
height: 70rpx;
|
||||
width: 100%;
|
||||
// position: fixed;
|
||||
// left: 0;
|
||||
// top: v-bind('sys_navBar') rpx;
|
||||
z-index: 1000;
|
||||
box-sizing: border-box;
|
||||
border-radius: 16rpx 16rpx 0 0;
|
||||
}
|
||||
|
||||
.cart-footer {
|
||||
height: 100rpx;
|
||||
background-color: var(--color16);
|
||||
box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.04);
|
||||
|
||||
.pay-btn {
|
||||
width: 180rpx;
|
||||
height: 70rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 28rpx;
|
||||
font-weight: 500;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.cart-content {
|
||||
.goods-box {
|
||||
position: relative;
|
||||
margin-bottom: 22rpx;
|
||||
}
|
||||
// 下架商品
|
||||
.down-box {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(var(--ui-BG-1), 0.8);
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #999;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.price-text {
|
||||
.priceNum {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
.ss-reset-button {
|
||||
background: linear-gradient(270deg, #f7772e 0%, #ee0a24 99%);
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<s-pages tabbar="/pages/index/category" title="分类" :showLeftButton="false" color="#ffffff">
|
||||
<card_search class="search" style="padding-bottom: 32rpx" @search="search"></card_search>
|
||||
<view class="page_bottom flex-row">
|
||||
<view class="classify shrink">
|
||||
<view
|
||||
class="c_name size26"
|
||||
:class="{ activeName: i == dataObj.index }"
|
||||
v-for="(v, i) in dataObj.categoryList"
|
||||
:key="v.id"
|
||||
@click="classifyChange(i)"
|
||||
>
|
||||
{{ v.name }}
|
||||
</view>
|
||||
</view>
|
||||
<pages_commodity
|
||||
class="commodity flex1"
|
||||
ref="pageCommodity"
|
||||
:dataList="dataObj.dataList"
|
||||
@getData="getData"
|
||||
:subclassification="subclassification"
|
||||
:height="height"
|
||||
></pages_commodity>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import SpuApi from '@/sheep/api/product/spu';
|
||||
import CategoryApi from '@/sheep/api/product/category';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { handleTree } from '@/sheep/helper/utils';
|
||||
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
|
||||
import goodsItem2 from '@/components/goodsItem/goodsItem2.vue';
|
||||
import pages_commodity from '@/components/pages_commodity/pages_commodity.vue';
|
||||
let sysInfo = uni.getSystemInfoSync();
|
||||
const windowHeight = sysInfo.windowHeight;
|
||||
let height = ref('100%');
|
||||
height.value =
|
||||
windowHeight -
|
||||
sysInfo.statusBarHeight -
|
||||
uni.upx2px(88) -
|
||||
uni.upx2px(80) -
|
||||
uni.upx2px(96) -
|
||||
uni.upx2px(16) +
|
||||
'px';
|
||||
const dataObj = reactive({
|
||||
categoryList: [], // 商品分类树
|
||||
index: 0, // 选中的一级菜单,在 categoryList 的下标
|
||||
c_id: null, // 选中的一级菜单 id
|
||||
dataList: [], // 商品列表
|
||||
});
|
||||
let pageCommodity = ref(null);
|
||||
// 获取分类
|
||||
const getcategoryList = async () => {
|
||||
const { code, data } = await CategoryApi.getCategoryList();
|
||||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
// dataObj.categoryList = data;
|
||||
dataObj.categoryList = handleTree(data);
|
||||
if (dataObj.categoryList.length) {
|
||||
dataObj.c_id = dataObj.categoryList[0].id;
|
||||
}
|
||||
classifyChange(0);
|
||||
};
|
||||
const subclassification = ref([]);
|
||||
const classifyChange = (i) => {
|
||||
dataObj.index = i;
|
||||
dataObj.c_id = dataObj.categoryList[i]?.id;
|
||||
subclassification.value = dataObj.categoryList[i]?.children || [];
|
||||
|
||||
// upCallback({
|
||||
// num: 1,
|
||||
// size: 10,
|
||||
// });
|
||||
|
||||
// pageCommodity.value.changeData()
|
||||
if (pageCommodity.value) {
|
||||
pageCommodity.value.clearAll();
|
||||
}
|
||||
};
|
||||
|
||||
const changeArr = (id, arr, names = []) => {
|
||||
if (!arr || !arr.length) return '';
|
||||
for (const item of arr) {
|
||||
const pathNames = [...names, item.name];
|
||||
if (item.id == id) {
|
||||
return pathNames.join(' | ');
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
const found = changeArr(id, item.children, pathNames);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
onLoad(async () => {
|
||||
let res = await getcategoryList();
|
||||
pageCommodity.value.changeData();
|
||||
// upCallback();
|
||||
});
|
||||
const getData = async (mescroll) => {
|
||||
let res = await SpuApi.getSpuPage({
|
||||
categoryId: dataObj.c_id,
|
||||
pageNo: mescroll?.num || 1,
|
||||
pageSize: mescroll?.size || 10,
|
||||
keyword: searchText.value,
|
||||
...mescroll.params,
|
||||
});
|
||||
if (res.code !== 0) {
|
||||
pageCommodity.value.requestResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const curPageData = res.data.list || []; // 当前页数据
|
||||
if (curPageData.length) {
|
||||
curPageData.forEach((item) => {
|
||||
item.categoryText = changeArr(item.categoryId, dataObj.categoryList);
|
||||
});
|
||||
}
|
||||
if (mescroll?.num == 1) dataObj.dataList = []; // 第一页需手动制空列表
|
||||
dataObj.dataList = dataObj.dataList.concat(curPageData); //追加新数据
|
||||
// mescroll.endSuccess(curPageData.length); // 请求成功, 结束加载
|
||||
pageCommodity.value.requestResult(true, curPageData.length);
|
||||
};
|
||||
let searchText = ref(null);
|
||||
const search = (text) => {
|
||||
searchText.value = text;
|
||||
pageCommodity.value.changeData();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page_bottom {
|
||||
width: 100%;
|
||||
height: calc(100vh - 88rpx - 72rpx - 32rpx - 100rpx - 8rpx);
|
||||
|
||||
.classify {
|
||||
width: 160rpx;
|
||||
overflow-y: auto;
|
||||
background-color: #f2f4f7;
|
||||
|
||||
.c_name {
|
||||
text-align: center;
|
||||
line-height: 120rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.activeName {
|
||||
background: rgba($color: #ffffff, $alpha: 1);
|
||||
position: relative;
|
||||
color: var(--color32);
|
||||
font-weight: 600;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 6rpx;
|
||||
height: 76rpx;
|
||||
background-color: var(--color32);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
border-radius: 0 4rpx 4rpx 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.commodity {
|
||||
width: calc(100% - 160rpx);
|
||||
}
|
||||
|
||||
.search {
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,26 @@
|
||||
<!-- 分类展示:first-one 风格 -->
|
||||
<template>
|
||||
<view class="ss-flex-col">
|
||||
<view class="goods-box" v-for="item in pagination.list" :key="item.id">
|
||||
<s-goods-column
|
||||
size="sl"
|
||||
:data="item"
|
||||
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import sheep from '@/sheep';
|
||||
|
||||
const props = defineProps({
|
||||
pagination: Object,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.goods-box {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,66 @@
|
||||
<!-- 分类展示:first-two 风格 -->
|
||||
<template>
|
||||
<view>
|
||||
<view class="ss-flex flex-wrap">
|
||||
<view class="goods-box" v-for="item in pagination?.list" :key="item.id">
|
||||
<view @click="sheep.$router.go('/pages/goods/index', { id: item.id })">
|
||||
<view class="goods-img">
|
||||
<image class="goods-img" :src="item.picUrl" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="goods-content">
|
||||
<view class="goods-title ss-line-1 ss-m-b-28">{{ item.name }}</view>
|
||||
<view class="goods-price">¥{{ fen2yuan(item.price) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import sheep from '@/sheep';
|
||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||
|
||||
const props = defineProps({
|
||||
pagination: Object,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.goods-box {
|
||||
width: calc((100% - 20rpx) / 2);
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.goods-img {
|
||||
width: 100%;
|
||||
height: 246rpx;
|
||||
border-radius: 10rpx 10rpx 0px 0px;
|
||||
}
|
||||
|
||||
.goods-content {
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
box-shadow: 0px 0px 20rpx 4rpx rgba(199, 199, 199, 0.22);
|
||||
padding: 20rpx 0 32rpx 16rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 0 0 10rpx 10rpx;
|
||||
|
||||
.goods-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.goods-price {
|
||||
font-size: 24rpx;
|
||||
font-family: OPPOSANS;
|
||||
font-weight: 500;
|
||||
color: #e1212b;
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(2n + 1) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,80 @@
|
||||
<!-- 分类展示:second-one 风格 -->
|
||||
<template>
|
||||
<view>
|
||||
<!-- 一级分类的名字 -->
|
||||
<view class="title-box ss-flex ss-col-center ss-row-center ss-p-b-30">
|
||||
<view class="title-line-left" />
|
||||
<view class="title-text ss-p-x-20">{{ props.data[activeMenu].name }}</view>
|
||||
<view class="title-line-right" />
|
||||
</view>
|
||||
<!-- 二级分类的名字 -->
|
||||
<view class="goods-item-box ss-flex ss-flex-wrap ss-p-b-20">
|
||||
<view
|
||||
class="goods-item"
|
||||
v-for="item in props.data[activeMenu].children"
|
||||
:key="item.id"
|
||||
@tap="
|
||||
sheep.$router.go('/pages/goods/list', {
|
||||
categoryId: item.id,
|
||||
})
|
||||
"
|
||||
>
|
||||
<image class="goods-img" :src="item.picUrl" mode="aspectFill" />
|
||||
<view class="ss-p-10">
|
||||
<view class="goods-title ss-line-1">{{ item.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import sheep from '@/sheep';
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
activeMenu: [Number, String],
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title-box {
|
||||
.title-line-left,
|
||||
.title-line-right {
|
||||
width: 15px;
|
||||
height: 1px;
|
||||
background: #d2d2d2;
|
||||
}
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
width: calc((100% - 20px) / 3);
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
&:nth-of-type(3n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.goods-img {
|
||||
width: calc((100vw - 140px) / 3);
|
||||
height: calc((100vw - 140px) / 3);
|
||||
}
|
||||
|
||||
.goods-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.goods-price {
|
||||
color: $red;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,304 @@
|
||||
<!-- 首页,支持店铺装修 -->
|
||||
<template>
|
||||
<s-pages title="首页" :showLeftButton="false">
|
||||
<view class="pagesIndex">
|
||||
<s-custom-navbarIndex />
|
||||
<view class="pages">
|
||||
<s-banner v-if="template?.components[0]?.property.items?.length" :data="template.components[0].property"
|
||||
:styles="template.components[0].property.style" />
|
||||
<!-- 文字滚动 -->
|
||||
<view class="noticeBar flex-center bg24 m-b-22" v-if="informText">
|
||||
<image class="noticeImg shrink" src="/static/index/notice.png" mode="scaleToFill" />
|
||||
<uni-notice-bar class="flex1" scrollable background-color="#ffffff" :text="informText"
|
||||
color="#333333" :speed="100" />
|
||||
</view>
|
||||
|
||||
<!-- <view class="navList flex-center ju-between">
|
||||
<view v-for="(v, i) in nav" :key="i" class="navItem flex-center flex-column" @click="go(v.url)">
|
||||
<image class="navImg shrink" :src="`/static/index/${v.icon}`" mode="scaleToFill" />
|
||||
<view class="size26 f500">{{ v.title }}</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
|
||||
<view class="activeItem" :style="{
|
||||
height: 160 + 'rpx',
|
||||
width: `${activeList?.length === 1
|
||||
? '100%'
|
||||
: activeList?.length === 2
|
||||
? 'calc((100% - 16rpx) / 2)'
|
||||
: i === 0
|
||||
? '100%'
|
||||
: 'calc((100% - 16rpx) / 2)'
|
||||
}`,
|
||||
}" v-for="(v, i) in activeList" :key="i" @click="go(v)">
|
||||
<image :src="sheep.$url.cdn(v.bannerImage)" mode="scaleToFill" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<su-sticky top="100rpx">
|
||||
<view class="goodsIndex">
|
||||
<goods :list="tagList" v-if="tagList?.length" />
|
||||
</view>
|
||||
</su-sticky>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
computed
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onPageScroll,
|
||||
onPullDownRefresh
|
||||
} from '@dcloudio/uni-app';
|
||||
import goods from '@/components/goods/goods.vue';
|
||||
import sheep from '@/sheep';
|
||||
import $share from '@/sheep/platform/share';
|
||||
import * as api from '@/sheep/api/index/index';
|
||||
let template = ref({
|
||||
page: {
|
||||
backgroundColor: '#F2F4F7',
|
||||
padding: '0 32rpx',
|
||||
boxSiziong: 'border-box',
|
||||
},
|
||||
navigationBar: {},
|
||||
components: [{
|
||||
id: 'Banner',
|
||||
property: {
|
||||
autoplay: true,
|
||||
indicator: 'number',
|
||||
interval: 3000,
|
||||
circular: true,
|
||||
indicatorDots: false,
|
||||
indicatorColor: '#D6D6D6', //点颜色
|
||||
indicatorActiveColor: '#FE4246', //当前点颜色
|
||||
items: [],
|
||||
style: {
|
||||
bgType: 'color',
|
||||
bgColor: '#fff',
|
||||
margin: '12rpx 0rpx',
|
||||
marginBottom: '42rpx',
|
||||
borderRadius: '24rpx',
|
||||
height: '240rpx',
|
||||
},
|
||||
bgColor: '',
|
||||
bgType: 'color',
|
||||
marginBottom: 8,
|
||||
type: 'default',
|
||||
},
|
||||
},],
|
||||
});
|
||||
let nav = ref([
|
||||
{
|
||||
icon: 'i1.png',
|
||||
title: '大健康',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i2.png',
|
||||
title: '大农业',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i3.png',
|
||||
title: '大文旅',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i4.png',
|
||||
title: '本地生活',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i5.png',
|
||||
title: '数据处理',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i6.png',
|
||||
title: '跨境电商',
|
||||
url: '',
|
||||
},
|
||||
]);
|
||||
|
||||
const getBanner = () => {
|
||||
api.getbannerlist({
|
||||
position: 1,
|
||||
}).then((res) => {
|
||||
let data = res.data;
|
||||
template.value.components[0].property.items = data;
|
||||
});
|
||||
};
|
||||
|
||||
// 商品标签列表
|
||||
let tagList = ref([]);
|
||||
const getproducttaglist = () => {
|
||||
api.getproducttaglist({
|
||||
categoryId: 1,
|
||||
}).then((res) => {
|
||||
tagList.value = res.data;
|
||||
});
|
||||
};
|
||||
// 消息通知
|
||||
let informText = ref('');
|
||||
const getnotification = () => {
|
||||
api.getnotification({}).then((res) => {
|
||||
if (res?.code === 0) {
|
||||
let data = res.data;
|
||||
if (!data?.length) return;
|
||||
// 拼接文案content
|
||||
informText.value = data.map((item) => item.content).join(' ');
|
||||
}
|
||||
});
|
||||
};
|
||||
// 活动banner
|
||||
let activeList = ref([]);
|
||||
// 列数
|
||||
let activeCol = ref(2);
|
||||
const getappbanner = () => {
|
||||
api.getappbanner({}).then((res) => {
|
||||
if (res.data) {
|
||||
activeList.value = res.data.list;
|
||||
activeCol.value = res.data.bannerDisplayNum;
|
||||
}
|
||||
});
|
||||
};
|
||||
const getData = () => {
|
||||
// banner
|
||||
getBanner();
|
||||
// 标签列表
|
||||
getproducttaglist();
|
||||
getnotification();
|
||||
getappbanner();
|
||||
};
|
||||
onLoad((options) => {
|
||||
getData();
|
||||
// #ifdef MP
|
||||
// 小程序识别二维码
|
||||
if (options.scene) {
|
||||
const sceneParams = decodeURIComponent(options.scene).split('=');
|
||||
options[sceneParams[0]] = sceneParams[1];
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 预览模板
|
||||
// if (options.templateId) {
|
||||
// sheep.$store('app').init(options.templateId);
|
||||
// }
|
||||
|
||||
// 解析分享信息
|
||||
if (options.spm) {
|
||||
$share.decryptSpm(options.spm);
|
||||
}
|
||||
|
||||
// 进入指定页面(完整页面路径)
|
||||
if (options.page) {
|
||||
sheep.$router.go(decodeURIComponent(options.page));
|
||||
}
|
||||
});
|
||||
//跳转浏览器
|
||||
const openExternal = (url) => {
|
||||
if (!url) return;
|
||||
if (typeof plus !== 'undefined' && plus.runtime && typeof plus.runtime.openURL === 'function') {
|
||||
plus.runtime.openURL(url);
|
||||
return;
|
||||
}
|
||||
if (typeof window !== 'undefined' && typeof window.open === 'function') {
|
||||
window.open(url, '_blank');
|
||||
return;
|
||||
}
|
||||
};
|
||||
const go = (e) => {
|
||||
// console.log(e);
|
||||
if (!e.linkUrl) {
|
||||
uni.showToast({
|
||||
title: '功能开发中, 敬请期待',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
} else if (e.title === '华贸专区') {
|
||||
openExternal(e.linkUrl);
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: e.linkUrl,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh(() => {
|
||||
// sheep.$store('app').init();
|
||||
getData();
|
||||
setTimeout(function () {
|
||||
uni.stopPullDownRefresh();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
onPageScroll(() => { });
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pages {
|
||||
padding: 0 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.noticeBar {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
padding-left: 12rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.noticeImg {
|
||||
width: 52rpx;
|
||||
height: 52rpx;
|
||||
}
|
||||
|
||||
:deep(.uni-noticebar) {
|
||||
height: 92rpx;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.navList {
|
||||
margin-top: 40rpx;
|
||||
margin-bottom: 52rpx;
|
||||
|
||||
.navItem {
|
||||
width: 120rpx;
|
||||
}
|
||||
|
||||
.navImg {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* .noticeBar{
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
} */
|
||||
.activeList {
|
||||
.activeItem {
|
||||
// width: calc((100% - 10rpx) / 2 - 10rpx);
|
||||
margin-bottom: 16rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagesIndex {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,384 @@
|
||||
<!-- 首页,支持店铺装修 -->
|
||||
<template>
|
||||
<s-layout
|
||||
title="首页"
|
||||
:bgStyle="template.page"
|
||||
:navbarStyle="template.navigationBar"
|
||||
onShareAppMessage
|
||||
>
|
||||
<mescroll-body
|
||||
:sticky="true"
|
||||
@init="mescrollInit"
|
||||
@down="downCallback"
|
||||
@up="upCallback"
|
||||
@scroll="scroll"
|
||||
>
|
||||
<s-custom-navbarIndex></s-custom-navbarIndex>
|
||||
<view class="pages">
|
||||
<view class="pages_top">
|
||||
<s-banner
|
||||
v-if="template.components[0].property.items.length"
|
||||
:data="template.components[0].property"
|
||||
:styles="template.components[0].property.style"
|
||||
></s-banner>
|
||||
<!-- 文字滚动 -->
|
||||
<view class="noticeBar flex-center" v-if="informText">
|
||||
<image class="noticeImg shrink" src="/static/index/notice.png" mode="scaleToFill" />
|
||||
<uni-notice-bar
|
||||
class="flex1"
|
||||
scrollable
|
||||
background-color="#fff"
|
||||
:text="informText"
|
||||
color="#535353"
|
||||
:speed="100"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="navList flex-center ju-between">
|
||||
<view v-for="(v, i) in nav" :key="i" class="navItem flex-center flex-column">
|
||||
<image class="navImg shrink" :src="`/static/index/${v.icon}`" mode="scaleToFill" />
|
||||
<view class="size26 f500">{{ v.title }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
|
||||
<view
|
||||
class="activeItem"
|
||||
:style="{
|
||||
height: 160 + 'rpx',
|
||||
width: `calc((100% - 10rpx) / ${activeCol} - 10rpx)`,
|
||||
}"
|
||||
v-for="(v, i) in activeList"
|
||||
:key="i"
|
||||
>
|
||||
<image :src="sheep.$url.cdn(v.bannerImage)" mode="aspectFill" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 商品列表 -->
|
||||
|
||||
<view
|
||||
class="sticky-tabs"
|
||||
:style="{
|
||||
top: '44px',
|
||||
}"
|
||||
>
|
||||
<view class="navs flex-center ju-flex-start">
|
||||
<view
|
||||
class="navItem flex-center flex-column"
|
||||
:class="{ tabIndex: i == tabIndex }"
|
||||
v-for="(v, i) in tagList"
|
||||
:key="i"
|
||||
@click="navChange(i)"
|
||||
>
|
||||
<view class="navText">
|
||||
{{ v.name }}
|
||||
</view>
|
||||
<image src="/static/index/active.png" mode="scaleToFill" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="cardItem" v-for="(v, i) in goods" :key="i">
|
||||
<card_goods :data="v"></card_goods>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</s-layout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
|
||||
import sheep from '@/sheep';
|
||||
import $share from '@/sheep/platform/share';
|
||||
import * as api from '@/sheep/api/index/index';
|
||||
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
|
||||
import SpuApi from '@/sheep/api/product/spu';
|
||||
|
||||
import card_goods from '@/components/goodsItem/card_goods.vue';
|
||||
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom); // 调用mescroll的hook
|
||||
|
||||
// 隐藏原生tabBar
|
||||
// uni.hideTabBar({
|
||||
// fail: () => {},
|
||||
// });
|
||||
// let template = computed(() => sheep.$store('app').template?.home);
|
||||
let template = ref({
|
||||
page: {
|
||||
backgroundColor: '#f5f5f5',
|
||||
padding: '0 32rpx',
|
||||
boxSiziong: 'border-box',
|
||||
},
|
||||
navigationBar: {},
|
||||
components: [
|
||||
{
|
||||
id: 'Banner',
|
||||
property: {
|
||||
autoplay: true,
|
||||
indicator: 'number',
|
||||
interval: 3000,
|
||||
circular: true,
|
||||
indicatorDots: false,
|
||||
indicatorColor: '#D6D6D6', //点颜色
|
||||
indicatorActiveColor: '#FE4246', //当前点颜色
|
||||
items: [],
|
||||
style: {
|
||||
bgType: 'color',
|
||||
bgColor: '#fff',
|
||||
margin: '12rpx 0rpx',
|
||||
marginBottom: '42rpx',
|
||||
borderRadius: '24rpx',
|
||||
height: '240rpx',
|
||||
},
|
||||
bgColor: '',
|
||||
bgType: 'color',
|
||||
marginBottom: 8,
|
||||
type: 'default',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
let nav = ref([
|
||||
{
|
||||
icon: 'i1.png',
|
||||
title: '大健康',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i2.png',
|
||||
title: '大农业',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i3.png',
|
||||
title: '大文旅',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i4.png',
|
||||
title: '本地生活',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i5.png',
|
||||
title: '数据处理',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
icon: 'i6.png',
|
||||
title: '跨境电商',
|
||||
url: '',
|
||||
},
|
||||
]);
|
||||
|
||||
const getBanner = () => {
|
||||
api
|
||||
.getbannerlist({
|
||||
position: 1,
|
||||
})
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
template.value.components[0].property.items = data;
|
||||
});
|
||||
};
|
||||
|
||||
// 商品标签列表
|
||||
let tagList = ref([]);
|
||||
const getproducttaglist = () => {
|
||||
api
|
||||
.getproducttaglist({
|
||||
categoryId: 1,
|
||||
})
|
||||
.then((res) => {
|
||||
tagList.value = res.data;
|
||||
navChange(0);
|
||||
});
|
||||
};
|
||||
// 消息通知
|
||||
let informText = ref('');
|
||||
const getnotification = () => {
|
||||
api.getnotification({}).then((res) => {
|
||||
if (res?.code != 0) {
|
||||
let data = res.data;
|
||||
if (!data?.length) return;
|
||||
// 拼接文案content
|
||||
informText.value = data.map((item) => item.content).join(' ');
|
||||
}
|
||||
});
|
||||
};
|
||||
// 活动banner
|
||||
let activeList = ref([]);
|
||||
// 列数
|
||||
let activeCol = ref(2);
|
||||
const getappbanner = () => {
|
||||
api.getappbanner({}).then((res) => {
|
||||
if (res.data) {
|
||||
activeList.value = res.data.list;
|
||||
activeCol.value = res.data.bannerDisplayNum;
|
||||
}
|
||||
});
|
||||
};
|
||||
const getData = () => {
|
||||
// banner
|
||||
getBanner();
|
||||
// 标签列表
|
||||
getproducttaglist();
|
||||
getnotification();
|
||||
getappbanner();
|
||||
};
|
||||
onLoad((options) => {
|
||||
getData();
|
||||
// #ifdef MP
|
||||
// 小程序识别二维码
|
||||
if (options.scene) {
|
||||
const sceneParams = decodeURIComponent(options.scene).split('=');
|
||||
options[sceneParams[0]] = sceneParams[1];
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 预览模板
|
||||
if (options.templateId) {
|
||||
sheep.$store('app').init(options.templateId);
|
||||
}
|
||||
|
||||
// 解析分享信息
|
||||
if (options.spm) {
|
||||
$share.decryptSpm(options.spm);
|
||||
}
|
||||
|
||||
// 进入指定页面(完整页面路径)
|
||||
if (options.page) {
|
||||
sheep.$router.go(decodeURIComponent(options.page));
|
||||
}
|
||||
});
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh(() => {
|
||||
// sheep.$store('app').init();
|
||||
getData();
|
||||
setTimeout(function () {
|
||||
uni.stopPullDownRefresh();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
onPageScroll(() => {});
|
||||
/**
|
||||
* 底部商品管理
|
||||
*/
|
||||
const tabIndex = ref(0);
|
||||
let navId = ref(null);
|
||||
let goods = ref([]);
|
||||
const navChange = (i) => {
|
||||
tabIndex.value = i;
|
||||
navId.value = tagList.value[i].id;
|
||||
};
|
||||
const scroll = (e) => {
|
||||
//console.log(e);
|
||||
};
|
||||
const upCallback = (mescroll) => {
|
||||
if (navId.value)
|
||||
SpuApi.getSpuPage({
|
||||
pageNo: mescroll.num,
|
||||
pageSize: mescroll.size,
|
||||
tagTypeId: navId.value,
|
||||
})
|
||||
.then((res) => {
|
||||
const list = res.data.list || []; // 当前页数据
|
||||
// if(list.length){
|
||||
// list.forEach(e=>{
|
||||
// e.hide = true
|
||||
// })
|
||||
// }
|
||||
if (mescroll.num == 1) goods.value = []; //如果是第一页需手动制空列表
|
||||
goods.value = goods.value.concat(list); //追加新数据
|
||||
mescroll.endSuccess(list.length); // 请求成功, 结束加载
|
||||
})
|
||||
.catch(() => {
|
||||
mescroll.endErr(); // 请求失败, 结束加载
|
||||
});
|
||||
|
||||
mescroll.endErr(); // 请求失败, 结束加载
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pages {
|
||||
}
|
||||
.pages_top {
|
||||
padding: 0 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.noticeBar {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
padding-left: 12rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.noticeImg {
|
||||
width: 52rpx;
|
||||
height: 52rpx;
|
||||
}
|
||||
:deep(.uni-noticebar) {
|
||||
height: 92rpx;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
.navList {
|
||||
margin-top: 40rpx;
|
||||
margin-bottom: 52rpx;
|
||||
.navItem {
|
||||
width: 120rpx;
|
||||
}
|
||||
.navImg {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
}
|
||||
/* .noticeBar{
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
} */
|
||||
.activeList {
|
||||
.activeItem {
|
||||
// width: calc((100% - 10rpx) / 2 - 10rpx);
|
||||
margin-bottom: 16rpx;
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
.sticky-tabs {
|
||||
z-index: 990;
|
||||
position: sticky;
|
||||
}
|
||||
.navs {
|
||||
padding: 0 32rpx;
|
||||
box-sizing: border-box;
|
||||
.navItem {
|
||||
color: #777777;
|
||||
font-size: 24rpx;
|
||||
width: 20%;
|
||||
// text-align: center;
|
||||
image {
|
||||
width: 40rpx;
|
||||
height: 12rpx;
|
||||
opacity: 0;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
}
|
||||
.tabIndex {
|
||||
color: #333333;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
image {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<view class="start-page">
|
||||
<image class="bg" :src="$url + 'home/startPage_yg.png'" mode="aspectFill" />
|
||||
<view class="count-down" :class="{ enabled: canEnter }" @click.stop="onEnterClick">
|
||||
{{ canEnter ? '进入' : `跳过 ${countDown}s` }}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const countDown = ref(3)
|
||||
let timer = null
|
||||
const canEnter = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
timer = setInterval(() => {
|
||||
if (countDown.value <= 1) {
|
||||
//点击进入
|
||||
// countDown.value = 0
|
||||
// canEnter.value = true
|
||||
clearInterval(timer)
|
||||
//直接进入
|
||||
toHome()
|
||||
return
|
||||
}
|
||||
countDown.value -= 1
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer) clearInterval(timer)
|
||||
})
|
||||
|
||||
function toHome() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
function onEnterClick() {
|
||||
if (!canEnter.value) return
|
||||
toHome()
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.start-page {
|
||||
position: relative;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
.bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.count-down {
|
||||
position: absolute;
|
||||
top: calc(env(safe-area-inset-top) + 100rpx);
|
||||
right: 60rpx;
|
||||
padding: 18rpx 20rpx;
|
||||
border-radius: 50rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
z-index: 10;
|
||||
}
|
||||
.count-down.enabled {
|
||||
// background: rgba(54, 110, 238, 0.85);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,535 @@
|
||||
<template>
|
||||
<view class="pages theme-ai">
|
||||
<view class="bc">
|
||||
<image src="/static/home/bc.png" mode="scaleToFill" />
|
||||
</view>
|
||||
<view class="con" :style="{ paddingTop: paddingTop + 'px' }">
|
||||
<view class="con_top flex-center ju-flex-start">
|
||||
<view class="head_info">
|
||||
<view class="head">
|
||||
<image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" />
|
||||
<image v-else :src="`${$url}home/head.png`" mode="scaleToFill" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="con_info flex-between w100">
|
||||
<view class="con_left">
|
||||
<view class="con_name ju-flex-start">
|
||||
{{ dataInfo?.nickname || '昵称' }}
|
||||
<image
|
||||
:src="`${$url}home/${dataInfo.type}.svg`"
|
||||
class="w_38 h_32 m-l-10"
|
||||
v-if="dataInfo.type !== 0"
|
||||
/>
|
||||
<image :src="$url + agentLevelObj[dataInfo.agentLevel]" class="w_38 h_32 m-l-10" />
|
||||
</view>
|
||||
<view class="con_id m-t-8">
|
||||
<text>ID:{{ dataInfo.id }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="auth-btn"
|
||||
:class="realStatus === 1 ? 'auth-btn-type1' : 'auth-btn-type2'"
|
||||
@click="goReal()"
|
||||
>
|
||||
{{ realStatus === 1 ? '已认证' : '去认证' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_money flex-center ju-between p-x-32" @click="go('/pages/home/wallet')">
|
||||
<!-- <view
|
||||
class="card_money flex-center ju-between p-x-32"
|
||||
@click="go('/pages/home/pointsDetail?type=5')"
|
||||
> -->
|
||||
<view>
|
||||
<view class="flex-center ju-flex-start m-b-8">
|
||||
<view class="line34 size28" style="margin-right: 18rpx">钱包</view>
|
||||
<view class="moneyNum line36 size36">¥ {{ $fen2yuan(dataInfo.wallet || 0) }}</view>
|
||||
</view>
|
||||
<!-- <view class="c_fff line34">邀请好友下单得奖励</view> -->
|
||||
</view>
|
||||
<!-- <view class="moneyBtn" @click="go('/pages/home/pointsDetail?type=5')">立即提现</view> -->
|
||||
</view>
|
||||
<view class="card3 flex-center ju-evenly color_5">
|
||||
<view v-for="(v, i) in moneyArr" :key="i" class="center" @click="go(v.url)">
|
||||
<view class="card3_num m-b-8"
|
||||
>{{ dataInfo[v.value] }}<text>{{ v.unit }}</text></view
|
||||
>
|
||||
<view>{{ v.name || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card card4 bg24">
|
||||
<view class="card_title flex-center ju-between">
|
||||
<view class="">我的订单</view>
|
||||
<view class="card_more flex-center" @click="go('/pages/order/list')"
|
||||
><span class="c0">全部</span><uni-icons type="right" size="14" color=""></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-center ju-between">
|
||||
<view
|
||||
class="flex-center flex-column orderItem"
|
||||
v-for="(v, i) in orderList"
|
||||
:key="i"
|
||||
@click="go(v.url)"
|
||||
>
|
||||
<uni-badge
|
||||
:text="i < 3 ? orderNum[v.value] : 0"
|
||||
:customStyle="{ background: '#FF0000' }"
|
||||
absolute="rightTop"
|
||||
>
|
||||
<view class="card4_icon">
|
||||
<image :src="$url + v.icon" mode="scaleToFill" />
|
||||
</view>
|
||||
</uni-badge>
|
||||
<view class="card4_name size28 color_3 m-t-16">{{ v.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card card5 bg24">
|
||||
<view class="card_title">我的服务</view>
|
||||
|
||||
<view class="flex-center card5_con wrap ju-flex-start">
|
||||
<view
|
||||
class="flex-center flex-column card5_item"
|
||||
v-for="(v, i) in menuList"
|
||||
:key="i"
|
||||
@click="go(v.url)"
|
||||
>
|
||||
<view class="card5_icon m-b-18 w_84 h_84">
|
||||
<image :src="$url + v.icon" mode="scaleToFill" />
|
||||
</view>
|
||||
<view class="card5_name size28 color_3">{{ v.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="h_150" style="background-color: #f2f4f7;"/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import sheep from '@/sheep';
|
||||
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { getWallet } from '@/sheep/api/home/pay';
|
||||
|
||||
import OrderApi from '@/sheep/api/trade/order';
|
||||
let { proxy } = getCurrentInstance();
|
||||
|
||||
let sysInfo = uni.getSystemInfoSync();
|
||||
let paddingTop = ref(20);
|
||||
paddingTop.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
||||
let realStatus = ref(0); //是否已经实名认证
|
||||
let agentLevelObj = {
|
||||
2: 'home/igency_1.png',
|
||||
4: 'home/igency_2.png',
|
||||
3: 'home/igency_3.png',
|
||||
5: 'home/igency_4.png',
|
||||
};
|
||||
|
||||
let dataInfo = ref({
|
||||
url: '',
|
||||
name: '',
|
||||
type: 2, //1:普通用户 2:商家
|
||||
money: 1200.0,
|
||||
green_num: 1000,
|
||||
commission_num: 20.23,
|
||||
agency_income: 999,
|
||||
consumption_num: 1000,
|
||||
});
|
||||
let moneyArr = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '绿色积分',
|
||||
value: 'point',
|
||||
url: '/pages/home/pointsDetail?type=1',
|
||||
},
|
||||
// {
|
||||
// id: 2,
|
||||
// name: '佣金',
|
||||
// value: 'commission_num',
|
||||
// unit: '元',
|
||||
// url: '/pages/home/pointsDetail?type=2',
|
||||
// },
|
||||
// {
|
||||
// id: 3,
|
||||
// name: '代理收益',
|
||||
// value: 'agency_income',
|
||||
// unit: '元',
|
||||
// url: '/pages/home/pointsDetail?type=3',
|
||||
// },
|
||||
{
|
||||
id: 4,
|
||||
name: '消费金',
|
||||
value: 'consumptionGold',
|
||||
url: '/pages/home/pointsDetail?type=4',
|
||||
},
|
||||
]);
|
||||
let orderList = ref([
|
||||
{
|
||||
name: '待支付',
|
||||
icon: 'home/order0_1.png',
|
||||
url: '/pages/order/list?type=1',
|
||||
value: 'unpaidCount',
|
||||
},
|
||||
{
|
||||
name: '待发货',
|
||||
icon: 'home/order4_1.png',
|
||||
url: '/pages/order/list?type=2',
|
||||
value: 'undeliveredCount',
|
||||
},
|
||||
{
|
||||
name: '待收货',
|
||||
icon: 'home/order1_1.png',
|
||||
url: '/pages/order/list?type=3',
|
||||
value: 'deliveredCount',
|
||||
},
|
||||
{
|
||||
name: '已完成',
|
||||
icon: 'home/order2_1.png',
|
||||
url: '/pages/order/list?type=4',
|
||||
value: 'uncommentedCount',
|
||||
},
|
||||
{
|
||||
name: '售后',
|
||||
icon: 'home/order3_1.png',
|
||||
url: '/pages/order/list?type=5',
|
||||
value: 'afterSaleCount',
|
||||
},
|
||||
]);
|
||||
let menuList = ref([
|
||||
{
|
||||
name: '邀请好友',
|
||||
icon: 'home/icon1.png',
|
||||
url: '/pages/home/share',
|
||||
},
|
||||
{
|
||||
name: '收货地址',
|
||||
icon: 'home/icon2.png',
|
||||
url: '/pages/user/address/list',
|
||||
},
|
||||
{
|
||||
name: '联系客服',
|
||||
icon: 'home/icon3.png',
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
name: '意见反馈',
|
||||
icon: 'home/icon4.png',
|
||||
url: '/pages/home/feedback',
|
||||
},
|
||||
{
|
||||
name: '我的收藏',
|
||||
icon: 'home/icon5.png',
|
||||
url: '/pages/user/goods-collect',
|
||||
},
|
||||
{
|
||||
name: '我的收益',
|
||||
icon: 'home/icon6.png',
|
||||
url: '/pages/home/agency',
|
||||
},
|
||||
{
|
||||
name: '我的社员',
|
||||
icon: 'home/icon8.png',
|
||||
url: '/pages/home/staff',
|
||||
},
|
||||
{
|
||||
name: '设置',
|
||||
icon: 'home/icon7.png',
|
||||
url: '/pages/public/setting',
|
||||
},
|
||||
]);
|
||||
const goReal = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/public/realname?status=' + realStatus.value,
|
||||
// query: obj,
|
||||
});
|
||||
};
|
||||
const go = (path, obj) => {
|
||||
if (!path) {
|
||||
// 打电话
|
||||
|
||||
// uni.makePhoneCall({
|
||||
// phoneNumber: '4000621698',
|
||||
// });
|
||||
uni.showToast({
|
||||
title: '功能开发中, 敬请期待',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: path,
|
||||
query: obj,
|
||||
});
|
||||
}
|
||||
};
|
||||
const getData = () => {
|
||||
sheep
|
||||
.$store('user')
|
||||
.getInfo()
|
||||
.then((res) => {
|
||||
dataInfo.value = res;
|
||||
dataInfo.value.consumptionGold = proxy.$fen2yuan(res.consumptionGold);
|
||||
realStatus.value = res.realStatus;
|
||||
getWallet().then((res) => {
|
||||
if (res.code === 0) {
|
||||
dataInfo.value.wallet = res.data.withdrawAmount;
|
||||
}
|
||||
});
|
||||
dataInfo.value.type = dataInfo.value?.level?.level || 0;
|
||||
});
|
||||
};
|
||||
let levelObj = {
|
||||
1: { name: '达人店长', color: '#E1C37A' },
|
||||
2: { name: '明星达人店长', color: '#B49DF4' },
|
||||
3: { name: '超级达人店长', color: '#43D787' },
|
||||
4: { name: '店主', color: '#FB8ED5' },
|
||||
};
|
||||
let orderNum = ref({});
|
||||
const getNumData = () => {
|
||||
OrderApi.getOrderCount().then((res) => {
|
||||
if (res.code === 0) {
|
||||
orderNum.value = res.data;
|
||||
}
|
||||
});
|
||||
};
|
||||
onShow(async () => {
|
||||
let res = await getData();
|
||||
|
||||
getNumData();
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.pages {
|
||||
position: relative;
|
||||
box-align: border-box;
|
||||
padding-bottom: 20rpx;
|
||||
background-color: #f2f4f7;
|
||||
min-height: 100vh;
|
||||
|
||||
.bc {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 484rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.con {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
padding: 0rpx 30rpx;
|
||||
box-sizing: border-box;
|
||||
padding-bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
|
||||
.con_top {
|
||||
margin-bottom: 36rpx;
|
||||
align-items: flex-end;
|
||||
|
||||
.head {
|
||||
width: 130rpx;
|
||||
height: 130rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.con_info {
|
||||
margin-left: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
// .con_left {
|
||||
// display: flex;
|
||||
// justify-content: center;
|
||||
// align-items: flex-start;
|
||||
// }
|
||||
|
||||
.con_id {
|
||||
background: linear-gradient(90deg, #50504e 0%, #292b28 100%);
|
||||
border-radius: 40rpx;
|
||||
font-size: 20rpx;
|
||||
color: #ffffff;
|
||||
// line-height: 36rpx;
|
||||
// text-align: center;
|
||||
padding: 7rpx 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
|
||||
// width: 100rpx;
|
||||
.img {
|
||||
width: 23rpx;
|
||||
height: 22rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.auth-btn {
|
||||
width: 108rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.auth-btn-type1 {
|
||||
background: #fff;
|
||||
color: #fb4d32;
|
||||
}
|
||||
|
||||
.auth-btn-type2 {
|
||||
background: linear-gradient(130deg, #fa8735 0%, #fe3b48 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.con_name {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
line-height: 44rpx;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.con_type {
|
||||
background: linear-gradient(90deg, #50504e 0%, #292b28 100%);
|
||||
border-radius: 40rpx 40rpx 40rpx 40rpx;
|
||||
padding: 6rpx 12rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
.type_name {
|
||||
line-height: 36rpx;
|
||||
font-size: 20rpx;
|
||||
color: #e1c37a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card_money {
|
||||
height: 120rpx;
|
||||
box-sizing: border-box;
|
||||
color: #ffe3b1;
|
||||
background: url('/static/home/img1.png');
|
||||
font-size: 24rpx;
|
||||
|
||||
.moneyNum {
|
||||
font-size: 30rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.moneyBtn {
|
||||
line-height: 50rpx;
|
||||
background-color: #ffe3b1;
|
||||
border-radius: 25rpx;
|
||||
color: #2d2d2c;
|
||||
padding: 0 22rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card3 {
|
||||
padding-top: 34rpx;
|
||||
padding-bottom: 18rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
border-radius: 0 0 20rpx 20rpx;
|
||||
font-size: 26rpx;
|
||||
border-image: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 0.5)) 2 2;
|
||||
|
||||
.card3_num {
|
||||
font-weight: 700;
|
||||
font-size: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.card4 {
|
||||
.card4_icon {
|
||||
width: 68rpx;
|
||||
height: 68rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card5 {
|
||||
.card5_icon {
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.card5_item {
|
||||
width: 25%;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 32rpx 28rpx;
|
||||
box-align: border-box;
|
||||
margin-top: 32rpx;
|
||||
|
||||
.card_title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
margin-bottom: 34rpx;
|
||||
}
|
||||
|
||||
.card_more {
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
|
||||
.con_title {
|
||||
line-height: 88rpx;
|
||||
}
|
||||
|
||||
.orderItem {
|
||||
width: 24%;
|
||||
}
|
||||
|
||||
.head_info {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.vipImg {
|
||||
width: 110rpx;
|
||||
height: 36rpx;
|
||||
position: absolute;
|
||||
bottom: -18rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user