第一次提交

This commit is contained in:
dengtongyu committed 2018-12-03 17:31:53 +08:00
commit 8121362a03
4412 files changed
+1091845

No files matched your search

@@ -0,0 +1,237 @@
define(function (require, exports, module) {
var Base64Tool = require("../../extend/BASE64");
var callExternal = window.parent.callExternal || function () { return {} };
var yy = window.parent.yy || {};
var YYUtils = {
parseChannelInfo: function (result) {
var channelInfo = {};
channelInfo.ret = 0;
channelInfo.longId = result.long_id;
channelInfo.shortId = result.short_id;
channelInfo.name = unescape(result.name);
channelInfo.userCount = result.user_count;
channelInfo.totalUserCount = result.total_user_count;
channelInfo.channelType = result.channel_type;
channelInfo.channelPoints = result.channel_points;
return channelInfo;
},
parseUserInfo: function parseUserInfo(result) {
var userInfo = {};
userInfo.ret = 0;
if (typeof (result) == "string") {
result = eval('(' + result + ')');
}
else if (result) {
result.name = unescape(String(result.name))
result.sign = unescape(String(result.sign))
}
userInfo.uid = result.uid;
userInfo.nick = userInfo.name = unescape(result.name);
userInfo.yyId = userInfo.imId = result.imid;
userInfo.role = result.role;
userInfo.points = result.points;
userInfo.level = result.level;
userInfo.gender = userInfo.sex = result.sex;
userInfo.sign = unescape(result.sign);
userInfo.vip = result.vip;
userInfo.vipLevel = result.vip_level;
userInfo.contribution = result.contribution;
return userInfo;
},
parseImUserInfo: function (result) {
var userInfo = {};
userInfo.ret = 0;
var retObj = callExternal("IIM_GetIMUserInfoEx", result.uid);
userInfo.uid = parseInt(result.uid);
userInfo.nick = userInfo.name = unescape(result.nick_name);
userInfo.yyId = userInfo.imId = result.imid;
userInfo.role = 0;
userInfo.points = 0;
userInfo.level = 0;
userInfo.gender = userInfo.sex = 0;
userInfo.sign = "";
userInfo.vip = 0;
userInfo.vipLevel = 0;
userInfo.contribution = 0;
userInfo.age = retObj.age;
userInfo.area = retObj.area;
userInfo.city = retObj.city;
userInfo.province = retObj.province;
userInfo.birthday = "";
return userInfo;
}
};
var obj =
{
tempChannelInfo:null,
tempSubChannelInfo:null,
getChannelInfo: function () {
if(this.tempChannelInfo)
return this.tempChannelInfo;
var result = callExternal("IChannel_GetCurrentChannelInfo");
if (result.ret == 0) {
this.tempChannelInfo = YYUtils.parseChannelInfo(result);
return this.tempChannelInfo;
}
else {
return result;
}
},
getSubChannelInfo: function () {
if(this.tempSubChannelInfo)
return this.tempChannelInfo;
var result = callExternal("IChannel_GetCurrentSubChannelInfo");
if (result.ret == 0) {
this.tempSubChannelInfo = YYUtils.parseChannelInfo(result);
return this.tempSubChannelInfo;
}
else {
return result;
}
},
myUserTemp: null,
getMyUserInfo: function () {
if (this.myUserTemp)
return this.myUserTemp;
var result = callExternal("IUser_GetCurrnetUserInfo");
if (result.ret == 0) {
this.myUserTemp = result = YYUtils.parseUserInfo(result);
return result;
}
else {
return result;
}
},
usersTemp: [],
getUserInfo: function(uid) {
if (this.usersTemp[uid])
return this.usersTemp[uid];
var result = callExternal("IUser_GetUserInfo",uid);
if (result.ret == 0) {
this.usersTemp[uid] = YYUtils.parseUserInfo(result);
return result;
}
else {
return result;
}
},
addChatPubMsgListener: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_CHAT1", fn);
},
addChatFromPubMsgListener: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_CHAT_FROM1", fn);
},
addRightMenuListener: function (fn) {
if (yy.channel && yy.channel.userListPopMenu)
yy.channel.userListPopMenu.addEventListener("YY_POP_MENU_CLICKED", fn);
},
addFontInfoListener: function (fn) {
if (yy.channel)
yy.channel.addEventListener("YY_CHANNEL_INPUT_FONT_INFO_CHANGED", fn);
},
getChannelDetail: function () {
return this.getSubChannelInfo();
},
getFontInfo: function () {
return callExternal("IChannelWindow_getCurrentFontInfo");
},
showSmilebox:function(x,y){
var str = '{\"FontSetting\": 1, \"VipRightPart\": 1, \"VipFacePage\":1, \"GameSmiliesPage\":1, \"VipMallPage\":1, \"VipMallFaces\":1,\"xPos\":'+ x +',\"yPos\":' + y +'}';
str = Base64Tool.encodeBase64(str);
callExternal("IChannelWindow_showChannelSmileWindowWithControl", str);
},
addSmileboxListener: function (fn) {
if (yy.channel && yy.channel)
yy.channel.addEventListener("YY_CHANNEL_SMILE_SELECTED", fn);
},
addSysMessageListener: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_SYSTEM_MESSAGE", fn);
},
addSysMessageListener2: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_SYSTEM_MESSAGE_EX", fn);
},
addChannelStartPrivateChatListener: function (fn) {
if (yy.channel && yy.channel)
yy.channel.addEventListener("YY_CHANNEL_START_PRIVATE_CHAT", fn);
},
gotoChannel : function(sid,subsid){
callExternal("IChannel_JoinChannel",0,sid,subsid,sid,"");
},
getImageInfo : function(imageKey){
return callExternal("IChannelWindow_getImageInfo", imageKey)
},
getClipboardImage : function(){
return callExternal("IChannelWindow_getClipboardImage")
},
openUrl:function(url){
callExternal("ISecurityInternal_OpenUrl", url);
},
showUserMenu:function(uid,userName,userRole){
var sid = this.getChannelInfo().longId;
callExternal("IChannelWindow_showChannelUserMenu", uid, sid, userName, userRole);
},
send: function (cmd, msg) {
var res;
switch (cmd) {
case "sendMessage":
res = callExternal("IChannelChatInternal_Chat", msg);
res.result = res.ret;
break;
case "sendPrivateMessage":
res = callExternal("IChannelChatInternal_ChatTo", parseInt(msg.toUid),msg.msg);
res.result = res.ret;
break;
}
return res;
},
resizeUI : function(){
var newHeight = $(window).height();
if (newHeight < 155)
newHeight = 155;
$(".pkChat .chat-cont").css("height", newHeight + "px");
var chatOprH = $(".chat-opr").height();
$(".pkChat .private-chat").css("bottom",chatOprH + 2);
return newHeight;
},
//关闭私聊,计算尺寸
minChatBox:function(){
var contHeight = this.resizeUI();
var chatOprH = $(".chat-opr").height();
$(".private-chat").css("height","0px");
$(".chat-list").css("height", contHeight- 5 - chatOprH + "px");
$(".chat-text .slimScrollDiv").css("height", contHeight- 5 - chatOprH + "px");
},
//打开私聊,计算尺寸
maxChatBox:function(){
var contHeight = this.resizeUI();
var chatOprH = $(".chat-opr").height();
$(".private-chat").css("height","160px");
var privateHeight = $(".private-chat").height();
$(".chat-list").css("height", contHeight- privateHeight - chatOprH + "px");
$(".chat-text .slimScrollDiv").css("height", contHeight- privateHeight - chatOprH + "px");
},
isReady: true
};
module.exports = obj;
});