进入uniapp
This commit is contained in:
131
im-uniapp/wx/tabbar2/index.vue
Normal file
131
im-uniapp/wx/tabbar2/index.vue
Normal file
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<view class="xw-book">
|
||||
<watermark></watermark>
|
||||
<uni-indexed-list-wx :options="list" @click="bindClick"></uni-indexed-list-wx>
|
||||
<!-- <top-right-tool-wx ref="trtw"></top-right-tool-wx> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import customHttp from "@/common/customHttp.js"
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
list: []
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
onShow() {
|
||||
this.getflist()
|
||||
this.$store.dispatch('tabBarpull')
|
||||
},
|
||||
methods: {
|
||||
bindClick(e){
|
||||
//注释之前的旧代码,直接跳转到里聊天页
|
||||
/*
|
||||
uni.navigateTo({
|
||||
url:'../personInfo/detail?param='+e.item.data.userId
|
||||
})
|
||||
*/
|
||||
uni.navigateTo({
|
||||
url: '../chatWindow/index?userId=' + e.item.data.userId + '&windowType=' + "SINGLE"
|
||||
});
|
||||
},
|
||||
getflist(){
|
||||
//TODO 从接口获取
|
||||
var list=[
|
||||
{
|
||||
name:"测试18200702230",
|
||||
avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png",
|
||||
userId:"18200702230",
|
||||
userType:"item.userType",
|
||||
chatNo:"item.chatNo"
|
||||
},
|
||||
{
|
||||
name:"测试18200000000",
|
||||
avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png",
|
||||
userId:"18200000000",
|
||||
userType:"item.userType",
|
||||
chatNo:"item.chatNo"
|
||||
},{
|
||||
name:"测试18200000001",
|
||||
avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png",
|
||||
userId:"18200000001",
|
||||
userType:"item.userType",
|
||||
chatNo:"item.chatNo"
|
||||
},{
|
||||
name:"测试lld3",
|
||||
avatar:"https://shudong2022.oss-cn-hangzhou.aliyuncs.com/common/user/logo.png",
|
||||
userId:"lld3",
|
||||
userType:"item.userType",
|
||||
chatNo:"item.chatNo"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
this.list=this.$fc.sortList({list:list,key:'name'})
|
||||
|
||||
|
||||
console.log(customHttp)
|
||||
console.log("================开始请求通讯录列表")
|
||||
|
||||
// 局部修改配置,局部配置优先级高于全局配置
|
||||
customHttp.customHttp.get('/api/im/app/addressList', {
|
||||
params: {}, /* 会加在url上 */
|
||||
header: {}, /* 会与全局header合并,如有同名属性,局部覆盖全局 */
|
||||
dataType: 'json',
|
||||
// 注:如果局部custom与全局custom有同名属性,则后面的属性会覆盖前面的属性,相当于Object.assign(全局,局部)
|
||||
custom: {target: "znzq"} , // 可以加一些自定义参数,在拦截器等地方使用。比如这里我加了一个auth,可在拦截器里拿到,如果true就传token
|
||||
}).then(res => {
|
||||
//userInfo
|
||||
const userId = uni.getStorageSync("userId")
|
||||
console.log("=========获取到数据")
|
||||
console.log(res)
|
||||
if(res.statusCode==200){
|
||||
if(res.data.code==200){
|
||||
var list=[]
|
||||
res.data.result.records.map((item)=>{
|
||||
console.log(item)
|
||||
//在通讯录中过滤掉自己
|
||||
if(userId!=item.userId){
|
||||
list.push({
|
||||
name:item.realname,
|
||||
avatar:item.portrait,
|
||||
userId:item.userId,
|
||||
userType:1,
|
||||
chatNo:item.userId
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
this.list=this.$fc.sortList({list:list,key:'name'})
|
||||
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
|
||||
})
|
||||
|
||||
},
|
||||
},
|
||||
onNavigationBarButtonTap(e) {
|
||||
switch (e.index) {
|
||||
case 0: //更多
|
||||
this.$refs['trtw'].showTab();
|
||||
break;
|
||||
case 1: //搜索
|
||||
uni.navigateTo({
|
||||
url: '../search/index'
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user