|
|
|
@ -21,21 +21,21 @@ module.exports = { |
|
|
|
|
// })
|
|
|
|
|
this.gpsObject = null; |
|
|
|
|
}, |
|
|
|
|
getNetworkType:function(successCallbck,failCallback){ |
|
|
|
|
getNetworkType: function(successCallbck, failCallback) { |
|
|
|
|
uni.getNetworkType({ |
|
|
|
|
success: function (res) { |
|
|
|
|
success: function(res) { |
|
|
|
|
if (successCallbck) { |
|
|
|
|
successCallbck(res); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail:function(){ |
|
|
|
|
if (failCallback) { |
|
|
|
|
failCallback(res); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: function() { |
|
|
|
|
if (failCallback) { |
|
|
|
|
failCallback(res); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
hideLoadingByTime:function(){ |
|
|
|
|
hideLoadingByTime: function() { |
|
|
|
|
setTimeout(function() { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
}, 10000); |
|
|
|
@ -60,9 +60,9 @@ module.exports = { |
|
|
|
|
param.clng = param.lng; |
|
|
|
|
if (this.gpsObject) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:"为了您的良好体验请打开GPS功能", |
|
|
|
|
icon:"none", |
|
|
|
|
duration:2000 |
|
|
|
|
title: "为了您的良好体验请打开GPS功能", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}) |
|
|
|
|
this.gpsObject.callGpsFail(); |
|
|
|
|
} |
|
|
|
@ -83,16 +83,16 @@ module.exports = { |
|
|
|
|
|
|
|
|
|
if (this.gpsObject) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:"为了您的良好体验请打开GPS功能", |
|
|
|
|
icon:"none", |
|
|
|
|
duration:2000 |
|
|
|
|
title: "为了您的良好体验请打开GPS功能", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}) |
|
|
|
|
this.gpsObject.callGpsFail(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//获取安卓内容
|
|
|
|
|
getAndroidData: function(code,mes,type,data){ |
|
|
|
|
getAndroidData: function(code, mes, type, data) { |
|
|
|
|
/* mes += "---------"+type+"-------"+code+"------"+data; |
|
|
|
|
uni.showModal({ |
|
|
|
|
title:"提示", |
|
|
|
@ -102,7 +102,7 @@ module.exports = { |
|
|
|
|
} |
|
|
|
|
}) */ |
|
|
|
|
if (code == "200") { |
|
|
|
|
if(type == "WxUserInfo"){ |
|
|
|
|
if (type == "WxUserInfo") { |
|
|
|
|
var wx_data = JSON.parse(data); |
|
|
|
|
// var unionid = "oaxUrw1nI4vDQ1ihKWlrDWIXHea0";
|
|
|
|
|
// uni.setStorageSync("unionid","oaxUrw1nI4vDQ1ihKWlrDWIXHea0");
|
|
|
|
@ -111,54 +111,54 @@ module.exports = { |
|
|
|
|
// uni.setStorageSync("headimgurl","http://thirdwx.qlogo.cn/mmopen/vi_32/0sUibCSJ47ia4mjIib7Xs2MTVxdMyr7jhq1kj0PDnuHOd5vUbibn7MrGekMqfFjUWXLGPZurvRlKRyZc5awpA1Sa7g/132");
|
|
|
|
|
var unionid = wx_data.unionid; |
|
|
|
|
var url = wx_data.headimgurl; |
|
|
|
|
url = url.substring(url.indexOf(":")+1); |
|
|
|
|
uni.setStorageSync("oauthTime",new Date().getTime()) |
|
|
|
|
uni.setStorageSync("unionid",aes.aesMinEncrypt(unionid)); |
|
|
|
|
uni.setStorageSync("openid",aes.aesMinEncrypt(wx_data.openid)); |
|
|
|
|
uni.setStorageSync("nickname",aes.aesMinEncrypt(wx_data.nickname)); |
|
|
|
|
uni.setStorageSync("headimgurl",aes.aesMinEncrypt(url)); |
|
|
|
|
url = url.substring(url.indexOf(":") + 1); |
|
|
|
|
uni.setStorageSync("oauthTime", new Date().getTime()) |
|
|
|
|
uni.setStorageSync("unionid", aes.aesMinEncrypt(unionid)); |
|
|
|
|
uni.setStorageSync("openid", aes.aesMinEncrypt(wx_data.openid)); |
|
|
|
|
uni.setStorageSync("nickname", aes.aesMinEncrypt(wx_data.nickname)); |
|
|
|
|
uni.setStorageSync("headimgurl", aes.aesMinEncrypt(url)); |
|
|
|
|
var that = this.gpsObject; |
|
|
|
|
wx_data.headimgurl = url; |
|
|
|
|
data = JSON.stringify(wx_data); |
|
|
|
|
//Android
|
|
|
|
|
// this.getUserInfo(that,unionid,function(){
|
|
|
|
|
that.$util.saveWxUser(that,data); |
|
|
|
|
that.callBackMethod(); |
|
|
|
|
that.$util.saveWxUser(that, data); |
|
|
|
|
that.callBackMethod(); |
|
|
|
|
// });
|
|
|
|
|
}else if(type == "DEVICEID"){ |
|
|
|
|
} else if (type == "DEVICEID") { |
|
|
|
|
this.gpsObject.imgPushTest(data); |
|
|
|
|
}else if(type == "GetVersionInfo"){ |
|
|
|
|
} else if (type == "GetVersionInfo") { |
|
|
|
|
this.gpsObject.version = data; |
|
|
|
|
}else if(type == "QRCODE"){ |
|
|
|
|
if(data.indexOf("userid") == 1){ |
|
|
|
|
} else if (type == "QRCODE") { |
|
|
|
|
if (data.indexOf("userid") == 1) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:"二维码错误", |
|
|
|
|
mask:true, |
|
|
|
|
icon:"none" |
|
|
|
|
title: "二维码错误", |
|
|
|
|
mask: true, |
|
|
|
|
icon: "none" |
|
|
|
|
}) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var map = JSON.parse(data); |
|
|
|
|
var userid= map.userid; |
|
|
|
|
var userid = map.userid; |
|
|
|
|
//扫码结果
|
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url:"/sunPackIndex/scenic/subscribe/qrcode/reserve_detail_2?userid="+userid |
|
|
|
|
url: "/sunPackIndex/scenic/subscribe/qrcode/reserve_detail_2?userid=" + userid |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}else if(code == "0" && mes == "未安装微信_小程序跳转"){ |
|
|
|
|
} else if (code == "0" && mes == "未安装微信_小程序跳转") { |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url:"/sunPackIndex/scenic/subscribe/yuyue/yue_list_js" |
|
|
|
|
url: "/sunPackIndex/scenic/subscribe/yuyue/yue_list_js" |
|
|
|
|
}) |
|
|
|
|
}else if(code == "0" && mes == "未安装微信_授权登陆"){ |
|
|
|
|
} else if (code == "0" && mes == "未安装微信_授权登陆") { |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url:"/pages/index/an_login/an_login" |
|
|
|
|
url: "/pages/index/an_login/an_login" |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
if(!mes == '失败'){ |
|
|
|
|
} else { |
|
|
|
|
if (!mes == '失败') { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:mes, |
|
|
|
|
icon:"none", |
|
|
|
|
duration:2000 |
|
|
|
|
title: mes, |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -224,7 +224,7 @@ module.exports = { |
|
|
|
|
break; |
|
|
|
|
case 'ios': |
|
|
|
|
console.log('运行iOS上') |
|
|
|
|
window.location.href="https://www.baidu.com"; |
|
|
|
|
window.location.href = "https://www.baidu.com"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
@ -232,28 +232,28 @@ module.exports = { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
getUser: function(that,obj,value,guid){ |
|
|
|
|
console.log(obj,) |
|
|
|
|
var url = that.$config.getOauthWxUser + "?type="+obj+"&value="+value+"&guid="+guid; |
|
|
|
|
getUser: function(that, obj, value, guid) { |
|
|
|
|
console.log(obj, ) |
|
|
|
|
var url = that.$config.getOauthWxUser + "?type=" + obj + "&value=" + value + "&guid=" + guid; |
|
|
|
|
console.log(url) |
|
|
|
|
window.location.href= url; |
|
|
|
|
window.location.href = url; |
|
|
|
|
}, |
|
|
|
|
getUserInfo: function(that,unionid,successCallMethod){ |
|
|
|
|
getUserInfo: function(that, unionid, successCallMethod) { |
|
|
|
|
var method = "LoginUN"; |
|
|
|
|
var sendData = { |
|
|
|
|
"api_token":that.$md5.hexMD5("API"+method+"lvyou"), |
|
|
|
|
"unionid":unionid |
|
|
|
|
"api_token": that.$md5.hexMD5("API" + method + "lvyou"), |
|
|
|
|
"unionid": unionid |
|
|
|
|
} |
|
|
|
|
var data = { |
|
|
|
|
"data":JSON.stringify(sendData), |
|
|
|
|
"data": JSON.stringify(sendData), |
|
|
|
|
"url": that.$config.LoginUN |
|
|
|
|
} |
|
|
|
|
that.$Request.post(that.$config.getAittoData,data).then(res => { |
|
|
|
|
if(res.code == 0){ |
|
|
|
|
uni.setStorageSync("user_token",aes.aesMinEncrypt(res.data.user_token)); |
|
|
|
|
uni.setStorageSync("user_info",res.data.userInfo); |
|
|
|
|
that.$Request.post(that.$config.getAittoData, data).then(res => { |
|
|
|
|
if (res.code == 0) { |
|
|
|
|
uni.setStorageSync("user_token", aes.aesMinEncrypt(res.data.user_token)); |
|
|
|
|
uni.setStorageSync("user_info", res.data.userInfo); |
|
|
|
|
successCallMethod(); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: "none", |
|
|
|
|
title: res.msg |
|
|
|
@ -261,24 +261,24 @@ module.exports = { |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
saveWxUser: function(that,obj){ |
|
|
|
|
saveWxUser: function(that, obj) { |
|
|
|
|
var data = { |
|
|
|
|
"data": obj, |
|
|
|
|
userkey:that.$param.userkey |
|
|
|
|
userkey: that.$param.userkey |
|
|
|
|
} |
|
|
|
|
that.$Request.post(that.$config.saveUser,data).then(res => { |
|
|
|
|
that.$Request.post(that.$config.saveUser, data).then(res => { |
|
|
|
|
var flag = that.$util.isSuccess(res); |
|
|
|
|
if (!flag) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var userid = res.data; |
|
|
|
|
uni.setStorageSync("userid",aes.aesMinEncrypt(userid)); |
|
|
|
|
uni.setStorageSync("userid", aes.aesMinEncrypt(userid)); |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
pay:function(obj,successCallbck){ |
|
|
|
|
pay: function(obj, successCallbck) { |
|
|
|
|
//是否在微信
|
|
|
|
|
if (wechat.isWechat()) { |
|
|
|
|
wechat.pay(obj,successCallbck); |
|
|
|
|
wechat.pay(obj, successCallbck); |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -307,9 +307,9 @@ module.exports = { |
|
|
|
|
}, |
|
|
|
|
getCurrentTime3: function() { |
|
|
|
|
let yyyy = new Date().getFullYear(); |
|
|
|
|
let mm = new Date().getMonth() + 1 < 10? '0' + (new Date().getMonth()+ 1) : new Date().getMonth()+ 1; |
|
|
|
|
let dd = new Date().getDate() < 10? '0' + new Date().getDate() : new Date().getDate(); |
|
|
|
|
let hh = new Date().getHours() < 10? '0' + new Date().getHours() : new Date().getHours(); |
|
|
|
|
let mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1; |
|
|
|
|
let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate(); |
|
|
|
|
let hh = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours(); |
|
|
|
|
let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes(); |
|
|
|
|
let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds(); |
|
|
|
|
return yyyy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf; |
|
|
|
@ -328,7 +328,7 @@ module.exports = { |
|
|
|
|
case 'ios': |
|
|
|
|
console.log('运行iOS上'); |
|
|
|
|
// successCallbck("");
|
|
|
|
|
window.location.href="https://www.baidu.com"; |
|
|
|
|
window.location.href = "https://www.baidu.com"; |
|
|
|
|
// this.$bridge.callHandler('getLocation', {}, function(response) {
|
|
|
|
|
// console.log('运行iOS上11');
|
|
|
|
|
// log('JS got response', response);
|
|
|
|
@ -440,22 +440,22 @@ module.exports = { |
|
|
|
|
let dd = new Date().getDate(); |
|
|
|
|
return yyyy + '-' + mm + '-' + dd; |
|
|
|
|
}, |
|
|
|
|
isBlack: function(obj){ |
|
|
|
|
isBlack: function(obj) { |
|
|
|
|
return obj == undefined || obj == null || obj == ""; |
|
|
|
|
}, |
|
|
|
|
isSuccess: function(res){ |
|
|
|
|
if(res.status == 200){ |
|
|
|
|
isSuccess: function(res) { |
|
|
|
|
if (res.status == 200) { |
|
|
|
|
return true; |
|
|
|
|
}else if(res.status == 400){ |
|
|
|
|
} else if (res.status == 400) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:res.msg, |
|
|
|
|
icon:"none" |
|
|
|
|
title: res.msg, |
|
|
|
|
icon: "none" |
|
|
|
|
}) |
|
|
|
|
return false; |
|
|
|
|
}else if(res.status == 500){ |
|
|
|
|
} else if (res.status == 500) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:res.msg, |
|
|
|
|
icon:"none" |
|
|
|
|
title: res.msg, |
|
|
|
|
icon: "none" |
|
|
|
|
}) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -473,20 +473,20 @@ module.exports = { |
|
|
|
|
美食 |
|
|
|
|
如果usertype=SCENIC等其他值时,usefun为:对应数据的主键id |
|
|
|
|
*/ |
|
|
|
|
saveOperatorLog: function(that,usertype,usefun){ |
|
|
|
|
saveOperatorLog: function(that, usertype, usefun) { |
|
|
|
|
var data = { |
|
|
|
|
"unionid":aes.aesDecrypt(uni.getStorageSync("unionid")), |
|
|
|
|
"userkey":that.$param.userkey, |
|
|
|
|
"unionid": aes.aesDecrypt(uni.getStorageSync("unionid")), |
|
|
|
|
"userkey": that.$param.userkey, |
|
|
|
|
"usertype": usertype, |
|
|
|
|
"usefun":usefun |
|
|
|
|
"usefun": usefun |
|
|
|
|
} |
|
|
|
|
that.$Request.post(that.$config.saveOperatorLog,data).then(res => { |
|
|
|
|
if(res.code == 200){ |
|
|
|
|
that.$Request.post(that.$config.saveOperatorLog, data).then(res => { |
|
|
|
|
if (res.code == 200) { |
|
|
|
|
console.log("保存日志成功") |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
convertDateFromString: function (dateString) {
|
|
|
|
|
convertDateFromString: function(dateString) { |
|
|
|
|
var ddd = new Date(dateString); |
|
|
|
|
return ddd; |
|
|
|
|
}, |
|
|
|
@ -496,5 +496,50 @@ module.exports = { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
}, |
|
|
|
|
// 表情转码
|
|
|
|
|
utf16toEntities(str) { |
|
|
|
|
const patt = /[\ud800-\udbff][\udc00-\udfff]/g; // 检测utf16字符正则
|
|
|
|
|
str = str.replace(patt, (char) => { |
|
|
|
|
let H; |
|
|
|
|
let L; |
|
|
|
|
let code; |
|
|
|
|
let s; |
|
|
|
|
|
|
|
|
|
if (char.length === 2) { |
|
|
|
|
H = char.charCodeAt(0); // 取出高位
|
|
|
|
|
L = char.charCodeAt(1); // 取出低位
|
|
|
|
|
code = (H - 0xD800) * 0x400 + 0x10000 + L - 0xDC00; // 转换算法
|
|
|
|
|
s = `&#${code};`; |
|
|
|
|
} else { |
|
|
|
|
s = char; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return str; |
|
|
|
|
}, |
|
|
|
|
// 表情解码
|
|
|
|
|
entitiestoUtf16(strObj) { |
|
|
|
|
const patt = /&#\d+;/g; |
|
|
|
|
const arr = strObj.match(patt) || []; |
|
|
|
|
|
|
|
|
|
let H; |
|
|
|
|
let L; |
|
|
|
|
let code; |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < arr.length; i += 1) { |
|
|
|
|
code = arr[i]; |
|
|
|
|
code = code.replace('&#', '').replace(';', ''); |
|
|
|
|
// 高位
|
|
|
|
|
H = Math.floor((code - 0x10000) / 0x400) + 0xD800; |
|
|
|
|
// 低位
|
|
|
|
|
L = ((code - 0x10000) % 0x400) + 0xDC00; |
|
|
|
|
code = `&#${code};`; |
|
|
|
|
const s = String.fromCharCode(H, L); |
|
|
|
|
strObj = strObj.replace(code, s); |
|
|
|
|
} |
|
|
|
|
return strObj; |
|
|
|
|
} |
|
|
|
|
} |