This commit is contained in:
21世纪小八路
2024-10-15 21:27:14 +08:00
30 changed files with 539 additions and 767 deletions

View File

@@ -6,12 +6,19 @@
:style="{ 'padding-top': `${props.isShowStatusBarHeight ? statusBarHeight : 0}px`, ...props.contentStyle }"> :style="{ 'padding-top': `${props.isShowStatusBarHeight ? statusBarHeight : 0}px`, ...props.contentStyle }">
<slot></slot> <slot></slot>
</view> </view>
<template v-if="props.showLoginModalDom">
<coreshop-login-modal :show="_useLoginStore.showLoginModalTogglePop"
@handleChangePopup="handleChangeLoginPopup" @getUserInfo="_useLoginStore.getUserInfo()"></coreshop-login-modal>
</template>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useSystemInfo } from '@/core/hooks'; import { useSystemInfo } from '@/core/hooks';
import { useLoginStore } from '@/core/store';
// 获取自定义导航栏高度 // 获取自定义导航栏高度
const { statusBarHeight } = useSystemInfo(); const { statusBarHeight } = useSystemInfo();
const _useLoginStore = useLoginStore();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
isBack : boolean, isBack : boolean,
@@ -23,6 +30,7 @@
customStyle : any; customStyle : any;
contentStyle : any; contentStyle : any;
handleCustomRouteJump : () => void | null, handleCustomRouteJump : () => void | null,
showLoginModalDom : boolean;
}>(), { }>(), {
isBack: true, isBack: true,
bgColor: '#EEF3F7', bgColor: '#EEF3F7',
@@ -33,7 +41,13 @@
customStyle: {}, customStyle: {},
contentStyle: {}, contentStyle: {},
handleCustomRouteJump: null, handleCustomRouteJump: null,
showLoginModalDom: false
}); });
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
_useLoginStore.setShowLoginModalTogglePop(isShow);
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>

View File

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

View File

