Compare commits
No commits in common. "98c6fe4c4a5cf39c8f31e345aea8b30192b5802d" and "1c2e924fcd71857a3f965651efb04fc27ab12481" have entirely different histories.
98c6fe4c4a
...
1c2e924fcd
@ -17,14 +17,10 @@ Page({
|
|||||||
total: 0,
|
total: 0,
|
||||||
isAtBottom: true,
|
isAtBottom: true,
|
||||||
loadingMore: false,
|
loadingMore: false,
|
||||||
// 新消息提醒
|
showNewMessageTip: false,
|
||||||
showNewMessageTip: false, // 是否显示新消息提醒
|
newMessageCount: 0,
|
||||||
newMessageCount: 0, // 新消息数量
|
lastMessageId: '',
|
||||||
lastMessageId: '', // 最后一条消息的ID,用于检测新消息
|
hasWelcomeMessageSent: false,
|
||||||
// 欢迎消息标记
|
|
||||||
hasWelcomeMessageSent: false, // 是否已发送欢迎消息
|
|
||||||
// 订阅消息
|
|
||||||
template_id: '',
|
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const accountInfo = wx.getAccountInfoSync();
|
const accountInfo = wx.getAccountInfoSync();
|
||||||
@ -45,33 +41,6 @@ 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() {
|
||||||
@ -399,11 +368,9 @@ Page({
|
|||||||
}, 50);
|
}, 50);
|
||||||
},
|
},
|
||||||
|
|
||||||
async sendText() {
|
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 = {
|
||||||
@ -444,9 +411,7 @@ Page({
|
|||||||
}, 50);
|
}, 50);
|
||||||
},
|
},
|
||||||
|
|
||||||
async chooseImage() {
|
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