优化微信授权登录

master
chen 2022-04-01 10:57:34 +08:00
parent 25cbc307b6
commit 6ceeddde35
11 changed files with 45 additions and 33 deletions

View File

@ -15,7 +15,7 @@
// #endif
// #ifdef MP-WEIXIN
// uni.setStorageSync('hostapi','http://maintain.7and5.cn');
getApp().globalData.hostapi = 'http://maintain.7and5.cn';
this.globalData.hostapi = 'http://maintain.7and5.cn';
// #endif
// #ifdef H5
// uni.setStorageSync('hostapi','/web');

View File

@ -214,6 +214,8 @@ button:after{content: none!important;}
.radius35{border-radius: 35rpx;}
.radius40{border-radius: 40rpx;}
.radius45{border-radius: 45rpx;}
.radius_50{border-radius: 50%;}
.radius_100{border-radius: 100%;}
/* 上下左右---外边距 */
.mar10{margin: 10rpx;}

View File

@ -115,7 +115,7 @@
if(index==0){
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
} else {
// if(!this.$toolAll.tools.judgeAuth()) {
if(this.$toolAll.tools.judgeAuth()) {
//
switch (index){
case 1:
@ -144,12 +144,7 @@
uni.reLaunch({url:'/pages/tabbar/my/my'})
break;
}
// } else {
// //
// uni.navigateTo({
// url:'/pages/login/login'
// })
// }
}
}
},
scanCode() {

View File

@ -1,3 +1,4 @@
const app = getApp();
const tools = {
timer:'',
timerNot:'',
@ -498,7 +499,7 @@ const tools = {
if (res.code) {
var params = {code:res.code}
uni.request({
url: `${getApp().globalData.hostapi}/api/user/login`,
url: `${app.globalData.hostapi}/api/user/login`,
method: 'post',
data: params,
header: {
@ -523,16 +524,17 @@ const tools = {
}
},
// 判断是否授权,没授权,前往登录页面授权
authTimer:null,
judgeAuth(){
let auth = true;
switch (uni.getStorageSync('phone_active')*1){
case 0: // 未注册
uni.navigateTo({url:'/pages/login/login'});
auth = false
break;
case 1: // 已注册
auth = true
break;
let auth = false;
clearTimeout(this.authTimer);
if(!uni.getStorageSync('token')) {
this.showToast('请登录');
this.authTimer = setTimeout(()=>{
uni.navigateTo({url:'/pages/login/login'});
},2000)
} else {
auth = true;
}
return auth;
},

View File

@ -87,7 +87,7 @@
/* */
"mp-weixin" : {
/* */
"appid" : "wx705dfb975654e53a",
"appid" : "wx372ffc194d87c693",
"setting" : {
"urlCheck" : true,
"es6" : true

View File

@ -50,6 +50,7 @@
import statusNav from '../../components/status-nav.vue';
import footTabOne from "../../components/foot-tabs/foot-tab-one.vue"
import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
const app = getApp();
export default {
components: {
footTabOne,
@ -141,7 +142,7 @@
const tempFilePaths = chooseImageRes.tempFilePaths;
this.imgSrc = chooseImageRes.tempFilePaths[0]
uni.uploadFile({
url: getApp().globalData.hostapi+'/universal/api.upload/upload', //
url: app.globalData.hostapi+'/universal/api.upload/upload', //
filePath: tempFilePaths[0],
name: 'image',
header:{

View File

@ -27,17 +27,16 @@
style="background: url(../../../static/public/icon-my-head.png) no-repeat;height: 400rpx;background-size: 100% 100%;">
<view class="disjbac" style="padding: 60rpx 80rpx 60rpx 60rpx;">
<view class="disac">
<image class="flexs mar-y10" v-if="!userInfo.avatar"
src="/static/public/icon-my-headimg.png" mode="aspectFill"
style="width: 91rpx;height: 91rpx;" lazy-load></image>
<image class="flexs mar-y10" v-else src="/static/public/icon-my-headimg.png"
mode="aspectFill" style="width: 91rpx;height: 91rpx;" lazy-load></image>
<!-- 用户头像 -->
<image class="flexs mar-y10 radius_100" @tap="replaceImg" :src="userInfo.avatar || '/static/public/icon-my-headimg.png'" mode="aspectFill" style="width: 91rpx;height: 91rpx;" lazy-load></image>
<view class="disjb fc" style="height: 91rpx;">
<!-- 用户手机号 -->
<view class="fon34 bold">{{tel(userInfo.username)}}</view>
<!-- 是否实名认证 -->
<view class="fon22" style="color: #717171;">未实名认证</view>
</view>
</view>
<!-- 等级图标 -->
<image src="/static/public/icon-my-level.png" mode="aspectFill"
style="width: 49rpx;height: 76rpx;" lazy-load></image>
</view>
@ -181,6 +180,16 @@
this.$toolAll.tools.disableShareEv();
},
methods: {
//
replaceImg(){
uni.chooseImage({
count: 1,
sourceType:['album','camera'],
success: (res) => {
this.userInfo.avatar = res.tempFilePaths[0];
}
})
},
// 退
logOutEv() {
this.$requst.post('/universal/api.login/signout').then(res => {

View File

@ -231,6 +231,7 @@
import lwNotice from '@/components/lw-notice/lw-notice.vue';
import footTabOne from '@/components/foot-tabs/foot-tab-one.vue';
import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
const app = getApp();
export default {
components:{
pitera,
@ -368,7 +369,7 @@
let obj = {
id:item.id,
title:item.name,
imgsrc: getApp().globalData.hostapi + '/' + item.cover_img,
imgsrc: app.globalData.hostapi + '/' + item.cover_img,
}
this.solutionList.push(obj);
})
@ -398,7 +399,7 @@
let obj = {
id:item.id,
title:item.title,
imgsrc: getApp().globalData.hostapi + '/' + item.cover_img,
imgsrc: app.globalData.hostapi + '/' + item.cover_img,
content:item.summary,
views:item.reading
}

View File

@ -218,9 +218,9 @@
},
goWorkorderTwo(){
console.log(this.targetObj);
// uni.navigateTo({
// url: "/pages/workOrder/workOrderThree"
// })
uni.navigateTo({
url: "/pages/workOrder/workOrderThree"
})
},
addMountingsList() {
uni.navigateTo({

View File

@ -21,6 +21,7 @@
</template>
<script>
const app = getApp();
export default {
data() {
return {
@ -54,7 +55,7 @@
//
this.dataObj.create_time = this.$toolAll.tools.timestampToTime(this.dataObj.create_time);
//
this.dataObj.cover_img = getApp().globalData.hostapi + '/' + this.dataObj.cover_img,
this.dataObj.cover_img = app.globalData.hostapi + '/' + this.dataObj.cover_img,
this.rich_text = this.$toolAll.tools.escape2Html(this.dataObj.content);
}
})

View File

@ -29,6 +29,7 @@
<script>
import rate from '@/components/rate.vue';
const app = getApp();
export default {
components:{
rate
@ -80,7 +81,7 @@
res.data.data.forEach(item=>{
let obj = {
id:item.id,
cover_img: getApp().globalData.hostapi + '/' + item.cover_img,
cover_img: app.globalData.hostapi + '/' + item.cover_img,
title:item.title,//
summary:item.summary,//
hot:item.hot,//