Compare commits

...

2 Commits

Author SHA1 Message Date
@zuopngfei
26563409c9 wewe 2025-11-27 18:18:37 +08:00
@zuopngfei
d13d026852 wewe 2025-11-27 09:38:39 +08:00
4 changed files with 55 additions and 27 deletions

View File

@ -20,12 +20,12 @@ function request(url, method = 'GET', data = {}) {
header,
success(res) {
if (res.data.code) {
if (res.data.code == 10103 || res.data.code == 10104) {
if (res.data.code == 10103 || res.data.code == 10101) {
wx.removeStorageSync('access_token');
// wx.navigateTo({
// url: '/pages/login/login',
// url: '/pages/login/index',
// });
reject(res.data);
// reject(res.data);
return;
}
wx.showToast({

View File

@ -216,7 +216,7 @@
</view>
</view>
</view>
<view class="logout-btn">退出登录</view>
<view class="logout-btn" @click="logout">退出登录</view>
</view>
<view class="quick-card">
<view class="quick-title">快捷功能</view>
@ -797,6 +797,12 @@ export default {
uni.navigateTo({
url: '/pages/my/editInfo/index'
});
},
logout() {
wx.removeStorageSync('access_token');
uni.reLaunch({
url: '/pages/login/index'
});
}
}
};

View File

@ -605,11 +605,22 @@ export default {
//
goToCart() {
const token = await uni.getStorageSync('access_token')
if (!token) {
uni.navigateTo({
url: '/pages/login/index'
})
return
}
uni.navigateTo({
url: '/pages/shoppingCart/index'
});
},
async fetchCartSelectedCount() {
const token = await uni.getStorageSync('access_token')
if (!token) {
return
}
try {
const res = await request('xcx/carts', 'GET', { page: 1, page_size: 99 });
const list = res.list || res.data || res || [];

View File

@ -19,7 +19,8 @@
<view class="item-price-row">
<view class="item-price">
<text class="price-symbol"></text>
<text class="price-value">{{ formatPrice(item.price) || formatPrice(item.sku_price) }}</text>
<text class="price-value">{{ formatPrice(item.price) || formatPrice(item.sku_price)
}}</text>
</view>
<view class="item-count">
<view class="count-btn" @click="decreaseCount(index)">-</view>
@ -101,13 +102,23 @@ export default {
}
},
onLoad() {
this.loadCartList();
this.getUserIsLogin();
},
onShow() {
//
this.loadCartList();
this.getUserIsLogin();
},
methods: {
async getUserIsLogin() {
const token = await uni.getStorageSync('access_token')
if (token) {
//
this.loadCartList();
} else {
uni.navigateTo({
url: '/pages/login/index'
})
}
},
formatPrice(value) {
if (!value) {
return 0.00;