83 lines
2.3 KiB
Vue
83 lines
2.3 KiB
Vue
<script>
|
|
import { themeEv } from '@/jsFile/public-api.js';
|
|
export default {
|
|
globalData:{
|
|
projectname:'', // 项目名称
|
|
lat:'', // 公司地址维度
|
|
lng:'' ,// 公司地址经度
|
|
hostapi:'https://luban.scdxtc.cn' // 域名配置
|
|
},
|
|
// 优先于show方法
|
|
onLaunch: function() {
|
|
uni.login({
|
|
success: (res) => {
|
|
uni.request({
|
|
url: this.globalData.hostapi +'/api/user/login',
|
|
data:{code:res.code},
|
|
success: (result) => {
|
|
if(result.data.code == 0) {
|
|
uni.setStorageSync('userId',result.data.account_id);
|
|
uni.setStorageSync('token',result.data.data.token);//缓存token
|
|
uni.setStorageSync('openid',result.data.data.openid);//缓存openid
|
|
uni.setStorageSync('expire',result.data.data.expire);//缓存失效时间(时间戳格式)
|
|
uni.setStorageSync('phone_active',result.data.data.phone_active);//是否授权手机号
|
|
uni.setStorageSync('is_active',result.data.data.is_active);//是否授权头像和昵称
|
|
uni.setStorageSync('invite_code',result.data.data.invite_code);//缓存邀请码
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
onShow: function(op) {
|
|
if(op.query.business_id){
|
|
uni.setStorageSync('business_id',op.query.business_id);
|
|
this.changeEv(op.query.business_id);
|
|
}else{
|
|
uni.setStorageSync('business_id',0);
|
|
this.changeEv(0);
|
|
}
|
|
},
|
|
onHide: function() {
|
|
|
|
},
|
|
methods:{
|
|
changeEv(id){
|
|
let headers = {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
'Authorization': 'Bearer '+uni.getStorageSync('token') || ''
|
|
}
|
|
uni.request({
|
|
url: this.globalData.hostapi +'/api/index/change-business',
|
|
data:{business_id:id},
|
|
methods:'POST',
|
|
header:headers,
|
|
success: (res) => {
|
|
console.log(id,'操作成功')
|
|
}
|
|
})
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
/*每个页面公共css */
|
|
|
|
/* 阿里巴巴矢量图标库 start */
|
|
@import url("./commons/icon-font.css");
|
|
/* 阿里巴巴矢量图标库 end */
|
|
/* 项目基础样式 start */
|
|
@import url("./commons/base.css");
|
|
/* 项目基础样式 end */
|
|
/* 项目页面样式 start */
|
|
@import url("./commons/style.css");
|
|
/* 项目页面样式 end */
|
|
|
|
/* 动画样式 start */
|
|
@import url("./commons/animate.min.css");
|
|
/* 动画样式 end */
|
|
@import url("./commons/loading.css");
|
|
</style>
|
|
|