Merge branch 'dev' into 'master'

【修复】(首页模块快):修复购买记录组件报错

See merge request jianweie/coreshoppro!34
This commit is contained in:
花城
2024-10-14 09:51:59 +00:00
22 changed files with 152 additions and 91 deletions

View File

@@ -1,7 +1,8 @@
<template>
<view class="core-tabs-box">
<slot name="left"> </slot>
<scroll-view :scroll-x="true" class="scroll-view" :scroll-left="state.scrollLeft" :scroll-with-animation="true">
<scroll-view :scroll-x="true" class="scroll-view" enable-flex :scroll-left="state.scrollLeft"
:scroll-with-animation="true">
<view v-for="item, index in props.list" :key="index"
:class="['tab-item-box', { 'on': index === state.current }]" @click="hanldeClickTab(item, index)">
{{ item[props.keyNname] }}

View File

@@ -1,6 +1,6 @@
// 不同的环境变量配置
const development = {
requestBaseUrl: 'https://api.test.pro.coreshop.cn',
requestBaseUrl: 'https://api.pro.demo.corecms.cn',
appid: '',
}

View File

@@ -2,11 +2,11 @@ import { handleRouteNavigateTo, handleShowToast } from '@/core/utils';
import { NavLinkEnum } from '@/core/enum';
import { queryReceiveCoupon } from '@/core/api';
export const handleAdvertiseDetail = (type : number, val : string) => {
export const handleAdvertiseDetail = (type : number | string, val : string) => {
if (!val) {
return ''
}
if (type === NavLinkEnum.urlLink) { /** url类型的链接 */
if (type == NavLinkEnum.urlLink) { /** url类型的链接 */
if (val.includes('http')) {
// #ifdef APP-PLUS || APP-PLUS-NVUE || MP
handleRouteNavigateTo(`/pages/subpackage/webview/webview?src=${val}`);
@@ -38,7 +38,7 @@ export const handleAdvertiseDetail = (type : number, val : string) => {
} else if (type == NavLinkEnum.intelligentForms) { /** 自定义表单类型的链接 */
handleRouteNavigateTo(`/pages/subpackage/form/detail/detail?id=${val}`);
} else if (type == NavLinkEnum.shopCategory) { /** 商品分类类型的链接 */
handleRouteNavigateTo(`/pages/subpackage/category/list/list?id=${val}`);
handleRouteNavigateTo(`/pages/subpackage/category/category?id=${val}`);
} else if (type == NavLinkEnum.wxMiNiProgram) { /** 小程序类型的链接 */
uni.navigateToMiniProgram({
appId: val,

View File

@@ -3,7 +3,7 @@
<!-- 头部大分类 -->
<view class="big-classify">
<view class="scroll-view-box">
<scroll-view class="scroll-view" :scroll-x="true" :scroll-left="state.topScrollLeft"
<scroll-view class="scroll-view" enable-flex :scroll-x="true" :scroll-left="state.topScrollLeft"
:scroll-with-animation="true">
<view :class="['item', { 'on': state.topTabId === item.id }]"
v-for="item, index in state.classifyData" :key="index" @click="hanldeChangeTopTab(item, index)">
@@ -24,7 +24,7 @@
<view class="classify-box" :style="{ height: `${props.height - state.bigClassifyH}px` }">
<view class="classify-left">
<scroll-view class="scroll-view" :scroll-y="true">
<scroll-view class="scroll-view" enable-flex :scroll-y="true">
<view :class="['item', { 'on': state.leftTabId === item.id }]"
v-for="item, index in state.leftTabList" :key="index" @click="hanldeChangeLeftTab(item)">
{{ item.name }}
@@ -39,7 +39,7 @@
@hanldeClickTab="hanldeChangeRightTab"></coreshop-tabs>
</view>
</view>
<scroll-view class="scroll-view"
<scroll-view class="scroll-view" enable-flex
:style="{ 'height': `${props.height - state.bigClassifyH - state.rightTabH}px` }" :scroll-y="true"
@scrolltolower="handleScrolltolower">
<view class="advert-box radius-15 m-b-20">
@@ -89,7 +89,7 @@
<text class="price">{{ state.cartMoney }}</text>
</view>
</view>
<view class="btn-buy" @click="handleRouteSwitchTab(RouteSwitchTabEnum.cart)">
<view class="btn-buy" @click="handleGoPay">
去结算
</view>
</view>
@@ -124,6 +124,7 @@
<script setup lang="ts">
import { reactive, watch, ref, onMounted, getCurrentInstance, nextTick } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { advertPosition, UserToken } from '@/core/consts';
import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api';
import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models';
@@ -202,10 +203,6 @@
state.catId = state.classifyData[0].child[0]?.id;
getGoodsPageList();
if (uni.getStorageSync(UserToken)) {
getCartNumAndMoney();
}
}
})
@@ -219,6 +216,12 @@
})
})
onShow(()=>{
if (uni.getStorageSync(UserToken)) {
getCartNumAndMoney();
}
});
// 获取商品列表数据
const getGoodsPageList = async () => {
uni.showLoading({
@@ -259,6 +262,15 @@
state.showSku = true;
}
/** 底部按钮去结算 */
const handleGoPay = () => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
handleRouteSwitchTab(RouteSwitchTabEnum.cart);
}
/** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => {
if (!uni.getStorageSync(UserToken)) {

View File

@@ -60,7 +60,7 @@
<text class="price">{{ state.cartMoney }}</text>
</view>
</view>
<view class="btn-buy" @click="handleRouteSwitchTab(RouteSwitchTabEnum.cart)">
<view class="btn-buy" @click="handleGoPay">
去结算
</view>
</view>
@@ -76,6 +76,7 @@
<script setup lang="ts">
import { reactive, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { advertPosition } from '@/core/consts';
import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api';
import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models';
@@ -135,13 +136,15 @@
state.rightTabList = state.classifyData[0]?.child;
getGoodsPageList();
if (uni.getStorageSync(UserToken)) {
getCartNumAndMoney();
}
}
})
onShow(() => {
if (uni.getStorageSync(UserToken)) {
getCartNumAndMoney();
}
});
/** 获取商品列表数据 */
const getGoodsPageList = async () => {
uni.showLoading({
@@ -182,6 +185,15 @@
state.showSku = true;
}
/** 底部按钮去结算 */
const handleGoPay = () => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
handleRouteSwitchTab(RouteSwitchTabEnum.cart);
}
/** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => {
if (!uni.getStorageSync(UserToken)) {

View File

@@ -1,7 +1,7 @@
<template>
<view class="classify-box" :style="{height: `${height}px`}">
<view class="classify-left">
<scroll-view class="scroll-view" :scroll-y="true">
<scroll-view class="scroll-view" enable-flex :scroll-y="true">
<view :class="['item', { 'on': state.leftTabId === item.id }]" v-for="item, index in props.data"
:key="index" @click="hanldeChangeLeftTab(item)">
{{ item.name }}
@@ -9,7 +9,7 @@
</scroll-view>
</view>
<view class="classify-right">
<scroll-view class="scroll-view" :scroll-y="true">
<scroll-view class="scroll-view" enable-flex :scroll-y="true">
<view class="advert-box radius-15">
<coreshop-advert :code="advertPosition.goodsClassifyBanner"></coreshop-advert>
</view>

View File

@@ -70,10 +70,6 @@
keyWord: "",
showLoginModal: false,
})
const getAllCategories = async () => {
const allCategories : Response<Array<CategoriesType>> = await queryAllCategories();
state.categoriesList = allCategories.data || [];
}
onMounted(async () => {
getAllCategories();
@@ -83,13 +79,15 @@
})
})
/** 获取购物车数量价格 */
const getAllCategories = async () => {
const allCategories : Response<Array<CategoriesType>> = await queryAllCategories();
state.categoriesList = allCategories.data || [];
}
/** 搜索 */
const handleSearch = () => {
if (state.keyWord) {
handleRouteNavigateTo(`/pages/subpackage/category/category?key=${state.keyWord}`);
} else {
handleShowToast('请输入搜索内容');
}
handleRouteNavigateTo(`/pages/subpackage/category/category?key=${state.keyWord}`);
}
/** 显示登录弹框 */

View File

@@ -4,7 +4,7 @@
<view class="title-icon">
<text class="tit">{{ props.data.list[0].title }}</text>
</view>
<coreshop-view-more @hanldeClickViewMore="hanldeClickViewMore" />
<coreshop-view-more @hanldeClickViewMore="hanldeClickViewMore" title="查看详情" />
</view>
<view class="m-t-25" v-for="item, index in props.data.list" :key="index">
<coreshop-article :data="hanldeCombinationArticleData(item)"

View File

@@ -6,7 +6,7 @@
<coreshop-view-more @hanldeClickViewMore="hanldeClickViewMore"></coreshop-view-more>
</view>
<view class="coupon-card-box">
<scroll-view :scroll-x="true" class="scroll-box">
<scroll-view :scroll-x="true" class="scroll-box" :enable-flex="true">
<view class="card-box" v-for="item, index in props.data?.list?.slice(0, props.data.limit)"
:key="index">
<image class="coupon-bg" :src="handleStaticResources('/static/images/coupon-bg.jpg')"></image>

View File

@@ -3,7 +3,7 @@
<template v-if="props.data?.style != 0">
<view :class="['img-box', `img-box-${props.data?.style}`]">
<view class="img-item" v-for="item, index in props.data.list" :key="index"
:style="{ 'padding': `${props.data.margin / 2}px` }">
:style="{ 'padding': `${props.data.margin / 2}px` }" @click="handleAdvertiseDetail(item?.linkType, item?.linkValue)">
<image class="img" :src="item.image || handleStaticResources('/static/images/common/empty.png')"
mode="widthFix"></image>
</view>

View File

@@ -23,7 +23,7 @@
}
}
.pintuan-box {
.pintuan-list {
white-space: nowrap;
width: 100%;
}

View File

@@ -7,7 +7,7 @@
<coreshop-view-more @hanldeClickViewMore="hanldeClickViewMore" color="#fff"
:icon="handleStaticResources('/static/images/icon/icon-rigth-fff.png')" />
</view>
<scroll-view :scroll-x="true" class="m-t-25 pintuan-box">
<scroll-view :scroll-x="true" class="m-t-25 pintuan-list" :enable-flex="true">
<view v-for="item, index in props.data.list" :key="index" class="card-box">
<coreshop-goods-card imgWidth="290rpx" imgHeight="290rpx" type="vertical"
:goodsData="hanldeCombinationGoodsData(item)" @hanldeClickGoods="hanldeClickGoods">

View File

@@ -1,17 +1,17 @@
<template>
<view class="record-box" v-if="state.recordObj" :style="{
[props.data.style.align]: 0,
top: `${props.data.style.top}%`
<view class="record-box" v-if="Object.keys(state.recordObj).length > 0" :style="{
[props.data?.style?.align || 'left']: 0,
top: `${props.data?.style?.top || 20}%`
}">
<image class="img" :src="state.recordObj.avatar"></image>
<text class="tit">{{state.recordObj.nickname}}{{state.recordObj.createTime}}{{state.recordObj.desc}}</text>
<image class="img" :src="state.recordObj?.avatar"></image>
<text class="tit">{{state.recordObj?.nickname}}{{state.recordObj?.createTime}}{{state.recordObj?.desc}}</text>
</view>
</template>
<script setup lang="ts">
import { onMounted, reactive } from 'vue';
import { reactive ,onMounted } from 'vue';
import { queryRecord } from '@/core/api';
import type { Response, RecordType } from '@/core/models'
import { onHide, onShow } from '@dcloudio/uni-app';
import { onHide } from '@dcloudio/uni-app';
const props = withDefaults(defineProps<{
data : any,
@@ -27,14 +27,14 @@
times: "",
})
// 获取日志
const getRecord = async () => {
const record : Response<RecordType> = await queryRecord({
type: 'home',
value: 0,
})
state.recordObj = record.data;
}
onMounted(() => {
query();
})
onHide(() => {
clearInterval(state.times);
})
const query = () => {
getRecord();
state.times = setInterval(() => {
@@ -42,17 +42,16 @@
}, 3000)
}
onMounted(() => {
query();
})
onShow(() => {
query();
})
onHide(() => {
clearInterval(state.times);
})
// 获取日志
const getRecord = async () => {
const record : Response<RecordType> = await queryRecord({
type: 'home',
value: 0,
});
if(record.status){
state.recordObj = record?.data;
};
}
</script>
<style lang="scss" scoped>
@import './home-record.scss';

View File

@@ -81,6 +81,7 @@
import Point from '@/pages/components/custom-page/components/home-goods/point.vue';
import { handleShowToast } from '@/core/utils';
import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue';
import { UserToken } from '@/core/consts'
const props = withDefaults(defineProps<{
goodsDetailData : any,
@@ -100,6 +101,8 @@
showShare: false,
});
const emits = defineEmits(['handleShowLoginPopup']);
watch(() => props.goodsDetailData, (newVla : any) => {
if (newVla) {
state.isFav = newVla.isFav;
@@ -107,6 +110,11 @@
});
const handleToggleGoodsCollection = async () => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
const goodsCollection = await queryGoodsCollection({ id: props.goodsDetailData.id });
if (goodsCollection.status) {
state.isFav = !state.isFav;
@@ -118,6 +126,10 @@
/** 分享弹框显示与否 */
const handleToggleShowShare = () => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
state.showShare = !state.showShare;
}
</script>

View File

@@ -116,10 +116,12 @@
const handleChangeNumberVal = (e : any) => {
state.numberVal = e.value;
}
/** sku弹框显示或者隐藏 */
const handleChangePopup = (e : any) => {
emits('handleChangePopup', e.show)
}
/** sku选择 */
const handleChooseSku = (index : number, sku : GoodsSpecListType) => {
let chooseSku : GoodsSkuListType = {}; // 选中的sku
@@ -161,6 +163,7 @@
});
}
/** 立即购买 */
const handleBuyNow = () => {
if (!handleHaveStock()) {
@@ -171,6 +174,7 @@
nums: state.numberVal,
});
}
/** 判断库存 */
const handleHaveStock = () => {
if (state.chooseSku.stock === 0) {

View File

@@ -8,7 +8,7 @@
<slot name="tip"></slot>
<!-- 商品信息 价格名字之类的 -->
<GoodsDetailInfo :goodsDetailData="props.goodsDetailData" :shareType="props.shareType"
<GoodsDetailInfo :goodsDetailData="props.goodsDetailData" :shareType="props.shareType" @handleShowLoginPopup="handleShowLoginPopup"
:isActivityGoods="props.isActivityGoods" @handleToggleGoodsCollection="handleToggleGoodsCollection">
<template #countDown>
<slot name="countDown"></slot>
@@ -93,7 +93,7 @@
shareType: ShareEnum.index, /** 分享类型 - 默认分享首页 */
});
const emits = defineEmits(['hanldeShowGoodSku', 'handleToggleGoodsCollection']);
const emits = defineEmits(['hanldeShowGoodSku', 'handleToggleGoodsCollection','handleShowLoginPopup']);
const state = reactive<{
commonQuestion : Array<CommonQuestionServiceType>;
@@ -170,6 +170,11 @@
const handleToggleGoodsCollection = () => {
emits('handleToggleGoodsCollection')
}
/** 显示登录弹框 */
const handleShowLoginPopup = ()=>{
emits('handleShowLoginPopup')
}
</script>
<style lang="scss" scoped></style>

View File

@@ -5,7 +5,7 @@
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.group"
@hanldeShowGoodSku="hanldeShowGoodSku">
@hanldeShowGoodSku="hanldeShowGoodSku" @handleShowLoginPopup="handleShowLoginPopup">
<template #tip>
<view class="tip-box" v-if="state.showTip && state.goodsDetailData.groupPromotionResult">
<view class="title">当前团购活动规则</view>
@@ -200,6 +200,11 @@
}
}
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;

