1 Star 0 Fork 1

金志成/小潴微服微帮便民平台 微信小程序

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.js 4.50 KB
一键复制 编辑 原始数据 按行查看 历史
羲云科技 提交于 2023-06-12 04:50 . 主程序
App({
onLaunch: function () {
var that=this;
this.globalData.view=[];//浏览
this.globalData.view.push({ac:'load',time:(new Date()).getTime()});
wx.showShareMenu({withShareTicket: true,menus: ['shareAppMessage', 'shareTimeline']})
var sys_info=wx.getStorageSync('sys_info');
console.log('数据',sys_info)
if(sys_info){
var d = JSON.parse (sys_info);
for(var i in d){
that.globalData[i]=d[i];
}
console.log('读取缓存',d);
}else{
wx.getSystemInfo({
success: (res) => {console.log(res)
var data={}
if(res.system.indexOf('iOS')!=-1){that.globalData.os='IOS';data.os='IOS';}else{ that.globalData.os='AN';data.os='AN';}//系统
that.globalData.nav_top = res.statusBarHeight;
data.nav_top=res.statusBarHeight;;
if(!res.safeArea.top){res.safeArea.top=44;}
that.globalData.safe_top=res.safeArea.top;
data.safe_top=res.safeArea.top;
that.globalData.safe_bottom=res.screenHeight-res.safeArea.bottom-20;
data.safe_bottom=res.screenHeight-res.safeArea.bottom-20;
var user_session=data.os+Math.ceil((new Date).getTime()/1000);
data.user_session=user_session;
that.globalData.user_session=user_session;
try {
// wx.setStorage({key:'sys_info',data:JSON.stringify(data)})
wx.setStorageSync('sys_info', JSON.stringify(data))
} catch (e) { }
}
});
}
//地区
var area=wx.getStorageSync('area');
if(!area){area=''}
console.log('所在城市'+area)
that.globalData.area=area;
var region=wx.getStorageSync('region');
if(!region){region=[]}
console.log('区域'+region)
that.globalData.region=region;
//登录信息
var val = wx.getStorageSync('login_info');
if (val) {
var d = JSON.parse(val);
that.globalData.user_id = d.user_id;
that.globalData.session = d.session;
that.globalData.user_info = d;
}
var val = wx.getStorageSync('adm_login');//管理员登录
if (val) {
var d = JSON.parse(val);
that.globalData.adm_id = d.id;
that.globalData.adm_session = d.session;
}
var user_session=wx.getStorageSync('user_session');
if(!user_session){
user_session=Math.ceil((new Date).getTime()/1000);
try {
wx.setStorageSync('user_session', user_session)
} catch (e) { }
}
this.globalData.user_session=user_session;
},
//全局信息
globalData: {
server:"https://www.zjhn.top/project/pig/",//测试服务器
map_key:"",//腾讯地图API
web:"小潴微服",
website:"https://www.zjhn.top/project/pig/",
sign:''
},
//消息提示
msg:function(t){wx.showToast({ title: t,icon: 'none',duration: 2000 });},
err: function (t) {console.log('消息');
wx.showModal({title: '提示',content: t,})
},onError:function(res){
var app=this.globalData.app;
if(!app){return;}
console.log('应用',app)
if(app.debug!=1){return;}
wx.showModal({title: '错误提示',content:res,});
//是否提交错误
wx.request({
url: this.globalData.server+'server.php',
header:{'content-type':'application/x-www-form-urlencoded'},
method:'POST',
enableHttp2:true,
data:{
ac:'send_err',
adm:this.globalData.adm,
app_id:this.globalData.app_id,
version:this.globalData.version?this.globalData.version:'',
val:res
},success(res){
}
})
},onHide(){//应用关闭时候推送信息
//var app=this.globalData.app;
if(!this.globalData.view){return;}
//if(!app){return;}
//console.log('应用',app)
var that=this;
console.log(this.globalData.view)
wx.request({
url: this.globalData.server+'ac.php',
header:{'content-type':'application/x-www-form-urlencoded'},
method:'POST',
enableHttp2:true,
data:{
ac:'app_view',
user_id:this.globalData.user_id?this.globalData.user_id:0,
session:this.globalData.session?this.globalData.session:'',
user_session:this.globalData.user_session?this.globalData.user_session:'',
data:JSON.stringify(this.globalData.view),
area:this.globalData.area?this.globalData.area:'',
},success(res){
that.globalData.view=[];
console.log(res)
}
})
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/scott219/pig.git
git@gitee.com:scott219/pig.git
scott219
pig
小潴微服微帮便民平台 微信小程序
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385