local
This commit is contained in:
@@ -1,213 +0,0 @@
|
||||
var _maskView, _contentView, _downloadTask, _loadingProgress, _screenHeight, _screenWidth, _config = {
|
||||
forceUpgrade: false,
|
||||
titleText: "版本更新",
|
||||
content: "",
|
||||
contentAlign: "left",
|
||||
loadingColor: "#329EEE",
|
||||
cancelText: "暂不升级",
|
||||
cancelColor: "#666",
|
||||
confirmText: "立即升级",
|
||||
confirmColor: "#329EEE",
|
||||
windowHeight: 380,
|
||||
packageUrl: "",
|
||||
browser: false,
|
||||
maskColor: "rgba(0,0,0,0.3)"
|
||||
},
|
||||
_calculatePosition = function() {
|
||||
return {
|
||||
top: (_screenHeight - _config.windowHeight) / 2,
|
||||
left: _screenWidth * .05,
|
||||
width: _screenWidth * .9,
|
||||
right: _screenWidth * .05,
|
||||
height: _config.windowHeight
|
||||
}
|
||||
},
|
||||
_createMask = function() {
|
||||
_maskView = new plus.nativeObj.View("maskView", {
|
||||
top: "0px",
|
||||
left: "0px",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
backgroundColor: _config.maskColor
|
||||
})
|
||||
},
|
||||
_createContentView = function() {
|
||||
var calculatePosition = _calculatePosition();
|
||||
_contentView = new plus.nativeObj.View("contentView", {
|
||||
top: calculatePosition.top + "px",
|
||||
left: calculatePosition.left + "px",
|
||||
height: _config.windowHeight + "px",
|
||||
width: calculatePosition.width + "px",
|
||||
overflow: "auto"
|
||||
});
|
||||
_contentView.drawRect({
|
||||
color: "#ffffff",
|
||||
radius: "20px"
|
||||
}, {
|
||||
width: "100%",
|
||||
height: "100%"
|
||||
}, "roundedRect");
|
||||
_contentView.drawText(_config.titleText, {
|
||||
top: "20px",
|
||||
height: "20px",
|
||||
}, {
|
||||
size: "16px",
|
||||
color: "#333",
|
||||
align: "center",
|
||||
}, "titleText");
|
||||
_contentView.drawText(_config.content, {
|
||||
top: "60px",
|
||||
left: "20px",
|
||||
right: "20px",
|
||||
height: _config.windowHeight - 120 + "px",
|
||||
}, {
|
||||
size: "16px",
|
||||
color: "#666",
|
||||
align: _config.contentAlign,
|
||||
verticalAlign: "top",
|
||||
whiteSpace: "normal",
|
||||
overflow: "ellipsis"
|
||||
}, "UpdaterContent");
|
||||
_createLoading(-2);
|
||||
var top = _config.windowHeight - 60 + 15;
|
||||
var fontSize = '16px';
|
||||
if (!_config.forceUpgrade) {
|
||||
_contentView.drawRichText("<font style=\"font-size:" + fontSize + ";\" color=\"" + _config.cancelColor +
|
||||
"\">" + _config
|
||||
.cancelText + "</font>", {
|
||||
width: "50%",
|
||||
top: top + "px",
|
||||
left: "0px"
|
||||
}, {
|
||||
align: "center",
|
||||
onClick: function() {
|
||||
close()
|
||||
}
|
||||
}, "cancel");
|
||||
_contentView.drawRichText("<font color=\"" + _config.confirmColor +
|
||||
"\" style=\"font-size:" + fontSize + ";\">" +
|
||||
_config.confirmText + "</font>", {
|
||||
width: "50%",
|
||||
right: "0px",
|
||||
top: top + "px"
|
||||
}, {
|
||||
align: "center",
|
||||
onClick: function() {
|
||||
_config.packageUrl ? "android" === plus.os.name.toLowerCase() ? _config.browser ? (plus
|
||||
.runtime.openURL(_config.packageUrl)) : _createTask() : plus.runtime.openURL(
|
||||
_config.packageUrl) : uni.showToast({
|
||||
title: "安装包地址为空",
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}, "submit")
|
||||
} else {
|
||||
_contentView.drawRichText("<font color=\"" + _config.confirmColor + "\" style=\"font-size:" + fontSize +
|
||||
";\">" +
|
||||
_config.confirmText + "</font>", {
|
||||
width: "100%",
|
||||
right: "0px",
|
||||
top: top + "px"
|
||||
}, {
|
||||
align: "center",
|
||||
onClick: function() {
|
||||
_config.packageUrl ? "android" === plus.os.name.toLowerCase() ? _config.browser ? (plus
|
||||
.runtime.openURL(_config.packageUrl)) : _createTask() : plus.runtime.openURL(
|
||||
_config.packageUrl) : uni.showToast({
|
||||
title: "安装包地址为空",
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}, "submit")
|
||||
}
|
||||
},
|
||||
_createLoading = function(progress) {
|
||||
var calculatePosition = _calculatePosition();
|
||||
var top = _config.windowHeight - 65;
|
||||
var width = 0 <= progress ? (calculatePosition.width - 100) / 100 * progress : 0;
|
||||
width = parseInt(width);
|
||||
var text = 100 <= progress ? "下载完成" : "下载中...";
|
||||
var loadingText = "";
|
||||
loadingText = -1 == progress ? "资源加载中..." : 0 <= progress ? text + "(" + progress + "%)" : "";
|
||||
_contentView.drawRect({
|
||||
color: _config.loadingColor
|
||||
}, {
|
||||
width: width + "px",
|
||||
height: "3px",
|
||||
left: "20px",
|
||||
top: top + "px"
|
||||
}, "loading");
|
||||
_contentView.drawRichText("<font color=\"" + _config.loadingColor + "\">" + loadingText + "</font>", {
|
||||
width: "100px",
|
||||
top: top + "px",
|
||||
left: width + "px"
|
||||
}, {
|
||||
align: "center"
|
||||
}, "loadingText")
|
||||
},
|
||||
_createTask = function() {
|
||||
return _downloadTask ? void console.log("正在下载中") : void(_createLoading(-1),
|
||||
_downloadTask =
|
||||
uni.downloadFile({
|
||||
url: _config.packageUrl,
|
||||
success: function(res) {
|
||||
if (200 === res.statusCode) {
|
||||
var tempFilePath = res.tempFilePath;
|
||||
uni.saveFile({
|
||||
tempFilePath: tempFilePath,
|
||||
success: function(res) {
|
||||
plus.runtime.install(res.savedFilePath, {
|
||||
force: true
|
||||
}, function(res) {
|
||||
console.log('安装包信息' + JSON.stringify(res))
|
||||
}, function(res) {
|
||||
uni.showToast({
|
||||
title: '安装失败,请检查下载链接',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
});
|
||||
close();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}), _downloadTask.onProgressUpdate(function(res) {
|
||||
_loadingProgress != res.progress && (_loadingProgress = res.progress, _createLoading(res
|
||||
.progress));
|
||||
}))
|
||||
},
|
||||
init = function(option) {
|
||||
_screenHeight = plus.screen.resolutionHeight;
|
||||
_screenWidth = plus.screen.resolutionWidth;
|
||||
_downloadTask = null;
|
||||
option.titleText && (_config.titleText = option.titleText);
|
||||
option.windowHeight && (_config.windowHeight = option.windowHeight);
|
||||
option.forceUpgrade && (_config.forceUpgrade = option.forceUpgrade);
|
||||
option.content && (_config.content = option.content);
|
||||
option.contentAlign && (_config.contentAlign = option.contentAlign);
|
||||
option.loadingColor && (_config.loadingColor = option.loadingColor);
|
||||
option.cancelText && (_config.cancelText = option.cancelText);
|
||||
option.cancelColor && (_config.cancelColor = option.cancelColor);
|
||||
option.confirmText && (_config.confirmText = option.confirmText);
|
||||
option.confirmColor && (_config.confirmColor = option.confirmColor);
|
||||
option.packageUrl && (_config.packageUrl = option.packageUrl);
|
||||
option.browser && (_config.browser = option.browser);
|
||||
option.maskColor && (_config.maskColor = option.maskColor);
|
||||
_createMask();
|
||||
_createContentView();
|
||||
},
|
||||
show = function() {
|
||||
_maskView && _maskView.show();
|
||||
_contentView && _contentView.show();
|
||||
},
|
||||
close = function() {
|
||||
_downloadTask && (_downloadTask.abort(), _downloadTask = null, _createLoading(-2));
|
||||
_maskView && _maskView.hide();
|
||||
_contentView && _contentView.hide();
|
||||
};
|
||||
export default {
|
||||
init: init,
|
||||
show: show,
|
||||
close: close
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
export default {
|
||||
init: function(options) {
|
||||
this.initWebview(options)
|
||||
this.handleEvent()
|
||||
return this
|
||||
},
|
||||
initWebview: function(options) {
|
||||
var hh=plus.screen.height-44
|
||||
var _self = this
|
||||
_self.webview = plus.webview.create('', 'browser', {
|
||||
scalable:true,
|
||||
height:hh+'px',
|
||||
bottom:'44px',
|
||||
background:'#ff5500',
|
||||
titleNView: {
|
||||
backgroundColor: '#FFFFFF',
|
||||
progress: { //进度条
|
||||
color: '#4678e7',
|
||||
height: '3px'
|
||||
},
|
||||
splitLine: { //底部分割线
|
||||
color: '#cccccc',
|
||||
height: '1px'
|
||||
},
|
||||
buttons: [{ //关闭按钮
|
||||
'float': 'left',
|
||||
fontSrc: '/static/uni.ttf',
|
||||
text: '\ue460',
|
||||
onclick: _self.close.bind(_self)
|
||||
}, { //更多按钮
|
||||
'float': 'right',
|
||||
fontSrc: '/static/uni.ttf',
|
||||
text: '\ue507',
|
||||
onclick: _self.more.bind(_self)
|
||||
}]
|
||||
},
|
||||
additionalHttpHeaders: options.headers || {}
|
||||
})
|
||||
// 配置下拉刷新
|
||||
_self.webview.setPullToRefresh({
|
||||
support: true
|
||||
}, function() {
|
||||
_self.reload()
|
||||
var titleUpdate = function() {
|
||||
setTimeout(function() {
|
||||
_self.webview.endPullToRefresh()
|
||||
_self.webview.removeEventListener('titleUpdate', titleUpdate)
|
||||
}, 300)
|
||||
};
|
||||
_self.webview.addEventListener('titleUpdate', titleUpdate)
|
||||
})
|
||||
|
||||
//绘制返回前进按钮
|
||||
this.navBottom = new plus.nativeObj.View("navBottom", {
|
||||
bottom: '0px',
|
||||
left: '0px',
|
||||
height: '44px',
|
||||
width: '100%',
|
||||
backgroundColor: 'rgb(255,255,255)'
|
||||
})
|
||||
var screenWidth = plus.screen.resolutionWidth
|
||||
var left = screenWidth / 4
|
||||
this.navBottom.draw([{
|
||||
tag: 'font',
|
||||
id: 'back',
|
||||
text: '\ue471',
|
||||
textStyles: {
|
||||
fontSrc: '/static/uni.ttf',
|
||||
size: '24px',
|
||||
color: '#000000'
|
||||
},
|
||||
position: {
|
||||
right: left+48,
|
||||
height: '100%',
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'forward',
|
||||
text: '\ue470',
|
||||
textStyles: {
|
||||
fontSrc: '/static/uni.ttf',
|
||||
size: '24px',
|
||||
color: '#000000'
|
||||
},
|
||||
position: {
|
||||
left: left,
|
||||
height: '100%',
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
//点击前进或后退
|
||||
this.navBottom.addEventListener("click", (e) => {
|
||||
if (e.clientX > left && e.clientX < (left + 24)) {
|
||||
_self.back()
|
||||
}
|
||||
if (e.clientX > (screenWidth - left - 12) && e.clientX < (screenWidth - left + 12)) {
|
||||
_self.forward()
|
||||
}
|
||||
})
|
||||
|
||||
//监听页面变化
|
||||
_self.webview.addEventListener('loaded', function() {
|
||||
_self.webview.canBack(function(event) {
|
||||
var canBack = false
|
||||
if (event.canBack) {
|
||||
canBack = true
|
||||
_self.navBottom.show()
|
||||
} else {
|
||||
canBack = false
|
||||
}
|
||||
_self.webview.canForward(function(event) {
|
||||
if (event.canForward) {
|
||||
_self.navBottom.drawText('\ue470', {
|
||||
left: left,
|
||||
height: '100%'
|
||||
}, {
|
||||
color: '#000000',
|
||||
fontSrc: '/static/uni.ttf',
|
||||
size: '24px'
|
||||
}, 'forward')
|
||||
} else {
|
||||
_self.navBottom.drawText('\ue470', {
|
||||
left: left,
|
||||
height: '100%'
|
||||
}, {
|
||||
color: '#EEEEEE',
|
||||
fontSrc: '/static/uni.ttf',
|
||||
size: '24px'
|
||||
}, 'forward')
|
||||
}
|
||||
if (!canBack && !event.canForward) {
|
||||
// _self.navBottom.hide()
|
||||
}
|
||||
})
|
||||
})
|
||||
_self.navBottom.show()
|
||||
}, false)
|
||||
},
|
||||
handleEvent: function(url) {
|
||||
var _self = this
|
||||
plus.key.addEventListener('backbutton', function() {
|
||||
_self.close()
|
||||
return
|
||||
var topWebview = plus.webview.getTopWebview()
|
||||
// 不等于浏览器窗口
|
||||
if (topWebview.id !== 'browser') {
|
||||
// 这里除了浏览器窗口就是首页了,直接退出了;
|
||||
plus.runtime.quit()
|
||||
} else {
|
||||
_self.back()
|
||||
}
|
||||
})
|
||||
},
|
||||
show: function(url) {
|
||||
url = url || 'https://www.baidu.com'
|
||||
this.webview.loadURL(url)
|
||||
this.webview.show('slide-in-right')
|
||||
},
|
||||
more: function() {
|
||||
var _self = this
|
||||
uni.showActionSheet({
|
||||
itemList: ['刷新', '浏览器打开'],
|
||||
success: function(res) {
|
||||
if (res.tapIndex == 0) {
|
||||
_self.reload()
|
||||
} else if (res.tapIndex == 1) {
|
||||
plus.runtime.openURL(_self.webview.getURL())
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
reload: function() {
|
||||
// 刷新
|
||||
this.webview.reload(true)
|
||||
},
|
||||
back: function() {
|
||||
//后退
|
||||
var _self = this
|
||||
_self.webview.canBack(function(event) {
|
||||
if (event.canBack) {
|
||||
_self.webview.back()
|
||||
} else {
|
||||
_self.close()
|
||||
}
|
||||
})
|
||||
},
|
||||
forward: function() {
|
||||
//前进
|
||||
var _self = this
|
||||
_self.webview.canForward(function(event) {
|
||||
if (event.canForward) {
|
||||
_self.webview.forward();
|
||||
} else {
|
||||
plus.nativeUI.toast('没有可前进的地址')
|
||||
}
|
||||
})
|
||||
},
|
||||
close: function() {
|
||||
//关闭
|
||||
// this.navBottom.hide()
|
||||
this.navBottom.close()
|
||||
this.navBottom=null;
|
||||
this.webview.close('browser', 'slide-out-right')
|
||||
this.webview.clear()
|
||||
plus.key.removeEventListener("backbutton", function() {
|
||||
});
|
||||
}
|
||||
}
|
||||
30165
im-uniapp/common/city.js
30165
im-uniapp/common/city.js
File diff suppressed because it is too large
Load Diff
@@ -1,48 +0,0 @@
|
||||
export default class config{
|
||||
static prod="online"
|
||||
static getZnzqApiUrl(){
|
||||
if(process.env.NODE_ENV === 'development' ){
|
||||
return 'http://work.ii999.live:19002/znzq'
|
||||
}else{
|
||||
if(this.prod=="online"){
|
||||
return 'http://work.ii999.live:19002/znzq'
|
||||
}else{
|
||||
return '/znzq'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static getBaseApiUrl(){
|
||||
//return process.env.NODE_ENV === 'development' ? 'http://119.45.242.222:8989' :'http://172.16.2.3:8989';
|
||||
return process.env.NODE_ENV === 'development' ? 'http://119.45.242.222:8989' :'/base_api';
|
||||
}
|
||||
static getImApiUrl(){
|
||||
//return process.env.NODE_ENV === 'development' ? 'http://119.45.242.222:28000/v1' :'http://172.16.2.3:28000/v1';
|
||||
return process.env.NODE_ENV === 'development' ? 'http://119.45.242.222/im_api/v1' :'/im_api/v1';
|
||||
}
|
||||
static getImAppId(){
|
||||
return 10000;
|
||||
}
|
||||
static getVideoRoomUrl(room,userid,isPublish=0,isPlayer=1,hasVideo=1,uname,tuid){
|
||||
if(process.env.NODE_ENV === 'development' ){
|
||||
return `http://localhost:8080/hd-glasses-app/#/call_room?showInviteConfirmDialog=1&isForce=0&isPublish=${isPublish}&isPlayer=${isPlayer}&uid=${userid}&room=${room}&hasVideo=${hasVideo}&uname=${uname}&tuid=${tuid}`
|
||||
}else{
|
||||
if(this.prod=="online"){
|
||||
return `https://119.45.242.222/hd-glasses-app/#/call_room?showInviteConfirmDialog=1&isForce=0&isPublish=${isPublish}&isPlayer=${isPlayer}&uid=${userid}&room=${room}&hasVideo=${hasVideo}&uname=${uname}&tuid=${tuid}`
|
||||
}else{
|
||||
return `https://172.16.3.19/hd-glasses-app/#/call_room?showInviteConfirmDialog=1&isForce=0&isPublish=${isPublish}&isPlayer=${isPlayer}&uid=${userid}&room=${room}&hasVideo=${hasVideo}&uname=${uname}&tuid=${tuid}`
|
||||
}
|
||||
}
|
||||
}
|
||||
static getSRSUrl(){
|
||||
if(process.env.NODE_ENV === 'development' ){
|
||||
return 'webrtc://119.45.242.222/'
|
||||
}else{
|
||||
if(this.prod=="online"){
|
||||
return 'webrtc://119.45.242.222/'
|
||||
}else{
|
||||
return 'webrtc://172.16.3.19/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default {
|
||||
fz:' ......................阿弥陀佛......................\n' + ' _oo0oo_ \n' + ' o8888888o \n' + ' 88" . "88 \n' + ' (| -_- |) \n' + ' 0\\ = /0 \n' + ' ___/‘---’\\___ \n' + " .' \\| |/ '. \n" + ' / \\\\||| : |||// \\ \n' + ' / _||||| -卍-|||||_ \\ \n' + ' | | \\\\\\ - /// | | \n' + " | \\_| ''\\---/'' |_/ | \n" + " \\ .-\\__ '-' ___/-. / \n" + " ___'. .' /--.--\\ '. .'___ \n" + ' ."" ‘< ‘.___\\_<|>_/___.’>’ "". \n' + ' | | : ‘- \\‘.;‘\\ _ /’;.’/ - ’ : | | \n' + ' \\ \\ ‘_. \\_ __\\ /__ _/ .-’ / / \n' + ' =====‘-.____‘.___ \\_____/___.-’___.-’===== \n' + ' ‘=---=’ \n' + ' \n' + '....................佛祖保佑 ,永无BUG...................'
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import Request from 'luch-request' // 使用npm
|
||||
import conf from "@/common/config.js"
|
||||
|
||||
const customHttp = new Request({
|
||||
timeout: 300000, //超时时长5分钟,
|
||||
header: {
|
||||
'Content-Type': 'application/json;charset=UTF-8;'
|
||||
}
|
||||
});
|
||||
|
||||
//请求拦截器
|
||||
customHttp.interceptors.request.use((config) => {
|
||||
if (config.custom.target != undefined) {
|
||||
if (config.custom.target == "znzq") {
|
||||
config.baseURL = conf.getZnzqApiUrl()
|
||||
const token = uni.getStorageSync('token');
|
||||
config.header["X-Access-Token"] = token;
|
||||
console.log("==================customHttp.interceptors.request.use")
|
||||
console.log(config)
|
||||
}
|
||||
}
|
||||
|
||||
console.log(config)
|
||||
return config
|
||||
}, error => {
|
||||
return Promise.resolve(error)
|
||||
})
|
||||
|
||||
// 响应拦截器
|
||||
customHttp.interceptors.response.use((response) => {
|
||||
console.log(response)
|
||||
return response
|
||||
}, (error) => {
|
||||
//未登录时清空缓存跳转
|
||||
if (error.statusCode == 401) {
|
||||
uni.clearStorageSync();
|
||||
uni.switchTab({
|
||||
url: "/pages/index/index.vue"
|
||||
})
|
||||
}
|
||||
return Promise.resolve(error)
|
||||
})
|
||||
|
||||
|
||||
export default {
|
||||
customHttp
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,17 +0,0 @@
|
||||
|
||||
function getIM(){
|
||||
// UNIAPP 环境
|
||||
if(typeof uni !== 'undefined'){
|
||||
return {im:uni['im'], im_webtoolkit:uni['im_webtoolkit']};
|
||||
}
|
||||
throw Error(" Couldn't not fetch lim.");
|
||||
}
|
||||
|
||||
|
||||
const lim = {
|
||||
im: getIM().im,
|
||||
};
|
||||
|
||||
export default {
|
||||
lim
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
|
||||
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
|
||||
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
|
||||
|
||||
/*
|
||||
* Perform a simple self-test to see if the VM is working
|
||||
*/
|
||||
function md5_vm_test()
|
||||
{
|
||||
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length
|
||||
*/
|
||||
function core_md5(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << ((len) % 32);
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
|
||||
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
|
||||
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
|
||||
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
|
||||
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
|
||||
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
|
||||
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
|
||||
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
|
||||
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
|
||||
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
|
||||
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
|
||||
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
|
||||
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
|
||||
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
|
||||
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
|
||||
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
|
||||
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
|
||||
|
||||
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
|
||||
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
|
||||
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
|
||||
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
|
||||
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
|
||||
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
|
||||
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
|
||||
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
|
||||
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
|
||||
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
|
||||
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
|
||||
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
|
||||
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
|
||||
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
|
||||
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
|
||||
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
|
||||
|
||||
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
|
||||
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
|
||||
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
|
||||
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
|
||||
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
|
||||
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
|
||||
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
|
||||
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
|
||||
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
|
||||
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
|
||||
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
|
||||
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
|
||||
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
|
||||
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
|
||||
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
|
||||
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
|
||||
|
||||
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
|
||||
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
|
||||
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
|
||||
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
|
||||
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
|
||||
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
|
||||
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
|
||||
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
|
||||
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
|
||||
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
|
||||
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
|
||||
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
|
||||
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
|
||||
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
|
||||
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
|
||||
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
}
|
||||
return Array(a, b, c, d);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5_cmn(q, a, b, x, s, t)
|
||||
{
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data
|
||||
*/
|
||||
function core_hmac_md5(key, data)
|
||||
{
|
||||
var bkey = str2binl(key);
|
||||
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
|
||||
return core_md5(opad.concat(hash), 512 + 128);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a string to an array of little-endian words
|
||||
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
|
||||
*/
|
||||
function str2binl(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
|
||||
return bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a hex string.
|
||||
*/
|
||||
function binl2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a base-64 string
|
||||
*/
|
||||
function binl2b64(binarray)
|
||||
{
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
export default {
|
||||
hex_md5
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
/// null = 未请求,1 = 已允许,0 = 拒绝|受限, 2 = 系统未开启
|
||||
|
||||
var isIOS
|
||||
|
||||
function album() {
|
||||
var result = 0;
|
||||
var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary");
|
||||
var authStatus = PHPhotoLibrary.authorizationStatus();
|
||||
if (authStatus === 0) {
|
||||
result = null;
|
||||
} else if (authStatus == 3) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(PHPhotoLibrary);
|
||||
return result;
|
||||
}
|
||||
|
||||
function camera() {
|
||||
var result = 0;
|
||||
var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
|
||||
var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
|
||||
if (authStatus === 0) {
|
||||
result = null;
|
||||
} else if (authStatus == 3) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(AVCaptureDevice);
|
||||
return result;
|
||||
}
|
||||
|
||||
function location() {
|
||||
var result = 0;
|
||||
var cllocationManger = plus.ios.import("CLLocationManager");
|
||||
var enable = cllocationManger.locationServicesEnabled();
|
||||
var status = cllocationManger.authorizationStatus();
|
||||
if (!enable) {
|
||||
result = 2;
|
||||
} else if (status === 0) {
|
||||
result = null;
|
||||
} else if (status === 3 || status === 4) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(cllocationManger);
|
||||
return result;
|
||||
}
|
||||
|
||||
function push() {
|
||||
var result = 0;
|
||||
var UIApplication = plus.ios.import("UIApplication");
|
||||
var app = UIApplication.sharedApplication();
|
||||
var enabledTypes = 0;
|
||||
if (app.currentUserNotificationSettings) {
|
||||
var settings = app.currentUserNotificationSettings();
|
||||
enabledTypes = settings.plusGetAttribute("types");
|
||||
if (enabledTypes == 0) {
|
||||
result = 0;
|
||||
console.log("推送权限没有开启");
|
||||
} else {
|
||||
result = 1;
|
||||
console.log("已经开启推送功能!")
|
||||
}
|
||||
plus.ios.deleteObject(settings);
|
||||
} else {
|
||||
enabledTypes = app.enabledRemoteNotificationTypes();
|
||||
if (enabledTypes == 0) {
|
||||
result = 3;
|
||||
console.log("推送权限没有开启!");
|
||||
} else {
|
||||
result = 4;
|
||||
console.log("已经开启推送功能!")
|
||||
}
|
||||
}
|
||||
plus.ios.deleteObject(app);
|
||||
plus.ios.deleteObject(UIApplication);
|
||||
return result;
|
||||
}
|
||||
|
||||
function contact() {
|
||||
var result = 0;
|
||||
var CNContactStore = plus.ios.import("CNContactStore");
|
||||
var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0);
|
||||
if (cnAuthStatus === 0) {
|
||||
result = null;
|
||||
} else if (cnAuthStatus == 3) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(CNContactStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
function record() {
|
||||
var result = null;
|
||||
var avaudiosession = plus.ios.import("AVAudioSession");
|
||||
var avaudio = avaudiosession.sharedInstance();
|
||||
var status = avaudio.recordPermission();
|
||||
console.log("permissionStatus:" + status);
|
||||
if (status === 1970168948) {
|
||||
result = null;
|
||||
} else if (status === 1735552628) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(avaudiosession);
|
||||
return result;
|
||||
}
|
||||
|
||||
function calendar() {
|
||||
var result = null;
|
||||
var EKEventStore = plus.ios.import("EKEventStore");
|
||||
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0);
|
||||
if (ekAuthStatus == 3) {
|
||||
result = 1;
|
||||
console.log("日历权限已经开启");
|
||||
} else {
|
||||
console.log("日历权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(EKEventStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
function memo() {
|
||||
var result = null;
|
||||
var EKEventStore = plus.ios.import("EKEventStore");
|
||||
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1);
|
||||
if (ekAuthStatus == 3) {
|
||||
result = 1;
|
||||
console.log("备忘录权限已经开启");
|
||||
} else {
|
||||
console.log("备忘录权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(EKEventStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function requestIOS(permissionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
switch (permissionID) {
|
||||
case "push":
|
||||
resolve(push());
|
||||
break;
|
||||
case "location":
|
||||
resolve(location());
|
||||
break;
|
||||
case "record":
|
||||
resolve(record());
|
||||
break;
|
||||
case "camera":
|
||||
resolve(camera());
|
||||
break;
|
||||
case "album":
|
||||
resolve(album());
|
||||
break;
|
||||
case "contact":
|
||||
resolve(contact());
|
||||
break;
|
||||
case "calendar":
|
||||
resolve(calendar());
|
||||
break;
|
||||
case "memo":
|
||||
resolve(memo());
|
||||
break;
|
||||
default:
|
||||
resolve(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function requestAndroid(permissionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
plus.android.requestPermissions(
|
||||
[permissionID],
|
||||
function(resultObj) {
|
||||
var result = 0;
|
||||
for (var i = 0; i < resultObj.granted.length; i++) {
|
||||
var grantedPermission = resultObj.granted[i];
|
||||
console.log('已获取的权限:' + grantedPermission);
|
||||
result = 1
|
||||
}
|
||||
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
|
||||
var deniedPresentPermission = resultObj.deniedPresent[i];
|
||||
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
|
||||
result = 0
|
||||
}
|
||||
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
|
||||
var deniedAlwaysPermission = resultObj.deniedAlways[i];
|
||||
console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
|
||||
result = -1
|
||||
}
|
||||
resolve(result);
|
||||
},
|
||||
function(error) {
|
||||
console.log('result error: ' + error.message)
|
||||
resolve({
|
||||
code: error.code,
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function gotoAppPermissionSetting() {
|
||||
if (permission.isIOS) {
|
||||
var UIApplication = plus.ios.import("UIApplication");
|
||||
var application2 = UIApplication.sharedApplication();
|
||||
var NSURL2 = plus.ios.import("NSURL");
|
||||
var setting2 = NSURL2.URLWithString("app-settings:");
|
||||
application2.openURL(setting2);
|
||||
plus.ios.deleteObject(setting2);
|
||||
plus.ios.deleteObject(NSURL2);
|
||||
plus.ios.deleteObject(application2);
|
||||
} else {
|
||||
var Intent = plus.android.importClass("android.content.Intent");
|
||||
var Settings = plus.android.importClass("android.provider.Settings");
|
||||
var Uri = plus.android.importClass("android.net.Uri");
|
||||
var mainActivity = plus.android.runtimeMainActivity();
|
||||
var intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
mainActivity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
const permission = {
|
||||
get isIOS(){
|
||||
return typeof isIOS === 'boolean' ? isIOS : (isIOS = uni.getSystemInfoSync().platform === 'ios')
|
||||
},
|
||||
requestIOS: requestIOS,
|
||||
requestAndroid: requestAndroid,
|
||||
gotoAppSetting: gotoAppPermissionSetting
|
||||
}
|
||||
|
||||
export default permission
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,302 +0,0 @@
|
||||
// #ifdef APP-PLUS
|
||||
import appUpgrade from '@/common/appUpgrade.js';
|
||||
// #endif
|
||||
import config from "@/common/config.js"
|
||||
let http = {
|
||||
'setBaseUrl': (url) => {
|
||||
if (url.charAt(url.length - 1) === "/") {
|
||||
url = url.substr(0, url.length - 1)
|
||||
}
|
||||
http.baseUrl = url;
|
||||
},
|
||||
'header': {},
|
||||
'beforeRequestFilter': (config) => {
|
||||
return config
|
||||
},
|
||||
'beforeResponseFilter': (res) => {
|
||||
return res
|
||||
},
|
||||
'afterResponseFilter': (successResult) => {},
|
||||
'get': get,
|
||||
'delete': deletE,
|
||||
'post': post,
|
||||
'put': put,
|
||||
'request': request,
|
||||
'uploadFile': uploadFile,
|
||||
'downloadFile': downloadFile
|
||||
}
|
||||
|
||||
|
||||
function init(con) {
|
||||
//url
|
||||
let url = http.baseUrl;
|
||||
if (url && con.url && !con.url.match(/^(http|https):\/\/([\w.]+\/?)\S*$/)) {
|
||||
if (con.url.charAt(0) !== "/") {
|
||||
con.url = "/" + con.url;
|
||||
}
|
||||
con.url = url.concat(con.url);
|
||||
}
|
||||
//header
|
||||
if (http.header != undefined && http.header != null) {
|
||||
if (!con.header) {
|
||||
con.header = http.header;
|
||||
} else {
|
||||
Object.keys(http.header).forEach(function(key) {
|
||||
con.header[key] = http.header[key]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function request(con) {
|
||||
init(con);
|
||||
let config = { //判断是否有以下属性没有就赋予默认值
|
||||
url: con.url ? con.url : http.baseUrl,
|
||||
data: con.data,
|
||||
header: con.header,
|
||||
method: con.method ? con.method : 'GET',
|
||||
dataType: con.dataType ? con.dataType : 'json',
|
||||
responseType: con.responseType ? con.responseType : 'text',
|
||||
success: con.success ? (res) => {
|
||||
http.afterResponseFilter(con.success(http.beforeResponseFilter(res)));
|
||||
} : null,
|
||||
fail: con.fail ? (res) => {
|
||||
con.fail(res);
|
||||
} : () => {
|
||||
uni.showToast({
|
||||
title: '请检查网络',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading();
|
||||
},
|
||||
complete: con.complete ? (res) => {
|
||||
con.complete(res);
|
||||
} : (res) => {
|
||||
if (!res.statusCode) {
|
||||
uni.showToast({
|
||||
title: '请求失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading();
|
||||
}
|
||||
if (res.statusCode !== 200) {
|
||||
uni.showToast({
|
||||
title: '请求失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading();
|
||||
}
|
||||
if (res.statusCode == 200) {
|
||||
if (res.data.code == 401) { //登录过期
|
||||
// uni.showToast({
|
||||
// title: '登录已过期,请重新登录',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// uni.hideLoading();
|
||||
// uni.reLaunch({
|
||||
// url:'/pages/wxindex/index'
|
||||
// })
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
if (res.data.code == 601) { //强制拉起升级
|
||||
request({
|
||||
url: '/common/getVersion',
|
||||
success: (res) => {
|
||||
appUpgrade.init({
|
||||
titleText: '版本更新'+res.data.data.version,
|
||||
packageUrl:res.data.data.url,
|
||||
content: res.data.data.content,
|
||||
forceUpgrade:true
|
||||
});
|
||||
appUpgrade.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
else if (res.data.code && res.data.code !== 200) { //这里code是自己的服务器正确标识
|
||||
uni.showToast({
|
||||
title: res.data.msg,
|
||||
icon: 'none',
|
||||
position:'top'
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
}
|
||||
uni.stopPullDownRefresh();
|
||||
}
|
||||
}
|
||||
const AUTH_TOKEN = ["Authorization","device","version"];
|
||||
for (var i = 0; i < AUTH_TOKEN.length; i++) {
|
||||
if (uni.getStorageSync(AUTH_TOKEN[i])) {
|
||||
http.header[AUTH_TOKEN[i]] = uni.getStorageSync(AUTH_TOKEN[i]);
|
||||
}
|
||||
}
|
||||
return uni.request(http.beforeRequestFilter(config));
|
||||
}
|
||||
|
||||
function get(url, con, success) {
|
||||
let conf = {};
|
||||
if (con && typeof con == 'function') {
|
||||
if (success && typeof success == 'object') {
|
||||
conf = success;
|
||||
}
|
||||
conf.success = con
|
||||
} else {
|
||||
if (con && typeof con == 'object') {
|
||||
conf = con;
|
||||
}
|
||||
conf.success = success;
|
||||
}
|
||||
|
||||
if (url) {
|
||||
conf.url = url
|
||||
}
|
||||
conf.method = "GET";
|
||||
return request(conf);
|
||||
}
|
||||
|
||||
function deletE(url, con, success) {
|
||||
let conf = {};
|
||||
if (con && typeof con == 'function') {
|
||||
if (success && typeof success == 'object') {
|
||||
conf = success;
|
||||
}
|
||||
conf.success = con
|
||||
} else {
|
||||
if (con && typeof con == 'object') {
|
||||
conf = con;
|
||||
}
|
||||
conf.success = success;
|
||||
}
|
||||
|
||||
if (url) {
|
||||
conf.url = url
|
||||
}
|
||||
conf.method = "DELETE";
|
||||
return request(conf);
|
||||
}
|
||||
|
||||
function post(url, data, con, success) {
|
||||
let conf = {};
|
||||
if (con && typeof con == 'function') {
|
||||
if (success && typeof success == 'object') {
|
||||
conf = success
|
||||
}
|
||||
conf.success = con;
|
||||
} else {
|
||||
if (con && typeof con == 'object') {
|
||||
conf = con;
|
||||
}
|
||||
conf.success = success;
|
||||
}
|
||||
if (url) {
|
||||
conf.url = url
|
||||
}
|
||||
if (data) {
|
||||
conf.data = data
|
||||
}
|
||||
conf.method = "POST";
|
||||
return request(conf);
|
||||
}
|
||||
|
||||
function put(url, data, con, success) {
|
||||
let conf = {};
|
||||
if (con && typeof con == 'function') {
|
||||
if (success && typeof success == 'object') {
|
||||
conf = success
|
||||
}
|
||||
conf.success = con;
|
||||
} else {
|
||||
if (con && typeof con == 'object') {
|
||||
conf = con;
|
||||
}
|
||||
conf.success = success;
|
||||
}
|
||||
if (url) {
|
||||
conf.url = url
|
||||
}
|
||||
if (data) {
|
||||
conf.data = data
|
||||
}
|
||||
conf.method = "PUT";
|
||||
return request(conf);
|
||||
}
|
||||
|
||||
function uploadFile(con) {
|
||||
init(con);
|
||||
console.log("========================")
|
||||
console.log("========================")
|
||||
console.log("========================")
|
||||
console.error(con.url)
|
||||
console.error(con.url)
|
||||
console.error(con.url)
|
||||
console.error(con.url)
|
||||
let config = {
|
||||
url: con.url ? con.url : http.baseUrl,
|
||||
files: con.files,
|
||||
filesType: con.filesType,
|
||||
filePath: con.filePath,
|
||||
name: con.name,
|
||||
header: con.header,
|
||||
formData: con.formData,
|
||||
success: con.success ? (res) => {
|
||||
http.afterResponseFilter(con.success(http.beforeResponseFilter(res)));
|
||||
} : null,
|
||||
fail: con.fail ? (res) => {
|
||||
con.fail(res);
|
||||
} : null,
|
||||
complete: con.complete ? (res) => {
|
||||
con.complete(res);
|
||||
} : null
|
||||
}
|
||||
const AUTH_TOKEN = ["Authorization","device","version"];
|
||||
for (var i = 0; i < AUTH_TOKEN.length; i++) {
|
||||
if (uni.getStorageSync(AUTH_TOKEN[i])) {
|
||||
http.header[AUTH_TOKEN[i]] = uni.getStorageSync(AUTH_TOKEN[i]);
|
||||
}
|
||||
}
|
||||
return uni.uploadFile(http.beforeRequestFilter(config));
|
||||
}
|
||||
|
||||
function downloadFile(con) {
|
||||
init(con);
|
||||
let config = {
|
||||
url: con.url ? con.url : http.baseUrl,
|
||||
header: con.header,
|
||||
success: con.success ? (res) => {
|
||||
http.afterResponseFilter(con.success(http.beforeResponseFilter(res)));
|
||||
} : null,
|
||||
fail: con.fail ? (res) => {
|
||||
con.fail(res);
|
||||
} : null,
|
||||
complete: con.complete ? (res) => {
|
||||
con.complete(res);
|
||||
} : null
|
||||
}
|
||||
return uni.downloadFile(http.beforeRequestFilter(config));
|
||||
}
|
||||
// 使用
|
||||
//POST
|
||||
// this.$http.request({
|
||||
// url: '/xxx',
|
||||
// method: 'POST',
|
||||
// data:JSON.stringify({id:111}),
|
||||
// success: (res) => {
|
||||
// if (res.data.code == 200) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//GET
|
||||
// this.$http.request({
|
||||
// url: '/xxx?id=111',
|
||||
// success: (res) => {
|
||||
// if (res.data.code == 200) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// 地址及配置
|
||||
http.setBaseUrl(config.getBaseApiUrl()); //在线服务器
|
||||
// http.setBaseUrl("http://192.168.0.105:8080"); //离线服务器
|
||||
export default http
|
||||
@@ -1,192 +0,0 @@
|
||||
import config from "@/common/config.js"
|
||||
let timer = null
|
||||
let retimer = null
|
||||
import store from '../store'
|
||||
import * as sdk from "@/common/imSdk/lim-sdk.js";
|
||||
import lim from "@/common/imSdk/sdk-bridge.js";
|
||||
|
||||
import publicFc from '@/common/publicFc';
|
||||
import localForage from 'localforage';
|
||||
|
||||
|
||||
export default {
|
||||
socketTask: null,
|
||||
// 连接WebSocket
|
||||
connectSocket() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const ListenerMap = {
|
||||
onSocketConnectEvent: (option, status, data) => {
|
||||
console.log("已建立连接:" + JSON.stringify(status));
|
||||
},
|
||||
onSocketErrorEvent: (error) => {
|
||||
console.log("连接出现错误:" + userId);
|
||||
},
|
||||
onSocketReConnectEvent: () => {
|
||||
console.log("正在重连:");
|
||||
},
|
||||
onSocketCloseEvent: () => {
|
||||
console.log("连接关闭:");
|
||||
},
|
||||
onSocketReConnectSuccessEvent: () => {
|
||||
console.log("重连成功");
|
||||
},
|
||||
onOfflineMessage: (e) => {
|
||||
// console.log("====================拉取到离线消息")
|
||||
// console.log(e)
|
||||
setTimeout(function() {
|
||||
if (e.length > 0) {
|
||||
e.map((msg) => {
|
||||
setTimeout(()=>{
|
||||
const _data = publicFc.formatMessage(msg)
|
||||
uni.$emit('onP2PMessage', _data);
|
||||
store.dispatch('onP2PMessage', _data)
|
||||
},500)
|
||||
})
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
},
|
||||
onTestMessage: (e) => {
|
||||
console.log("onTestMessage :");
|
||||
store.dispatch('onP2PMessage', e)
|
||||
},
|
||||
onP2PMessage: (e) => {
|
||||
console.log("onP2PMessag e :::");
|
||||
console.log(JSON.parse(e))
|
||||
e = JSON.parse(e)
|
||||
|
||||
const _data = publicFc.formatMessage(e.data)
|
||||
|
||||
uni.$emit('onP2PMessage', _data);
|
||||
store.dispatch('onP2PMessage', _data)
|
||||
|
||||
},
|
||||
onLogin: (uid) => {
|
||||
console.log("用户" + uid + "登陆sdk成功");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
const userId = uni.getStorageSync("userId")
|
||||
|
||||
const imUserSign = uni.getStorageSync("imUserSign")
|
||||
|
||||
var listeners = {};
|
||||
for (const v in ListenerMap) {
|
||||
listeners[v] = ListenerMap[v];
|
||||
}
|
||||
|
||||
console.log(lim)
|
||||
|
||||
// 防止多次建立ws链接,貌似还没有生效,需要检查
|
||||
if (this.socketTask != null) {
|
||||
return false
|
||||
}
|
||||
|
||||
lim.lim.im.init(config.getImApiUrl(), config.getImAppId(), userId, imUserSign, listeners, (
|
||||
sdk) => {
|
||||
if (sdk) {
|
||||
console.warn("====================")
|
||||
this.socketTask = sdk;
|
||||
console.log(this.socketTask)
|
||||
|
||||
console.log('sdk 成功连接的回调, 可以使用 sdk 请求数据了.');
|
||||
|
||||
|
||||
sdk.getSingleUserInfo(userId).then(res=>{
|
||||
console.log("获取到自己的用户信息")
|
||||
console.log(res)
|
||||
if(res.code==200){
|
||||
uni.setStorageSync('userInfo', res.data);
|
||||
}
|
||||
})
|
||||
|
||||
// sdk.getAllFriend().then(res => {
|
||||
// console.warn(res)
|
||||
// })
|
||||
// sdk.getUserSequence().then(res => {
|
||||
// console.warn(res)
|
||||
// })
|
||||
|
||||
sdk.getUserConversationList(0).then(res => {
|
||||
console.warn(res)
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
console.log('sdk 初始化失败.');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
|
||||
this.socketTask = uni.connectSocket({
|
||||
url: 'wss://im-api.q3z3.com/ws?Authorization=' + uni.getStorageSync('Authorization'),
|
||||
complete: () => {}
|
||||
});
|
||||
this.socketTask.onOpen(res => {
|
||||
console.log('WebSocket连接已打开!');
|
||||
// 设置心跳
|
||||
timer = setInterval(() => {
|
||||
uni.sendSocketMessage({
|
||||
data: 'isConnact',
|
||||
success: res => {
|
||||
if (res.errMsg == 'sendSocketMessage:ok') {
|
||||
console.log('WebSocket已连接')
|
||||
} else {
|
||||
this.connectSocket()
|
||||
}
|
||||
}
|
||||
})
|
||||
}, 5000)
|
||||
})
|
||||
// 监听接收
|
||||
this.socketTask.onMessage(res => {
|
||||
if (res.data == 'ok') {
|
||||
return
|
||||
}
|
||||
var data = JSON.parse(res.data);
|
||||
fc.getPush(data);
|
||||
console.log('WebSocket接收消息!');
|
||||
})
|
||||
// 监听关闭
|
||||
this.socketTask.onClose(res => {
|
||||
console.log('WebSocket连接已关闭!');
|
||||
let token = uni.getStorageSync('Authorization');
|
||||
if (this.socketTask && token) {
|
||||
this.socketTaskClose()
|
||||
retimer = setTimeout(() => {
|
||||
this.connectSocket()
|
||||
}, 5000)
|
||||
}
|
||||
})
|
||||
// 监听异常
|
||||
this.socketTask.onError(res => {
|
||||
console.log('WebSocket连接打开失败,正在尝试重新打开!');
|
||||
if (this.socketTask) {
|
||||
this.socketTaskClose()
|
||||
retimer = setTimeout(() => {
|
||||
this.connectSocket()
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
},
|
||||
// 关闭WebSocket
|
||||
socketTaskClose() {
|
||||
if (this.socketTask) {
|
||||
this.socketTask.close()
|
||||
clearInterval(timer)
|
||||
clearTimeout(retimer)
|
||||
console.log('关闭WebSocket!');
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
export function appInit(ms) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var i = 0;
|
||||
let timer = setInterval(() => {
|
||||
var im_imUserSign = uni.getStorageSync("im_imUserSign")
|
||||
var hd_userId = uni.getStorageSync("hd_userid")
|
||||
if(hd_userId){
|
||||
uni.setStorageSync("userId",hd_userId)
|
||||
|
||||
}else{
|
||||
console.log("============未获取到hd_userid")
|
||||
}
|
||||
var hd_token = localStorage.getItem("hd_token")
|
||||
|
||||
i = 100;
|
||||
if (i < 0) {
|
||||
reject("error")
|
||||
}
|
||||
if (im_imUserSign) {
|
||||
|
||||
uni.setStorageSync("imUserSign",im_imUserSign)
|
||||
uni.setStorageSync("token",hd_token)
|
||||
|
||||
if(uni.getStorageSync("userId")!=null&&uni.getStorageSync("imUserSign")!=null&&uni.getStorageSync("token")!=null){
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
resolve("ok")
|
||||
}
|
||||
|
||||
}else{
|
||||
uni.setStorageSync("initReady",null)
|
||||
}
|
||||
}, ms);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getUrlKey 截取地址栏参数
|
||||
* @param value
|
||||
* @returns {String}
|
||||
*/
|
||||
export function getUrlParam(name) {
|
||||
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
||||
let url = window.location.href
|
||||
let search = url.split('?')[1];
|
||||
console.log(search);
|
||||
if (search) {
|
||||
var r = search.substr(0).match(reg);
|
||||
if (r !== null) {
|
||||
return unescape(r[2]);
|
||||
}
|
||||
return null;
|
||||
} else return null;
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
// 表单验证
|
||||
// zmm2113@qq.com
|
||||
/**
|
||||
* @property {Object} formData 表单
|
||||
* @property {Object} rules 验证规则
|
||||
**/
|
||||
export default {
|
||||
error: '',
|
||||
check: function(formData, rules) {
|
||||
var formDataKeys = Object.keys(formData)
|
||||
for (var i = 0; i < formDataKeys.length; i++) {
|
||||
var key = formDataKeys[i]
|
||||
if (rules[key]) {
|
||||
var itemRules = rules[key].rules
|
||||
var itemValue = formData[key]
|
||||
for (var j = 0; j < itemRules.length; j++) {
|
||||
var rule = itemRules[j]
|
||||
switch (rule.checkType){
|
||||
case 'required'://必填项
|
||||
if(!itemValue) {this.error = rule.errorMsg; return false;}
|
||||
break;
|
||||
|
||||
case 'phone'://手机号码验证
|
||||
var reg = /^1[0-9]{10,10}$/;
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'email'://邮箱验证
|
||||
var reg = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'idcard'://15-18位身份证验证
|
||||
var reg = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'url'://网址验证
|
||||
var reg = /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'reg'://正则验证 checkRule必填
|
||||
if(!rule.checkRule){
|
||||
this.error=key+' 校验失败'
|
||||
console.warn(key+' checkRule规则未填写')
|
||||
return false;
|
||||
}
|
||||
var reg = rule.checkRule;
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'number'://数字
|
||||
var reg = /^\d+$/;
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'same'://是否相同 checkRule必填
|
||||
if(!rule.checkRule){
|
||||
this.error=key+' 校验失败'
|
||||
console.warn(key+' checkRule规则未填写')
|
||||
return false;
|
||||
}
|
||||
if (itemValue!==formData[rule.checkRule]) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
case 'string'://字符串 checkRule必填
|
||||
if(!rule.checkRule){
|
||||
this.error=key+' 校验失败'
|
||||
console.warn(key+' checkRule规则未填写')
|
||||
return false;
|
||||
}
|
||||
var reg = new RegExp('^.{' + rule.checkRule + '}$');
|
||||
if (!reg.test(itemValue)) { this.error = rule.errorMsg; return false; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user