Compare commits

...

2 Commits

Author SHA1 Message Date
@zuopngfei
98c6fe4c4a weew 2025-11-11 18:38:30 +08:00
@zuopngfei
386e2238ea weew 2025-11-11 18:35:49 +08:00

View File

@ -17,10 +17,14 @@ Page({
total: 0,
isAtBottom: true,
loadingMore: false,
showNewMessageTip: false,
newMessageCount: 0,
lastMessageId: '',
hasWelcomeMessageSent: false,
// 新消息提醒
showNewMessageTip: false, // 是否显示新消息提醒
newMessageCount: 0, // 新消息数量
lastMessageId: '', // 最后一条消息的ID用于检测新消息
// 欢迎消息标记
hasWelcomeMessageSent: false, // 是否已发送欢迎消息
// 订阅消息
template_id: '',
},
onLoad(options) {
const accountInfo = wx.getAccountInfoSync();
@ -41,6 +45,33 @@ Page({
} else {
this.silentLogin();
}
this.getTemplateId();
},
// onShow() {
// this.getMessages()
// },
getTemplateId() {
const accountInfo = wx.getAccountInfoSync();
request('wechat/template', 'post', {
app_id: accountInfo.miniProgram.appId
}).then((res) => {
this.setData({
template_id: res.template_id
});
});
},
dingyue() {
return new Promise((resolve, reject) => {
wx.requestSubscribeMessage({
tmplIds: [this.data.template_id],
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
}
});
});
},
getMessages() {
@ -368,9 +399,11 @@ Page({
}, 50);
},
sendText() {
async sendText() {
const text = this.data.inputText && this.data.inputText.trim();
if (!text) return;
const res = await this.dingyue()
const now = new Date();
const id = 'u' + Date.now();
const msg = {
@ -411,7 +444,9 @@ Page({
}, 50);
},
chooseImage() {
async chooseImage() {
const resDy = await this.dingyue()
console.log(resDy);
const that = this;
wx.chooseImage({
count: 1,