@@ -12,3 +12,7 @@ export interface UserInfoStoreType {
export interface UserCartType { export interface UserCartType {
cartNum ?: number cartNum ?: number
} }
export interface UserLoginStoreType {
showLoginModalTogglePop ?: boolean
}

View File

@@ -4,3 +4,7 @@ export * from './config';
export * from './userInfo'; export * from './userInfo';
/** 购物车 */ /** 购物车 */
export * from './cart'; export * from './cart';
/** 登录 */
export * from './login';

View File

@@ -0,0 +1,38 @@
import { defineStore } from 'pinia';
import { UserToken } from '@/core/consts';
import { handleShowToast } from '@/core/utils';
import { queryUserInfo } from '@/core/api';
import type { UserLoginStoreType, Response, UserInfoType } from '@/core/models';
import { useUserInfoStore } from './userInfo';
export const useLoginStore = defineStore('useLoginStore', {
state: () : UserLoginStoreType => {
return {
showLoginModalTogglePop: false
};
},
actions: {
/** 检查是否登录 */
checkLogin(callBack : () => void) {
if (!uni.getStorageSync(UserToken)) {
this.setShowLoginModalTogglePop(true);
} else {
callBack();
}
},
/** 获取用户数据 */
async getUserInfo() {
const userInfoStore = useUserInfoStore();
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
},
/** 设置登录弹框打开或者关闭 */
setShowLoginModalTogglePop(showLoginModalTogglePop : boolean) {
this.showLoginModalTogglePop = showLoginModalTogglePop;
},
},
});

View File

@@ -168,6 +168,18 @@ export const authorize = (options : UniNamespace.AuthorizeOptions) : Promise<any
}); });
} }
export const showToast = (options : UniNamespace.ShowToastOptions) : Promise<any> => {
return new Promise((success, fail) => {
uni.showToast({
...options,
success,
fail
});
})
}
export default { export default {
request, request,
login, login,
@@ -184,5 +196,6 @@ export default {
getLocation, getLocation,
getSetting, getSetting,
openSetting, openSetting,
authorize authorize,
showToast
} }

View File

@@ -126,6 +126,7 @@
import { reactive, watch, ref, onMounted, getCurrentInstance, nextTick } from 'vue'; import { reactive, watch, ref, onMounted, getCurrentInstance, nextTick } from 'vue';
import { onShow } from '@dcloudio/uni-app'; import { onShow } from '@dcloudio/uni-app';
import { advertPosition, UserToken } from '@/core/consts'; import { advertPosition, UserToken } from '@/core/consts';
import { useLoginStore } from '@/core/store';
import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api'; import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api';
import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models'; import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models';
import { getDomInfo, handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils'; import { getDomInfo, handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils';
@@ -134,6 +135,9 @@
const instance = getCurrentInstance(); const instance = getCurrentInstance();
/** 登录store */
const _useLoginStore = useLoginStore();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
data : Array<CategoriesType>, data : Array<CategoriesType>,
height : number, height : number,
@@ -182,8 +186,6 @@
goodsDetailData: {}, goodsDetailData: {},
}); });
const emits = defineEmits(['handleShowLoginPopup']);
watch(() => props.data, (newVal : Array<CategoriesType>) => { watch(() => props.data, (newVal : Array<CategoriesType>) => {
if (newVal) { if (newVal) {
state.classifyData = newVal.map((item : CategoriesType) => { state.classifyData = newVal.map((item : CategoriesType) => {
@@ -216,7 +218,7 @@
}) })
}) })
onShow(()=>{ onShow(() => {
if (uni.getStorageSync(UserToken)) { if (uni.getStorageSync(UserToken)) {
getCartNumAndMoney(); getCartNumAndMoney();
} }
@@ -232,8 +234,10 @@
limit: 10, limit: 10,
where: `{"catId":${state.catId}}` where: `{"catId":${state.catId}}`
}); });
state.totalPages = goodsPageList.data.totalPages; if(goodsPageList.status){
state.goodsList = state.goodsList.concat(goodsPageList.data.list); state.totalPages = goodsPageList.data?.totalPages;
state.goodsList = state.goodsList.concat(goodsPageList.data?.list);
}
uni.hideLoading(); uni.hideLoading();
} }
@@ -245,38 +249,34 @@
} }
/** 选择sku */ /** 选择sku */
const handleSelectSku = async (id : number) => { const handleSelectSku = (id : number) => {
let goodsDetail : any = null; _useLoginStore.checkLogin(async () => {
if (uni.getStorageSync(UserToken)) { let goodsDetail : any = null;
goodsDetail = await queryGoodsDetailByToken({ if (uni.getStorageSync(UserToken)) {
id: id, goodsDetail = await queryGoodsDetailByToken({
data: true, id: id,
}) data: true,
} else { })
goodsDetail = await queryGoodsDetail({ } else {
id: id, goodsDetail = await queryGoodsDetail({
data: true, id: id,
}) data: true,
} })
state.goodsDetailData = goodsDetail.data; }
state.showSku = true; state.goodsDetailData = goodsDetail.data;
state.showSku = true;
});
} }
/** 底部按钮去结算 */ /** 底部按钮去结算 */
const handleGoPay = () => { const handleGoPay = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
emits('handleShowLoginPopup'); handleRouteSwitchTab(RouteSwitchTabEnum.cart);
return; });
}
handleRouteSwitchTab(RouteSwitchTabEnum.cart);
} }
/** 添加购物车 */ /** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => { const handleAddCart = async ({ productId, nums } : any) => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,
@@ -295,10 +295,6 @@
/** 立即购买 */ /** 立即购买 */
const handleBuyNow = async ({ productId, nums } : any) => { const handleBuyNow = async ({ productId, nums } : any) => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,
@@ -314,13 +310,12 @@
} }
} }
/** sku弹框显示隐藏 */ /** sku弹框显示隐藏 */
const handleChangePopup = (show : boolean) => { const handleChangePopup = (show : boolean) => {
state.showSku = show; state.showSku = show;
} }
// 切换顶部tab /** 切换顶部tab */
const hanldeChangeTopTab = (item : CategoriesType, index : number) => { const hanldeChangeTopTab = (item : CategoriesType, index : number) => {
if (state.leftTabId != item.id) { if (state.leftTabId != item.id) {
state.topTabId = item.id; state.topTabId = item.id;
@@ -335,16 +330,16 @@
} }
} }
// 显示顶部大分类弹框 /** 显示顶部大分类弹框 */
const hanldeShowBigClassifyPop = () => { const hanldeShowBigClassifyPop = () => {
bigClassifyPop.value.open(); bigClassifyPop.value.open();
} }
// 隐藏顶部大分类弹框 /** 隐藏顶部大分类弹框 */
const hanlderHidebigClassifyPop = () => { const hanlderHidebigClassifyPop = () => {
bigClassifyPop.value.close(); bigClassifyPop.value.close();
} }
//计算顶部tab移动的距离 /** 计算顶部tab移动的距离 */
const calculationTopMovingDistance = (index : number) => { const calculationTopMovingDistance = (index : number) => {
let topScrollLeft = 0; let topScrollLeft = 0;
for (let i = 0; i < index - 1; i++) { for (let i = 0; i < index - 1; i++) {
@@ -353,7 +348,7 @@
state.topScrollLeft = topScrollLeft state.topScrollLeft = topScrollLeft
} }
// 切换左侧tab /** 切换左侧tab */
const hanldeChangeLeftTab = (item : CategoriesType) => { const hanldeChangeLeftTab = (item : CategoriesType) => {
if (state.leftTabId != item.id) { if (state.leftTabId != item.id) {
state.leftTabId = item.id; state.leftTabId = item.id;
@@ -363,13 +358,13 @@
} }
} }
//切换右侧tab /** 切换右侧tab */
const hanldeChangeRightTab = (item : CategoriesType) => { const hanldeChangeRightTab = (item : CategoriesType) => {
state.catId = item.id; state.catId = item.id;
handleResetGoodsList(); handleResetGoodsList();
} }
// 组合商品数据传入组件 /** 组合商品数据传入组件 */
const hanldeCombinationGoodsData = (item : GoodsType) => { const hanldeCombinationGoodsData = (item : GoodsType) => {
return { return {
id: item.id, id: item.id,
@@ -389,7 +384,7 @@
}) })
} }
// 加载下一页数据 /** 加载下一页数据 */
const handleScrolltolower = () => { const handleScrolltolower = () => {
if (state.totalPages > state.page) { if (state.totalPages > state.page) {
state.page++; state.page++;
@@ -397,7 +392,7 @@
} }
} }
// 重置商品列表数据 /** 重置商品列表数据 */
const handleResetGoodsList = () => { const handleResetGoodsList = () => {
state.page = 1; state.page = 1;
state.goodsList = []; state.goodsList = [];

View File

@@ -77,14 +77,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, watch } from 'vue'; import { reactive, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app'; import { onShow } from '@dcloudio/uni-app';
import { advertPosition } from '@/core/consts'; import { UserToken, advertPosition } from '@/core/consts';
import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api'; import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api';
import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models'; import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models';
import { handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils'; import { handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils';
import { UserToken } from '@/core/consts' import { useLoginStore } from '@/core/store'
import { AddCartEnum, PaymentTypeEnum, RouteSwitchTabEnum } from '@/core/enum'; import { AddCartEnum, PaymentTypeEnum, RouteSwitchTabEnum } from '@/core/enum';
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue'; import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
/** 登录store */
const _useLoginStore = useLoginStore();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
data : Array<CategoriesType>, data : Array<CategoriesType>,
height : number, height : number,
@@ -119,8 +122,6 @@
goodsDetailData: {}, goodsDetailData: {},
}); });
const emits = defineEmits(['handleShowLoginPopup']);
watch(() => props.data, (newVal : Array<CategoriesType>) => { watch(() => props.data, (newVal : Array<CategoriesType>) => {
if (newVal) { if (newVal) {
state.classifyData = newVal.map((item : CategoriesType) => { state.classifyData = newVal.map((item : CategoriesType) => {
@@ -155,8 +156,10 @@
limit: 10, limit: 10,
where: `{"catId":${state.catId}}` where: `{"catId":${state.catId}}`
}); });
state.totalPages = goodsPageList.data.totalPages; if(goodsPageList.status){
state.goodsList = state.goodsList.concat(goodsPageList.data.list); state.totalPages = goodsPageList.data?.totalPages;
state.goodsList = state.goodsList.concat(goodsPageList.data?.list);
}
uni.hideLoading(); uni.hideLoading();
} }
@@ -168,38 +171,34 @@
} }
/** 选择sku */ /** 选择sku */
const handleSelectSku = async (id : number) => { const handleSelectSku = (id : number) => {
let goodsDetail : any = null; _useLoginStore.checkLogin(async () => {
if (uni.getStorageSync(UserToken)) { let goodsDetail : any = null;
goodsDetail = await queryGoodsDetailByToken({ if (uni.getStorageSync(UserToken)) {
id: id, goodsDetail = await queryGoodsDetailByToken({
data: true, id: id,
}) data: true,
} else { })
goodsDetail = await queryGoodsDetail({ } else {
id: id, goodsDetail = await queryGoodsDetail({
data: true, id: id,
}) data: true,
} })
state.goodsDetailData = goodsDetail.data; }
state.showSku = true; state.goodsDetailData = goodsDetail.data;
state.showSku = true;
})
} }
/** 底部按钮去结算 */ /** 底部按钮去结算 */
const handleGoPay = () => { const handleGoPay = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
emits('handleShowLoginPopup'); handleRouteSwitchTab(RouteSwitchTabEnum.cart);
return; });
}
handleRouteSwitchTab(RouteSwitchTabEnum.cart);
} }
/** 添加购物车 */ /** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => { const handleAddCart = async ({ productId, nums } : any) => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,
@@ -218,10 +217,6 @@
/** 立即购买 */ /** 立即购买 */
const handleBuyNow = async ({ productId, nums } : any) => { const handleBuyNow = async ({ productId, nums } : any) => {
if (!uni.getStorageSync(UserToken)) {
emits('handleShowLoginPopup');
return;
}
const addCart : Response<number> = await queryAddCart({ const addCart : Response<number> = await queryAddCart({
productId, productId,
nums, nums,

View File

@@ -1,48 +1,46 @@
<template> <template>
<view class="layout-classify-page"> <coreshop-page :isBack="false" bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<uv-navbar bgColor="#EEF3F7"> <view class="layout-classify-page">
<template #left> <uv-navbar bgColor="#EEF3F7">
<view class="search-box"> <template #left>
<view class="page-name">分类</view> <view class="search-box">
<uv-input v-model="state.keyWord" @confirm="handleSearch" shape="circle" placeholder="请输入关键词" <view class="page-name">分类</view>
prefixIcon="search" :customStyle="{ 'background-color': '#fff' ,'padding':'3px 9px'}" <uv-input v-model="state.keyWord" @confirm="handleSearch" shape="circle" placeholder="请输入关键词"
prefixIconStyle="font-size: 22px;color: #909399"> prefixIcon="search" :customStyle="{ 'background-color': '#fff' ,'padding':'3px 9px'}"
<template #suffix> prefixIconStyle="font-size: 22px;color: #909399">
<view class="search-tit" @click.stop="handleSearch">搜索</view> <template #suffix>
</template> <view class="search-tit" @click.stop="handleSearch">搜索</view>
</uv-input> </template>
</view> </uv-input>
</template> </view>
</uv-navbar> </template>
</uv-navbar>
<view class="content-box" :style="{ 'padding-top': `${statusBarHeight}px`, 'height': `${state.height}px` }"> <view class="content-box" :style="{ 'padding-top': `${statusBarHeight}px`, 'height': `${state.height}px` }">
<classifyOne v-if="shopConfigStore.config.cateStyle == GoodsListEnum.one" :data="state.categoriesList"> <classifyOne v-if="shopConfigStore.config.cateStyle == GoodsListEnum.one" :data="state.categoriesList">
</classifyOne> </classifyOne>
<classifyTwo v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.two" :data="state.categoriesList"> <classifyTwo v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.two"
</classifyTwo> :data="state.categoriesList">
<classifyThree v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.three" </classifyTwo>
:data="state.categoriesList" :height="state.height"></classifyThree> <classifyThree v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.three"
<classifyFour v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.four" :data="state.categoriesList" :height="state.height"></classifyThree>
:data="state.categoriesList" :height="state.height" @handleShowLoginPopup="handleShowLoginPopup"> <classifyFour v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.four"
</classifyFour> :data="state.categoriesList" :height="state.height">
<classifyFive v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.five" </classifyFour>
:data="state.categoriesList" :height="state.height" :statusBarHeight="statusBarHeight" <classifyFive v-else-if="shopConfigStore.config.cateStyle == GoodsListEnum.five"
@handleShowLoginPopup="handleShowLoginPopup"></classifyFive> :data="state.categoriesList" :height="state.height" :statusBarHeight="statusBarHeight"></classifyFive>
</view>
</view> </view>
</coreshop-page>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, reactive, nextTick } from 'vue'; import { onMounted, reactive, nextTick } from 'vue';
import { useShopConfigStore, useUserInfoStore } from '@/core/store'; import { useShopConfigStore } from '@/core/store';
import { queryAllCategories, queryUserInfo } from '@/core/api'; import { queryAllCategories } from '@/core/api';
import { GoodsListEnum } from '@/core/enum'; import { GoodsListEnum } from '@/core/enum';
import { handleRouteNavigateTo, handleShowToast } from '@/core/utils'; import { handleRouteNavigateTo } from '@/core/utils';
import type { Response, ShopConfigStoreType, CategoriesType, UserInfoType } from '@/core/models'; import type { Response, ShopConfigStoreType, CategoriesType } from '@/core/models';
import classifyOne from './classify-page/classify-one/classify-one.vue'; import classifyOne from './classify-page/classify-one/classify-one.vue';
import classifyTwo from './classify-page/classify-two/classify-two.vue'; import classifyTwo from './classify-page/classify-two/classify-two.vue';
import classifyThree from './classify-page/classify-three/classify-three.vue'; import classifyThree from './classify-page/classify-three/classify-three.vue';
@@ -56,19 +54,14 @@
// 获取自定义导航栏高度 // 获取自定义导航栏高度
const { statusBarHeight, systemInfo } = useSystemInfo(); const { statusBarHeight, systemInfo } = useSystemInfo();
/** 获取用户数据 */
const userInfoStore = useUserInfoStore();
const state = reactive<{ const state = reactive<{
categoriesList : Array<CategoriesType>, categoriesList : Array<CategoriesType>,
height : number, height : number,
keyWord : string; keyWord : string;
showLoginModal : boolean;
}>({ }>({
categoriesList: [], categoriesList: [],
height: 0, height: 0,
keyWord: "", keyWord: "",
showLoginModal: false,
}) })
onMounted(async () => { onMounted(async () => {
@@ -89,26 +82,6 @@
const handleSearch = () => { const handleSearch = () => {
handleRouteNavigateTo(`/pages/subpackage/category/category?key=${state.keyWord}`); handleRouteNavigateTo(`/pages/subpackage/category/category?key=${state.keyWord}`);
} }
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -33,7 +33,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js'; import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
import { handleStaticResources, handleRouteNavigateTo, receiveCoupon } from '@/core/utils'; import { handleStaticResources, handleRouteNavigateTo, receiveCoupon } from '@/core/utils';
import { UserToken } from '@/core/consts'; import { useLoginStore } from '@/core/store';
/** 登录store */
const _useLoginStore = useLoginStore();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
data : any, data : any,
@@ -41,18 +44,14 @@
data: {} data: {}
}); });
const emits = defineEmits(['handleShowLoginPopup']);
const hanldeClickViewMore = () => { const hanldeClickViewMore = () => {
handleRouteNavigateTo('/pages/subpackage/coupon/coupon'); handleRouteNavigateTo('/pages/subpackage/coupon/coupon');
} }
const handleReceiveCoupon = (id:number) => { const handleReceiveCoupon = (id : number) => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
emits('handleShowLoginPopup'); receiveCoupon(id)
return ; });
}
receiveCoupon(id)
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -48,7 +48,7 @@
type: 'home', type: 'home',
value: 0, value: 0,
}); });
if(record.status){ if(record.status && record.data){
state.recordObj = record?.data; state.recordObj = record?.data;
}; };
} }

