Compare commits
2 Commits
1c2e924fcd
...
98c6fe4c4a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98c6fe4c4a | ||
|
|
386e2238ea |
@ -17,10 +17,14 @@ Page({
|
|||||||
total: 0,
|
total: 0,
|
||||||
isAtBottom: true,
|
isAtBottom: true,
|
||||||
loadingMore: false,
|
loadingMore: false,
|
||||||
showNewMessageTip: false,
|
// 新消息提醒
|
||||||
newMessageCount: 0,
|
showNewMessageTip: false, // 是否显示新消息提醒
|
||||||
lastMessageId: '',
|
newMessageCount: 0, // 新消息数量
|
||||||
hasWelcomeMessageSent: false,
|
lastMessageId: '', // 最后一条消息的ID,用于检测新消息
|
||||||
|
// 欢迎消息标记
|
||||||
|
hasWelcomeMessageSent: false, // 是否已发送欢迎消息
|
||||||
|
// 订阅消息
|
||||||
|
template_id: '',
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const accountInfo = wx.getAccountInfoSync();
|
const accountInfo = wx.getAccountInfoSync();
|
||||||
@ -41,6 +45,33 @@ Page({
|
|||||||
} else {
|
} else {
|
||||||
this.silentLogin();
|
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() {
|
getMessages() {
|
||||||
@ -368,9 +399,11 @@ Page({
|
|||||||
}, 50);
|
}, 50);
|
||||||
},
|
},
|
||||||
|
|
||||||
sendText() {
|
async sendText() {
|
||||||
|
|
||||||
const text = this.data.inputText && this.data.inputText.trim();
|
const text = this.data.inputText && this.data.inputText.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
const res = await this.dingyue()
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const id = 'u' + Date.now();
|
const id = 'u' + Date.now();
|
||||||
const msg = {
|
const msg = {
|
||||||
@ -411,7 +444,9 @@ Page({
|
|||||||
}, 50);
|
}, 50);
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseImage() {
|
async chooseImage() {
|
||||||
|
const resDy = await this.dingyue()
|
||||||
|
console.log(resDy);
|
||||||
const that = this;
|
const that = this;
|
||||||
wx.chooseImage({
|
wx.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user