123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- // const appUrl = "https://www.mang406.top/omp/api/wx/";
- const appUrl = "http://localhost:8081/omp/api/wx/";
- let lock = false;
- App({
- onLaunch: function () { },
- Url: {
- // 登录
- login: appUrl + "user/login.do",
- // 获取设备最新位置信息
- getLatestState: appUrl + "device/getLatestState.do",
- // 获取用户设备集合
- getDeviceList: appUrl + "device/getListByOpenId.do",
- //修改默认设备
- changeDefault: appUrl + "device/changeDefault.do",
- //添加用户设备绑定关系
- bind: appUrl + "device/bind.do",
- //获取默认的设备
- getDefaultDevice: appUrl + "device/getDefaultDevice.do",
- // 修改设备名称
- updateName: appUrl + "device/updateName.do",
- //获取音量设置
- getVolume: appUrl + "setInfo/volume.do",
- //设置功能-音量
- setVolume: appUrl + "set/volume.do",
- //获取联系人设置
- getSos: appUrl + "setInfo/sos.do",
- //设置功能-联系人
- setSos: appUrl + "set/sos.do",
- //设置功能-语音播报
- setNews: appUrl + "set/news.do",
- //获取其他设置
- getOther: appUrl + "setInfo/other.do",
- //设置功能-定位频率
- setGpsRate: appUrl + "set/gpsRate.do",
- //设置功能-持续定位
- setContinue: appUrl + "set/continue.do",
- },
- /**
- * 发送Get请求
- * showLoading 是否显示等待
- */
- Get: function (url, params, showLoading) {
- const that = this;
- if (showLoading) wx.showLoading();
- return new Promise((resolve, reject) => {
- wx.request({
- url: url,
- header: {
- "verify": "omp",
- "user": that.globalData.openId
- },
- data: params,
- success: function (res) {
- that.success(url, resolve, res);
- },
- fail: function () {
- console.log("网络异常:" + url);
- that.Modal.tips("网络异常")
- },
- })
- })
- },
- /**
- * 发送Post请求
- */
- Post: function (url, params) {
- const that = this;
- wx.showLoading();
- return new Promise((resolve, reject) => {
- wx.request({
- url: url,
- method: 'POST',
- header: {
- "user": that.globalData.openId,
- "Content-Type": "application/x-www-form-urlencoded",
- "verify": "omp"
- },
- data: params,
- success: function (res) {
- that.success(url, resolve, res);
- },
- fail: function () {
- console.log("网络异常:" + url);
- that.Modal.tips("网络异常")
- }
- })
- })
- },
- /**
- * 请求成功回调函数
- */
- success: function (url, resolve, res) {
- console.log(url);
- console.log(res.data);
- console.log("-------------------------------------------------------")
- wx.hideLoading();
- //请求成功回调函数
- switch (res.data.status) {
- case 200: //成功
- resolve(res.data);
- break;
- case 300: //警告
- this.Modal.tips(res.data.msg);
- break;
- case 500: //服务器异常
- console.log(res)
- this.Modal.tips("服务器开小差了");
- break;
- }
- },
- /**
- * 弹出层
- */
- Modal: {
- tips: function (content) {
- wx.hideLoading();
- wx.showToast({
- icon: 'none',
- title: content,
- duration: 2500,
- })
- },
- },
- /**
- * 静态数据
- */
- globalData: {
- openId: "O+i+s1mSwU2sVfojgKde6sUW5zgr+q3fCLJaWTDiI1o=",
- openNum: "867435051513166",
- }
- })
|