瑞梦思预约小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

59 lines
1.4 KiB

// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
},
login(loginInfo){
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
http(methods,url,params){
var header = {
'content-type': 'application/json',
'Authorization' : wx.getStorageSync('token') || ''
};
return new Promise((resolve,reject)=>{
wx.showLoading({
title: '正在加载中...',
})
wx.request({
url: this.globalData.baseUrl + url,
method: methods,
header: header,
data: params || {},
success: res=> {
wx.hideLoading();
if(!res.data.success && res.data.status == 401){
// console.log('登陆失效')
wx.navigateTo({
url: '/pages/login/index',
})
}
resolve(res);
},
fail: err=> {
wx.hideLoading();
wx.showToast({
title: '服务器错误,请稍后再试!',
icon : 'none'
})
reject(err)
}
})
})
},
globalData: {
baseURL : 'http://192.168.0.114:8092/api/',
// baseURL : 'https://cloud.api.cyjyyjy.com/api/',
}
})