123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <script>
- /**
- * vuex管理登陆状态,具体可以参考官方登陆模板示例
- */
- import { mapState,mapMutations} from 'vuex';
- import authorize from '@/common/config/authorize.js'
- export default {
- onLaunch: function() {
- this.refresh()
- let _self = this;
- uni.getSystemInfo({
- success: res => {
- let modelmes = res.model;
- if (modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
- this.$store.dispatch('setVariableFun',true)
- }
- // uni.setStorageSync('modelmes', modelmes)
- }
- })
- },
- methods:{
- getCheekeyCode(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- authorize.getCode('weixin').then(wechatcode =>{
- // console.log(wechatcode);
- this.$api.get('/login/doLogin',{userOrganizeID:this.userOrganizeID,code:wechatcode},
- response =>{
- // console.log(response);
- if(response.code == '1'){
- let user_key = {code:response.code,openid:response.data.openid,userID:response.data.userID}
- this.$store.commit('updateStatus',user_key)
- // uni.setStorageSync('cookieKey','JSESSIONID='+response.data.sessionId)
- }else{
- let user_key = {code:response.code,tel:response.data,userID:'',openid:''}
- this.$store.commit('updateStatus',user_key)
- }
- }
- )
- })
- },
- refresh(){
- let TIME = (20*60)*1000;
- let self = this;
- setInterval(function(){
- self.getCheekeyCode()
- },TIME)
- }
- },
- onShow: function() {
- console.log('App Show')
- uni.setStorageSync('token','token')
- },
- onHide: function() {
- console.log('App Hide')
- },
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "@/common/css/common.scss";
- @import "@/common/css/iconfont.scss";
- view,
- scroll-view,
- swiper,
- swiper-item,
- cover-view,
- cover-image,
- icon,
- text,
- rich-text,
- progress,
- button,
- checkbox,
- form,
- input,
- label,
- radio,
- slider,
- switch,
- textarea,
- navigator,
- audio,
- camera,
- image,
- video {
- // box-sizing: border-box;
- }
- page{
- height: 100%;
- background-color: #FFFFFF;
- }
- /* 骨架屏替代方案 */
- .Skeleton {
- background: #f3f3f3;
- padding: 20upx 0;
- border-radius: 8upx;
- }
- .clamp {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- display: block;
- }
- .common-hover {
- background: #f5f5f5;
- }
- /* input 样式 */
- .input-placeholder {
- color: #999999;
- }
- .placeholder {
- color: #999999;
- }
- </style>
|