2024-02-21 17:43:11 +08:00
|
|
|
|
App({
|
2024-04-25 13:46:43 +08:00
|
|
|
|
// 郑州小程序配置信息
|
2024-03-15 14:51:25 +08:00
|
|
|
|
APPID: 'wx5582a07c1fbbcf06',
|
2024-04-25 13:46:43 +08:00
|
|
|
|
APPSECRET: 'ad24130a8919c613efd9538f69abafd3',
|
2024-05-06 15:33:08 +08:00
|
|
|
|
tenantId : '1', // 地区-郑州
|
2024-05-06 15:24:42 +08:00
|
|
|
|
// 域名
|
2024-06-12 13:56:28 +08:00
|
|
|
|
DOMAIN_NAME_PREFIX: 'https://www.chuangzhikj.com',
|
2024-05-06 15:24:42 +08:00
|
|
|
|
// 本地测试
|
2024-05-06 15:33:08 +08:00
|
|
|
|
// DOMAIN_NAME: 'http://192.168.0.11:9227', //接口域名
|
|
|
|
|
// IMG_NAME: 'http://192.168.0.11:9227',
|
2024-05-06 15:24:42 +08:00
|
|
|
|
// 生产
|
2024-06-12 13:56:28 +08:00
|
|
|
|
DOMAIN_NAME: 'https://www.chuangzhikj.com/saas-ics', //接口域名
|
|
|
|
|
IMG_NAME: 'https://www.chuangzhikj.com/saas-ics',
|
2024-02-26 15:34:59 +08:00
|
|
|
|
globals: {
|
|
|
|
|
refreshMyPages: false,
|
|
|
|
|
homedata: {},
|
|
|
|
|
editPro: {
|
|
|
|
|
projectId: 0, //项目ID
|
|
|
|
|
isedit: 0, //是否编辑
|
|
|
|
|
json: {} //项目编辑后的详细数据
|
|
|
|
|
},
|
|
|
|
|
trainBeginCity: ''
|
2024-02-21 17:43:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
onLaunch(res) {
|
|
|
|
|
var that = this
|
|
|
|
|
},
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//获取当前用户的openid
|
|
|
|
|
Getopenid: function () {
|
|
|
|
|
var token = wx.getStorageSync('token');
|
|
|
|
|
return token;
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
/**
|
|
|
|
|
* 对象转URL
|
|
|
|
|
*/
|
|
|
|
|
urlEncode(data) {
|
|
|
|
|
var _result = [];
|
|
|
|
|
for (var key in data) {
|
|
|
|
|
var value = data[key];
|
|
|
|
|
if (value.constructor == Array) {
|
|
|
|
|
value.forEach(_value => {
|
|
|
|
|
_result.push(key + "=" + _value);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
_result.push(key + '=' + value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return _result.join('&');
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
/**
|
|
|
|
|
* 显示失败提示框
|
|
|
|
|
*/
|
|
|
|
|
showError(msg, callback) {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '友情提示',
|
|
|
|
|
content: msg,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
success(res) {
|
|
|
|
|
// callback && (setTimeout(() => {
|
|
|
|
|
// callback();
|
|
|
|
|
// }, 1500));
|
|
|
|
|
callback && callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
/**
|
|
|
|
|
* 显示成功提示框
|
|
|
|
|
*/
|
|
|
|
|
showSuccess(msg, callback) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: msg,
|
|
|
|
|
icon: 'success',
|
|
|
|
|
success() {
|
|
|
|
|
callback && (setTimeout(() => {
|
|
|
|
|
callback();
|
|
|
|
|
}, 1500));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
// 根据出生日期计算年龄周岁 传参格式为1996-06-08
|
|
|
|
|
getAge: function (strBirthday) {
|
|
|
|
|
var returnAge = '';
|
|
|
|
|
var mouthAge = '';
|
|
|
|
|
var strBirthdayArr = strBirthday.split("-");
|
|
|
|
|
var birthYear = strBirthdayArr[0];
|
|
|
|
|
var birthMonth = strBirthdayArr[1];
|
|
|
|
|
var birthDay = strBirthdayArr[2];
|
|
|
|
|
var d = new Date();
|
|
|
|
|
var nowYear = d.getFullYear();
|
|
|
|
|
var nowMonth = d.getMonth() + 1;
|
|
|
|
|
var nowDay = d.getDate();
|
|
|
|
|
if (nowYear == birthYear) {
|
|
|
|
|
// returnAge = 0; //同年 则为0岁
|
|
|
|
|
var monthDiff = nowMonth - birthMonth; //月之差
|
|
|
|
|
if (monthDiff < 0) {} else {
|
|
|
|
|
mouthAge = monthDiff + '个月';
|
|
|
|
|
}
|
2024-02-21 17:43:11 +08:00
|
|
|
|
} else {
|
2024-02-26 15:34:59 +08:00
|
|
|
|
var ageDiff = nowYear - birthYear; //年之差
|
|
|
|
|
if (ageDiff > 0) {
|
|
|
|
|
if (nowMonth == birthMonth) {
|
|
|
|
|
var dayDiff = nowDay - birthDay; //日之差
|
|
|
|
|
if (dayDiff < 0) {
|
|
|
|
|
returnAge = ageDiff - 1 + '岁';
|
|
|
|
|
} else {
|
|
|
|
|
returnAge = ageDiff + '岁';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
var monthDiff = nowMonth - birthMonth; //月之差
|
|
|
|
|
if (monthDiff < 0) {
|
|
|
|
|
returnAge = ageDiff - 1 + '岁';
|
|
|
|
|
} else {
|
|
|
|
|
mouthAge = monthDiff + '个月';
|
|
|
|
|
returnAge = ageDiff + '岁';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
|
2024-02-21 17:43:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-26 15:34:59 +08:00
|
|
|
|
return returnAge + mouthAge; //返回周岁年龄+月份
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
Upload: function (tempFilePaths, call) {
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
mask: true,
|
|
|
|
|
title: '正在上传'
|
|
|
|
|
});
|
|
|
|
|
var that = this
|
|
|
|
|
wx.uploadFile({
|
2024-03-13 15:14:37 +08:00
|
|
|
|
url: that.DOMAIN_NAME + '/api/dfs/upload',
|
2024-02-26 15:34:59 +08:00
|
|
|
|
header: {
|
|
|
|
|
'Authorization': 'Bearer ' + that.Getopenid()
|
|
|
|
|
},
|
|
|
|
|
filePath: tempFilePaths,
|
|
|
|
|
name: 'file',
|
|
|
|
|
success(res) {
|
|
|
|
|
var deta = JSON.parse(res.data)
|
|
|
|
|
if (call) call(deta);
|
|
|
|
|
if (deta.code == 401) {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '好的',
|
|
|
|
|
content: deta.msg || '身份已过期,需重登录',
|
|
|
|
|
success: res => {
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '/pages/login/login',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else if (deta.code != 0) {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '好的',
|
|
|
|
|
content: '服务器开小差去了,请重试',
|
|
|
|
|
showCancel: false
|
|
|
|
|
})
|
|
|
|
|
} else if (deta.code == 0) {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: function (ret) {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '再试一次',
|
|
|
|
|
content: '无法连接网络',
|
|
|
|
|
showCancel: false,
|
|
|
|
|
success: function () {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
that.Upload(tempFilePaths, call);
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
console.log('用户点击取消')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-02-21 17:43:11 +08:00
|
|
|
|
})
|
2024-02-26 15:34:59 +08:00
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
getParkid() {
|
|
|
|
|
var token = wx.getStorageSync('token');
|
|
|
|
|
return token
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
getlogin() {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '好的',
|
|
|
|
|
content: '请先登录后再点击查看',
|
|
|
|
|
success: res => {
|
2024-04-09 15:19:40 +08:00
|
|
|
|
wx.navigateTo({
|
2024-02-26 15:34:59 +08:00
|
|
|
|
url: '/pages/login/login',
|
2024-02-21 17:43:11 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2024-02-26 15:34:59 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//统一请求封装
|
|
|
|
|
//mandate 接口值
|
|
|
|
|
//data 传值,已自动转换为JSON
|
|
|
|
|
//call 请求成功后回调的方法
|
|
|
|
|
AjaxRequest: function (methods, header, url, data, call) {
|
|
|
|
|
var token = wx.getStorageSync('token');
|
|
|
|
|
if (wx.getStorageSync('parkId')) {
|
|
|
|
|
data.parkId = wx.getStorageSync('parkId')
|
|
|
|
|
}
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
mask: true,
|
|
|
|
|
title: '正在加载'
|
|
|
|
|
})
|
|
|
|
|
var that = this
|
|
|
|
|
//发送请求
|
|
|
|
|
wx.request({
|
|
|
|
|
header: header,
|
|
|
|
|
method: methods,
|
|
|
|
|
url: that.DOMAIN_NAME + url,
|
|
|
|
|
data: data,
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (call) call(ret.data);
|
|
|
|
|
if (ret.data.code == 402 || ret.data.code == 401) {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '确认',
|
|
|
|
|
content: '身份已过期,需重登录',
|
|
|
|
|
success(res) {
|
|
|
|
|
wx.removeStorageSync('MemberInfo')
|
|
|
|
|
wx.removeStorageSync('token')
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '/pages/login/login',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else if (ret.data.code != 0) {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '好的',
|
|
|
|
|
content: ret.data.msg || '服务器开小差去了,请重试',
|
|
|
|
|
showCancel: false,
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
if (!wx.getStorageSync('parkId')) {
|
|
|
|
|
if (ret.data.msg == '请选择园区!!') {
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '../index/parkList/parkList'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-21 17:43:11 +08:00
|
|
|
|
})
|
2024-02-26 15:34:59 +08:00
|
|
|
|
} else if (ret.data.code == 0) {
|
|
|
|
|
wx.hideLoading()
|
2024-02-21 17:43:11 +08:00
|
|
|
|
}
|
2024-02-26 15:34:59 +08:00
|
|
|
|
},
|
|
|
|
|
fail: function (ret) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showModal({
|
|
|
|
|
confirmText: '再试一次',
|
|
|
|
|
content: '无法连接网络',
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
that.AjaxRequest(methods, header, url, data, call);
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
console.log('用户点击取消')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-02-21 17:43:11 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
2024-02-26 15:34:59 +08:00
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
ToWebURL(url) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: pages / outer / outer, //要跳转的页面(需要新建立一个page页面)
|
|
|
|
|
success: () => {
|
2024-02-21 17:43:11 +08:00
|
|
|
|
|
2024-02-26 15:34:59 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-04-18 09:19:46 +08:00
|
|
|
|
|
|
|
|
|
selfShowMsg(content, url) {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: content,
|
|
|
|
|
confirmText: '确认',
|
|
|
|
|
showCancel: false,
|
|
|
|
|
success: res => {
|
|
|
|
|
if (url) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
})
|