72 lines
1.7 KiB
Vue
72 lines
1.7 KiB
Vue
<script>
|
|
export default {
|
|
onLaunch: function () {
|
|
var that = this
|
|
uni.login({
|
|
provider: 'weixin',
|
|
success: function (loginRes) {
|
|
console.log(loginRes)
|
|
uni.showLoading({
|
|
title: '自动登录中...',
|
|
mask: true
|
|
})
|
|
that.$u.api.login({
|
|
code: loginRes.code
|
|
}).then(
|
|
res => {
|
|
console.log(res)
|
|
// this.$u.vuex('vuex_cookie', res.header['Set-Cookie'])
|
|
that.$u.vuex('vuex_token', res.data.token)
|
|
that.$u.api.getInfo().then(res => {
|
|
that.$u.vuex('vuex_user', res.data)
|
|
if(res.data.icon===""){
|
|
that.$u.vuex('vuex_user.icon', '/static/img/face.jpg')
|
|
}else{
|
|
that.$u.vuex('vuex_user.icon', that.vuex_host + 'public/' + res.data.icon)
|
|
}
|
|
})
|
|
that.$u.api.getAddress({prePage:50}).then(res=>{
|
|
for(var i=0;i<res.data.length;i++){
|
|
if(res.data[i].often==1){
|
|
uni.setStorageSync('selectAddress', res.data[i])
|
|
}
|
|
}
|
|
})
|
|
that.$u.api.getInvoice({prePage:50}).then(res=>{
|
|
for(let key in res.data){
|
|
if(res.data[key].often==1){
|
|
uni.setStorageSync('selectInvoice', res.data[key])
|
|
}
|
|
}
|
|
|
|
})
|
|
uni.hideLoading()
|
|
// uni.showToast({
|
|
// title: '登录成功',
|
|
// icon: "success"
|
|
// });
|
|
// uni.navigateBack({})
|
|
|
|
}
|
|
).catch(res=>{
|
|
uni.redirectTo({
|
|
url:'/pages/login/login'
|
|
})
|
|
})
|
|
}
|
|
});
|
|
},
|
|
onShow: function () {
|
|
console.log('App Show')
|
|
},
|
|
onHide: function () {
|
|
console.log('App Hide')
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
/*每个页面公共css */
|
|
@import "/static/iconfont/font.scss";
|
|
</style>
|