锦水居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

136 lines
2.8 KiB

const app = getApp()
Component({
data: {
alphabetList: [], // 字母列表
listCur: 'A', // 当前显示字母
hidden: true,
listCurID: 'A',
boxTop: 0,
btnName: '',
loadFlag: ''
},
options:{
multipleSlots: true
},
properties: {
scrollViewTop: {
type: Number,
value: 0
},
scrollViewBottom: {
type: Number,
value: 0
},
pageType: {
type: String,
value: 'none',
observer: function (type) {
let btnContent = ''
if (type === 'none') {
btnContent = ''
} else if (type === 'invite') {
btnContent = '邀请'
} else if (type === 'delete') {
btnContent = '删除'
} else if (type === 'verify') {
btnContent = '审核'
}
this.setData({
btnName: btnContent
})
}
},
dataList: {
type: Array,
value: []
},
groupCategory: {
type: String,
value: '1'
}
},
pageLifetimes: {
show () {
this.setData({
loadFlag: app.globalData.groupInfo.lordFlag
})
},
hide () {
}
},
lifetimes: {
created () {
},
attached () {
this.alphabetListInit()
const that = this
wx.createSelectorQuery().in(this).select('.indexBar-box').boundingClientRect(function (res) {
that.setData({
boxTop: res.top
})
}).exec()
}
},
methods: {
// 初始化字母表
alphabetListInit () {
let list = []
for (let i = 0; i < 26; i ++) {
list[i] = String.fromCharCode(65 + i)
}
this.setData({
alphabetList: list,
listCur: list[0]
})
},
//获取文字信息
getCur(e) {
this.setData({
hidden: false,
listCur: e.target.id,
})
},
// 设置文本信息
setCur(e) {
this.setData({
hidden: true,
listCur: this.data.listCur
})
},
//滑动选择Item
tMove(e) {
let y = e.touches[0].clientY
let offsettop = this.data.boxTop
console.log(offsettop)
//判断选择区域,只有在选择区才会生效
if (y > offsettop) {
let num = parseInt((y - offsettop) / 20);
this.setData({
listCur: this.data.alphabetList[num]
})
};
},
//触发全部开始选择
tStart() {
this.setData({
hidden: false
})
},
//触发结束选择
tEnd() {
this.setData({
hidden: true,
listCurID: this.data.listCur
})
},
chooseMember (e) {
this.triggerEvent('chooseFriend', { userId: e.currentTarget.dataset.userid, alphabet: e.currentTarget.dataset.alphabet})
},
operationBtn (e) {
this.triggerEvent('operationBtn', { id: e.currentTarget.dataset.id, userId: e.currentTarget.dataset.userid })
}
}
})