Merge branch 'main' of https://git.1024tool.vip/xz/wx-chant into main
This commit is contained in:
commit
42565511df
BIN
pages/.DS_Store
vendored
Normal file
BIN
pages/.DS_Store
vendored
Normal file
Binary file not shown.
@ -35,9 +35,8 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
appid: accountInfo.miniProgram.appId,
|
appid: accountInfo.miniProgram.appId,
|
||||||
});
|
});
|
||||||
console.log('contact page onLoad, options:', options);
|
|
||||||
|
|
||||||
// this.getMessages()
|
// 检查是否已有用户信息
|
||||||
if (wx.getStorageSync('user_info')) {
|
if (wx.getStorageSync('user_info')) {
|
||||||
this.setData({
|
this.setData({
|
||||||
showGetUser: false,
|
showGetUser: false,
|
||||||
@ -47,16 +46,9 @@ Page({
|
|||||||
// start polling when page loads and user is present
|
// start polling when page loads and user is present
|
||||||
this.startPolling();
|
this.startPolling();
|
||||||
} else {
|
} else {
|
||||||
this.setData({
|
// 直接进行静默登录,不显示授权弹窗
|
||||||
showGetUser: true,
|
this.silentLogin();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.setData({
|
|
||||||
// appid: accountInfo.miniProgram.appId,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// console.log('appId',accountInfo.miniProgram);
|
|
||||||
},
|
},
|
||||||
// onShow() {
|
// onShow() {
|
||||||
// this.getMessages()
|
// this.getMessages()
|
||||||
@ -139,43 +131,43 @@ Page({
|
|||||||
that.setData({ loadingMore: false });
|
that.setData({ loadingMore: false });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
requestUserProfile(e) {
|
// 静默登录方法,只需要appid和js_code
|
||||||
console.log('user', e.detail);
|
silentLogin() {
|
||||||
const user = e.detail;
|
|
||||||
const that = this;
|
const that = this;
|
||||||
// wx.setStorageSync('user_info', e.detail.userInfo);
|
|
||||||
const accountInfo = wx.getAccountInfoSync();
|
const accountInfo = wx.getAccountInfoSync();
|
||||||
wx.login({
|
wx.login({
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
request('wechat/miniprogram/login', 'post', {
|
request('wechat/miniprogram/login', 'post', {
|
||||||
"app_id": accountInfo.miniProgram.appId,
|
"app_id": accountInfo.miniProgram.appId,
|
||||||
"js_code": res.code,
|
"js_code": res.code
|
||||||
"encrypted_data": user.encryptedData,
|
|
||||||
"iv": user.iv,
|
|
||||||
"raw_data": user.rawData,
|
|
||||||
"signature": user.signature
|
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
wx.setStorageSync('user_info', resp);
|
wx.setStorageSync('user_info', resp);
|
||||||
// wx.setStorageSync('open_id', resp.openid);
|
|
||||||
that.setData({
|
that.setData({
|
||||||
showGetUser: false,
|
showGetUser: false,
|
||||||
userInfo: resp
|
userInfo: resp
|
||||||
});
|
});
|
||||||
request('app/user/create', 'post', {
|
request('app/user/create', 'post', {
|
||||||
"app_id": accountInfo.miniProgram.appId,
|
"app_id": accountInfo.miniProgram.appId,
|
||||||
"user_avatar": resp.user_avatar,
|
"user_avatar": resp.user_avatar || '/static/user.png',
|
||||||
"user_id": resp.openid,
|
"user_id": resp.openid,
|
||||||
"user_name": resp.user_name
|
"user_name": resp.user_name || '微信用户'
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
that.getMessages()
|
that.getMessages()
|
||||||
// start polling once user info exists
|
// start polling once user info exists
|
||||||
that.startPolling();
|
that.startPolling();
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('静默登录失败:', err);
|
||||||
|
// 如果静默登录失败,可以选择显示授权弹窗或其他处理
|
||||||
|
that.setData({
|
||||||
|
showGetUser: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
fail: function(err) {
|
||||||
|
console.error('wx.login失败:', err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Start polling messages every 1 second. Ensures only one interval exists.
|
// Start polling messages every 1 second. Ensures only one interval exists.
|
||||||
@ -234,11 +226,7 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
dismissGetUser() {
|
|
||||||
this.setData({
|
|
||||||
showGetUser: false
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onReady() {
|
onReady() {
|
||||||
// 初始化欢迎消息,带时间分割线
|
// 初始化欢迎消息,带时间分割线
|
||||||
|
|||||||
@ -39,17 +39,12 @@
|
|||||||
<button class="btn-send" bindtap="sendText">发送</button>
|
<button class="btn-send" bindtap="sendText">发送</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 获取用户信息弹窗 -->
|
<!-- 静默登录中提示 -->
|
||||||
<block wx:if="{{showGetUser}}">
|
<block wx:if="{{showGetUser}}">
|
||||||
<view class="overlay">
|
<view class="overlay">
|
||||||
<view class="popup">
|
<view class="popup">
|
||||||
<text class="popup-title">授权获取您的用户信息</text>
|
<text class="popup-title">正在登录...</text>
|
||||||
<text class="popup-desc">授权后可用于显示头像、昵称等,提升聊天体验。</text>
|
<text class="popup-desc">请稍候,正在为您自动登录。</text>
|
||||||
<view class="popup-actions">
|
|
||||||
<button class="btn-primary" open-type="getUserInfo" bindgetuserinfo="requestUserProfile">获取用户信息</button>
|
|
||||||
|
|
||||||
<!-- <button class="btn-secondary" bindtap="dismissGetUser">稍后再说</button> -->
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
|||||||
@ -144,5 +144,19 @@ Page({
|
|||||||
danceIndex: nextIndex,
|
danceIndex: nextIndex,
|
||||||
currentDance: danceList[nextIndex]
|
currentDance: danceList[nextIndex]
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
handleContact() {
|
||||||
|
wx.requestSubscribeMessage({
|
||||||
|
tmplIds: ['9dCV3z7vRPBGm8iMtSXsD7ZVyUjld46w7HTH9zLnzWw'],
|
||||||
|
success: (res) => {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/contact/index`
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -9,14 +9,14 @@
|
|||||||
></image>
|
></image>
|
||||||
|
|
||||||
<!-- 客服跳转导航:url 拼接 appId,与 JS 中 appId 变量对齐 -->
|
<!-- 客服跳转导航:url 拼接 appId,与 JS 中 appId 变量对齐 -->
|
||||||
<navigator
|
<view
|
||||||
url="/pages/contact/index{{ appId ? ('?app_id=' + appId) : '' }}"
|
bindtap="handleContact"
|
||||||
style="position:fixed; width:80%; margin-left:10%; bottom:240rpx; color:#fff; background:#ec6d23; border-radius:15rpx; height:75rpx; display:flex; justify-content:center; align-items:center; margin-top:50rpx; z-index:9999; text-decoration:none;"
|
style="position:fixed; width:80%; margin-left:10%; bottom:240rpx; color:#fff; background:#ec6d23; border-radius:15rpx; height:75rpx; display:flex; justify-content:center; align-items:center; margin-top:50rpx; z-index:9999; text-decoration:none;"
|
||||||
>
|
>
|
||||||
<view style="width:100%; height:100%; display:flex; justify-content:center; align-items:center; color:#fff;">
|
<view style="width:100%; height:100%; display:flex; justify-content:center; align-items:center; color:#fff;">
|
||||||
欢迎联系人工客服
|
欢迎联系人工客服
|
||||||
</view>
|
</view>
|
||||||
</navigator>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 2. 舞蹈详情区域(对应原逻辑中 wallpaperUrl≠1 的场景) -->
|
<!-- 2. 舞蹈详情区域(对应原逻辑中 wallpaperUrl≠1 的场景) -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user