Initial commit
This commit is contained in:
@@ -3,12 +3,20 @@ const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
coupons: [],
|
||||
user: {}
|
||||
user: {},
|
||||
loading: true
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchCoupons();
|
||||
},
|
||||
onShow() {
|
||||
// Optimistically update from global data
|
||||
if (app.globalData.userInfo && app.globalData.userInfo.phone) {
|
||||
this.setData({
|
||||
user: app.globalData.userInfo,
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
this.getUserInfo();
|
||||
this.fetchCoupons();
|
||||
},
|
||||
@@ -19,12 +27,14 @@ Page({
|
||||
// Fetch latest user info from backend to check if phone exists in DB
|
||||
request({ url: '/user/' }).then(user => {
|
||||
app.globalData.userInfo = user; // Sync global data
|
||||
this.setData({ user: user });
|
||||
this.setData({ user: user, loading: false });
|
||||
}).catch(err => {
|
||||
console.error('Failed to fetch user info', err)
|
||||
// Fallback to global data if fetch fails
|
||||
if (app.globalData.userInfo) {
|
||||
this.setData({ user: app.globalData.userInfo });
|
||||
this.setData({ user: app.globalData.userInfo, loading: false });
|
||||
} else {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</view>
|
||||
|
||||
<!-- VIP Banner -->
|
||||
<view class="vip-banner" wx:if="{{!user.phone}}">
|
||||
<view class="vip-banner" wx:if="{{!loading && !user.phone}}">
|
||||
<view class="vip-info">
|
||||
<view class="vip-title">VIP会员权益</view>
|
||||
<view class="vip-desc">开通会员享受更多优惠</view>
|
||||
|
||||
Reference in New Issue
Block a user