在app.js页面中配置信息
//app.js
App({
globalData:{
userinfo:null,
scenicid:117, //景区id
appid:'S_76539349', //景区appid
//4b87f66ccbe2ad9', //景区秘钥
//myUrl: 'https://zh', //测试地址/https://zh/
myUrl: 'https://zh',
xappid: '', //小程序appid
//xsecrectad9', //小程序秘钥
mchid:'142', //商户号
key:'', //支付秘钥
tempid:'', //购票模板id
userid:'',
username:'',
usertype:'',
phone:'',
name:'',
//分销用到的数据
//fxUrl:'' , // 正式http://
fxUrl:'', // 正式https://
DistrbutorID:'', //分销商ID
},
onLaunch: function() {
//初始化加载,先判断用户登录状态
const that = this;
if(wx.getStorageSync('usertype') == 1 && wx.getStorageSync('userid') != ''){
wx.navigateTo({
url: '/pages/fenxiao/index/index'
})
}else if(wx.getStorageSync('usertype') == 2 && wx.getStorageSync('userid') != ''){
wx.switchTab({
url: '/pages/index/index'
})
}else if(wx.getStorageSync('userid') == '') {
wx.showToast({
title: '提示:登录过期请重新登录',
icon: "none",
duration: 5000
})
wx.reLaunch({
url: 'pages/login/login'
})
}
},
formatDateTime:function(fmt, date) {
var o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"h+": date.getHours(), //小时
"m+": date.getMinutes(), //分
"s+": date.getSeconds(), //秒
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
},
/* onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
traceUser: true,
})
}
}*/
})