View File

@@ -3,7 +3,7 @@
<view class="goods-detail">
<!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan"
:swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan" @handleShowLoginPopup="handleShowLoginPopup"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true">
<template #activityGoodsOtheService>
<view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0">
@@ -273,6 +273,11 @@
}
}
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;

View File

@@ -3,7 +3,7 @@
<view class="goods-detail">
<!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc"
:swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc" @handleShowLoginPopup="handleShowLoginPopup"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.seckill"
@hanldeShowGoodSku="hanldeShowGoodSku">
<template #tip>
@@ -200,6 +200,11 @@
}
}
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;

View File

@@ -207,6 +207,10 @@
/**立即购买 */
const handleBuyNow = () => {
if (!uni.getStorageSync(UserToken)) {
state.showLoginModal = true;
return;
}
if (state.totalprice == 0) {
handleShowToast('请先选择商品');
return;
@@ -237,11 +241,6 @@
}
}
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
@@ -281,6 +280,10 @@
/** 分享弹框显示与否 */
const handleToggleShowShare = () => {
if (!uni.getStorageSync(UserToken)) {
state.showLoginModal = true;
return;
}
state.showShare = !state.showShare;
}

View File

@@ -6,7 +6,7 @@
:swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent"
:userAgentGrade="state.userAgentGrade" :agentProductsList="state.agentProductsList"
:goodsPromotionList="state.goodsPromotionList" :spesDesc="state.spesDesc"
@hanldeShowGoodSku="hanldeShowGoodSku">
@hanldeShowGoodSku="hanldeShowGoodSku" @handleShowLoginPopup="handleShowLoginPopup">
</GoodsDetail>
<!-- 为您推荐 -->

View File

@@ -8,7 +8,7 @@
</map>
</view>
<view class="store-box">
<scroll-view class="store-list" scroll-y>
<scroll-view class="store-list" enable-flex scroll-y>
<view class="item-box" v-for="item in state.storeList" :key="item.id">
<view class="img-box">
<image class="img" :src="item.logoImage"></image>