jiuyiUniapp/jiuyi2/unpackage/dist/dev/mp-weixin/pages/news/group-chat/book.js

256 lines
5.9 KiB
JavaScript

"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_index = require("../../../api/index.js");
if (!Array) {
const _easycom_uni_swipe_action2 = common_vendor.resolveComponent("uni-swipe-action");
_easycom_uni_swipe_action2();
}
const _easycom_uni_swipe_action = () => "../../../uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.js";
if (!Math) {
_easycom_uni_swipe_action();
}
const _sfc_main = {
__name: "book",
props: {
search: {
type: String,
default: ""
}
},
emits: ["checkboxChange"],
setup(__props, { emit: __emit }) {
const { format_url, alert } = common_vendor.inject("util");
const emit = __emit;
const {
proxy
} = common_vendor.getCurrentInstance();
const store = common_vendor.useStore();
const userinfo = common_vendor.computed(() => {
let result = store.state.userinfo;
return result;
});
const checkboxChange = (e) => {
emit("checkboxChange", e);
console.log("checkboxChange", e);
};
const list = common_vendor.reactive([]);
const listKey = common_vendor.ref("");
const letterList = [
{
key: "other",
name: "#"
},
{
key: "a",
name: "A"
},
{
key: "b",
name: "B"
},
{
key: "c",
name: "C"
},
{
key: "d",
name: "D"
},
{
key: "e",
name: "E"
},
{
key: "f",
name: "F"
},
{
key: "g",
name: "G"
},
{
key: "h",
name: "H"
},
{
key: "i",
name: "I"
},
{
key: "j",
name: "J"
},
{
key: "k",
name: "K"
},
{
key: "l",
name: "L"
},
{
key: "m",
name: "M"
},
{
key: "n",
name: "N"
},
{
key: "o",
name: "O"
},
{
key: "p",
name: "P"
},
{
key: "q",
name: "Q"
},
{
key: "r",
name: "R"
},
{
key: "s",
name: "S"
},
{
key: "t",
name: "T"
},
{
key: "u",
name: "U"
},
{
key: "v",
name: "V"
},
{
key: "w",
name: "W"
},
{
key: "x",
name: "X"
},
{
key: "y",
name: "Y"
},
{
key: "z",
name: "Z"
}
];
const touchmove = common_vendor.ref(false);
const letterDom = common_vendor.reactive({
itemHeight: 0,
minHeight: 0,
maxHeight: 0,
height: 0
});
const userList = common_vendor.reactive({
data: [],
pageNum: 1,
pageSize: 10,
total: 0
});
common_vendor.onLoad(() => {
getFriendList();
});
common_vendor.onMounted(() => {
getLetterProperty();
});
function getFriendList() {
api_index.api.video.getFriendList({
path: [userinfo.value.userId],
query: {
pageNum: userList.pageNum,
pageSize: userList.pageSize
}
}).then((rs) => {
if (rs.code == 200) {
if (userList.pageNum)
userList.data.length = 0;
rs.data.forEach((item2) => {
let char = common_vendor.pinyin.getCamelChars(item2.userNickname);
item2.format_userPortrait = format_url(item2.userPortrait, "img");
list.push({ key: char.charAt(0), letter: char.charAt(0), child: [item2] });
});
userList.total = rs.total;
return;
}
alert({
content: rs.msg,
showCancel: false
});
}).finally(() => {
common_vendor.index.stopPullDownRefresh();
});
}
function getLetterProperty() {
const query = common_vendor.index.createSelectorQuery().in(proxy);
query.select(".letterBox").boundingClientRect((data) => {
letterDom.minHeight = data.top;
letterDom.height = data.height;
letterDom.maxHeight = data.bottom;
letterDom.itemHeight = data.height / letterList.length;
}).exec();
}
function handleTouchStart(ev) {
touchmove.value = true;
}
function handleTouchMove(ev) {
if (!touchmove.value)
return;
let result = ev.touches[0].pageY;
result = Math.max(result, letterDom.minHeight);
result = Math.min(result, letterDom.maxHeight);
let index = Math.floor(result - letterDom.minHeight) / letterDom.itemHeight;
index = parseInt(index);
listKey.value = letterList[index].key;
}
function handleTouchEnd(ev) {
touchmove.value = false;
}
function handleLetter(item) {
listKey.value = item.key;
}
return (_ctx, _cache) => {
return {
a: common_vendor.f(list, (item, index, i0) => {
return {
a: common_vendor.f(item.child.filter((data) => !__props.search || data.userNickname.includes(__props.search)), (user, secIndex, i1) => {
return {
a: user,
b: common_vendor.t(user.userNickname),
c: secIndex
};
}),
b: item.format_userPortrait,
c: item.key,
d: item.key
};
}),
b: common_vendor.o$1(checkboxChange),
c: listKey.value,
d: common_vendor.f(letterList, (item, index, i0) => {
return {
a: common_vendor.t(item.name),
b: item,
c: common_vendor.o$1(($event) => handleLetter(item), item)
};
}),
e: common_vendor.o$1(handleTouchStart),
f: common_vendor.o$1(handleTouchMove),
g: common_vendor.o$1(handleTouchEnd)
};
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c101eb66"]]);
wx.createComponent(Component);