253 lines
7.2 KiB
JavaScript
253 lines
7.2 KiB
JavaScript
var siteroot = require('./siteinfo.js');
|
||
var url = siteroot.siteroot+'?c=entry&a=wxapp&i='+siteroot.uniacid+'&m=sd_moyue&do=';
|
||
var func = {
|
||
util: require('../we7/resource/js/util.js'),
|
||
api:{
|
||
upload_img:url+'upload_img',
|
||
wxlogin:url+'wxlogin',
|
||
appland:url+'appland',//app登陆
|
||
write_userinfo:url+'write_userinfo',
|
||
get_users:url+'get_users',
|
||
app_wx_land:url+'app_wx_land',
|
||
get_userinfo:url+'get_userinfo',
|
||
change_user_address:url+'change_user_address',
|
||
get_system:url+'get_system',
|
||
white_lock_action_record:url+'white_lock_action_record',
|
||
praise:url+'praise',
|
||
send_comment:url+'send_comment',
|
||
report_action:url+'report_action',
|
||
del_action:url+'del_action',
|
||
follow_user:url+'follow_user',
|
||
bind_userid:url+'bind_userid',
|
||
bind_roomid:url+'bind_roomid',
|
||
send_user_message:url+'send_user_message',
|
||
send_room_message:url+'send_room_message',
|
||
user_send_liwu_pay:url+'user_send_liwu_pay',
|
||
user_send_room_liwu_pay:url+'user_send_room_liwu_pay',
|
||
user_join_room:url+'user_join_room',
|
||
user_greet:url+'user_greet',
|
||
websocket_get_message:url+'websocket_get_message',
|
||
change_room_status:url+'change_room_status',
|
||
/************************/
|
||
get_user_live:url+'get_user_live',
|
||
live_apply:url+'live_apply',
|
||
create_live_room:url+'create_live_room',
|
||
get_live_room:url+'get_live_room',
|
||
write_room_info:url+'write_room_info',
|
||
get_live_set:url+'get_live_set',
|
||
get_room_list:url+'get_room_list',
|
||
change_live_room:url+'change_live_room',
|
||
send_room_message:url+'send_room_message',
|
||
get_room_message:url+'get_room_message'
|
||
/*********************************/
|
||
|
||
},
|
||
system:function(){
|
||
uni.request({
|
||
url:url+'system',
|
||
data:{
|
||
},
|
||
method:"POST",
|
||
header: {
|
||
'content-type': 'application/x-www-form-urlencoded'
|
||
},
|
||
success:(res)=>{
|
||
console.log(res);
|
||
uni.setNavigationBarTitle({//标题
|
||
title: res.data.data.system.title
|
||
});
|
||
uni.setNavigationBarColor({//导航栏
|
||
frontColor: res.data.data.system.frontColor,
|
||
backgroundColor: res.data.data.system.nvgcolor,
|
||
animation: {
|
||
duration: 400,
|
||
timingFunc: 'easeIn'
|
||
}
|
||
})
|
||
uni.setTabBarStyle({//底部导航
|
||
backgroundColor: '#F0F0F0'
|
||
})
|
||
}
|
||
|
||
})
|
||
},
|
||
|
||
set_mid:function(u,m){
|
||
uni.request({//设置分享来源
|
||
url:url+'set_mid',
|
||
data:{
|
||
userid:u,
|
||
mid:m
|
||
},
|
||
method:"POST",
|
||
header: {
|
||
'content-type': 'application/x-www-form-urlencoded'
|
||
},
|
||
success:(res)=>{
|
||
}
|
||
})
|
||
},
|
||
|
||
jump:function(type,u){
|
||
if(type == 1){
|
||
uni.navigateTo({
|
||
url: '/pages/'+u
|
||
});
|
||
}else if(type == 2){
|
||
uni.redirectTo({
|
||
url: '/pages/'+u
|
||
});
|
||
}else if(type == 3){
|
||
uni.reLaunch({
|
||
url: '/pages/'+u
|
||
});
|
||
}else if(type == 4){
|
||
uni.navigateBack({
|
||
delta: 1
|
||
});
|
||
}
|
||
},
|
||
change_room_status:function(e,s,u){
|
||
const t = this;
|
||
uni.request({//返回系统数据
|
||
url:url+'change_room_status',
|
||
data:{
|
||
roomid:e,
|
||
status:s,
|
||
userid:u
|
||
},
|
||
method:"POST",
|
||
header: {
|
||
'content-type': 'application/x-www-form-urlencoded'
|
||
},
|
||
success:(res)=>{
|
||
console.log('改变房间状态')
|
||
console.log(res)
|
||
}
|
||
})
|
||
},
|
||
bindroomid:function(roomid){
|
||
if(!roomid){
|
||
console.log('绑定直播间失败')
|
||
return
|
||
}
|
||
/*var client_id = uni.getStorageSync('client_id');
|
||
uni.request({//使用长连接绑定房间id 用以监听房间消息,若不使用长连接请自行设置监听函数或者使用腾讯IM消息监听
|
||
url:url+'bind_roomid',
|
||
data:{
|
||
roomid:roomid,
|
||
client_id:client_id
|
||
},
|
||
method:"POST",
|
||
header: {
|
||
'content-type': 'application/x-www-form-urlencoded'
|
||
},
|
||
success:(res)=>{
|
||
console.log('绑定直播间')
|
||
console.log(res)
|
||
}
|
||
})*/
|
||
},
|
||
base64_encode:function(str) { // 编码,配合encodeURIComponent使用
|
||
var c1, c2, c3;
|
||
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||
var i = 0, len = str.length, strin = '';
|
||
while (i < len) {
|
||
c1 = str.charCodeAt(i++) & 0xff;
|
||
if (i == len) {
|
||
strin += base64EncodeChars.charAt(c1 >> 2);
|
||
strin += base64EncodeChars.charAt((c1 & 0x3) << 4);
|
||
strin += "==";
|
||
break;
|
||
}
|
||
c2 = str.charCodeAt(i++);
|
||
if (i == len) {
|
||
strin += base64EncodeChars.charAt(c1 >> 2);
|
||
strin += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
|
||
strin += base64EncodeChars.charAt((c2 & 0xF) << 2);
|
||
strin += "=";
|
||
break;
|
||
}
|
||
c3 = str.charCodeAt(i++);
|
||
strin += base64EncodeChars.charAt(c1 >> 2);
|
||
strin += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
|
||
strin += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
|
||
strin += base64EncodeChars.charAt(c3 & 0x3F)
|
||
}
|
||
return strin
|
||
},
|
||
|
||
base64_decode:function(input) { // 解码,配合decodeURIComponent使用
|
||
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||
var output = "";
|
||
var chr1, chr2, chr3;
|
||
var enc1, enc2, enc3, enc4;
|
||
var i = 0;
|
||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||
while (i < input.length) {
|
||
enc1 = base64EncodeChars.indexOf(input.charAt(i++));
|
||
enc2 = base64EncodeChars.indexOf(input.charAt(i++));
|
||
enc3 = base64EncodeChars.indexOf(input.charAt(i++));
|
||
enc4 = base64EncodeChars.indexOf(input.charAt(i++));
|
||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||
output = output + String.fromCharCode(chr1);
|
||
if (enc3 != 64) {
|
||
output = output + String.fromCharCode(chr2);
|
||
}
|
||
if (enc4 != 64) {
|
||
output = output + String.fromCharCode(chr3);
|
||
}
|
||
}
|
||
return this.utf8_decode(output);
|
||
},
|
||
|
||
utf8_decode:function(utftext) { // utf-8解码
|
||
var string = '';
|
||
let i = 0;
|
||
let c = 0;
|
||
let c1 = 0;
|
||
let c2 = 0;
|
||
while (i < utftext.length) {
|
||
c = utftext.charCodeAt(i);
|
||
if (c < 128) {
|
||
string += String.fromCharCode(c);
|
||
i++;
|
||
} else if ((c > 191) && (c < 224)) {
|
||
c1 = utftext.charCodeAt(i + 1);
|
||
string += String.fromCharCode(((c & 31) << 6) | (c1 & 63));
|
||
i += 2;
|
||
} else {
|
||
c1 = utftext.charCodeAt(i + 1);
|
||
c2 = utftext.charCodeAt(i + 2);
|
||
string += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63));
|
||
i += 3;
|
||
}
|
||
}
|
||
return string;
|
||
},
|
||
isBase64:function(str) {
|
||
const notBase64 = /[^A-Z0-9+\/=]/i; // remove this line and make sure you pass in a string
|
||
const len = str.length;
|
||
if (!len || len % 4 !== 0 || notBase64.test(str)) {
|
||
return false;
|
||
}
|
||
const firstPaddingChar = str.indexOf('=');
|
||
return firstPaddingChar === -1 || firstPaddingChar === len - 1 || (firstPaddingChar === len - 2 && str[len - 1] === '=');
|
||
},
|
||
geturlParam:function(name){//获取url指定参数
|
||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||
var r = window.location.search.substr(1).match(reg);//umEn
|
||
if(r!= null){
|
||
return unescape(r[2]);
|
||
}else{
|
||
return null//返回参数值
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
module.exports = func
|
||
|