123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <template>
- <view>
-
- </view>
- </template>
- <script>
- import {
- sysloginoa
- } from "@/common/api/loginApi.js";
-
- export default {
- data() {
- return {
- usercode:this.$util.getQuery("userid")
- }
- },
- created:function(){
- this.syslogin();
- },
- methods: {
- syslogin: function(e) {
- let usercode=this.$util.getQuery("userid");
- console.info('syslogin',usercode);
- if (usercode) {
- //uni.showToast({title:"验证通过!", icon:"none"});
- this.loading = true;
-
- //this.$store.dispatch('user/login', this.formData)
- sysloginoa(usercode)
- .then((res) => {
- console.info('sysloginoa',res);
- if (!res.isSuccess) //失败,显示错误
- {
- uni.showModal({
- title:'提示',
- content:res.errorMsg,
- showCancel:false
- })
- return;
- }
-
- //设置状态中的各种值
- this.$store.commit('setIsLogin',true);
- this.$store.commit('setToken',res.tnToken);
- this.$store.commit('setAvatar',res.data.avatar);
- this.$store.commit('setName',res.data.name);
- this.$store.commit('setIntroduction',res.data.introduction);
- this.$store.commit('setRoles',res.data.roles);
- this.$store.commit('setUser',res.data.user);
- this.$store.commit('setStationName',res.data.stationName);
- this.$store.commit('setStationCode',res.data.stationCode);
- this.$store.commit('setDepartmentName',res.data.departmentName);
- this.$store.commit('setDepartmentCode',res.data.departmentCode);
- if(res.data.projectCode){
- this.$store.commit('setProjectCode',res.projectCode);
- }
- console.info("登录页面state:",this.$store.state);
-
- uni.setStorage({
- key:'storage_state',
- data:this.$store.state,
- success:function(){
- console.info("setStorage状态缓存成功");
- console.info('storage_state',uni.getStorageSync('storage_state'));
- },
- fail: () => {
- console.error("setStorage状态缓存失败");
- }
- });
- this.loading = false;
- if(this.$store.state.projectCode==="")
- {
- uni.navigateTo({
- url: "/pages/SelectProject/SelectProject"
- });
- return;
- }
-
- //导向到首页
- uni.navigateTo({
- url: "/pages/index/index"
- });
- })
- .catch((error) => {
- console.log(error);
- this.loading = false;
- })
-
-
- } else {
- uni.showModal({
- title:'提示',
- content:'用户名不能为空',
- showCancel:false
- })
- }
- }
- }
- }
- </script>
- <style>
- </style>
|