diff --git a/aiChat/mixins/chatMixins.js b/aiChat/mixins/chatMixins.js index b2a478a..95a99e1 100644 --- a/aiChat/mixins/chatMixins.js +++ b/aiChat/mixins/chatMixins.js @@ -68,17 +68,6 @@ export const chatMixins = { } }.bind(this)).exec() }, - onLoad(options) { - if (!options.click) { - uni.switchTab({ url: '/pages/home/index' }) - return - } - // 监听键盘高度变化 - wx.onKeyboardHeightChange((res) => { - console.log('监听键盘高度变化%s', res.height) - this.keyboardHeight = res.height - }) - }, onUnload() { this.closeWsFn() // console.log('在页面卸载时取消监听') diff --git a/aiChat/views/history.vue b/aiChat/views/history.vue index ac19c98..046bf23 100644 --- a/aiChat/views/history.vue +++ b/aiChat/views/history.vue @@ -193,6 +193,17 @@ export default { this.pageTitle = this.pageTitle.length > 8 ? (this.pageTitle.substring(0, 8) + '...') : this.pageTitle this.init() }, + onLoad(options) { + if (!options.click) { + uni.switchTab({ url: '/pages/home/index' }) + return + } + // 监听键盘高度变化 + wx.onKeyboardHeightChange((res) => { + console.log('监听键盘高度变化%s', res.height) + this.keyboardHeight = res.height + }) + }, methods: { init() { this.loading = true diff --git a/aiChat/views/index.vue b/aiChat/views/index.vue index 958c3b5..876140a 100644 --- a/aiChat/views/index.vue +++ b/aiChat/views/index.vue @@ -256,6 +256,25 @@ export default { settingInfo: {}, topicList: [] } + }, + onLoad(options) { + if (!options.click) { + uni.switchTab({ url: '/pages/home/index' }) + return + } + // 监听键盘高度变化 + wx.onKeyboardHeightChange((res) => { + console.log('监听键盘高度变化%s', res.height) + this.keyboardHeight = res.height + }) + }, + onUnload() { + this.closeWsFn() + if (this.chatNumber) { + uni.redirectTo({ + url: '/aiChat/views/index?click=1&back=1' + }) + } }, methods: { createdCallbak() {