View File

@@ -19,7 +19,7 @@
<!-- 服务商品 --> <!-- 服务商品 -->
<HomeServiceGood v-if="item.widgetCode === WidgetCodeEnum.service" :data="item.parameters"></HomeServiceGood> <HomeServiceGood v-if="item.widgetCode === WidgetCodeEnum.service" :data="item.parameters"></HomeServiceGood>
<!-- 优惠券 --> <!-- 优惠券 -->
<HomeCoupon v-if="item.widgetCode === WidgetCodeEnum.coupon" :data="item.parameters" @handleShowLoginPopup="handleShowLoginPopup"></HomeCoupon> <HomeCoupon v-if="item.widgetCode === WidgetCodeEnum.coupon" :data="item.parameters"></HomeCoupon>
<!-- 拼团 --> <!-- 拼团 -->
<HomePinTuan v-if="item.widgetCode === WidgetCodeEnum.pinTuan" :data="item.parameters"></HomePinTuan> <HomePinTuan v-if="item.widgetCode === WidgetCodeEnum.pinTuan" :data="item.parameters"></HomePinTuan>
<!-- 图组 --> <!-- 图组 -->
@@ -79,13 +79,6 @@
}>(), { }>(), {
coreshopData: () => [] coreshopData: () => []
}); });
const emits = defineEmits(['handleShowLoginPopup']);
/** 显示登录弹框 */
const handleShowLoginPopup = ()=>{
emits('handleShowLoginPopup');
}
</script> </script>
<style></style> <style></style>

View File

@@ -81,7 +81,10 @@
import Point from '@/pages/components/custom-page/components/home-goods/point.vue'; import Point from '@/pages/components/custom-page/components/home-goods/point.vue';
import { handleShowToast } from '@/core/utils'; import { handleShowToast } from '@/core/utils';
import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue'; import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue';
import { UserToken } from '@/core/consts' import { useLoginStore } from '@/core/store';
/** 登录store */
const _useLoginStore = useLoginStore();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
goodsDetailData : any, goodsDetailData : any,
@@ -101,36 +104,29 @@
showShare: false, showShare: false,
}); });
const emits = defineEmits(['handleShowLoginPopup']);
watch(() => props.goodsDetailData, (newVla : any) => { watch(() => props.goodsDetailData, (newVla : any) => {
if (newVla) { if (newVla) {
state.isFav = newVla.isFav; state.isFav = newVla.isFav;
} }
}); });
const handleToggleGoodsCollection = async () => { const handleToggleGoodsCollection = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(async () => {
emits('handleShowLoginPopup'); const goodsCollection = await queryGoodsCollection({ id: props.goodsDetailData.id });
return; if (goodsCollection.status) {
} state.isFav = !state.isFav;
handleShowToast(goodsCollection.msg, 'success');
const goodsCollection = await queryGoodsCollection({ id: props.goodsDetailData.id }); } else {
if (goodsCollection.status) { handleShowToast(goodsCollection.msg);
state.isFav = !state.isFav; }
handleShowToast(goodsCollection.msg, 'success'); });
} else {
handleShowToast(goodsCollection.msg);
}
} }
/** 分享弹框显示与否 */ /** 分享弹框显示与否 */
const handleToggleShowShare = () => { const handleToggleShowShare = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
emits('handleShowLoginPopup'); state.showShare = !state.showShare;
return; });
}
state.showShare = !state.showShare;
} }
</script> </script>

View File

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

View File

