99 lines
2.5 KiB
JavaScript

// template/indexSidebar/indexSidebar.js
const util = require('../../utils/util')
// const common = require('../../utils/commonMethod')
const app = getApp()
var miucms = require('../../utils/miucms.js');
Component({
/**
* 组件的属性列表
*/
properties: {
isInitFinish: {
type: Boolean,
observer(res) {
if (res) {
this.openSidebarTwoHide()
}
},
value: false,
},
},
/**
* 组件的初始数据
*/
data: {
helperPopState: false, // offer捷报右侧-申请小助手弹窗的状态
isSidebarShowState: true, // 侧边栏的展开状态 相反的是 收起
sidebarState: 1, // 侧边栏有三种内容状态 1 只有申请助手 2 申请 + offer按钮 3 申请 + offer按钮 + 置顶
sidebarTimer: null, // 侧边栏的定时器
ishongkongoffer: 0, // 是否报告 香港 offer
gtergreenonionqrcode: miucms.gtergreenonionqrcode, // 群 二维码
groupState: false, // 群 弹窗显示状态
},
/**
* 组件的方法列表
*/
methods: {
// 开启两秒后收起
openSidebarTwoHide() {
clearTimeout(this.data.sidebarTimer)
if (!this.data.isSidebarShowState) {
this.setData({
isSidebarShowState: true
})
}
this.data.sidebarTimer = setTimeout(() => {
this.setData({
isSidebarShowState: false
})
}, 2000);
},
// 专门处理侧边栏的事件 隐藏消失
sidebarShowHide(e) {
clearTimeout(this.data.sidebarTimer)
if (!this.data.isSidebarShowState) {
this.openSidebarTwoHide()
return
}
const type = e.currentTarget.dataset.type
if (type == 'top') {
wx.pageScrollTo({
scrollTop: 0
})
return
}
if (type == 'group') {
this.setData({
groupState: true,
})
// miucms.statistics({
// name: "side-group"
// })
return
}
this.openSidebarTwoHide()
},
closeGroup() {
this.setData({
groupState: false,
})
},
}
})