作者 lihongjuan

1

@@ -71,9 +71,18 @@ data(){ @@ -71,9 +71,18 @@ data(){
71 }, 71 },
72 methods:{ 72 methods:{
73 toPubArticle(){ 73 toPubArticle(){
  74 + let token=uni.getStorageSync("token");
  75 + if(token==''{
  76 + uni.showToast({
  77 + title:'请登录后操作',
  78 + icon:'none'
  79 + })
  80 + }else{
74 wx.navigateTo({ 81 wx.navigateTo({
75 url:"./pubArticle" 82 url:"./pubArticle"
76 }) 83 })
  84 + }
  85 +
77 }, 86 },
78 getuserinfo(){ 87 getuserinfo(){
79 var that = this 88 var that = this
@@ -37,10 +37,14 @@ @@ -37,10 +37,14 @@
37 if(options.istoken!=undefined){ 37 if(options.istoken!=undefined){
38 this.istoken=options.istoken 38 this.istoken=options.istoken
39 } 39 }
  40 + console.log(uni.getStorageSync('token'))
  41 + console.log(this.istoken)
40 if(uni.getStorageSync('token')!=''&&this.istoken==''){ 42 if(uni.getStorageSync('token')!=''&&this.istoken==''){
  43 +
41 this.getusermsg() 44 this.getusermsg()
42 }else if (uni.getStorageSync('token')==''&&this.istoken==''){ 45 }else if (uni.getStorageSync('token')==''&&this.istoken==''){
43 - uni.navigateTo({ 46 + uni.setStorageSync("chosetype",1)
  47 + uni.switchTab({
44 url:'../school/school' 48 url:'../school/school'
45 }) 49 })
46 } 50 }
@@ -76,8 +80,9 @@ @@ -76,8 +80,9 @@
76 token:uni.getStorageSync('token') 80 token:uni.getStorageSync('token')
77 } 81 }
78 app.post(url,params,"get").then((res)=>{ 82 app.post(url,params,"get").then((res)=>{
79 - uni.setStorageSync("chosetype",1) 83 +
80 if(res.level==1){ 84 if(res.level==1){
  85 + uni.setStorageSync("chosetype",1)
81 wx.switchTab({ 86 wx.switchTab({
82 url:'../school/school' 87 url:'../school/school'
83 }) 88 })
@@ -90,10 +95,10 @@ @@ -90,10 +95,10 @@
90 }).catch((err)=>{ 95 }).catch((err)=>{
91 console.log(err) 96 console.log(err)
92 uni.setStorageSync("chosetype",1) 97 uni.setStorageSync("chosetype",1)
93 - uni.clearStorageSync()  
94 wx.switchTab({ 98 wx.switchTab({
95 url:'../school/school' 99 url:'../school/school'
96 }) 100 })
  101 + uni.clearStorageSync()
97 }) 102 })
98 }, 103 },
99 104
@@ -125,19 +130,14 @@ @@ -125,19 +130,14 @@
125 uni.login({ 130 uni.login({
126 provider: "weixin", 131 provider: "weixin",
127 success(r) { 132 success(r) {
128 - console.log(r) 133 +
129 let url = "common/getSessionKey"; 134 let url = "common/getSessionKey";
130 app.post(url, { 135 app.post(url, {
131 code: r.code 136 code: r.code
132 }, "post").then(r => { 137 }, "post").then(r => {
133 - console.log(r) 138 +
134 that.session_key = r.session_key; 139 that.session_key = r.session_key;
135 that.openid = r.openid; 140 that.openid = r.openid;
136 -  
137 - console.log(that.session_key);  
138 - console.log(that.openid)  
139 -  
140 -  
141 // uni.setStorageSync('openid', r.openid); 141 // uni.setStorageSync('openid', r.openid);
142 // uni.setStorageSync('session_key', r.session_key); 142 // uni.setStorageSync('session_key', r.session_key);
143 }).catch(err => {}) 143 }).catch(err => {})