@@ -1,28 +1,27 @@
<template> <template>
<view class="layout-home-page page-bg"> <coreshop-page :isBack="false" bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<image class="home-bg" :src="handleStaticResources('/static/images/home-bg.jpg')"></image> <view class="layout-home-page page-bg">
<uv-navbar :title="shopConfigStore.config?.shopName" <image class="home-bg" :src="handleStaticResources('/static/images/home-bg.jpg')"></image>
:bg-color="state.isScrollTop ? handleStaticResources('/static/images/home-bg.jpg') : 'rgba(0,0,0,0)'" <uv-navbar :title="shopConfigStore.config?.shopName"
imgMode="aspectFill" :titleStyle="{'color':'#fff','font-size':'32rpx'}"> :bg-color="state.isScrollTop ? handleStaticResources('/static/images/home-bg.jpg') : 'rgba(0,0,0,0)'"
<template #left> imgMode="aspectFill" :titleStyle="{'color':'#fff','font-size':'32rpx'}">
<uv-icon name="search" size="22" color="#fff" @click="handleSearch"></uv-icon> <template #left>
</template> <uv-icon name="search" size="22" color="#fff" @click="handleSearch"></uv-icon>
</uv-navbar> </template>
</uv-navbar>
<view class="content-box p-25" :style="{ 'padding-top': `${statusBarHeight + 10}px` }"> <view class="content-box p-25" :style="{ 'padding-top': `${statusBarHeight + 10}px` }">
<CustomPage :coreshopData="state.coreshopData" @handleShowLoginPopup="handleShowLoginPopup"></CustomPage> <CustomPage :coreshopData="state.coreshopData">
</CustomPage>
</view>
<!-- 备案信息 -->
<coreshop-copyright></coreshop-copyright>
<!-- 弹框广告 -->
<HomeAdpop></HomeAdpop>
</view> </view>
</coreshop-page>
<!-- 备案信息 -->
<coreshop-copyright></coreshop-copyright>
<!-- 弹框广告 -->
<HomeAdpop></HomeAdpop>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -37,7 +36,7 @@
import { UserToken } from '@/core/consts'; import { UserToken } from '@/core/consts';
import { useUserInfoStore, useShopConfigStore } from '@/core/store'; import { useUserInfoStore, useShopConfigStore } from '@/core/store';
// 获取项目配置 /** 获取项目配置 */
const shopConfigStore = useShopConfigStore(); const shopConfigStore = useShopConfigStore();
/** 获取自定义导航栏高度 */ /** 获取自定义导航栏高度 */
@@ -49,11 +48,9 @@
const state = reactive<{ const state = reactive<{
coreshopData : Array<PageConfigItemsType>; coreshopData : Array<PageConfigItemsType>;
isScrollTop : boolean; isScrollTop : boolean;
showLoginModal:boolean;
}>({ }>({
coreshopData: [], coreshopData: [],
isScrollTop: false, isScrollTop: false,
showLoginModal:false,
}) })
const getPageConfig = async () => { const getPageConfig = async () => {
@@ -76,16 +73,6 @@
} }
}) })
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 显示登录弹框*/
const handleShowLoginPopup = ()=>{
state.showLoginModal = true;
}
/** 获取用户信息 */ /** 获取用户信息 */
const getUserInfo = async () => { const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo(); const userInfo : Response<UserInfoType> = await queryUserInfo();

View File

@@ -1,20 +1,17 @@
:deep(.layout-page-content) { .member-head{
&::before { position: relative;
position: absolute; .memeber-bg{
left: 0;
top: -50px;
display: block; display: block;
content: ''; width: 750rpx;
width: 100%; height: 600rpx;
height: 685rpx;
background: #d33123 url(/static/images/member/bg.png);
background-size: cover;
} }
} }
.head-box {
position: relative;
margin-top: -20rpx;
.head-box {
position: absolute;
bottom: 13rpx;
left: 0;
width: 100%;
.user-info { .user-info {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -86,24 +83,12 @@
} }
} }
.member-box { .member-box {
position: relative;
.bg {
display: block;
width: 100%;
height: 100rpx;
}
.member-content { .member-content {
position: absolute;
left: 50%;
top: 44%;
transform: translate(-50%, -50%);
width: 88%; width: 88%;
margin: auto;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.content { .content {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -1,67 +1,70 @@
<template> <template>
<coreshop-page :title="state.isScrollToTop ? '' : state.userInfo?.nickName || ''" titleColor="#fff" mode="left" <coreshop-page :title="state.isScrollToTop ? '' : userInfoStore.userInfo?.nickName || ''" titleColor="#fff"
:bgColor=" state.isScrollToTop ? 'rgba(0,0,0,0)':'#d33123'" :isBack="false"> mode="left" :bgColor=" state.isScrollToTop ? 'rgba(0,0,0,0)':'#d33123'" :isShowStatusBarHeight="false"
:isBack="false" showLoginModalDom>
<view class="layout-member-page"> <view class="layout-member-page">
<view class="head-box m-b-10"> <view class="member-head">
<view class="user-info"> <image class="memeber-bg" src="/static/images/member/bg.png"></image>
<view class="img-box"> <view class="head-box m-b-10">
<image class="img" <view class="user-info">
:src="handleStaticResources(state.userInfo?.avatarImage || '/static/images/common/empty.png')"> <view class="img-box">
</image> <image class="img"
</view> :src="handleStaticResources(userInfoStore.userInfo?.avatarImage || '/static/images/common/empty.png')">
<template v-if="Object.keys(state.userInfo).length > 0">
<view class="info-box">
<view class="name">{{ state.userInfo?.nickName }}</view>
<view class="price">我的余额{{ state.userInfo?.balance || 0 }}</view>
</view>
<view class="icon-box"
@click="handleRouteNavigateTo(`/pages/subpackage/member/set/userInfo/userInfo`)">
<image class="icon" :src="handleStaticResources('/static/images/member/icon-right.png')">
</image> </image>
</view> </view>
</template> <template v-if="Object.keys(userInfoStore.userInfo).length > 0">
<template v-else> <view class="info-box">
<view class="info-box"> <view class="name">{{ userInfoStore.userInfo?.nickName }}</view>
<view class="login" @click="handleLogin">立即登录</view> <view class="price">我的余额{{ userInfoStore.userInfo?.balance || 0 }}</view>
</view>
</template>
</view>
<view class="user-info-num-box">
<view class="item" @click="handleJumpPage('/pages/subpackage/member/footprint/footprint')">
<view class="num">{{ state.userInfo?.footPrintCount || 0 }}</view>
<view class="tit">足迹</view>
</view>
<view class="item" @click="handleJumpPage('/pages/subpackage/member/coupon/coupon')">
<view class="num">{{ state.userInfo?.userCouponCount || 0 }}</view>
<view class="tit">优惠券</view>
</view>
<view class="item" @click="handleJumpPage('/pages/subpackage/member/collection/collection')">
<view class="num">{{ state.userInfo?.collectionCount || 0 }}</view>
<view class="tit">收藏</view>
</view>
<view class="item" @click="handleJumpPage('/pages/subpackage/member/afterSales/list/list')">
<view class="num">{{ state?.afterSaleNums || 0 }}</view>
<view class="tit">售后</view>
</view>
</view>
<view class="member-box">
<image class="bg" :src="handleStaticResources('/static/images/member/member-bg.png')"></image>
<view class="member-content">
<view class="content">
<view class="grade">{{ state.userInfo?.gradeName || '普通会员' }}</view>
<view class="integral">
我的{{ shopConfigStore?.config?.pointShowName || '积分' }}{{ state.userInfo?.point || 0 }}
</view> </view>
<view class="icon-box"
@click="handleRouteNavigateTo(`/pages/subpackage/member/set/userInfo/userInfo`)">
<image class="icon"
:src="handleStaticResources('/static/images/member/icon-right.png')">
</image>
</view>
</template>
<template v-else>
<view class="info-box">
<view class="login" @click="handleLogin">立即登录</view>
</view>
</template>
</view>
<view class="user-info-num-box">
<view class="item" @click="handleJumpPage('/pages/subpackage/member/footprint/footprint')">
<view class="num">{{ userInfoStore.userInfo?.footPrintCount || 0 }}</view>
<view class="tit">足迹</view>
</view> </view>
<view class="view-detail" <view class="item" @click="handleJumpPage('/pages/subpackage/member/coupon/coupon')">
@click="handleJumpPage('/pages/subpackage/member/integral/integral')"> <view class="num">{{ userInfoStore.userInfo?.userCouponCount || 0 }}</view>
<text class="tit">查看详情</text> <view class="tit">优惠券</view>
<uv-icon name="arrow-right" size="13" color="#292B2E"></uv-icon> </view>
<view class="item" @click="handleJumpPage('/pages/subpackage/member/collection/collection')">
<view class="num">{{ userInfoStore.userInfo?.collectionCount || 0 }}</view>
<view class="tit">收藏</view>
</view>
<view class="item" @click="handleJumpPage('/pages/subpackage/member/afterSales/list/list')">
<view class="num">{{ state?.afterSaleNums || 0 }}</view>
<view class="tit">售后</view>
</view>
</view>
<view class="member-box">
<view class="member-content">
<view class="content">
<view class="grade">{{ userInfoStore.userInfo?.gradeName || '普通会员' }}</view>
<view class="integral">
我的{{ shopConfigStore?.config?.pointShowName || '积分' }}{{ userInfoStore.userInfo?.point || 0 }}
</view>
</view>
<view class="view-detail"
@click="handleJumpPage('/pages/subpackage/member/integral/integral')">
<text class="tit">查看详情</text>
<uv-icon name="arrow-right" size="13" color="#292B2E"></uv-icon>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="p-20"> <view class="p-20">
<!-- 我的订单 --> <!-- 我的订单 -->
<view class="view-box"> <view class="view-box">
@@ -88,8 +91,7 @@
<view class="desc">最高提现20元</view> <view class="desc">最高提现20元</view>
</view> </view>
</view> </view>
<view class="item" <view class="item" @click="handleJumpPage(`/pages/subpackage/member/invite/invite/invite`)">
@click="handleJumpPage(`/pages/subpackage/member/invite/invite/invite`)">
<image class="img" :src="handleStaticResources('/static/images/member/invitation-02.png')"> <image class="img" :src="handleStaticResources('/static/images/member/invitation-02.png')">
</image> </image>
<view class="tit-desc"> <view class="tit-desc">
@@ -142,9 +144,6 @@
</view> </view>
</view> </view>
</view> </view>
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
@@ -154,15 +153,21 @@
import { onPageScroll, onShow } from '@dcloudio/uni-app'; import { onPageScroll, onShow } from '@dcloudio/uni-app';
import { handleStaticResources, handleRouteNavigateTo, handleShowToast } from '@/core/utils'; import { handleStaticResources, handleRouteNavigateTo, handleShowToast } from '@/core/utils';
import { queryUserInfo, queryOrderStatusNum, queryUserIsClerk } from '@/core/api'; import { queryUserInfo, queryOrderStatusNum, queryUserIsClerk } from '@/core/api';
import type { Response, MemberOrderType, UserInfoType, UserIsClerkType ,MemberServiceType} from '@/core/models'; import type { Response, MemberOrderType, UserInfoType, UserIsClerkType, MemberServiceType } from '@/core/models';
import { useShopConfigStore } from '@/core/store'; import { useShopConfigStore, useUserInfoStore, useLoginStore } from '@/core/store';
import { ShowVasEnum, ShowInviterEnum, OrderTabStatusEnum ,MemberPageNameEnum} from '@/core/enum'; import { ShowVasEnum, ShowInviterEnum, OrderTabStatusEnum, MemberPageNameEnum } from '@/core/enum';
import { useNavHook } from './use-nav-hook'; import { useNavHook } from './use-nav-hook';
import { UserToken } from '@/core/consts' import { UserToken } from '@/core/consts'
/** 获取项目配置 */ /** 获取项目配置 */
const shopConfigStore = useShopConfigStore(); const shopConfigStore = useShopConfigStore();
/** 用户数据store */
const userInfoStore = useUserInfoStore();
/** 登录store */
const _useLoginStore = useLoginStore();
/** 获取服务导航 */ /** 获取服务导航 */
const { getNav, navState } = useNavHook(); const { getNav, navState } = useNavHook();
getNav(); getNav();
@@ -170,16 +175,12 @@
const state = reactive<{ const state = reactive<{
orderList : Array<MemberOrderType>; orderList : Array<MemberOrderType>;
afterSaleNums : number; afterSaleNums : number;
userInfo : UserInfoType,
userIsClerk : UserIsClerkType, userIsClerk : UserIsClerkType,
showLoginModal : boolean;
isScrollToTop : boolean, isScrollToTop : boolean,
}>({ }>({
orderList: navState.orderList, orderList: navState.orderList,
afterSaleNums: 0, afterSaleNums: 0,
userInfo: {},
userIsClerk: {}, userIsClerk: {},
showLoginModal: false,
isScrollToTop: true, isScrollToTop: true,
}) })
@@ -202,7 +203,7 @@
const getUserInfo = async () => { const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo(); const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) { if (userInfo.status) {
state.userInfo = userInfo?.data; userInfoStore.setUserInfo(userInfo?.data);
getUserIsClerk(); getUserIsClerk();
} else { } else {
handleShowToast(userInfo.msg) handleShowToast(userInfo.msg)
@@ -231,7 +232,7 @@
/** 去登录 */ /** 去登录 */
const handleLogin = () => { const handleLogin = () => {
// #ifdef MP-ALIPAY || MP-WEIXIN // #ifdef MP-ALIPAY || MP-WEIXIN
state.showLoginModal = !state.showLoginModal; _useLoginStore.setShowLoginModalTogglePop(true);
// #endif // #endif
// #ifndef MP-WEIXIN || MP-ALIPAY // #ifndef MP-WEIXIN || MP-ALIPAY
@@ -239,30 +240,23 @@
// #endif // #endif
} }
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 跳转页面 */ /** 跳转页面 */
const handleJumpPage = (url:string)=>{ const handleJumpPage = (url : string) => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; handleRouteNavigateTo(url);
return ; });
}
handleRouteNavigateTo(url);
} }
/** 分类服务跳转页面 */ /** 分类服务跳转页面 */
const handleClassifyServiceJumpPage = (item:MemberServiceType)=>{ const handleClassifyServiceJumpPage = (item : MemberServiceType) => {
/** 判断签到,系统设置 */ /** 判断签到,系统设置 */
if(item.name == MemberPageNameEnum.checkIn || item.name == MemberPageNameEnum.setting){ if (item.name == MemberPageNameEnum.checkIn || item.name == MemberPageNameEnum.setting) {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; handleRouteNavigateTo(item.url);
return ; })
} } else {
handleRouteNavigateTo(item.url);
} }
handleRouteNavigateTo(item.url);
} }
</script> </script>

View File

@@ -85,7 +85,6 @@
weeks_ch : Array<string>; weeks_ch : Array<string>;
dataSource : Array<any>; dataSource : Array<any>;
sumCount : number; sumCount : number;
showLoginModal : boolean;
}>({ }>({
days: [], days: [],
SignUp: [], SignUp: [],
@@ -97,7 +96,6 @@
weeks_ch: ['日', '一', '二', '三', '四', '五', '六'], weeks_ch: ['日', '一', '二', '三', '四', '五', '六'],
dataSource: [], //已签到的数据源 dataSource: [], //已签到的数据源
sumCount: 0, sumCount: 0,
showLoginModal: false,
}); });
onLoad(() => { onLoad(() => {

View File

@@ -1,11 +1,11 @@
<template> <template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false"> <coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<view class="goods-detail"> <view class="goods-detail">
<!-- 商品详情 --> <!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc" :swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.group" :goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.group"
@hanldeShowGoodSku="hanldeShowGoodSku" @handleShowLoginPopup="handleShowLoginPopup"> @hanldeShowGoodSku="hanldeShowGoodSku">
<template #tip> <template #tip>
<view class="tip-box" v-if="state.showTip && state.goodsDetailData.groupPromotionResult"> <view class="tip-box" v-if="state.showTip && state.goodsDetailData.groupPromotionResult">
<view class="title">当前团购活动规则</view> <view class="title">当前团购活动规则</view>
@@ -57,20 +57,17 @@
:isShowAddCartBtn="false" btnBuyTitlt="立即团购" @handleChangePopup="handleChangePopup" :isShowAddCartBtn="false" btnBuyTitlt="立即团购" @handleChangePopup="handleChangePopup"
@handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup> @handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import { queryActivityDetial, queryCartNum, queryShare, queryAddCart, queryUserInfo } from '@/core/api'; import { queryActivityDetial, queryCartNum, queryShare, queryAddCart } from '@/core/api';
import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
import type { Response, UserInfoType } from '@/core/models'; import type { Response } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts' import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useUserInfoStore } from '@/core/store'; import { useCartStore, useLoginStore } from '@/core/store';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; import GoodsDetail from '@/pages/components/goods-detail/index.vue';
@@ -82,9 +79,10 @@
id : number; id : number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
/** 购物车store */
const cartStore = useCartStore(); const cartStore = useCartStore();
const state = reactive<{ const state = reactive<{
@@ -96,7 +94,6 @@
id : number; id : number;
showTip : boolean; showTip : boolean;
spesDesc : string; spesDesc : string;
showLoginModal : boolean;
timeData : { timeData : {
days : number, days : number,
hours : number, hours : number,
@@ -112,7 +109,6 @@
id: 0, id: 0,
showTip: true, showTip: true,
spesDesc: "", spesDesc: "",
showLoginModal: false,
timeData: { timeData: {
days: 0, days: 0,
hours: 0, hours: 0,
@@ -175,11 +171,9 @@
/** 立即购买打开sku弹框 */ /** 立即购买打开sku弹框 */
const hanldeShowGoodSku = () => { const hanldeShowGoodSku = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; state.showSku = true;
return; });
}
state.showSku = true;
} }
/** 立即秒杀 */ /** 立即秒杀 */
@@ -200,26 +194,6 @@
} }
} }
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
/** 获取分享url */ /** 获取分享url */
const getShareUrl = async () => { const getShareUrl = async () => {
let data = { let data = {

View File

@@ -1,9 +1,9 @@
<template> <template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false"> <coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<view class="goods-detail"> <view class="goods-detail">
<!-- 商品详情 --> <!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan" @handleShowLoginPopup="handleShowLoginPopup" :swiperBanner="state.swiperBanner" :shareType="ShareEnum.pinTuan"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true"> :goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true">
<template #activityGoodsOtheService> <template #activityGoodsOtheService>
<view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0"> <view class="pinTuan-record" v-if="state.goodsDetailData?.pinTuanRecord?.length > 0">
@@ -65,20 +65,16 @@
:isShowAddCartBtn="false" @handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow" :isShowAddCartBtn="false" @handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow"
:btnBuyTitlt="state.btnBuyTitlt"> :btnBuyTitlt="state.btnBuyTitlt">
</GoodsDetailSkuPopup> </GoodsDetailSkuPopup>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { queryPinTuanGoodsDetail, queryUserInfo, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api'; import { queryPinTuanGoodsDetail, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api';
import type { Response, UserInfoType } from '@/core/models'; import type { Response } from '@/core/models';
import { UserToken } from '@/core/consts' import { UserToken } from '@/core/consts'
import { useCartStore, useUserInfoStore } from '@/core/store'; import { useCartStore, useLoginStore } from '@/core/store';
import { PaymentTypeEnum, ShareEnum } from '@/core/enum'; import { PaymentTypeEnum, ShareEnum } from '@/core/enum';
import { handleRouteNavigateTo, handleShowToast } from '@/core/utils'; import { handleRouteNavigateTo, handleShowToast } from '@/core/utils';
import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js'; import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
@@ -93,8 +89,8 @@
teamId ?: number; teamId ?: number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
/** 获取购物车数据 */ /** 获取购物车数据 */
const cartStore = useCartStore(); const cartStore = useCartStore();
@@ -112,7 +108,6 @@
isSingleBuy : boolean; isSingleBuy : boolean;
btnBuyTitlt : string; btnBuyTitlt : string;
teamInfo : any; teamInfo : any;
showLoginModal : boolean;
}>({ }>({
id: 0, id: 0,
goodsDetailData: {}, goodsDetailData: {},
@@ -126,7 +121,6 @@
isSingleBuy: true, isSingleBuy: true,
btnBuyTitlt: "发起拼团", btnBuyTitlt: "发起拼团",
teamInfo: {}, teamInfo: {},
showLoginModal: false,
}); });
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
@@ -193,28 +187,24 @@
/** 单独购买 */ /** 单独购买 */
const handleSingleBuy = () => { const handleSingleBuy = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; state.teamId = 0;
return; state.showSku = true;
} state.isSingleBuy = true;
state.teamId = 0; state.btnBuyTitlt = '单独购买';
state.showSku = true; state.goodsDetailData.skuList.sku_list = state.defaultSkuList;
state.isSingleBuy = true; });
state.btnBuyTitlt = '单独购买';
state.goodsDetailData.skuList.sku_list = state.defaultSkuList;
} }
/** 拼团购买 */ /** 拼团购买 */
const handleMultipleBuy = () => { const handleMultipleBuy = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; state.teamId = 0;
return; state.showSku = true;
} state.isSingleBuy = false;
state.teamId = 0; state.btnBuyTitlt = '发起拼团';
state.showSku = true; state.goodsDetailData.skuList.sku_list = state.activitySkuList;
state.isSingleBuy = false; });
state.btnBuyTitlt = '发起拼团';
state.goodsDetailData.skuList.sku_list = state.activitySkuList;
} }
/** 去拼单 */ /** 去拼单 */
@@ -272,26 +262,6 @@
handleShowToast(addCart.msg); handleShowToast(addCart.msg);
} }
} }
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './detail.scss'; @import './detail.scss';

