import config from ‘…/…/static/js/common.js’//调用登录接口
const host = config.host
const app = getApp()
export default {
data() {
return {
add: [],
datas: [],
recommend: [],
cuss:[],
}
},
methods: {
group(gid) { //传参
uni.navigateTo({
url: './group/group?gid=' + gid
})
},
oneself(self) {
uni.navigateTo({
url: './oneself/oneself?self' + self
})
},
info(inf) {
uni.navigateTo({
url: 'info/info?inf' + inf
})
},
onLoad(e){
var _t = this //this统一用_t
// let add = option.id;
// _t.add = add
console.log("ull", _t.add)
_t.ull()
_t.mess()
_t.discuss()
},
// 消息
ull(e) {
var _t = this //this统一用_t
var pid = 0
if (e != undefined && e.pid != undefined) {
pid = e.pid
}
var p1 = config.getToken(pid)
p1.then(function(token) {
uni.request({
url: host + '/wxapp/msg/...', //接口地址。
data: {
// token: token
token: 'f7f7987f39b017695753cda71858',
},
method: 'GET', //请求方式
success: (res) => {
if (res.data.code == -1) {
config.doLogin()
return false
}
let datas = res.data.data
for (var x in datas) {
if (datas[x].type == 1) {
datas[x].sms = JSON.parse(datas[x].sms).data.text
} //JSON.parse将字符串转换成json对象
datas[x].fatime = datas[x].fatime.slice(11, 16) //截取第11个开头,16结尾的time
datas[x].headimg = datas[x].headimg.split(',')[0] //用逗号隔开
}
_t.datas = datas
console.log(_t.datas)
}
});
})
},
// 群聊
mess(e) {
var _t = this //this统一用_t
var pid = 0
if (e != undefined && e.pid != undefined) {
pid = e.pid
}
var p1 = config.getToken(pid)
p1.then(function(token) {
uni.request({
url: host + '/wxapp/msg/...i', //接口地址。
data: {
token: token
},
method: 'GET', //请求方式
success: (res) => {
if (res.data.code == -1) {
config.doLogin()
return false
}
let recommend = res.data
_t.recommend = recommend
console.log('qunTui', _t.recommend)
}
});
})
},
// 加入的群
discuss(e) {
var _t = this //this统一用_t
var pid = 0
if (e != undefined && e.pid != undefined) {
pid = e.pid
}
var p1 = config.getToken(pid)
p1.then(function(token) {
uni.request({
url: host + '/wxapp/msg/...', //接口地址。
data: {
token: token
},
method: 'GET', //请求方式
success: (res) => {
if (res.data.code == -1) {
config.doLogin()
return false
}
let cuss = res.data
// for (var i in cuss) {
// if (cuss[i]) {
// cuss[i].sms = JSON.parse(cuss[i].sms).data.text
// } //JSON.parse将字符串转换成json对象
// cuss[i].fatime = cuss[i].fatime.slice(11, 16) //截取第11个开头,16结尾的time
// cuss[i].headimg = cuss[i].headimg.split(',')[0] //用逗号隔开
// }
_t.cuss = cuss
console.log("getQun",_t.cuss)
}
});
})
},
},
}
不理解的可以提问