|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
|
|
import aes from "@/common/aes.js";
|
|
|
|
|
|
|
|
|
|
// import * as wechat from './wechat'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import param from './param'
|
|
|
|
|
|
|
|
|
|
//金额过滤
|
|
|
|
|
Vue.filter('money', function (val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
let value = Math.round(parseFloat(val) * 100) / 100;
|
|
|
|
|
let valMoney = value.toString().split(".");
|
|
|
|
|
if (valMoney.length == 1) {
|
|
|
|
|
value = value.toString() + ".00";
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
if (valMoney.length > 1) {
|
|
|
|
|
if (valMoney[1].length < 2) {
|
|
|
|
|
value = value.toString() + "0";
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
} else {
|
|
|
|
|
return "0.00";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//手机号中间4位为*
|
|
|
|
|
Vue.filter('phone', function (val) {
|
|
|
|
|
var tel = val;
|
|
|
|
|
tel = "" + tel;
|
|
|
|
|
var telShort = tel.replace(tel.substring(3, 7), "****")
|
|
|
|
|
return telShort
|
|
|
|
|
})
|
|
|
|
|
//工具方法
|
|
|
|
|
module.exports = {
|
|
|
|
|
//GPS定位业务vue对象
|
|
|
|
|
gpsObject: null,
|
|
|
|
|
|
|
|
|
|
bindGpsObj: function(obj) {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// title: "util的bindgpsobj方法:"
|
|
|
|
|
// })
|
|
|
|
|
this.gpsObject = obj;
|
|
|
|
|
//this.callBackGpsResult("200","",0,0);
|
|
|
|
|
},
|
|
|
|
|
unbindGpsObj: function() {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// title: "util的取消bindgpsobj方法:"
|
|
|
|
|
// })
|
|
|
|
|
this.gpsObject = null;
|
|
|
|
|
},
|
|
|
|
|
getNetworkType:function(successCallbck,failCallback){
|
|
|
|
|
uni.getNetworkType({
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (successCallbck) {
|
|
|
|
|
successCallbck(res);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail:function(){
|
|
|
|
|
if (failCallback) {
|
|
|
|
|
failCallback(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
hideLoadingByTime:function(){
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
}, 10000);
|
|
|
|
|
},
|
|
|
|
|
receiveFile: function(code, object) {
|
|
|
|
|
if (code == "200") {
|
|
|
|
|
this.gpsObject.receiveSuccess(object);
|
|
|
|
|
} else {
|
|
|
|
|
this.gpsObject.receiveFail();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
callBackGpsResult: function(code, mes, lat, lng) {
|
|
|
|
|
if (code == "200") {
|
|
|
|
|
param.clat = lat;
|
|
|
|
|
param.clng = lng;
|
|
|
|
|
// var that = this.gpsObject;
|
|
|
|
|
if (this.gpsObject) {
|
|
|
|
|
this.gpsObject.callGpsSuccess(lat, lng);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
param.clat = param.lat;
|
|
|
|
|
param.clng = param.lng;
|
|
|
|
|
if (this.gpsObject) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:"为了您的良好体验请打开GPS功能",
|
|
|
|
|
icon:"none",
|
|
|
|
|
duration:2000
|
|
|
|
|
})
|
|
|
|
|
this.gpsObject.callGpsFail();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
iosCallBackGpsResult: function(code, mes, lat, lng) {
|
|
|
|
|
console.log('iosCallBackGpsResult>>>');
|
|
|
|
|
if (code == "200") {
|
|
|
|
|
param.clat = lat;
|
|
|
|
|
param.clng = lng;
|
|
|
|
|
|
|
|
|
|
if (this.gpsObject) {
|
|
|
|
|
this.gpsObject.callGpsSuccess(lat, lng);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
param.clat = param.lat;
|
|
|
|
|
param.clng = param.lng;
|
|
|
|
|
|
|
|
|
|
if (this.gpsObject) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:"为了您的良好体验请打开GPS功能",
|
|
|
|
|
icon:"none",
|
|
|
|
|
duration:2000
|
|
|
|
|
})
|
|
|
|
|
this.gpsObject.callGpsFail();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//获取安卓内容
|
|
|
|
|
getAndroidData: function(code,mes,type,data){
|
|
|
|
|
/* mes += "---------"+type+"-------"+code+"------"+data;
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title:"提示",
|
|
|
|
|
content:mes,
|
|
|
|
|
showCancel:false,
|
|
|
|
|
success() {
|
|
|
|
|
}
|
|
|
|
|
}) */
|
|
|
|
|
if (code == "200") {
|
|
|
|
|
if(type == "WxUserInfo"){
|
|
|
|
|
var wx_data = JSON.parse(data);
|
|
|
|
|
// var unionid = "oaxUrw1nI4vDQ1ihKWlrDWIXHea0";
|
|
|
|
|
// uni.setStorageSync("unionid","oaxUrw1nI4vDQ1ihKWlrDWIXHea0");
|
|
|
|
|
// uni.setStorageSync("openid","oA5vYww6QNBd5Y8sqM9Ss0AVvhl8");
|
|
|
|
|
// uni.setStorageSync("nickname","你怎么了");
|
|
|
|
|
// 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));
|
|
|
|
|
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();
|
|
|
|
|
// });
|
|
|
|
|
}else if(type == "DEVICEID"){
|
|
|
|
|
this.gpsObject.imgPushTest(data);
|
|
|
|
|
}else if(type == "GetVersionInfo"){
|
|
|
|
|
this.gpsObject.version = data;
|
|
|
|
|
}else if(type == "QRCODE"){
|
|
|
|
|
if(data.indexOf("userid") == 1){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:"二维码错误",
|
|
|
|
|
mask:true,
|
|
|
|
|
icon:"none"
|
|
|
|
|
})
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var map = JSON.parse(data);
|
|
|
|
|
var userid= map.userid;
|
|
|
|
|
//扫码结果
|
|
|
|
|
// uni.navigateTo({
|
|
|
|
|
// url:"/subPageA/scenic/subscribe/qrcode/reserve_detail_2?userid="+userid
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
}else if(code == "0" && mes == "未安装微信_小程序跳转"){
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:"/subPageA/scenic/subscribe/yuyue/yue_list_js"
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
if(!mes == '失败'){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:mes,
|
|
|
|
|
icon:"none",
|
|
|
|
|
duration:2000
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//传入数字 返回其公里数 例如传入3500 返回3.5km
|
|
|
|
|
formatDistance: function(num) {
|
|
|
|
|
var reg = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/
|
|
|
|
|
if (reg.test(num)) {
|
|
|
|
|
var fomatFloat = parseFloat(num);
|
|
|
|
|
|
|
|
|
|
if (fomatFloat < 1000) {
|
|
|
|
|
return fomatFloat.toFixed(0) + 'm';
|
|
|
|
|
} else if (fomatFloat > 1000) {
|
|
|
|
|
return (fomatFloat / 1000).toFixed(1) + 'km';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return "未知";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//格式化字符串(将携带html标签的内容将标签去掉)
|
|
|
|
|
returnString: function(data) {
|
|
|
|
|
return data.replace(/<[^>]+>/g, "");
|
|
|
|
|
},
|
|
|
|
|
showPosition: function(position) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: "允许定位"
|
|
|
|
|
})
|
|
|
|
|
console.log("获取到的信息:" + JSON.stringify(position));
|
|
|
|
|
console.log("Latitude: " + position.coords.latitude + "<br />Longitude: " + position.coords.longitude);
|
|
|
|
|
},
|
|
|
|
|
showError: function(error) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: "不允许定位"
|
|
|
|
|
})
|
|
|
|
|
switch (error.code) {
|
|
|
|
|
case error.PERMISSION_DENIED:
|
|
|
|
|
alert("定位失败,用户拒绝请求地理定位");
|
|
|
|
|
break;
|
|
|
|
|
case error.POSITION_UNAVAILABLE:
|
|
|
|
|
alert("定位失败,位置信息是不可用");
|
|
|
|
|
break;
|
|
|
|
|
case error.TIMEOUT:
|
|
|
|
|
alert("定位失败,请求获取用户位置超时");
|
|
|
|
|
break;
|
|
|
|
|
case error.UNKNOWN_ERROR:
|
|
|
|
|
alert("定位失败,定位系统失效");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
userLocation: function() {
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
|
|
|
|
|
if (this.isWechat()) {
|
|
|
|
|
wechat.getLocation(successCallbck, failCallback);
|
|
|
|
|
} else {
|
|
|
|
|
switch (uni.getSystemInfoSync().platform) {
|
|
|
|
|
case 'android':
|
|
|
|
|
console.log('运行Android上')
|
|
|
|
|
var jwd = Android.getLocation();
|
|
|
|
|
// var jwd = "38.042836,114.496002";
|
|
|
|
|
if (jwd != '' && jwd != null && jwd != undefined) {
|
|
|
|
|
return jwd;
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
break;
|
|
|
|
|
case 'ios':
|
|
|
|
|
console.log('运行iOS上')
|
|
|
|
|
window.location.href="https://www.baidu.com";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#endif
|
|
|
|
|
},
|
|
|
|
|
getUser: function(that,obj,value,guid){
|
|
|
|
|
var url = that.$config.getOauthWxUser + "?type="+obj+"&value="+value+"&guid="+guid;
|
|
|
|
|
window.location.href= url;
|
|
|
|
|
},
|
|
|
|
|
getUserInfo: function(that,unionid,successCallMethod){
|
|
|
|
|
var method = "LoginUN";
|
|
|
|
|
var sendData = {
|
|
|
|
|
"api_token":that.$md5.hexMD5("API"+method+"lvyou"),
|
|
|
|
|
"unionid":unionid
|
|
|
|
|
}
|
|
|
|
|
var data = {
|
|
|
|
|
"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);
|
|
|
|
|
successCallMethod();
|
|
|
|
|
}else{
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: "none",
|
|
|
|
|
title: res.msg
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
saveWxUser: function(that,obj){
|
|
|
|
|
var data = {
|
|
|
|
|
"data": obj,
|
|
|
|
|
userkey:that.$param.userkey
|
|
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
pay:function(obj,successCallbck){
|
|
|
|
|
//是否在微信
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
|
|
|
|
|
if (wechat.isWechat()) {
|
|
|
|
|
wechat.pay(obj,successCallbck);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//#endif
|
|
|
|
|
},
|
|
|
|
|
setLocation: function(lng, lat) {
|
|
|
|
|
this.$param.clng = lng;
|
|
|
|
|
this.$param.clat = lat;
|
|
|
|
|
},
|
|
|
|
|
getCurrentTime: function() {
|
|
|
|
|
let yyyy = new Date().getFullYear();
|
|
|
|
|
let mm = new Date().getMonth() + 1;
|
|
|
|
|
let dd = new Date().getDate();
|
|
|
|
|
let hh = 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 + ':' + ss;
|
|
|
|
|
},
|
|
|
|
|
getCurrentTime2: function() {
|
|
|
|
|
let yyyy = new Date().getFullYear();
|
|
|
|
|
let mm = new Date().getMonth() + 1;
|
|
|
|
|
let dd = new Date().getDate();
|
|
|
|
|
let hh = 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 + ':' + ss;
|
|
|
|
|
},
|
|
|
|
|
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 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;
|
|
|
|
|
},
|
|
|
|
|
getLocation: function(successCallbck, failCallback) {
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
if (wechat.isWechat()) {
|
|
|
|
|
wechat.getLocation(successCallbck, failCallback);
|
|
|
|
|
} else {
|
|
|
|
|
switch (uni.getSystemInfoSync().platform) {
|
|
|
|
|
case 'android':
|
|
|
|
|
console.log('运行Android上');
|
|
|
|
|
// successCallbck("");
|
|
|
|
|
Android.getLocation();
|
|
|
|
|
break;
|
|
|
|
|
case 'ios':
|
|
|
|
|
console.log('运行iOS上');
|
|
|
|
|
// successCallbck("");
|
|
|
|
|
window.location.href="https://www.baidu.com";
|
|
|
|
|
// this.$bridge.callHandler('getLocation', {}, function(response) {
|
|
|
|
|
// console.log('运行iOS上11');
|
|
|
|
|
// log('JS got response', response);
|
|
|
|
|
// });
|
|
|
|
|
// this.$bridge.callhandler('getLocation', params, (data) => {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// title: '提示',
|
|
|
|
|
// content: 'ios进入getLocation方法'
|
|
|
|
|
// });
|
|
|
|
|
// console.log('getLocation>>>');
|
|
|
|
|
// });
|
|
|
|
|
// this.$bridge.registerhandler('iosCallBackGpsResult', (data, responseCallback) => {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// title: '提示',
|
|
|
|
|
// content: 'ios进入iosCallBackGpsResult方法'
|
|
|
|
|
// });
|
|
|
|
|
// console.log('registerhandler>>>');
|
|
|
|
|
// // alert('JS Echo called with:', data) ;
|
|
|
|
|
// responseCallback(data);
|
|
|
|
|
// });
|
|
|
|
|
// window.webkit.messageHandlers.getLocation.postMessage();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// successCallbck("");
|
|
|
|
|
Android.getLocation();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
console.log("----util---getLocation---");
|
|
|
|
|
uni.getLocation({
|
|
|
|
|
type: 'gcj02',
|
|
|
|
|
success: function(res) {
|
|
|
|
|
console.log(res);
|
|
|
|
|
if (successCallbck) {
|
|
|
|
|
successCallbck(res);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
if (failCallback) {
|
|
|
|
|
failCallback(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// #endif
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 根据平台类型调用不同的方式打开地图
|
|
|
|
|
*/
|
|
|
|
|
openLocation: function(mapParam) {
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
if (wechat.isWechat()) {
|
|
|
|
|
wechat.openLocation(mapParam);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
|
|
|
|
|
uni.openLocation({
|
|
|
|
|
latitude: mapParam.latitude,
|
|
|
|
|
longitude: mapParam.longitude,
|
|
|
|
|
scale: mapParam.scale,
|
|
|
|
|
name: mapParam.name,
|
|
|
|
|
address: mapParam.address,
|
|
|
|
|
success: function() {
|
|
|
|
|
console.log('success');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
// #endif
|
|
|
|
|
},
|
|
|
|
|
secsToStr: function($secs) {
|
|
|
|
|
var $r = "";
|
|
|
|
|
var $hours = "";
|
|
|
|
|
var $minutes = "";
|
|
|
|
|
if ($secs >= 3600) {
|
|
|
|
|
$hours = parseInt($secs / 3600);
|
|
|
|
|
$secs = $secs % 3600;
|
|
|
|
|
$r += $hours + ':';
|
|
|
|
|
}
|
|
|
|
|
if ($secs >= 60) {
|
|
|
|
|
$minutes = parseInt($secs / 60);
|
|
|
|
|
if ($minutes < 10) {
|
|
|
|
|
$secs = $secs % 60;
|
|
|
|
|
$r += "0" + $minutes + ':';
|
|
|
|
|
} else {
|
|
|
|
|
$secs = $secs % 60;
|
|
|
|
|
$r += $minutes + ':';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$r += '00:';
|
|
|
|
|
}
|
|
|
|
|
if ($secs < 10) {
|
|
|
|
|
$r += "0" + $secs;
|
|
|
|
|
} else {
|
|
|
|
|
$r += $secs;
|
|
|
|
|
}
|
|
|
|
|
return $r;
|
|
|
|
|
},
|
|
|
|
|
getCurrentTime: function() {
|
|
|
|
|
let yyyy = new Date().getFullYear();
|
|
|
|
|
let mm = new Date().getMonth() + 1;
|
|
|
|
|
let dd = new Date().getDate();
|
|
|
|
|
return yyyy + '-' + mm + '-' + dd;
|
|
|
|
|
},
|
|
|
|
|
isBlack: function(obj){
|
|
|
|
|
return obj == undefined || obj == null || obj == "";
|
|
|
|
|
},
|
|
|
|
|
isSuccess: function(res){
|
|
|
|
|
if(res.status == 200){
|
|
|
|
|
return true;
|
|
|
|
|
}else if(res.status == 400){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:res.msg,
|
|
|
|
|
icon:"none"
|
|
|
|
|
})
|
|
|
|
|
return false;
|
|
|
|
|
}else if(res.status == 500){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title:res.msg,
|
|
|
|
|
icon:"none"
|
|
|
|
|
})
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/*
|
|
|
|
|
参数解释:
|
|
|
|
|
that:当前页的this对象,使用var that = this;的方式将that传递到这个方法
|
|
|
|
|
usertype:操作类型,是功能还是数据
|
|
|
|
|
功能:FUN
|
|
|
|
|
数据:
|
|
|
|
|
例如:SCENIC---景区
|
|
|
|
|
FOOD---美食
|
|
|
|
|
usefun: 如果usertype=FUN,则usefun为:
|
|
|
|
|
例如:景区
|
|
|
|
|
美食
|
|
|
|
|
如果usertype=SCENIC等其他值时,usefun为:对应数据的主键id
|
|
|
|
|
*/
|
|
|
|
|
saveOperatorLog: function(that,usertype,usefun){
|
|
|
|
|
var data = {
|
|
|
|
|
"unionid":aes.aesDecrypt(uni.getStorageSync("unionid")),
|
|
|
|
|
"userkey":that.$param.userkey,
|
|
|
|
|
"usertype": usertype,
|
|
|
|
|
"usefun":usefun
|
|
|
|
|
}
|
|
|
|
|
that.$Request.post(that.$config.saveOperatorLog,data).then(res => {
|
|
|
|
|
if(res.code == 200){
|
|
|
|
|
console.log("保存日志成功")
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
convertDateFromString: function (dateString) {
|
|
|
|
|
var ddd = new Date(dateString);
|
|
|
|
|
return ddd;
|
|
|
|
|
},
|
|
|
|
|
phone: function(TEL) {
|
|
|
|
|
var strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
|
|
|
|
|
if (strTemp.test(TEL)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
parseTime: function (time, pattern) {
|
|
|
|
|
if (arguments.length === 0 || !time) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
|
|
|
|
|
let date
|
|
|
|
|
if (typeof time === 'object') {
|
|
|
|
|
date = time
|
|
|
|
|
} else {
|
|
|
|
|
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
|
|
|
|
time = parseInt(time)
|
|
|
|
|
} else if (typeof time === 'string') {
|
|
|
|
|
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm), '');
|
|
|
|
|
}
|
|
|
|
|
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
|
|
|
|
time = time * 1000
|
|
|
|
|
}
|
|
|
|
|
date = new Date(time)
|
|
|
|
|
}
|
|
|
|
|
const formatObj = {
|
|
|
|
|
y: date.getFullYear(),
|
|
|
|
|
m: date.getMonth() + 1,
|
|
|
|
|
d: date.getDate(),
|
|
|
|
|
h: date.getHours(),
|
|
|
|
|
i: date.getMinutes(),
|
|
|
|
|
s: date.getSeconds(),
|
|
|
|
|
a: date.getDay()
|
|
|
|
|
}
|
|
|
|
|
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
|
|
|
|
|
let value = formatObj[key]
|
|
|
|
|
// Note: getDay() returns 0 on Sunday
|
|
|
|
|
if (key === 'a') {
|
|
|
|
|
return ['日', '一', '二', '三', '四', '五', '六'][value]
|
|
|
|
|
}
|
|
|
|
|
if (result.length > 0 && value < 10) {
|
|
|
|
|
value = '0' + value
|
|
|
|
|
}
|
|
|
|
|
return value || 0
|
|
|
|
|
})
|
|
|
|
|
return time_str
|
|
|
|
|
},
|
|
|
|
|
// 浏览器判断是否微信
|
|
|
|
|
isWechat: function () {
|
|
|
|
|
let ua = navigator.userAgent.toLowerCase();
|
|
|
|
|
if (ua.match(/MicroMessenger/i) == "micromessenger") {
|
|
|
|
|
//console.log('是微信客户端')
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
//console.log('不是微信客户端')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|