View File

@@ -1,9 +1,9 @@
<template> <template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false"> <coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<view class="goods-detail"> <view class="goods-detail">
<!-- 商品详情 --> <!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc" @handleShowLoginPopup="handleShowLoginPopup" :swiperBanner="state.swiperBanner" :spesDesc="state.spesDesc"
:goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.seckill" :goodsDetailContent="state.goodsDetailContent" :isActivityGoods="true" :shareType="ShareEnum.seckill"
@hanldeShowGoodSku="hanldeShowGoodSku"> @hanldeShowGoodSku="hanldeShowGoodSku">
<template #tip> <template #tip>
@@ -56,10 +56,6 @@
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
:isShowAddCartBtn="false" btnBuyTitlt="立即秒杀" @handleChangePopup="handleChangePopup" :isShowAddCartBtn="false" btnBuyTitlt="立即秒杀" @handleChangePopup="handleChangePopup"
@handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup> @handleBuyNow="handleSeckillNow"></GoodsDetailSkuPopup>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
@@ -70,7 +66,7 @@
import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
import type { Response, UserInfoType } from '@/core/models'; import type { Response, UserInfoType } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts' import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useUserInfoStore } from '@/core/store'; import { useCartStore, useUserInfoStore ,useLoginStore} from '@/core/store';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; import GoodsDetail from '@/pages/components/goods-detail/index.vue';
@@ -82,8 +78,8 @@
id : number; id : number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
const cartStore = useCartStore(); const cartStore = useCartStore();
@@ -96,7 +92,6 @@
id : number; id : number;
showTip : boolean; showTip : boolean;
spesDesc : string; spesDesc : string;
showLoginModal : boolean;
timeData : { timeData : {
days : number, days : number,
hours : number, hours : number,
@@ -112,7 +107,6 @@
id: 0, id: 0,
showTip: true, showTip: true,
spesDesc: "", spesDesc: "",
showLoginModal: false,
timeData: { timeData: {
days: 0, days: 0,
hours: 0, hours: 0,
@@ -175,11 +169,9 @@
/** 立即购买打开sku弹框 */ /** 立即购买打开sku弹框 */
const hanldeShowGoodSku = () => { const hanldeShowGoodSku = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; state.showSku = true;
return; });
}
state.showSku = true;
} }
/** 立即秒杀 */ /** 立即秒杀 */
@@ -200,26 +192,6 @@
} }
} }
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
/** 获取分享url */ /** 获取分享url */
const getShareUrl = async () => { const getShareUrl = async () => {
let data = { let data = {

View File

@@ -1,5 +1,5 @@
<template> <template>
<coreshop-page title="接龙详情" mode="left" bgColor="#D33123" titleColor="#fff"> <coreshop-page title="接龙详情" mode="left" bgColor="#D33123" titleColor="#fff" showLoginModalDom>
<view class="layout-solitaire-box"> <view class="layout-solitaire-box">
<view class="config-box"> <view class="config-box">
<image class="img" :src="shopConfigStore?.config?.shopLogo"></image> <image class="img" :src="shopConfigStore?.config?.shopLogo"></image>
@@ -92,34 +92,29 @@
<!-- 分享弹框 --> <!-- 分享弹框 -->
<CoreshopShare :show="state.showShare" :shareType="ShareEnum.solitaire" <CoreshopShare :show="state.showShare" :shareType="ShareEnum.solitaire"
:goodsDetailData="state.solitaireInfo" @handleClosePopup="handleToggleShowShare"></CoreshopShare> :goodsDetailData="state.solitaireInfo" @handleClosePopup="handleToggleShowShare"></CoreshopShare>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import { querySolitaireDetail, queryShare, queryAddCart, queryRemoveCart, queryUserInfo } from '@/core/api'; import { querySolitaireDetail, queryShare, queryAddCart, queryRemoveCart } from '@/core/api';
import { ShareClientEnum, ShareModelEnum, ShareEnum, EmptyEnum, PaymentTypeEnum, AddCartEnum } from '@/core/enum'; import { ShareClientEnum, ShareModelEnum, ShareEnum, EmptyEnum, PaymentTypeEnum, AddCartEnum } from '@/core/enum';
import type { Response, UserInfoType } from '@/core/models'; import type { Response } from '@/core/models';
import { UserToken, shareUrl } from '@/core/consts' import { UserToken, shareUrl } from '@/core/consts'
import { useShopConfigStore, useUserInfoStore } from '@/core/store'; import { useShopConfigStore, useLoginStore } from '@/core/store';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js'; import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue'; import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue';
interface QueryParams { interface QueryParams {
id : number; id : number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
// 获取项目配置 /** 获取项目配置 */
const shopConfigStore = useShopConfigStore(); const shopConfigStore = useShopConfigStore();
const state = reactive<{ const state = reactive<{
@@ -130,7 +125,6 @@
totalprice : number; totalprice : number;
shareUrl : string; shareUrl : string;
showShare : boolean; showShare : boolean;
showLoginModal : boolean;
}>({ }>({
id: 0, id: 0,
solitaireInfo: {}, solitaireInfo: {},
@@ -139,7 +133,6 @@
totalprice: 0, totalprice: 0,
shareUrl: "", shareUrl: "",
showShare: false, showShare: false,
showLoginModal: false,
}); });
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
@@ -207,29 +200,27 @@
/**立即购买 */ /**立即购买 */
const handleBuyNow = () => { const handleBuyNow = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; if (state.totalprice == 0) {
return; handleShowToast('请先选择商品');
} return;
if (state.totalprice == 0) { }
handleShowToast('请先选择商品'); if (state.totalprice < state.solitaireInfo.startBuyPrice) {
return; handleShowToast(`最小购买价格为${state.solitaireInfo.startBuyPrice}元,请增加购买产品`)
} return true
if (state.totalprice < state.solitaireInfo.startBuyPrice) { }
handleShowToast(`最小购买价格为${state.solitaireInfo.startBuyPrice}元,请增加购买产品`) let ids : Array<number> = [];
return true state.goodsData.forEach((item : any) => {
} if (item.num > 0) {
let ids : Array<number> = []; ids.push(item.addCardId)
state.goodsData.forEach((item : any) => { }
if (item.num > 0) { });
ids.push(item.addCardId) if (ids.length > 0) {
handleRouteNavigateTo(`/pages/subpackage/order/submit/submit?orderType=${PaymentTypeEnum.solitaire}&objectId=${state.id}&cartIds=${ids.join(',')}`)
} else {
handleShowToast('请先选择商品');
} }
}); });
if (ids.length > 0) {
handleRouteNavigateTo(`/pages/subpackage/order/submit/submit?orderType=${PaymentTypeEnum.solitaire}&objectId=${state.id}&cartIds=${ids.join(',')}`)
} else {
handleShowToast('请先选择商品');
}
} }
/** 联系商家 */ /** 联系商家 */
@@ -241,21 +232,6 @@
} }
} }
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
/** 获取分享url */ /** 获取分享url */
const getShareUrl = async () => { const getShareUrl = async () => {
let data = { let data = {
@@ -280,11 +256,9 @@
/** 分享弹框显示与否 */ /** 分享弹框显示与否 */
const handleToggleShowShare = () => { const handleToggleShowShare = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => {
state.showLoginModal = true; state.showShare = !state.showShare;
return; })
}
state.showShare = !state.showShare;
} }
/** 分享 */ /** 分享 */

View File

@@ -1,5 +1,5 @@
<template> <template>
<coreshop-page title="优惠券" mode="left"> <coreshop-page title="优惠券" mode="left" showLoginModalDom>
<view> <view>
<view class="content-box p-25" v-if="state.couponList.length > 0"> <view class="content-box p-25" v-if="state.couponList.length > 0">
<view v-for="item, index in state.couponList" :key="index" class="coupon-box"> <view v-for="item, index in state.couponList" :key="index" class="coupon-box">
@@ -52,39 +52,32 @@
<view v-else class="layout-empty-box"> <view v-else class="layout-empty-box">
<coreshop-empty :mode="EmptyEnum.coupon" text="暂无优惠券可领取"></coreshop-empty> <coreshop-empty :mode="EmptyEnum.coupon" text="暂无优惠券可领取"></coreshop-empty>
</view> </view>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, onMounted } from 'vue'; import { reactive, onMounted } from 'vue';
import { queryCouponList, queryReceiveCoupon, queryUserInfo } from '@/core/api'; import { queryCouponList, queryReceiveCoupon } from '@/core/api';
import { onReachBottom } from '@dcloudio/uni-app'; import { onReachBottom } from '@dcloudio/uni-app';
import type { Response, UserInfoType } from '@/core/models'; import type { Response } from '@/core/models';
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js'; import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
import { handleStaticResources, handleShowToast } from '@/core/utils'; import { handleStaticResources, handleShowToast } from '@/core/utils';
import { EmptyEnum } from '@/core/enum'; import { EmptyEnum } from '@/core/enum';
import { UserToken } from '@/core/consts' import { useLoginStore } from '@/core/store';
import { useUserInfoStore } from '@/core/store';
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
const state = reactive<{ const state = reactive<{
couponList : Array<any>; couponList : Array<any>;
totalPages : number; totalPages : number;
page : number; page : number;
limit : number; limit : number;
showLoginModal : boolean;
}>({ }>({
couponList: [], couponList: [],
totalPages: 1, totalPages: 1,
page: 1, page: 1,
limit: 10, limit: 10,
showLoginModal: false,
}) })
onMounted(() => { onMounted(() => {
@@ -118,21 +111,19 @@
}) })
/** 立即领取 */ /** 立即领取 */
const handleReceiveCoupon = async (id : number) => { const handleReceiveCoupon = (id : number) => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(async () => {
state.showLoginModal = true; uni.showLoading({
return; title: '加载中',
} });
uni.showLoading({ const receiveCoupon = await queryReceiveCoupon({ id, });
title: '加载中', uni.hideLoading();
}); if (receiveCoupon.status) {
const receiveCoupon = await queryReceiveCoupon({ id, }); handleShowToast('领取成功', 'success');
uni.hideLoading(); } else {
if (receiveCoupon.status) { handleShowToast(receiveCoupon.msg);
handleShowToast('领取成功', 'success'); }
} else { })
handleShowToast(receiveCoupon.msg);
}
} }
/** 查看使用规则 */ /** 查看使用规则 */
@@ -146,21 +137,6 @@
state.couponList[index].showRules = false; state.couponList[index].showRules = false;
state.couponList[index].showDiscount = !state.couponList[index].showDiscount; state.couponList[index].showDiscount = !state.couponList[index].showDiscount;
} }
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './coupon.scss'; @import './coupon.scss';

