Compare commits
2 Commits
1c2e924fcd
...
98c6fe4c4a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98c6fe4c4a | ||
|
|
386e2238ea |
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user