Compare commits
2 Commits
a99c3884e2
...
26563409c9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26563409c9 | ||
|
|
d13d026852 |
@ -20,12 +20,12 @@ function request(url, method = 'GET', data = {}) {
|
|||||||
header,
|
header,
|
||||||
success(res) {
|
success(res) {
|
||||||
if (res.data.code) {
|
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.removeStorageSync('access_token');
|
||||||
// wx.navigateTo({
|
// wx.navigateTo({
|
||||||
// url: '/pages/login/login',
|
// url: '/pages/login/index',
|
||||||
// });
|
// });
|
||||||
reject(res.data);
|
// reject(res.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
|
|||||||
@ -216,7 +216,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="logout-btn">退出登录</view>
|
<view class="logout-btn" @click="logout">退出登录</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="quick-card">
|
<view class="quick-card">
|
||||||
<view class="quick-title">快捷功能</view>
|
<view class="quick-title">快捷功能</view>
|
||||||
@ -797,6 +797,12 @@ export default {
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/my/editInfo/index'
|
url: '/pages/my/editInfo/index'
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
logout() {
|
||||||
|
wx.removeStorageSync('access_token');
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/login/index'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -605,11 +605,22 @@ export default {
|
|||||||
|
|
||||||
// 跳转到购物车
|
// 跳转到购物车
|
||||||
goToCart() {
|
goToCart() {
|
||||||
|
const token = await uni.getStorageSync('access_token')
|
||||||
|
if (!token) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/login/index'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/shoppingCart/index'
|
url: '/pages/shoppingCart/index'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async fetchCartSelectedCount() {
|
async fetchCartSelectedCount() {
|
||||||
|
const token = await uni.getStorageSync('access_token')
|
||||||
|
if (!token) {
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await request('xcx/carts', 'GET', { page: 1, page_size: 99 });
|
const res = await request('xcx/carts', 'GET', { page: 1, page_size: 99 });
|
||||||
const list = res.list || res.data || res || [];
|
const list = res.list || res.data || res || [];
|
||||||
|
|||||||
@ -19,7 +19,8 @@
|
|||||||
<view class="item-price-row">
|
<view class="item-price-row">
|
||||||
<view class="item-price">
|
<view class="item-price">
|
||||||
<text class="price-symbol">¥</text>
|
<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>
|
||||||
<view class="item-count">
|
<view class="item-count">
|
||||||
<view class="count-btn" @click="decreaseCount(index)">-</view>
|
<view class="count-btn" @click="decreaseCount(index)">-</view>
|
||||||
@ -101,13 +102,23 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.loadCartList();
|
this.getUserIsLogin();
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
// 页面显示时刷新购物车
|
this.getUserIsLogin();
|
||||||
this.loadCartList();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async getUserIsLogin() {
|
||||||
|
const token = await uni.getStorageSync('access_token')
|
||||||
|
if (token) {
|
||||||
|
// 页面显示时刷新购物车
|
||||||
|
this.loadCartList();
|
||||||
|
} else {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/login/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
formatPrice(value) {
|
formatPrice(value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return 0.00;
|
return 0.00;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user