View File

@@ -1,5 +1,5 @@
<template> <template>
<coreshop-page :title="state.formInfo?.name || '表单详情'" mode="left"> <coreshop-page :title="state.formInfo?.name || '表单详情'" mode="left" showLoginModalDom>
<view class="layout-form-box"> <view class="layout-form-box">
<view class="form-head"> <view class="form-head">
<view class="swiper" <view class="swiper"
@@ -128,24 +128,21 @@
<view class="btn-box" @click="handleSubmit"> <view class="btn-box" @click="handleSubmit">
<view class="p-20"> <view class="p-20">
<view class="btn" :style="{ 'background-color': state.formInfo?.buttonColor }"> <view class="btn" :style="{ 'background-color': state.formInfo?.buttonColor }">
{{ state.formInfo?.buttonName }}</view> {{ state.formInfo?.buttonName }}
</view>
</view> </view>
</view> </view>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import { queryFormDetial, queryUploadImages, queryAddSubmit, queryShare ,queryUserInfo} from '@/core/api'; import { queryFormDetial, queryUploadImages, queryAddSubmit, queryShare } from '@/core/api';
import type { Response, CityAddressType ,UserInfoType} from '@/core/models'; import type { Response, CityAddressType } from '@/core/models';
import { handleShowToast, handleStaticResources, handleRouteRedirectTo, handleRouteSwitchTab, chooseImage, getSetting } from '@/core/utils'; import { handleShowToast, handleStaticResources, handleRouteRedirectTo, handleRouteSwitchTab, chooseImage, getSetting } from '@/core/utils';
import { queryAreas } from '@/core/api'; import { queryAreas } from '@/core/api';
import { useUserInfoStore } from '@/core/store'; import { useLoginStore } from '@/core/store';
import { UserToken, shareUrl } from '@/core/consts'; import { UserToken, shareUrl } from '@/core/consts';
import { FormHeadEnum, ShareClientEnum, ShareEnum, ShareModelEnum, FormTypeEnum, PaymentTypeEnum } from '@/core/enum'; import { FormHeadEnum, ShareClientEnum, ShareEnum, ShareModelEnum, FormTypeEnum, PaymentTypeEnum } from '@/core/enum';
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js'; import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
@@ -155,8 +152,8 @@
id : number; id : number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
const datePicker = ref(); const datePicker = ref();
const timePicker = ref(); const timePicker = ref();
@@ -171,7 +168,6 @@
goodsDetailData : any; goodsDetailData : any;
paymentType : number, paymentType : number,
shareUrl : string; shareUrl : string;
showLoginModal:boolean;
}>({ }>({
formInfo: {}, formInfo: {},
id: 0, id: 0,
@@ -182,7 +178,6 @@
goodsDetailData: {}, goodsDetailData: {},
paymentType: 0, paymentType: 0,
shareUrl: "", shareUrl: "",
showLoginModal:false,
}) })
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
@@ -255,21 +250,6 @@
} }
} }
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
/** 获取分享url */ /** 获取分享url */
const getShareUrl = async () => { const getShareUrl = async () => {
let data = { let data = {
@@ -403,60 +383,58 @@
} }
/** 按钮提交 */ /** 按钮提交 */
const handleSubmit = async () => { const handleSubmit = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(async () => {
state.showLoginModal = true;
return;
}
let data = state.formInfo.items.find((item : any) => item.required && !item.defaultValue); let data = state.formInfo.items.find((item : any) => item.required && !item.defaultValue);
if (data) { if (data) {
handleShowToast(`${data.name}不能为空`); return; handleShowToast(`${data.name}不能为空`); return;
}
/** 判断图片的 */
let images = state.formInfo.items.find((item : any) => item.type === FormTypeEnum.image && item.required && item.defaultValue.length == 0);
if (images) {
handleShowToast(`${images.name}不能为空`); return;
}
/** 判断商品的 */
let goods = state.formInfo.items.find((item : any) => item.type === FormTypeEnum.goods && item.required && item.defaultValue.length == 0);
if (goods) {
handleShowToast(`${goods.name}不能为空`); return;
}
let submitData = state.formInfo.items.map((item : any) => {
if (item.type === FormTypeEnum.image) {
return {
key: item.id,
value: item.defaultValue.join(',')
}
} else {
return {
key: item.id,
value: item.defaultValue
}
} }
});
const form : Response<any> = await queryAddSubmit({ /** 判断图片的 */
data: submitData, let images = state.formInfo.items.find((item : any) => item.type === FormTypeEnum.image && item.required && item.defaultValue.length == 0);
id: state.id, if (images) {
token: uni.getStorageSync(UserToken) handleShowToast(`${images.name}不能为空`); return;
}); }
if (form.status) {
handleShowToast(form.msg, 'success', () => { /** 判断商品的 */
setTimeout(() => { let goods = state.formInfo.items.find((item : any) => item.type === FormTypeEnum.goods && item.required && item.defaultValue.length == 0);
if (state.formInfo.type == 1 || state.formInfo.type == 2) { if (goods) {
handleRouteRedirectTo(`/pages/subpackage/order/pay/pay?formId=${form.data.formSubmitId}&orderType=${state.paymentType}&recharge=${form.data.money}`); handleShowToast(`${goods.name}不能为空`); return;
} else { }
handleRouteSwitchTab();
let submitData = state.formInfo.items.map((item : any) => {
if (item.type === FormTypeEnum.image) {
return {
key: item.id,
value: item.defaultValue.join(',')
} }
}, 1000) } else {
}) return {
} else { key: item.id,
handleShowToast(form.msg) value: item.defaultValue
} }
}
});
const form : Response<any> = await queryAddSubmit({
data: submitData,
id: state.id,
token: uni.getStorageSync(UserToken)
});
if (form.status) {
handleShowToast(form.msg, 'success', () => {
setTimeout(() => {
if (state.formInfo.type == 1 || state.formInfo.type == 2) {
handleRouteRedirectTo(`/pages/subpackage/order/pay/pay?formId=${form.data.formSubmitId}&orderType=${state.paymentType}&recharge=${form.data.money}`);
} else {
handleRouteSwitchTab();
}
}, 1000)
})
} else {
handleShowToast(form.msg)
}
})
} }
/** 分享 */ /** 分享 */

