talk.js
1.1 KB
$(function() {
if(readCookie('accountList')) {
var accountList = JSON.parse(readCookie('accountList'))
//判断如果是老板登录 则显示客服列表
if(readCookie('flag') == 1) {
var oDiv = $("<div id='selectWrap'></div>")
var oSpan = $("<span class='selectTitle'>客服列表</span>")
var oSelect = $("<select id='changeAccount'></select>")
for(var i = 0; i < accountList.length; i++) {
oSelect.append("<option value='" + accountList[i].token + "' uid='" + accountList[i].accid + "'>" + accountList[i].name + "</option>");
}
oDiv.prepend(oSelect)
oDiv.prepend(oSpan)
$("body").prepend(oDiv)
if(readCookie('currentSelect')) {
var uid = readCookie('currentSelect')
oSelect.find("option[uid='" + uid + "']").attr("selected", true);
}
oSelect.change(function() {
setCookie('currentSelect', oSelect.find("option:checked").attr("uid"));
YX.fn.doLogout()
setCookie('uid', oSelect.find("option:checked").attr("uid"));
setCookie('sdktoken', oSelect.val())
setTimeout(function() {
window.location.reload()
}, 500)
})
}
}
})