diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-page.vue b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-page.vue
index a456b3c0..013a4e51 100644
--- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-page.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-page/coreshop-page.vue
@@ -6,12 +6,19 @@
:style="{ 'padding-top': `${props.isShowStatusBarHeight ? statusBarHeight : 0}px`, ...props.contentStyle }">
+
+
+
\ No newline at end of file
diff --git a/CoreCms.Net.Uni-App/CoreShop/config/env.js b/CoreCms.Net.Uni-App/CoreShop/config/env.js
index 34c157a9..68e6b857 100644
--- a/CoreCms.Net.Uni-App/CoreShop/config/env.js
+++ b/CoreCms.Net.Uni-App/CoreShop/config/env.js
@@ -1,6 +1,6 @@
// 不同的环境变量配置
const development = {
- requestBaseUrl: 'https://api.pro.demo.corecms.cn',
+ requestBaseUrl: 'https://api.test.pro.coreshop.cn',
appid: '',
}
diff --git a/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts b/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts
index 6f01a561..57e9de48 100644
--- a/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts
+++ b/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts
@@ -1,2 +1,2 @@
/** 系统配置 */
-export * from './systemInfo';
\ No newline at end of file
+export * from './systemInfo';
diff --git a/CoreCms.Net.Uni-App/CoreShop/core/models/store.ts b/CoreCms.Net.Uni-App/CoreShop/core/models/store.ts
index 66bedcf2..73a8be02 100644
--- a/CoreCms.Net.Uni-App/CoreShop/core/models/store.ts
+++ b/CoreCms.Net.Uni-App/CoreShop/core/models/store.ts
@@ -11,4 +11,8 @@ export interface UserInfoStoreType {
export interface UserCartType {
cartNum ?: number
+}
+
+export interface UserLoginStoreType {
+ showLoginModalTogglePop ?: boolean
}
\ No newline at end of file
diff --git a/CoreCms.Net.Uni-App/CoreShop/core/store/index.ts b/CoreCms.Net.Uni-App/CoreShop/core/store/index.ts
index a544ae6e..6c99a87c 100644
--- a/CoreCms.Net.Uni-App/CoreShop/core/store/index.ts
+++ b/CoreCms.Net.Uni-App/CoreShop/core/store/index.ts
@@ -3,4 +3,8 @@ export * from './config';
/** 用户信息 */
export * from './userInfo';
/** 购物车 */
-export * from './cart';
\ No newline at end of file
+export * from './cart';
+/** 登录 */
+export * from './login';
+
+
diff --git a/CoreCms.Net.Uni-App/CoreShop/core/store/login.ts b/CoreCms.Net.Uni-App/CoreShop/core/store/login.ts
new file mode 100644
index 00000000..eae2f630
--- /dev/null
+++ b/CoreCms.Net.Uni-App/CoreShop/core/store/login.ts
@@ -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 = await queryUserInfo();
+ if (userInfo.status) {
+ userInfoStore.setUserInfo(userInfo?.data);
+ } else {
+ handleShowToast(userInfo.msg)
+ }
+ },
+ /** 设置登录弹框打开或者关闭 */
+ setShowLoginModalTogglePop(showLoginModalTogglePop : boolean) {
+ this.showLoginModalTogglePop = showLoginModalTogglePop;
+ },
+ },
+});
\ No newline at end of file
diff --git a/CoreCms.Net.Uni-App/CoreShop/core/utils/uni-promise.ts b/CoreCms.Net.Uni-App/CoreShop/core/utils/uni-promise.ts
index a88063bb..223d9b57 100644
--- a/CoreCms.Net.Uni-App/CoreShop/core/utils/uni-promise.ts
+++ b/CoreCms.Net.Uni-App/CoreShop/core/utils/uni-promise.ts
@@ -168,6 +168,18 @@ export const authorize = (options : UniNamespace.AuthorizeOptions) : Promise => {
+ return new Promise((success, fail) => {
+ uni.showToast({
+ ...options,
+ success,
+ fail
+ });
+ })
+}
+
+
+
export default {
request,
login,
@@ -184,5 +196,6 @@ export default {
getLocation,
getSetting,
openSetting,
- authorize
+ authorize,
+ showToast
}
\ No newline at end of file
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-five/classify-five.vue b/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-five/classify-five.vue
index a27eaa61..618b08d2 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-five/classify-five.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-five/classify-five.vue
@@ -126,6 +126,7 @@
import { reactive, watch, ref, onMounted, getCurrentInstance, nextTick } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { advertPosition, UserToken } from '@/core/consts';
+ import { useLoginStore } from '@/core/store';
import { queryGoodsPageList, queryCartNumAndMoney, queryGoodsDetailByToken, queryGoodsDetail, queryAddCart } from '@/core/api';
import type { CategoriesType, Response, GoodsListType, GoodsType } from '@/core/models';
import { getDomInfo, handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab } from '@/core/utils';
@@ -134,6 +135,9 @@
const instance = getCurrentInstance();
+ /** 登录store */
+ const _useLoginStore = useLoginStore();
+
const props = withDefaults(defineProps<{
data : Array,
height : number,
@@ -182,8 +186,6 @@
goodsDetailData: {},
});
- const emits = defineEmits(['handleShowLoginPopup']);
-
watch(() => props.data, (newVal : Array) => {
if (newVal) {
state.classifyData = newVal.map((item : CategoriesType) => {
@@ -202,7 +204,7 @@
state.rightTabList = state.classifyData[0]?.child[0]?.child;
state.catId = state.classifyData[0].child[0]?.id;
- getGoodsPageList();
+ getGoodsPageList();
}
})
@@ -215,13 +217,13 @@
}, 100)
})
})
-
- onShow(()=>{
+
+ onShow(() => {
if (uni.getStorageSync(UserToken)) {
getCartNumAndMoney();
}
});
-
+
// 获取商品列表数据
const getGoodsPageList = async () => {
uni.showLoading({
@@ -232,8 +234,10 @@
limit: 10,
where: `{"catId":${state.catId}}`
});
- state.totalPages = goodsPageList.data.totalPages;
- state.goodsList = state.goodsList.concat(goodsPageList.data.list);
+ if(goodsPageList.status){
+ state.totalPages = goodsPageList.data?.totalPages;
+ state.goodsList = state.goodsList.concat(goodsPageList.data?.list);
+ }
uni.hideLoading();
}
@@ -245,38 +249,34 @@
}
/** 选择sku */
- const handleSelectSku = async (id : number) => {
- let goodsDetail : any = null;
- if (uni.getStorageSync(UserToken)) {
- goodsDetail = await queryGoodsDetailByToken({
- id: id,
- data: true,
- })
- } else {
- goodsDetail = await queryGoodsDetail({
- id: id,
- data: true,
- })
- }
- state.goodsDetailData = goodsDetail.data;
- state.showSku = true;
+ const handleSelectSku = (id : number) => {
+ _useLoginStore.checkLogin(async () => {
+ let goodsDetail : any = null;
+ if (uni.getStorageSync(UserToken)) {
+ goodsDetail = await queryGoodsDetailByToken({
+ id: id,
+ data: true,
+ })
+ } else {
+ goodsDetail = await queryGoodsDetail({
+ id: id,
+ data: true,
+ })
+ }
+ state.goodsDetailData = goodsDetail.data;
+ state.showSku = true;
+ });
}
-
+
/** 底部按钮去结算 */
const handleGoPay = () => {
- if (!uni.getStorageSync(UserToken)) {
- emits('handleShowLoginPopup');
- return;
- }
- handleRouteSwitchTab(RouteSwitchTabEnum.cart);
+ _useLoginStore.checkLogin(() => {
+ handleRouteSwitchTab(RouteSwitchTabEnum.cart);
+ });
}
-
+
/** 添加购物车 */
const handleAddCart = async ({ productId, nums } : any) => {
- if (!uni.getStorageSync(UserToken)) {
- emits('handleShowLoginPopup');
- return;
- }
const addCart : Response = await queryAddCart({
productId,
nums,
@@ -295,10 +295,6 @@
/** 立即购买 */
const handleBuyNow = async ({ productId, nums } : any) => {
- if (!uni.getStorageSync(UserToken)) {
- emits('handleShowLoginPopup');
- return;
- }
const addCart : Response = await queryAddCart({
productId,
nums,
@@ -314,13 +310,12 @@
}
}
-
/** sku弹框显示隐藏 */
const handleChangePopup = (show : boolean) => {
state.showSku = show;
}
- // 切换顶部tab
+ /** 切换顶部tab */
const hanldeChangeTopTab = (item : CategoriesType, index : number) => {
if (state.leftTabId != item.id) {
state.topTabId = item.id;
@@ -335,16 +330,16 @@
}
}
- // 显示顶部大分类弹框
+ /** 显示顶部大分类弹框 */
const hanldeShowBigClassifyPop = () => {
bigClassifyPop.value.open();
}
- // 隐藏顶部大分类弹框
+ /** 隐藏顶部大分类弹框 */
const hanlderHidebigClassifyPop = () => {
bigClassifyPop.value.close();
}
- //计算顶部tab移动的距离
+ /** 计算顶部tab移动的距离 */
const calculationTopMovingDistance = (index : number) => {
let topScrollLeft = 0;
for (let i = 0; i < index - 1; i++) {
@@ -353,7 +348,7 @@
state.topScrollLeft = topScrollLeft
}
- // 切换左侧tab
+ /** 切换左侧tab */
const hanldeChangeLeftTab = (item : CategoriesType) => {
if (state.leftTabId != item.id) {
state.leftTabId = item.id;
@@ -363,13 +358,13 @@
}
}
- //切换右侧tab
+ /** 切换右侧tab */
const hanldeChangeRightTab = (item : CategoriesType) => {
state.catId = item.id;
handleResetGoodsList();
}
- // 组合商品数据传入组件
+ /** 组合商品数据传入组件 */
const hanldeCombinationGoodsData = (item : GoodsType) => {
return {
id: item.id,
@@ -389,7 +384,7 @@
})
}
- // 加载下一页数据
+ /** 加载下一页数据 */
const handleScrolltolower = () => {
if (state.totalPages > state.page) {
state.page++;
@@ -397,7 +392,7 @@
}
}
- // 重置商品列表数据
+ /** 重置商品列表数据 */
const handleResetGoodsList = () => {
state.page = 1;
state.goodsList = [];
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-four/classify-four.vue b/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-four/classify-four.vue
index 2dcb4a07..3b8d9803 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-four/classify-four.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/classify/classify-page/classify-four/classify-four.vue
@@ -77,14 +77,17 @@
\ No newline at end of file
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/components/goods-detail-info/goods-detail-info.vue b/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/components/goods-detail-info/goods-detail-info.vue
index 36338f8a..cf449ca7 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/components/goods-detail-info/goods-detail-info.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/components/goods-detail-info/goods-detail-info.vue
@@ -80,9 +80,12 @@
import { ShareEnum } from '@/core/enum';
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'
-
+ import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue';
+ import { useLoginStore } from '@/core/store';
+
+ /** 登录store */
+ const _useLoginStore = useLoginStore();
+
const props = withDefaults(defineProps<{
goodsDetailData : any,
isActivityGoods : boolean,
@@ -99,38 +102,31 @@
}>({
isFav: false,
showShare: false,
- });
-
- const emits = defineEmits(['handleShowLoginPopup']);
-
+ });
+
watch(() => props.goodsDetailData, (newVla : any) => {
if (newVla) {
state.isFav = newVla.isFav;
}
});
- 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;
- handleShowToast(goodsCollection.msg, 'success');
- } else {
- handleShowToast(goodsCollection.msg);
- }
+ const handleToggleGoodsCollection = () => {
+ _useLoginStore.checkLogin(async () => {
+ const goodsCollection = await queryGoodsCollection({ id: props.goodsDetailData.id });
+ if (goodsCollection.status) {
+ state.isFav = !state.isFav;
+ handleShowToast(goodsCollection.msg, 'success');
+ } else {
+ handleShowToast(goodsCollection.msg);
+ }
+ });
}
/** 分享弹框显示与否 */
const handleToggleShowShare = () => {
- if (!uni.getStorageSync(UserToken)) {
- emits('handleShowLoginPopup');
- return;
- }
- state.showShare = !state.showShare;
+ _useLoginStore.checkLogin(() => {
+ state.showShare = !state.showShare;
+ });
}
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/index.vue b/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/index.vue
index ce7086ee..4f3e60ca 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/index.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/components/goods-detail/index.vue
@@ -8,7 +8,7 @@
-
@@ -93,7 +93,7 @@
shareType: ShareEnum.index, /** 分享类型 - 默认分享首页 */
});
- const emits = defineEmits(['hanldeShowGoodSku', 'handleToggleGoodsCollection','handleShowLoginPopup']);
+ const emits = defineEmits(['hanldeShowGoodSku', 'handleToggleGoodsCollection']);
const state = reactive<{
commonQuestion : Array;
@@ -169,12 +169,7 @@
/** 商品收藏 */
const handleToggleGoodsCollection = () => {
emits('handleToggleGoodsCollection')
- }
-
- /** 显示登录弹框 */
- const handleShowLoginPopup = ()=>{
- emits('handleShowLoginPopup')
- }
+ }
\ No newline at end of file
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/home/home.vue b/CoreCms.Net.Uni-App/CoreShop/pages/home/home.vue
index 35b52924..fee2b800 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/home/home.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/home/home.vue
@@ -1,28 +1,27 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/checkIn/checkIn.vue b/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/checkIn/checkIn.vue
index 270a1de5..62097cbe 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/checkIn/checkIn.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/checkIn/checkIn.vue
@@ -85,7 +85,6 @@
weeks_ch : Array;
dataSource : Array;
sumCount : number;
- showLoginModal : boolean;
}>({
days: [],
SignUp: [],
@@ -97,7 +96,6 @@
weeks_ch: ['日', '一', '二', '三', '四', '五', '六'],
dataSource: [], //已签到的数据源
sumCount: 0,
- showLoginModal: false,
});
onLoad(() => {
diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/groupBuying/detail/detail.vue b/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/groupBuying/detail/detail.vue
index f35f90cf..95ee722a 100644
--- a/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/groupBuying/detail/detail.vue
+++ b/CoreCms.Net.Uni-App/CoreShop/pages/subpackage/activity/groupBuying/detail/detail.vue
@@ -1,11 +1,11 @@
-
+
+ @hanldeShowGoodSku="hanldeShowGoodSku">
当前团购活动规则:
@@ -57,20 +57,17 @@
:isShowAddCartBtn="false" btnBuyTitlt="立即团购" @handleChangePopup="handleChangePopup"
@handleBuyNow="handleSeckillNow">
-
-