解决项目第一次进去默认需要登录而不是去往主程序首页问题

This commit is contained in:
胥林川 2025-08-26 10:20:14 +08:00
parent ab511f863e
commit 32556723bb
6 changed files with 53 additions and 18 deletions

View File

@ -48,11 +48,14 @@ router.beforeEach(async (to, from, next) => {
} }
} }
} else { } else {
if (whiteList.indexOf(to.path) !== -1) {
next(); next();
} else {
next(`/login?redirect=${to.path}`); // if (whiteList.indexOf(to.path) !== -1) {
} // next();
// } else {
// next(`/login?redirect=${to.path}`);
// }
} }
}); });

View File

@ -42,14 +42,17 @@ router.beforeEach(async (to, from, next) => {
} else { } else {
NProgress.done(); NProgress.done();
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
next(); // next();
window.location.href = `/login?redirect=${encodeURIComponent(to.fullPath)}`;
} else { } else {
if (qiankunWindow.__POWERED_BY_QIANKUN__) { // if (qiankunWindow.__POWERED_BY_QIANKUN__) {
window.location.href = VITE_APP_MIAN_URL; // window.location.href = VITE_APP_MIAN_URL;
return; // return;
} // }
next(`/login?redirect=${to.path}`); // next(`/login?redirect=${to.path}`);
window.location.href = `/login?redirect=${encodeURIComponent(to.fullPath)}`;
} }
} }
}); });

View File

@ -17,7 +17,7 @@
<el-badge :hidden="goodNum < 1" :value="goodNum" :max="99" class="item" :offset="[-3, 10]"> <el-badge :hidden="goodNum < 1" :value="goodNum" :max="99" class="item" :offset="[-3, 10]">
<div style="display: flex" @click="toCart"> <div style="display: flex" @click="toCart">
<div class="iconfont icon-shopcar" style="font-size: 14px; margin: 0 5px; color: #25bf82; font-weight: bold"></div> <div class="iconfont icon-shopcar" style="font-size: 14px; margin: 0 5px; color: #25bf82; font-weight: bold"></div>
<div></div> <div>购车</div>
</div> </div>
</el-badge> </el-badge>
<el-badge :hidden="true" :value="0" :max="99" class="item" :offset="[-3, 10]"> <el-badge :hidden="true" :value="0" :max="99" class="item" :offset="[-3, 10]">

View File

@ -48,7 +48,8 @@ router.beforeEach(async (to, from, next) => {
} }
} else { } else {
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
next(); // next();
window.location.href = `/login?redirect=${encodeURIComponent(to.fullPath)}`;
} else { } else {
next(`/login?redirect=${to.path}`); next(`/login?redirect=${to.path}`);
} }

View File

@ -26,6 +26,34 @@
</div> </div>
<div class="tips-list"> <div class="tips-list">
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="24">
<div style="display: flex; justify-content: flex-start">
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div style="display: flex; justify-content: flex-start">
<div style="margin-right: 16px">
<p style="width: 100%; line-height: 20px">
<span></span>
<span style="font-size: 24px; font-weight: bold">{{ currentGood.priceRange?.[0] }}</span>
</p>
<p style="width: 100%; line-height: 20px; font-size: 12px; color: #ccc">{{ currentGood.numberRange?.[0] }}</p>
</div>
<div style="margin-right: 16px">
<p style="width: 100%; line-height: 20px">
<span></span>
<span style="font-size: 24px; font-weight: bold">{{ currentGood.priceRange?.[1] }}</span>
</p>
<p style="width: 100%; line-height: 20px; font-size: 12px; color: #ccc">{{ currentGood.numberRange?.[1] }}</p>
</div>
<div style="margin-right: 16px">
<p style="width: 100%; line-height: 20px">
<span></span>
<span style="font-size: 24px; font-weight: bold">{{ currentGood.priceRange?.[2] }}</span>
</p>
<p style="width: 100%; line-height: 20px; font-size: 12px; color: #ccc">{{ currentGood.numberRange?.[2] }}</p>
</div>
</div>
</div>
</el-col>
<el-col :span="24">发货地址{{ currentGood.detailAddress }}</el-col> <el-col :span="24">发货地址{{ currentGood.detailAddress }}</el-col>
<el-col :span="24" <el-col :span="24"
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{
@ -35,7 +63,7 @@
</el-row> </el-row>
</div> </div>
<div class="spu-sku-list"> <div class="spu-sku-list">
<div class="spu-title"></div> <div class="spu-title">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="spu-sku-warp"> <div class="spu-sku-warp">
<div <div
v-for="(item, index) in currentGood.netWeight" v-for="(item, index) in currentGood.netWeight"
@ -58,10 +86,10 @@
</div> </div>
<div class="top-btn"> <div class="top-btn">
<div class="item-btn sign" @click="buyGood"> <div class="item-btn sign" @click="buyGood">
<span>立即</span> <span>立即</span>
</div> </div>
<div class="item-btn reservation" @click="addGoodToCart"> <div class="item-btn reservation" @click="addGoodToCart">
<span>入购物</span> <span>采购</span>
</div> </div>
<div class="contact" @click="showPhone = true"> <div class="contact" @click="showPhone = true">
<div><img :src="getAssetsFile('images/ecommerce/contact.png')" alt="" width="15" /></div> <div><img :src="getAssetsFile('images/ecommerce/contact.png')" alt="" width="15" /></div>

View File

@ -8,9 +8,9 @@
<div class="goods-name txt-ellipsis clamp2">{{ data.goodName }}</div> <div class="goods-name txt-ellipsis clamp2">{{ data.goodName }}</div>
<div class="goods-do"> <div class="goods-do">
<div class="price txt-ellipsis clamp">{{ data.goodPrice }}</div> <div class="price txt-ellipsis clamp">{{ data.goodPrice }}</div>
<div class="do" @click.stop="openDialog(data)"> <!-- <div class="do" @click.stop="openDialog(data)">
<div class="iconfont icon-cart"></div> <div class="iconfont icon-cart"></div>
</div> </div> -->
</div> </div>
</div> </div>
<el-dialog v-model="centerDialogVisible" title="Warning" width="80%" align-center :show-close="false" style="border-radius: 16px"> <el-dialog v-model="centerDialogVisible" title="Warning" width="80%" align-center :show-close="false" style="border-radius: 16px">