商品详情.评价页面.购物车页面.首页轮播图.搜索功能.分类接口

pull/9/head
落日晚风 2023-10-31 17:41:57 +08:00
parent 6a327ac0e7
commit f4c1b30f2e
14 changed files with 496 additions and 470 deletions

View File

@ -1,160 +1,170 @@
<!-- 页面 --> <!-- 页面 -->
<template> <template>
<s-layout title="全部评价"> <s-layout title="全部评价">
<su-tabs <su-tabs :list="state.type" :scrollable="false" @change="onTabsChange" :current="state.currentTab"></su-tabs>
:list="state.type" <view class="ss-m-t-20">
:scrollable="false" <view class="list-item" v-for="item in state.pagination.data" :key="item">
@change="onTabsChange" <comment-item :item="item"></comment-item>
:current="state.currentTab" </view>
></su-tabs> </view>
<view class="ss-m-t-20"> <s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
<view class="list-item" v-for="item in state.pagination.data" :key="item"> <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
<comment-item :item="item"></comment-item>
</view>
</view>
<s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }" @tap="loadmore" />
@tap="loadmore" </s-layout>
/>
</s-layout>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import {
import { computed, reactive } from 'vue'; onLoad,
import _ from 'lodash'; onReachBottom
import commentItem from '../components/detail/comment-item.vue'; } from '@dcloudio/uni-app';
import {
computed,
reactive
} from 'vue';
import _ from 'lodash';
import commentItem from '../components/detail/comment-item.vue';
const pagination = { const pagination = {
data: [], data: [],
current_page: 1, current_page: 1,
total: 1, total: 1,
last_page: 1, last_page: 1,
}; };
const state = reactive({ const state = reactive({
list: [], list: [],
type: [], type: [],
currentTab: 0, currentTab: 0,
pagination: { pagination: {
data: [], data: [],
current_page: 1, current_page: 1,
total: 1, total: 1,
last_page: 1, last_page: 1,
}, },
commentId: 0, commentId: 0,
code: 'all', code: 0,
}); });
// //
function onTabsChange(e) { function onTabsChange(e) {
state.pagination = pagination state.pagination = pagination
state.currentTab = e.index; state.currentTab = e.index;
state.code = e.code; state.code = e.code;
getList(state.commentId, e.code); getList(state.commentId, e.code);
} }
async function getType(id) { async function getType(id) {
const { error, data } = await sheep.$api.goods.getType(id); const {
if (error === 0) { error,
state.type = data; data
} } = await sheep.$api.goods.getType(id);
} if (error === 0) {
async function getList(id, code, page = 1, list_rows = 6) { console.log(data)
state.loadStatus = 'loading'; // state.type = data;
let res = await sheep.$api.goods.comment(id, { state.type = [{code:0,name:'全部'},{code:1,name:'好评'},{code:2,name:'中评'},{code:3,name:'差评'}];
type: code, }
list_rows, }
page, async function getList(id, code=0, page = 1, list_rows = 6) {
}); state.loadStatus = 'loading';
if (res.error === 0) { let res = await sheep.$api.goods.comment2(id, {
let orderList = _.concat(state.pagination.data, res.data.data); type: code,
state.pagination = { pageSize: list_rows,
...res.data, pageNo: page,
data: orderList, });
}; console.log(res);
if (state.pagination.current_page < state.pagination.last_page) { if (res.code === 0) {
state.loadStatus = 'more'; let orderList = _.concat(state.pagination.data, res.data.list);
} else { state.pagination = {
state.loadStatus = 'noMore'; ...res.data,
} data: orderList,
} };
} if (state.pagination.current_page < state.pagination.last_page) {
// state.loadStatus = 'more';
function loadmore() { } else {
if (state.loadStatus !== 'noMore') { state.loadStatus = 'noMore';
getList(state.commentId, state.code, state.pagination.current_page + 1); }
} }
} }
onLoad((options) => { //
state.commentId = options.id; function loadmore() {
getType(state.commentId); if (state.loadStatus !== 'noMore') {
getList(state.commentId); getList(state.commentId, state.code, state.pagination.current_page + 1);
}); }
// }
onReachBottom(() => { onLoad((options) => {
loadmore(); state.commentId = options.id;
}); getType(state.commentId);
getList(state.commentId);
});
//
onReachBottom(() => {
loadmore();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.list-item { .list-item {
padding: 32rpx 30rpx 20rpx 20rpx; padding: 32rpx 30rpx 20rpx 20rpx;
background: #fff; background: #fff;
.avatar {
width: 52rpx;
height: 52rpx;
border-radius: 50%;
}
.nickname {
font-size: 26rpx;
font-weight: 500;
color: #999999;
}
.create-time {
font-size: 24rpx;
font-weight: 500;
color: #c4c4c4;
}
.content-title {
font-size: 26rpx;
font-weight: 400;
color: #666666;
line-height: 42rpx;
}
.content-img {
width: 174rpx;
height: 174rpx;
}
.cicon-info-o {
font-size: 26rpx;
color: #c4c4c4;
}
.foot-title {
font-size: 24rpx;
font-weight: 500;
color: #999999;
}
}
.btn-box { .avatar {
width: 100%; width: 52rpx;
height: 120rpx; height: 52rpx;
background: #fff; border-radius: 50%;
border-top: 2rpx solid #eee; }
}
.tab-btn { .nickname {
width: 130rpx; font-size: 26rpx;
height: 62rpx; font-weight: 500;
background: #eeeeee; color: #999999;
border-radius: 31rpx; }
font-size: 28rpx;
font-weight: 400; .create-time {
color: #999999; font-size: 24rpx;
border: 1px solid #e5e5e5; font-weight: 500;
margin-right: 10rpx; color: #c4c4c4;
} }
.content-title {
font-size: 26rpx;
font-weight: 400;
color: #666666;
line-height: 42rpx;
}
.content-img {
width: 174rpx;
height: 174rpx;
}
.cicon-info-o {
font-size: 26rpx;
color: #c4c4c4;
}
.foot-title {
font-size: 24rpx;
font-weight: 500;
color: #999999;
}
}
.btn-box {
width: 100%;
height: 120rpx;
background: #fff;
border-top: 2rpx solid #eee;
}
.tab-btn {
width: 130rpx;
height: 62rpx;
background: #eeeeee;
border-radius: 31rpx;
font-size: 28rpx;
font-weight: 400;
color: #999999;
border: 1px solid #e5e5e5;
margin-right: 10rpx;
}
</style> </style>

View File

@ -5,19 +5,19 @@
<image class="avatar" :src="sheep.$url.cdn(item.user_avatar)"></image> <image class="avatar" :src="sheep.$url.cdn(item.user_avatar)"></image>
</view> </view>
<view class="nickname ss-m-r-20"> <view class="nickname ss-m-r-20">
{{ item.user_nickname }} {{ item.userNickname }}
</view> </view>
<view class=""> <view class="">
<uni-rate :readonly="true" v-model="item.level" size="18" /> <uni-rate :readonly="true" v-model="item.scores" size="18" />
</view> </view>
</view> </view>
<view class="content"> <view class="content">
{{ item.content }} {{ item.content }}
</view> </view>
<view class="ss-m-t-24" v-if="item.images?.length"> <view class="ss-m-t-24" v-if="item.picUrls?.length">
<scroll-view class="scroll-box" scroll-x scroll-anchoring> <scroll-view class="scroll-box" scroll-x scroll-anchoring>
<view class="ss-flex"> <view class="ss-flex">
<view v-for="(item, index) in item.images" :key="item" class="ss-m-r-10"> <view v-for="(item, index) in item.picUrls" :key="item" class="ss-m-r-10">
<su-image class="content-img" isPreview :previewList="state.commentImages" :current="index" :src="item" <su-image class="content-img" isPreview :previewList="state.commentImages" :current="index" :src="item"
:height="120" :width="120" mode="aspectFill"></su-image> :height="120" :width="120" mode="aspectFill"></su-image>
</view> </view>

View File

@ -47,9 +47,9 @@
const { data } = await sheep.$api.goods.comment(id, { const { data } = await sheep.$api.goods.comment(id, {
list_rows: 3, list_rows: 3,
}); });
console.log(data) const {data:datas} = await sheep.$api.goods.comment2(id);
state.commentList = data; state.commentList = data;
state.total = data.total; state.total = datas.total;
} }
onBeforeMount(() => { onBeforeMount(() => {
getComment(props.goodsId); getComment(props.goodsId);

View File

@ -95,7 +95,7 @@
<!-- 评价 --> <!-- 评价 -->
<detail-comment-card class="detail-comment-selector" :goodsId="state.goodsId" /> <detail-comment-card class="detail-comment-selector" :goodsId="state.goodsId" />
<!-- 详情 --> <!-- 详情 -->
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.content" /> <detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
<!-- 活动跳转 --> <!-- 活动跳转 -->
<detail-activity-tip <detail-activity-tip

View File

@ -261,12 +261,12 @@
sort: Sort, sort: Sort,
order: Order, order: Order,
category_id: !keyword ? categoryId : '', category_id: !keyword ? categoryId : '',
list_rows, pageSize:list_rows,
keyword: keyword, keyword: keyword,
page, pageNo:page,
}); });
if (res.error === 0) { if (res.code === 0) {
let couponList = _.concat(state.pagination.data, res.data.data); let couponList = _.concat(state.pagination.data, res.data.list);
state.pagination = { state.pagination = {
...res.data, ...res.data,
data: couponList, data: couponList,

View File

@ -36,19 +36,19 @@
/> />
</label> </label>
<s-goods-item <s-goods-item
:title="item.goods.title" :title="item.spu.name"
:img="item.sku_price.image || item.goods.image" :img="item.spu.picUrl || item.goods.image"
:price="item.sku_price.price" :price="item.sku.price/100"
:skuText="item.sku_price.goods_sku_text" :skuText="item.sku.properties.length>1? item.sku.properties.reduce((items2,items)=>items2.valueName+' '+items.valueName):item.sku.properties[0].valueName"
priceColor="#FF3000" priceColor="#FF3000"
:titleWidth="400" :titleWidth="400"
> >
<template v-if="!state.editMode" v-slot:tool> <template v-if="!state.editMode" v-slot:tool>
<su-number-box <su-number-box
:min="0" :min="0"
:max="item.sku_price.stock" :max="item.sku.stock"
:step="1" :step="1"
v-model="item.goods_num" v-model="item.count"
@change="onNumberChange($event, item)" @change="onNumberChange($event, item)"
></su-number-box> ></su-number-box>
</template> </template>
@ -112,9 +112,9 @@
isAllSelected: computed(() => cart.isAllSelected), isAllSelected: computed(() => cart.isAllSelected),
totalPriceSelected: computed(() => cart.totalPriceSelected), totalPriceSelected: computed(() => cart.totalPriceSelected),
}); });
// //
function onSelectSingle(id) { function onSelectSingle(id) {
console.log('单选')
cart.selectSingle(id); cart.selectSingle(id);
} }
// //
@ -154,7 +154,7 @@
if(cartItem.goods_num === e) return; if(cartItem.goods_num === e) return;
cartItem.goods_num = e; cartItem.goods_num = e;
cart.update({ cart.update({
goods_id: cartItem.goods_id, goods_id: cartItem.id,
goods_num: e, goods_num: e,
goods_sku_price_id: cartItem.goods_sku_price_id, goods_sku_price_id: cartItem.goods_sku_price_id,
}); });

View File

@ -1,250 +1,232 @@
<template> <template>
<s-layout title="分类" tabbar="/pages/index/category" :bgStyle="{ color: '#fff' }"> <s-layout title="分类" tabbar="/pages/index/category" :bgStyle="{ color: '#fff' }">
<view class="s-category"> <view class="s-category">
<view class="three-level-wrap ss-flex ss-col-top" :style="[{ height: pageHeight + 'px' }]"> <view class="three-level-wrap ss-flex ss-col-top" :style="[{ height: pageHeight + 'px' }]">
<scroll-view class="side-menu-wrap" scroll-y :style="[{ height: pageHeight + 'px' }]"> <scroll-view class="side-menu-wrap" scroll-y :style="[{ height: pageHeight + 'px' }]">
<view <view class="menu-item ss-flex" v-for="(item, index) in state.categoryList?.children" :key="item.id"
class="menu-item ss-flex" :class="[{ 'menu-item-active': index == state.activeMenu }]" @tap="onMenu(index)">
v-for="(item, index) in state.categoryList?.children" <view class="menu-title ss-line-1">
:key="item.id" {{ item.name }}
:class="[{ 'menu-item-active': index == state.activeMenu }]" </view>
@tap="onMenu(index)" </view>
> </scroll-view>
<view class="menu-title ss-line-1"> <scroll-view class="goods-list-box" scroll-y :style="[{ height: pageHeight + 'px' }]"
{{ item.name }} v-if="state.categoryList?.children?.length">
</view> <image v-if="state.categoryList.children[state.activeMenu].image" class="banner-img"
</view> :src="sheep.$url.cdn(state.categoryList.children[state.activeMenu].image)" mode="widthFix">
</scroll-view> </image>
<scroll-view <first-one v-if="state.categoryList.style === 'first_one'" :data="state.categoryList"
class="goods-list-box" :activeMenu="state.activeMenu" :pagination="state.pagination" />
scroll-y <first-two v-if="state.categoryList.style === 'first_two'" :data="state.categoryList"
:style="[{ height: pageHeight + 'px' }]" :activeMenu="state.activeMenu" :pagination="state.pagination" />
v-if="state.categoryList?.children?.length" <second-one v-if="state.categoryList.style === 'second_one'" :data="state.categoryList"
> :activeMenu="state.activeMenu" :pagination="state.pagination" />
<image <third-one v-if="state.categoryList.style === 'third_one'" :data="state.categoryList"
v-if="state.categoryList.children[state.activeMenu].image" :activeMenu="state.activeMenu" :pagination="state.pagination" />
class="banner-img" <uni-load-more v-if="
:src="sheep.$url.cdn(state.categoryList.children[state.activeMenu].image)"
mode="widthFix"
>
</image>
<first-one
v-if="state.categoryList.style === 'first_one'"
:data="state.categoryList"
:activeMenu="state.activeMenu"
:pagination="state.pagination"
/>
<first-two
v-if="state.categoryList.style === 'first_two'"
:data="state.categoryList"
:activeMenu="state.activeMenu"
:pagination="state.pagination"
/>
<second-one
v-if="state.categoryList.style === 'second_one'"
:data="state.categoryList"
:activeMenu="state.activeMenu"
:pagination="state.pagination"
/>
<third-one
v-if="state.categoryList.style === 'third_one'"
:data="state.categoryList"
:activeMenu="state.activeMenu"
:pagination="state.pagination"
/>
<uni-load-more
v-if="
(state.categoryList.style === 'first_one' || (state.categoryList.style === 'first_one' ||
state.categoryList.style === 'first_two') && state.categoryList.style === 'first_two') &&
state.pagination.total > 0 state.pagination.total > 0
" " :status="state.loadStatus" :content-text="{
:status="state.loadStatus"
:content-text="{
contentdown: '点击查看更多', contentdown: '点击查看更多',
}" }" @tap="loadmore" />
@tap="loadmore" </scroll-view>
/> </view>
</scroll-view> </view>
</view> </s-layout>
</view>
</s-layout>
</template> </template>
<script setup> <script setup>
import secondOne from './components/second-one.vue'; import secondOne from './components/second-one.vue';
import thirdOne from './components/third-one.vue'; import thirdOne from './components/third-one.vue';
import firstOne from './components/first-one.vue'; import firstOne from './components/first-one.vue';
import firstTwo from './components/first-two.vue'; import firstTwo from './components/first-two.vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import {
import { computed, reactive } from 'vue'; onLoad,
import _ from 'lodash'; onReachBottom
const state = reactive({ } from '@dcloudio/uni-app';
categoryList: [], import {
activeMenu: '0', computed,
reactive
} from 'vue';
import _ from 'lodash';
const state = reactive({
categoryList: [],
activeMenu: '0',
pagination: { pagination: {
data: [], data: [],
current_page: 1, current_page: 1,
total: 1, total: 1,
last_page: 1, last_page: 1,
}, },
loadStatus: '', loadStatus: '',
}); });
const { screenHeight, safeAreaInsets, screenWidth, safeArea } = sheep.$platform.device; const {
const pageHeight = computed(() => safeArea.height - 44 - 50); screenHeight,
safeAreaInsets,
screenWidth,
safeArea
} = sheep.$platform.device;
const pageHeight = computed(() => safeArea.height - 44 - 50);
async function getList(options) { async function getList(options) {
const { error, data } = await sheep.$api.category.list({ const {
id: options.id, code,
}); data
if (error === 0) { } = await sheep.$api.category.list({
state.categoryList = data; id: options.id,
} });
} if (code === 0) {
state.categoryList = {
children: data
};
}
}
const onMenu = (val) => { const onMenu = (val) => {
state.activeMenu = val; state.activeMenu = val;
if (state.categoryList.style === 'first_one' || state.categoryList.style === 'first_two') { if (state.categoryList.style === 'first_one' || state.categoryList.style === 'first_two') {
state.pagination = { state.pagination = {
data: [], data: [],
current_page: 1, current_page: 1,
total: 1, total: 1,
last_page: 1, last_page: 1,
}; };
getGoodsList(state.categoryList.children[val].id); }
} //
}; getGoodsList(state.categoryList.children[val].id);
};
async function getGoodsList(id, page = 1, list_rows = 6) { async function getGoodsList(id, page = 1, list_rows = 6) {
state.loadStatus = 'loading'; state.loadStatus = 'loading';
const res = await sheep.$api.goods.list({ const res = await sheep.$api.goods.list({
category_id: id, categoryId: id,
list_rows, pageSize:list_rows,
page, pageNo:page,
}); });
if (res.error === 0) { if (res.code === 0) {
let couponList = _.concat(state.pagination.data, res.data.data); let couponList = _.concat(state.pagination.data, res.data.list);
state.pagination = { state.pagination = {
...res.data, ...res.data,
data: couponList, data: couponList,
}; };
if (state.pagination.current_page < state.pagination.last_page) { console.log(state.pagination)
state.loadStatus = 'more'; if (state.pagination.current_page < state.pagination.last_page) {
} else { state.loadStatus = 'more';
state.loadStatus = 'noMore'; } else {
} state.loadStatus = 'noMore';
} }
} }
// }
function loadmore() { //
if (state.loadStatus !== 'noMore') { function loadmore() {
getGoodsList( if (state.loadStatus !== 'noMore') {
state.categoryList.children[state.activeMenu].id, getGoodsList(
state.pagination.current_page + 1, state.categoryList.children[state.activeMenu].id,
); state.pagination.current_page + 1,
} );
} }
onLoad(async (options) => { }
await getList(options); onLoad(async (options) => {
if (state.categoryList.style === 'first_one' || state.categoryList.style === 'first_two') { await getList(options);
getGoodsList(state.categoryList.children[0].id); if (state.categoryList.style === 'first_one' || state.categoryList.style === 'first_two') {
} getGoodsList(state.categoryList.children[0].id);
}); }
onReachBottom(() => { });
loadmore(); onReachBottom(() => {
}); loadmore();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.s-category { .s-category {
:deep() { :deep() {
.side-menu-wrap { .side-menu-wrap {
width: 200rpx; width: 200rpx;
height: 100%; height: 100%;
padding-left: 12rpx; padding-left: 12rpx;
background-color: #f6f6f6; background-color: #f6f6f6;
.menu-item { .menu-item {
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
position: relative; position: relative;
transition: all linear 0.2s; transition: all linear 0.2s;
.menu-title { .menu-title {
line-height: 32rpx; line-height: 32rpx;
font-size: 30rpx; font-size: 30rpx;
font-weight: 400; font-weight: 400;
color: #333; color: #333;
margin-left: 28rpx; margin-left: 28rpx;
position: relative; position: relative;
z-index: 0; z-index: 0;
&::before { &::before {
content: ''; content: '';
width: 64rpx; width: 64rpx;
height: 12rpx; height: 12rpx;
background: linear-gradient( background: linear-gradient(90deg,
90deg, var(--ui-BG-Main-gradient),
var(--ui-BG-Main-gradient), var(--ui-BG-Main-light)) !important;
var(--ui-BG-Main-light) position: absolute;
) !important; left: -64rpx;
position: absolute; bottom: 0;
left: -64rpx; z-index: -1;
bottom: 0; transition: all linear 0.2s;
z-index: -1; }
transition: all linear 0.2s; }
}
}
&.menu-item-active { &.menu-item-active {
background-color: #fff; background-color: #fff;
border-radius: 20rpx 0 0 20rpx; border-radius: 20rpx 0 0 20rpx;
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
right: 0; right: 0;
bottom: -20rpx; bottom: -20rpx;
width: 20rpx; width: 20rpx;
height: 20rpx; height: 20rpx;
background: radial-gradient(circle at 0 100%, transparent 20rpx, #fff 0); background: radial-gradient(circle at 0 100%, transparent 20rpx, #fff 0);
} }
&::after { &::after {
content: ''; content: '';
position: absolute; position: absolute;
top: -20rpx; top: -20rpx;
right: 0; right: 0;
width: 20rpx; width: 20rpx;
height: 20rpx; height: 20rpx;
background: radial-gradient(circle at 0% 0%, transparent 20rpx, #fff 0); background: radial-gradient(circle at 0% 0%, transparent 20rpx, #fff 0);
} }
.menu-title { .menu-title {
font-weight: 600; font-weight: 600;
&::before { &::before {
left: 0; left: 0;
} }
} }
} }
} }
} }
.goods-list-box { .goods-list-box {
background-color: #fff; background-color: #fff;
width: calc(100vw - 100px); width: calc(100vw - 100px);
padding: 10px; padding: 10px;
} }
.banner-img { .banner-img {
width: calc(100vw - 130px); width: calc(100vw - 130px);
border-radius: 5px; border-radius: 5px;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
} }
} }
</style> </style>

View File

@ -1,70 +1,84 @@
<template> <template>
<view v-if="template"> <view v-if="template">
<s-layout <s-layout title="首页" navbar="custom" tabbar="/pages/index/index" :bgStyle="template.style?.background"
title="首页" :navbarStyle="template.style?.navbar" onShareAppMessage>
navbar="custom" <s-block v-for="(item, index) in template.data" :key="index" :styles="item.style">
tabbar="/pages/index/index" <s-block-item :type="item.type" :data="item.data" :styles="item.style" />
:bgStyle="template.style?.background" </s-block>
:navbarStyle="template.style?.navbar" <!-- 广告模块 -->
onShareAppMessage <s-popup-image />
> </s-layout>
<s-block v-for="(item, index) in template.data" :key="index" :styles="item.style"> </view>
<s-block-item :type="item.type" :data="item.data" :styles="item.style" />
</s-block>
<!-- 广告模块 -->
<s-popup-image />
</s-layout>
</view>
</template> </template>
<script setup> <script setup>
import { computed } from 'vue'; import {
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'; computed
import sheep from '@/sheep'; } from 'vue';
import $share from '@/sheep/platform/share'; import {
onLoad,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
import index2Api from '@/sheep/api/index2';
// tabBar
uni.hideTabBar();
// tabBar const template = computed(() => sheep.$store('app').template?.home);
uni.hideTabBar(); //
(async function() {
let {
data
} = await index2Api.decorate();
template.value.data[0].data.list = JSON.parse(data[0].value).map(item => {
return {
src: item.picUrl,
url: item.url,
title: item.name,
type: "image"
}
})
}())
const template = computed(() => sheep.$store('app').template?.home); onLoad((options) => {
// #ifdef MP
//
if (options.scene) {
const sceneParams = decodeURIComponent(options.scene).split('=');
options[sceneParams[0]] = sceneParams[1];
}
// #endif
onLoad((options) => { //
// #ifdef MP if (options.templateId) {
// sheep.$store('app').init(options.templateId);
if (options.scene) { }
const sceneParams = decodeURIComponent(options.scene).split('=');
options[sceneParams[0]] = sceneParams[1];
}
// #endif
// //
if (options.templateId) { if (options.spm) {
sheep.$store('app').init(options.templateId); $share.decryptSpm(options.spm);
} }
// // ()
if (options.spm) { if (options.page) {
$share.decryptSpm(options.spm); sheep.$router.go(decodeURIComponent(options.page));
} }
// () // TODO
if (options.page) { sheep.$api.app.test();
sheep.$router.go(decodeURIComponent(options.page)); });
}
// TODO //
sheep.$api.app.test(); onPullDownRefresh(() => {
}); sheep.$store('app').init();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 800);
});
// onPageScroll(() => {});
onPullDownRefresh(() => {
sheep.$store('app').init();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 800);
});
onPageScroll(() => {});
</script> </script>
<style></style> <style></style>

View File

@ -1,9 +1,10 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
list: (data) => list: (data) =>
request({ request2({
url: 'cart', url: 'trade/cart/list',
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,
@ -25,14 +26,14 @@ export default {
}), }),
// 删除购物车 // 删除购物车
delete: (ids) => delete: (ids) =>
request({ request2({
url: 'cart/' + ids, url: 'trade/cart/delete?ids=' + ids,
method: 'DELETE', method: 'DELETE',
}), }),
update: (data) => update: (data) =>
request({ request2({
url: 'cart', url: 'trade/cart/update-count',
method: 'POST', method: 'PUT',
data: { data: {
...data, ...data,
type: 'cover', type: 'cover',

View File

@ -1,9 +1,9 @@
import request from '@/sheep/request'; import request2 from '@/sheep/request2';
export default { export default {
list: (params) => list: (params) =>
request({ request2({
url: 'category', url: 'product/category/list',
method: 'GET', method: 'GET',
params, params,
}), }),

View File

@ -16,8 +16,8 @@ export default {
// 商品列表 // 商品列表
list: (params) => list: (params) =>
request({ request2({
url: 'goods/goods', url: 'product/spu/page',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
@ -49,6 +49,16 @@ export default {
showError: false, showError: false,
}, },
}), }),
comment2: (id, params = {pageNo:1,pageSize:10,type:0}) =>
request2({
url: 'product/comment/page?spuId='+id,
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品评价类型 // 商品评价类型
getType: (id) => getType: (id) =>
request({ request({

9
sheep/api/index2.js Normal file
View File

@ -0,0 +1,9 @@
import request2 from '@/sheep/request2';
export default {
decorate: () =>
request2({
url: 'promotion/decorate/list?page=1',
method: 'GET',
}),
};

View File

@ -68,7 +68,7 @@ const http = new Request({
*/ */
http.interceptors.request.use( http.interceptors.request.use(
(config) => { (config) => {
console.log(config); // console.log(config);
if (config.custom.auth && !$store('user').isLogin) { if (config.custom.auth && !$store('user').isLogin) {
showAuthModal(); showAuthModal();
return Promise.reject(); return Promise.reject();
@ -110,7 +110,7 @@ http.interceptors.response.use(
} }
response.config.custom.showLoading && closeLoading(); response.config.custom.showLoading && closeLoading();
if (response.data.error !== 0) { if (response.data.code !== 0) {
if (response.config.custom.showError) if (response.config.custom.showError)
uni.showToast({ uni.showToast({
title: response.data.msg || '服务器开小差啦,请稍后再试~', title: response.data.msg || '服务器开小差啦,请稍后再试~',

View File

@ -15,7 +15,7 @@ const cart = defineStore({
if (!state.selectedIds.length) return price.toFixed(2); if (!state.selectedIds.length) return price.toFixed(2);
state.list.forEach((item) => { state.list.forEach((item) => {
price += state.selectedIds.includes(item.id) price += state.selectedIds.includes(item.id)
? Number(item.sku_price.price) * item.goods_num ? Number(item.sku.price/100) * item.count
: 0; : 0;
}); });
return price.toFixed(2); return price.toFixed(2);
@ -24,9 +24,9 @@ const cart = defineStore({
actions: { actions: {
// 获取购物车列表 // 获取购物车列表
async getList() { async getList() {
const { data, error } = await cartApi.list(); const { data, code } = await cartApi.list();
if (error === 0) { if (code === 0) {
this.list = data; this.list = data.validList;
} }
}, },
// 添加购物车 // 添加购物车
@ -44,8 +44,8 @@ const cart = defineStore({
// 更新购物车 // 更新购物车
async update(goodsInfo) { async update(goodsInfo) {
const { error } = await cartApi.update({ const { error } = await cartApi.update({
goods_id: goodsInfo.goods_id, id: goodsInfo.goods_id,
goods_num: goodsInfo.goods_num, count: goodsInfo.goods_num,
goods_sku_price_id: goodsInfo.goods_sku_price_id, goods_sku_price_id: goodsInfo.goods_sku_price_id,
}); });
if (error === 0) { if (error === 0) {
@ -58,8 +58,8 @@ const cart = defineStore({
if (typeof ids === 'array') { if (typeof ids === 'array') {
ids = ids.join(','); ids = ids.join(',');
} }
const { error } = await cartApi.delete(ids); const { code } = await cartApi.delete(ids);
if (error === 0) { if (code === 0) {
this.selectAll(false); this.selectAll(false);
this.getList(); this.getList();
} }