133 lines
5.3 KiB
JavaScript
133 lines
5.3 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../../../common/vendor.js");
|
|
require("../../../adapter-vue.js");
|
|
const common_assets = require("../../../../common/assets.js");
|
|
const TUIKit_utils_env = require("../../../utils/env.js");
|
|
const TUIKit_utils_lodash = require("../../../utils/lodash.js");
|
|
if (!Math) {
|
|
Icon();
|
|
}
|
|
const Icon = () => "../../common/Icon.js";
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "index",
|
|
setup(__props) {
|
|
const searchingPlaceholder = common_vendor.Wt.t("TUIContact.输入ID");
|
|
const isSearching = common_vendor.ref(false);
|
|
const searchValue = common_vendor.ref("");
|
|
const searchResult = common_vendor.ref({
|
|
user: {
|
|
label: "联系人",
|
|
list: []
|
|
},
|
|
group: {
|
|
label: "群聊",
|
|
list: []
|
|
}
|
|
});
|
|
const changeContactSearchingStatus = TUIKit_utils_lodash.debounce(function(status) {
|
|
isSearching.value = status;
|
|
}, 200);
|
|
const search = async () => {
|
|
if (!searchValue.value) {
|
|
return;
|
|
}
|
|
common_vendor.R.callService({
|
|
serviceName: common_vendor.E.TUISearch.SERVICE.NAME,
|
|
method: common_vendor.E.TUISearch.SERVICE.METHOD.SEARCH_USER,
|
|
params: {
|
|
userID: searchValue.value
|
|
}
|
|
}).then((res) => {
|
|
searchResult.value.user.list = res.data;
|
|
}).catch((error) => {
|
|
searchResult.value.user.list = [];
|
|
common_vendor.index.__f__("warn", "at TUIKit/components/TUIContact/contact-search/index.vue:111", "search user error", error);
|
|
});
|
|
common_vendor.R.callService({
|
|
serviceName: common_vendor.E.TUISearch.SERVICE.NAME,
|
|
method: common_vendor.E.TUISearch.SERVICE.METHOD.SEARCH_GROUP,
|
|
params: {
|
|
groupID: searchValue.value
|
|
}
|
|
}).then((res) => {
|
|
searchResult.value.group.list = [res.data.group];
|
|
}).catch((error) => {
|
|
searchResult.value.group.list = [];
|
|
common_vendor.index.__f__("warn", "at TUIKit/components/TUIContact/contact-search/index.vue:125", "search group error", error);
|
|
});
|
|
};
|
|
common_vendor.watch(
|
|
() => searchResult.value,
|
|
() => {
|
|
common_vendor.Jt.update(
|
|
common_vendor.o.CUSTOM,
|
|
"currentContactSearchResult",
|
|
searchResult.value
|
|
);
|
|
},
|
|
{
|
|
deep: true,
|
|
immediate: true
|
|
}
|
|
);
|
|
common_vendor.watch(
|
|
() => isSearching.value,
|
|
() => {
|
|
common_vendor.Jt.update(
|
|
common_vendor.o.CUSTOM,
|
|
"currentContactSearchingStatus",
|
|
isSearching.value
|
|
);
|
|
if (isSearching.value) {
|
|
searchValue.value = "";
|
|
searchResult.value.user.list = [];
|
|
searchResult.value.group.list = [];
|
|
}
|
|
},
|
|
{
|
|
deep: true,
|
|
immediate: true
|
|
}
|
|
);
|
|
common_vendor.i.updateContactSearch = search;
|
|
common_vendor.i.closeSearching = () => {
|
|
isSearching.value = false;
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: !common_vendor.unref(isSearching) || !common_vendor.unref(TUIKit_utils_env.isPC)
|
|
}, !common_vendor.unref(isSearching) || !common_vendor.unref(TUIKit_utils_env.isPC) ? {
|
|
b: common_vendor.p({
|
|
file: common_vendor.unref(isSearching) ? common_vendor.unref(common_assets.backIcon) : common_vendor.unref(common_assets.addSVG),
|
|
width: common_vendor.unref(isSearching) ? "20px" : "14px",
|
|
height: common_vendor.unref(isSearching) ? "20px" : "14px"
|
|
}),
|
|
c: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-contact-search-h5-header-icon"),
|
|
d: common_vendor.o$1(($event) => common_vendor.unref(changeContactSearchingStatus)(!common_vendor.unref(isSearching))),
|
|
e: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIContact.添加好友/群聊")),
|
|
f: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-contact-search-h5-header-title"),
|
|
g: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-contact-search-h5-header"),
|
|
h: common_vendor.n(common_vendor.unref(isSearching) && "tui-contact-searching-h5-header"),
|
|
i: common_vendor.o$1(($event) => common_vendor.unref(changeContactSearchingStatus)(true))
|
|
} : {}, {
|
|
j: common_vendor.unref(isSearching)
|
|
}, common_vendor.unref(isSearching) ? {
|
|
k: common_vendor.unref(searchingPlaceholder),
|
|
l: common_vendor.o$1(search),
|
|
m: common_vendor.o$1(search),
|
|
n: common_vendor.o$1(search),
|
|
o: common_vendor.unref(searchValue),
|
|
p: common_vendor.o$1(($event) => common_vendor.isRef(searchValue) ? searchValue.value = $event.detail.value : null),
|
|
q: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("取消")),
|
|
r: common_vendor.o$1(($event) => isSearching.value = false),
|
|
s: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-contact-search-h5-main")
|
|
} : {}, {
|
|
t: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-contact-search-h5")
|
|
});
|
|
};
|
|
}
|
|
});
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-efa1a0fe"]]);
|
|
wx.createComponent(Component);
|
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIContact/contact-search/index.js.map
|