59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
const STORAGE_KEY = 'tousuFloatHidden';
|
|
|
|
Component({
|
|
data: {
|
|
hidden: false,
|
|
},
|
|
|
|
lifetimes: {
|
|
attached() {
|
|
this._syncHidden();
|
|
},
|
|
},
|
|
|
|
pageLifetimes: {
|
|
show() {
|
|
this._syncHidden();
|
|
},
|
|
},
|
|
|
|
methods: {
|
|
_syncHidden() {
|
|
let hidden = false;
|
|
try {
|
|
hidden = wx.getStorageSync(STORAGE_KEY) === 1 || wx.getStorageSync(STORAGE_KEY) === '1';
|
|
} catch (e) {}
|
|
if (hidden !== this.data.hidden) {
|
|
this.setData({ hidden });
|
|
}
|
|
},
|
|
|
|
go() {
|
|
wx.navigateTo({
|
|
url: '/pages/gongdan/create/create',
|
|
fail: (err) => {
|
|
console.error('打开投诉页失败', err);
|
|
wx.showToast({ title: '打开失败,请重试', icon: 'none' });
|
|
},
|
|
});
|
|
},
|
|
|
|
onDismiss(e) {
|
|
if (e && e.stopPropagation) e.stopPropagation();
|
|
wx.showModal({
|
|
title: '隐藏投诉入口',
|
|
content: '隐藏后可在「我的 / 工单」中继续投诉。需要恢复时可清除小程序缓存。',
|
|
confirmText: '不再显示',
|
|
cancelText: '取消',
|
|
success: (res) => {
|
|
if (!res.confirm) return;
|
|
try {
|
|
wx.setStorageSync(STORAGE_KEY, 1);
|
|
} catch (err) {}
|
|
this.setData({ hidden: true });
|
|
},
|
|
});
|
|
},
|
|
},
|
|
});
|