View File

@@ -1,12 +1,12 @@
<template> <template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false"> <coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<view class=" goods-detail"> <view class=" goods-detail">
<!-- 商品详情 --> <!-- 商品详情 -->
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent" :swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent"
:userAgentGrade="state.userAgentGrade" :agentProductsList="state.agentProductsList" :userAgentGrade="state.userAgentGrade" :agentProductsList="state.agentProductsList"
:goodsPromotionList="state.goodsPromotionList" :spesDesc="state.spesDesc" :goodsPromotionList="state.goodsPromotionList" :spesDesc="state.spesDesc"
@hanldeShowGoodSku="hanldeShowGoodSku" @handleShowLoginPopup="handleShowLoginPopup"> @hanldeShowGoodSku="hanldeShowGoodSku">
</GoodsDetail> </GoodsDetail>
<!-- 为您推荐 --> <!-- 为您推荐 -->
@@ -15,16 +15,11 @@
<!-- 商品sku弹框 --> <!-- 商品sku弹框 -->
<GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData" <GoodsDetailSkuPopup :showSku="state.showSku" :goodsDetailData="state.goodsDetailData"
@handleAddCart="handleAddCart" @handleChangeGoodSku="handleChangeGoodSku" :safeAreaInsetBottom="false" @handleAddCart="handleAddCart" @handleChangeGoodSku="handleChangeGoodSku" :safeAreaInsetBottom="false"
@handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow" @handleChangePopup="handleChangePopup" @handleBuyNow="handleBuyNow"></GoodsDetailSkuPopup>
@handleShowLoginPopup="handleShowLoginPopup"></GoodsDetailSkuPopup>
<!-- 底部导航按钮 --> <!-- 底部导航按钮 -->
<GoodsDetailBottomTabbar :price="state.skuPrice" @handleAddCart="hanldeShowGoodSku" <GoodsDetailBottomTabbar :price="state.skuPrice" @handleAddCart="hanldeShowGoodSku"
@handleBuyNow="hanldeShowGoodSku"></GoodsDetailBottomTabbar> @handleBuyNow="hanldeShowGoodSku"></GoodsDetailBottomTabbar>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
@@ -33,25 +28,26 @@
import { reactive } from 'vue'; import { reactive } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import { queryGoodsDetail, queryCartNum, queryShare, queryGoodsDetailByToken, queryPromotionList, queryAddCart, queryUserInfo } from '@/core/api'; import { queryGoodsDetail, queryCartNum, queryShare, queryGoodsDetailByToken, queryPromotionList, queryAddCart, queryUserInfo } from '@/core/api';
import type { UserInfoType, Response, GoodsAgentListType, GoodsPromotionType, GoodsSkuListType } from "@/core/models"; import type { Response, GoodsAgentListType, GoodsPromotionType, GoodsSkuListType } from "@/core/models";
import { PromotionEnum, AddCartEnum, PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; import { PromotionEnum, AddCartEnum, PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
import { UserToken, shareUrl } from '@/core/consts' import { UserToken, shareUrl } from '@/core/consts'
import { useCartStore, useUserInfoStore } from '@/core/store'; import { useCartStore } from '@/core/store';
import { handleRouteNavigateTo, handleShowToast } from '@/core/utils'; import { handleRouteNavigateTo, handleShowToast } from '@/core/utils';
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; import GoodsDetail from '@/pages/components/goods-detail/index.vue';
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue'; import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue'; import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue'; import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
import { useLoginStore } from '@/core/store';
interface QueryParams { interface QueryParams {
id : number; id : number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
const cartStore = useCartStore(); /** 购物车store */
const _useCartStore = useCartStore();
const state = reactive<{ const state = reactive<{
goodsDetailData : any; goodsDetailData : any;
@@ -64,7 +60,6 @@
showSku : boolean; showSku : boolean;
skuPrice : Number; skuPrice : Number;
shareUrl : string; shareUrl : string;
showLoginModal : boolean;
}>({ }>({
goodsDetailData: {}, goodsDetailData: {},
swiperBanner: [], swiperBanner: [],
@@ -76,7 +71,6 @@
showSku: false, showSku: false,
skuPrice: 0, skuPrice: 0,
shareUrl: "", shareUrl: "",
showLoginModal: false,
}) })
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
@@ -139,7 +133,7 @@
/** 获取购物车数量 */ /** 获取购物车数量 */
const getCartNum = async () => { const getCartNum = async () => {
const num : Response<number> = await queryCartNum(); const num : Response<number> = await queryCartNum();
cartStore.setCartNum(num?.data || 0); _useCartStore.setCartNum(num?.data || 0);
} }
/** 获取商品促销列表 */ /** 获取商品促销列表 */
@@ -152,11 +146,7 @@
/** 立即购买打开sku弹框 */ /** 立即购买打开sku弹框 */
const hanldeShowGoodSku = () => { const hanldeShowGoodSku = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(() => state.showSku = true);
state.showLoginModal = true;
return;
}
state.showSku = true;
} }
/** sku弹框显示隐藏 */ /** sku弹框显示隐藏 */
@@ -179,6 +169,7 @@
}); });
if (addCart.status) { if (addCart.status) {
handleShowToast(addCart.msg, 'success'); handleShowToast(addCart.msg, 'success');
/** 添加成功后,重新获取购物车数量 */ /** 添加成功后,重新获取购物车数量 */
getCartNum(); getCartNum();
/** 关闭sku弹框 */ /** 关闭sku弹框 */
@@ -205,26 +196,6 @@
} }
} }
/** 显示登录弹框 */
const handleShowLoginPopup = () => {
state.showLoginModal = true;
}
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
/** 获取分享url */ /** 获取分享url */
const getShareUrl = async (goodsId : number) => { const getShareUrl = async (goodsId : number) => {
let data = { let data = {

View File

@@ -38,7 +38,7 @@
import { queryGoodsBrowsing, queryDelGoodsBrowsing, queryGoodsCollection } from '@/core/api'; import { queryGoodsBrowsing, queryDelGoodsBrowsing, queryGoodsCollection } from '@/core/api';
import type { Response, GoodsFootprintType } from '@/core/models'; import type { Response, GoodsFootprintType } from '@/core/models';
import { EmptyEnum } from '@/core/enum'; import { EmptyEnum } from '@/core/enum';
import { handleShowToast } from '@/core/utils'; import { handleShowToast, showToast } from '@/core/utils';
const state = reactive<{ const state = reactive<{
list : Array<GoodsFootprintType>; list : Array<GoodsFootprintType>;

View File

@@ -1,5 +1,5 @@
<template> <template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false"> <coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" showLoginModalDom>
<view class="layout-goods-detail"> <view class="layout-goods-detail">
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent" :swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent"
@@ -77,22 +77,17 @@
</view> </view>
</template> </template>
</GoodsDetailBottomTabbar> </GoodsDetailBottomTabbar>
<!-- 登录弹框 -->
<coreshop-login-modal :show="state.showLoginModal" @handleChangePopup="handleChangeLoginPopup"
@getUserInfo="getUserInfo"></coreshop-login-modal>
</view> </view>
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import type { Response, ServiceGoodsType ,UserInfoType} from '@/core/models'; import type { Response, ServiceGoodsType } from '@/core/models';
import { queryServiceDetail, queryAddServiceOrder ,queryUserInfo} from '@/core/api'; import { queryServiceDetail, queryAddServiceOrder } from '@/core/api';
import { ServiceGoodsOpenEnum, ShareEnum, PaymentTypeEnum } from '@/core/enum'; import { ServiceGoodsOpenEnum, ShareEnum, PaymentTypeEnum } from '@/core/enum';
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils'; import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
import { useUserInfoStore } from '@/core/store'; import { useUserInfoStore, useLoginStore } from '@/core/store';
import { UserToken } from '@/core/consts'
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; import GoodsDetail from '@/pages/components/goods-detail/index.vue';
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue'; import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue'; import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
@@ -101,21 +96,19 @@
id : number; id : number;
} }
/** 获取用户数据 */ /** 登录store */
const userInfoStore = useUserInfoStore(); const _useLoginStore = useLoginStore();
const state = reactive<{ const state = reactive<{
id : number; id : number;
goodsDetailData : ServiceGoodsType, goodsDetailData : ServiceGoodsType,
swiperBanner : Array<string>; swiperBanner : Array<string>;
goodsDetailContent : string; goodsDetailContent : string;
showLoginModal:boolean;
}>({ }>({
id: 0, id: 0,
goodsDetailData: {}, goodsDetailData: {},
swiperBanner: [], swiperBanner: [],
goodsDetailContent: "", goodsDetailContent: "",
showLoginModal:false,
}); });
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
@@ -157,35 +150,16 @@
} }
/** 立即购买 */ /** 立即购买 */
const handleBuyNow = async () => { const handleBuyNow = () => {
if (!uni.getStorageSync(UserToken)) { _useLoginStore.checkLogin(async () => {
state.showLoginModal = true; const serviceOrder : Response<any> = await queryAddServiceOrder({ id: state.id });
return; if (serviceOrder.status) {
} handleRouteNavigateTo(`/pages/subpackage/order/pay/pay?orderId=${serviceOrder.data}&orderType=${PaymentTypeEnum.serviceOrder}&serviceId=${state.id}`);
} else {
const serviceOrder : Response<any> = await queryAddServiceOrder({ id: state.id }); handleShowToast(serviceOrder.msg)
if (serviceOrder.status) { }
handleRouteNavigateTo(`/pages/subpackage/order/pay/pay?orderId=${serviceOrder.data}&orderType=${PaymentTypeEnum.serviceOrder}&serviceId=${state.id}`); })
} else {
handleShowToast(serviceOrder.msg)
}
} }
/** 打开获取关闭login弹框 */
const handleChangeLoginPopup = (isShow : boolean) => {
state.showLoginModal = isShow;
}
/** 获取用户信息 */
const getUserInfo = async () => {
const userInfo : Response<UserInfoType> = await queryUserInfo();
if (userInfo.status) {
userInfoStore.setUserInfo(userInfo?.data);
} else {
handleShowToast(userInfo.msg)
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './detail.scss'; @import './detail.scss';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB