|
@@ -104,6 +104,7 @@
|
|
|
import {
|
|
|
computed,
|
|
|
onMounted,
|
|
|
+ onUnmounted,
|
|
|
watch,
|
|
|
reactive,
|
|
|
ref,
|
|
@@ -117,13 +118,11 @@ export default {
|
|
|
setup () {
|
|
|
const filterKeyword = ref('')
|
|
|
|
|
|
+ // 初始化数据列表
|
|
|
const corpListRaw = reactive({ value: null })
|
|
|
const corpListMap = reactive(new Map())
|
|
|
- watch(filterKeyword, utils.debounce(async (vNew) => {
|
|
|
- corpListRaw.value = await api.getGeneralList({
|
|
|
- searchKey: filterKeyword.value
|
|
|
- })
|
|
|
- corpListMap.clear()
|
|
|
+ onMounted(async () => {
|
|
|
+ corpListRaw.value = await api.getGeneralList()
|
|
|
corpListRaw.value.forEach(element => {
|
|
|
let decade = ''
|
|
|
if (element.createDay.substring(0, 2) === '18') {
|
|
@@ -140,10 +139,24 @@ export default {
|
|
|
}
|
|
|
corpListMap.get(decade).push(element)
|
|
|
})
|
|
|
- }, 500, false), {
|
|
|
- immediate: true,
|
|
|
})
|
|
|
|
|
|
+ // 自动选中第一个条目
|
|
|
+ function selectFirstItemAuto() {
|
|
|
+ onClickCorpItem(corpListRaw.value[0].id)
|
|
|
+ }
|
|
|
+ window.gMitt.on('RequestApiSuccess-general', selectFirstItemAuto)
|
|
|
+ onUnmounted(() => {
|
|
|
+ window.gMitt.off('RequestApiSuccess-general', selectFirstItemAuto)
|
|
|
+ })
|
|
|
+
|
|
|
+ // 搜索框功能
|
|
|
+ // watch(filterKeyword, utils.debounce(async (vNew) => {
|
|
|
+ // }, 500, false), {
|
|
|
+ // immediate: true,
|
|
|
+ // })
|
|
|
+
|
|
|
+ // 被选中的数据
|
|
|
const activeCorpId = ref(null)
|
|
|
const isShowDesc = ref(true)
|
|
|
const activeCorpInfo = computed(() => {
|
|
@@ -155,17 +168,24 @@ export default {
|
|
|
return {}
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
// 无论是网页里还是unity内部点击了企业,都调用这个
|
|
|
function onClickCorpItem(id) {
|
|
|
- if ((typeof activeCorpId.value === 'number')) {
|
|
|
- gUnityInst.SendMessage('Panel1', 'SetEnterpriseUnSelected', activeCorpId.value) //设置id为1的企业为未选中状态(此id需要是已显示的)
|
|
|
+ let isFound = false
|
|
|
+ for (let index = 0; index < corpListRaw.value.length; index++) {
|
|
|
+ const element = corpListRaw.value[index]
|
|
|
+ if (element.id === id) {
|
|
|
+ isFound = true
|
|
|
+ window.gUnityInst.SendMessage('Panel1', 'ShowEnterprise', element.id) //显示某个企业
|
|
|
+ window.gUnityInst.SendMessage('Panel1', 'SetEnterpriseUnSelected', element.id) //高亮某个企业
|
|
|
+ } else if (!isFound) {
|
|
|
+ window.gUnityInst.SendMessage('Panel1', 'ShowEnterprise', element.id) //显示某个企业
|
|
|
+ } else {
|
|
|
+ window.gUnityInst.SendMessage('Panel1', 'HideEnterprise', element.id) //隐藏某个企业
|
|
|
+ }
|
|
|
}
|
|
|
- gUnityInst.SendMessage('Panel1', 'SetEnterpriseSelected', id) //设置id为1的企业为选中状态(此id需要是已显示的)
|
|
|
-
|
|
|
activeCorpId.value = id
|
|
|
isShowDesc.value = true
|
|
|
-
|
|
|
- console.log(`corp-item-${id}`)
|
|
|
const clickedElement = document.querySelector(`#corp-item-${id}`)
|
|
|
if (clickedElement) {
|
|
|
clickedElement.scrollIntoView()
|
|
@@ -173,6 +193,7 @@ export default {
|
|
|
}
|
|
|
window.handleClickEnterprise = onClickCorpItem
|
|
|
|
|
|
+ // loading mask相关
|
|
|
const isShowLoadingMask = ref(true)
|
|
|
onMounted(() => {
|
|
|
setTimeout(() => {
|
|
@@ -202,7 +223,6 @@ export default {
|
|
|
]),
|
|
|
},
|
|
|
mounted() {
|
|
|
- // this.$mitt.emit('test', { msg: 'home mounted' })
|
|
|
},
|
|
|
beforeUnmount() {
|
|
|
},
|