优化微信授权登录

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 // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// uni.setStorageSync('hostapi','http://maintain.7and5.cn'); // uni.setStorageSync('hostapi','http://maintain.7and5.cn');
getApp().globalData.hostapi = 'http://maintain.7and5.cn'; this.globalData.hostapi = 'http://maintain.7and5.cn';
// #endif // #endif
// #ifdef H5 // #ifdef H5
// uni.setStorageSync('hostapi','/web'); // uni.setStorageSync('hostapi','/web');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,17 +27,16 @@
style="background: url(../../../static/public/icon-my-head.png) no-repeat;height: 400rpx;background-size: 100% 100%;"> 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="disjbac" style="padding: 60rpx 80rpx 60rpx 60rpx;">
<view class="disac"> <view class="disac">
<image class="flexs mar-y10" v-if="!userInfo.avatar" <!-- 用户头像 -->
src="/static/public/icon-my-headimg.png" mode="aspectFill" <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>
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>
<view class="disjb fc" style="height: 91rpx;"> <view class="disjb fc" style="height: 91rpx;">
<!-- 用户手机号 -->
<view class="fon34 bold">{{tel(userInfo.username)}}</view> <view class="fon34 bold">{{tel(userInfo.username)}}</view>
<!-- 是否实名认证 -->
<view class="fon22" style="color: #717171;">未实名认证</view> <view class="fon22" style="color: #717171;">未实名认证</view>
</view> </view>
</view> </view>
<!-- 等级图标 -->
<image src="/static/public/icon-my-level.png" mode="aspectFill" <image src="/static/public/icon-my-level.png" mode="aspectFill"
style="width: 49rpx;height: 76rpx;" lazy-load></image> style="width: 49rpx;height: 76rpx;" lazy-load></image>
</view> </view>
@ -181,6 +180,16 @@
this.$toolAll.tools.disableShareEv(); this.$toolAll.tools.disableShareEv();
}, },
methods: { methods: {
//
replaceImg(){
uni.chooseImage({
count: 1,
sourceType:['album','camera'],
success: (res) => {
this.userInfo.avatar = res.tempFilePaths[0];
}
})
},
// 退 // 退
logOutEv() { logOutEv() {
this.$requst.post('/universal/api.login/signout').then(res => { 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 lwNotice from '@/components/lw-notice/lw-notice.vue';
import footTabOne from '@/components/foot-tabs/foot-tab-one.vue'; import footTabOne from '@/components/foot-tabs/foot-tab-one.vue';
import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue'; import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
const app = getApp();
export default { export default {
components:{ components:{
pitera, pitera,
@ -368,7 +369,7 @@
let obj = { let obj = {
id:item.id, id:item.id,
title:item.name, title:item.name,
imgsrc: getApp().globalData.hostapi + '/' + item.cover_img, imgsrc: app.globalData.hostapi + '/' + item.cover_img,
} }
this.solutionList.push(obj); this.solutionList.push(obj);
}) })
@ -398,7 +399,7 @@
let obj = { let obj = {
id:item.id, id:item.id,
title:item.title, title:item.title,
imgsrc: getApp().globalData.hostapi + '/' + item.cover_img, imgsrc: app.globalData.hostapi + '/' + item.cover_img,
content:item.summary, content:item.summary,
views:item.reading views:item.reading
} }

View File

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

View File

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

View File

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