1111
This commit is contained in:
123
common/wxSilentLogin.js
Normal file
123
common/wxSilentLogin.js
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
// 静默登录
|
||||||
|
import {
|
||||||
|
isEmpty
|
||||||
|
} from './TextUtils.js'
|
||||||
|
|
||||||
|
//引入bus
|
||||||
|
import bus from '@/common/bus';
|
||||||
|
|
||||||
|
const wxSilentLogin = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wx.login({
|
||||||
|
success: function(res) {
|
||||||
|
if (res.code) {
|
||||||
|
console.log('Http网络请求信息', {
|
||||||
|
"wxCode": res.code
|
||||||
|
})
|
||||||
|
uni.request({
|
||||||
|
// 组装请求地址
|
||||||
|
url: getApp().globalData.wxSilentLoginURL + "?wxCode=" + res
|
||||||
|
.code,
|
||||||
|
// 请求方式 GET POST
|
||||||
|
method: "GET",
|
||||||
|
header: {
|
||||||
|
// 传参方式
|
||||||
|
'content-type': "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
// 具体参数
|
||||||
|
data: {
|
||||||
|
"wxCode": res.code
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
console.log("请求openid", res)
|
||||||
|
// if (getApp().globalData.isDebug) {
|
||||||
|
// console.log('Http网络路径', getApp().globalData
|
||||||
|
// .wxSilentLoginURL)
|
||||||
|
// }
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
if (!res.data.success) {
|
||||||
|
|
||||||
|
// if (res.data.code == 500) {
|
||||||
|
// uni.showModal({
|
||||||
|
// title: '温馨提示',
|
||||||
|
// content: '您的平台应用未被授权,请联系工作人员。',
|
||||||
|
// showCancel: false,
|
||||||
|
// success: function(res) {
|
||||||
|
// if (res.confirm) {
|
||||||
|
// wx.exitMiniProgram({
|
||||||
|
// success: function() {},
|
||||||
|
// fail: function() {}
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// console.log('点击了取消')
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (res.data.code == 100) {
|
||||||
|
// 未绑定用户
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '../index/BindPhone?openid=' +
|
||||||
|
res.data.data.openid+"&unionid="+
|
||||||
|
res.data.data.unionid
|
||||||
|
})
|
||||||
|
// }
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
console.log("Http网络请求res", res)
|
||||||
|
console.log("Global-Auth-Token", res.data.data
|
||||||
|
.token)
|
||||||
|
|
||||||
|
|
||||||
|
getApp().globalData.username = res.data.data
|
||||||
|
.name
|
||||||
|
getApp().globalData.token = res.data.data.token
|
||||||
|
getApp().globalData.sid = res.data.data.sid
|
||||||
|
getApp().globalData.mobile = res.data.data
|
||||||
|
.mobile
|
||||||
|
|
||||||
|
getApp().globalData.isAdmin = res.data.data.isAdmin
|
||||||
|
getApp().globalData.orgSidPath = res.data.data.orgSidPath
|
||||||
|
getApp().globalData.orgNamePath = res.data.data.orgNamePath
|
||||||
|
getApp().globalData.organizationSid = res.data.data.organizationSid
|
||||||
|
getApp().globalData.headImage = res.data.data.headImage
|
||||||
|
|
||||||
|
getApp().globalData.isLogin = true
|
||||||
|
|
||||||
|
uni.setStorageSync("Global-Auth-Token", res.data
|
||||||
|
.data.token)
|
||||||
|
uni.setStorageSync("sid", res.data.data.sid)
|
||||||
|
uni.setStorageSync("isLogin", true)
|
||||||
|
|
||||||
|
bus.$emit('wholeSpin', true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getApp().globalData.isLogin = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
if (getApp().globalData.isDebug) {
|
||||||
|
console.log("Http网络请求fail", err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: () => {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function(res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "静默登录失败:" + res.errMsg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
|
||||||
|
reject(res.errMsg)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export default wxSilentLogin
|
||||||
101
components/UserItem/UserItem.vue
Normal file
101
components/UserItem/UserItem.vue
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
<view class="user-item-content" @click="click">
|
||||||
|
<view class="user-item-left">
|
||||||
|
<image :src="src" style="width: 40rpx;height: 40rpx;" mode="aspectFit"></image>
|
||||||
|
<text class="user-item-textBlack">{{text}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="user-item-right">
|
||||||
|
<text class="user-item-textBlack2">{{notes}}</text>
|
||||||
|
<image class="user-item-right_img" src="../../static/baseIcon/zy.png"></image>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
src: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
notes: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
clickId: {
|
||||||
|
type: String,
|
||||||
|
default: "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
click() {
|
||||||
|
var clickId = this.$props.clickId;
|
||||||
|
this.$emit("click", clickId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.user-item-content {
|
||||||
|
width: 100%;
|
||||||
|
height: 120rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
padding-left: 40rpx;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-bottom: 1px solid #f5f5f5;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.user-item-left {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
height: 89rpx;
|
||||||
|
align-items: center;
|
||||||
|
flex: 1;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.user-item-textBlack {
|
||||||
|
color: #333333;
|
||||||
|
margin-left: 15px;
|
||||||
|
font-size: 30rpx;
|
||||||
|
height: 89rpx;
|
||||||
|
line-height: 89rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-item-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
height: 89rpx;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.user-item-right_img {
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
margin-right: 35rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-item-textBlack2 {
|
||||||
|
color: #ccc;
|
||||||
|
font-size: 25rpx;
|
||||||
|
height: 89rpx;
|
||||||
|
line-height: 89rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
234
pages/home/UserFragment.vue
Normal file
234
pages/home/UserFragment.vue
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<template>
|
||||||
|
<view class="page">
|
||||||
|
|
||||||
|
<view class="top">
|
||||||
|
|
||||||
|
<image class="img" :src="baseUrl" @click="chooseImage"></image>
|
||||||
|
|
||||||
|
<view class="top_right">
|
||||||
|
|
||||||
|
<text class="top_right_text1">{{name}}</text>
|
||||||
|
<text class="top_right_text2">{{orgName}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="user-item-bg">
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/wdxm.png' text="我的项目" @click="click" clickId="0">
|
||||||
|
</UserItem>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- <view class="user-item-bg">
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/smxx.png' text="实名信息" notes="完善信息" @click="click" clickId="1"></UserItem>
|
||||||
|
|
||||||
|
</view> -->
|
||||||
|
|
||||||
|
<view class="user-item-bg">
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/sz.png' text="设置" @click="click" clickId="2">
|
||||||
|
</UserItem>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="user-item-bg">
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/wdxm.png' text="关注公众号" @click="click" clickId="8">
|
||||||
|
</UserItem>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- #ifdef APP-PLUS -->
|
||||||
|
<!-- <view class="user-item-bg"> -->
|
||||||
|
<!-- <UserItem src='https://supervise.yxtsoft.com/img/user/zzjg.png' text="组织结构" @click="click" clickId="3"></UserItem>
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/xmgl.png' text="项目管理" @click="click" clickId="4"></UserItem>
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/ycgl.png' text="云仓管理" @click="click" clickId="5"></UserItem>
|
||||||
|
<UserItem src='https://supervise.yxtsoft.com/img/user/xtgl.png' text="系统管理" @click="click" clickId="6"></UserItem> -->
|
||||||
|
<!-- <UserItem src='https://supervise.yxtsoft.com/img/user/xtgl.png' text="检查更新" :notes="version" @click="click"
|
||||||
|
clickId="7">
|
||||||
|
</UserItem> -->
|
||||||
|
<!-- </view> -->
|
||||||
|
<!-- #endif -->
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import APPUpdate, {
|
||||||
|
getCurrentNo
|
||||||
|
} from '../../plugins/APPUpdate/index.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
baseUrl: "",
|
||||||
|
name: "",
|
||||||
|
orgName: "",
|
||||||
|
version: ""
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
/* #ifdef APP-PLUS */
|
||||||
|
let that = this;
|
||||||
|
getCurrentNo(version => {
|
||||||
|
that.version = version.version
|
||||||
|
console.log("version", version)
|
||||||
|
console.log("qqqq", that.version)
|
||||||
|
})
|
||||||
|
|
||||||
|
/* #endif */
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
console.log('onShow', getApp().globalData.isLogin)
|
||||||
|
|
||||||
|
let token = uni.getStorageSync("Global-Auth-Token")
|
||||||
|
if (token != null && token.length != 0) {
|
||||||
|
getApp().globalData.token = token
|
||||||
|
}
|
||||||
|
let isLogin = uni.getStorageSync("isLogin")
|
||||||
|
if (isLogin != null && isLogin == 1) {
|
||||||
|
getApp().globalData.isLogin = isLogin
|
||||||
|
}
|
||||||
|
let sid = uni.getStorageSync("sid")
|
||||||
|
if (sid != null && sid.length != 0) {
|
||||||
|
getApp().globalData.sid = sid
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('用户Sid', getApp().globalData.sid)
|
||||||
|
console.log('token', getApp().globalData.token)
|
||||||
|
console.log('是否登陆', getApp().globalData.isLogin)
|
||||||
|
|
||||||
|
// setTimeout(() => {
|
||||||
|
if (getApp().globalData.isLogin) {
|
||||||
|
var userSid = getApp().globalData.sid
|
||||||
|
var headImage = getApp().globalData.headImage
|
||||||
|
var username = getApp().globalData.username
|
||||||
|
var orgNamePath = getApp().globalData.orgNamePath
|
||||||
|
console.log(">>>>>", userSid)
|
||||||
|
console.log(">>>>>", headImage)
|
||||||
|
console.log(">>>>>", username)
|
||||||
|
console.log(">>>>>", orgNamePath)
|
||||||
|
|
||||||
|
this.name = username == "" ? "用户名称" : username
|
||||||
|
this.orgName = orgNamePath == "" ? "暂无部门信息" : orgNamePath
|
||||||
|
this.baseUrl = headImage == "" ? "https://supervise.yxtsoft.com/img/user/userImage.png" : headImage
|
||||||
|
|
||||||
|
|
||||||
|
// this.getData(userSid, true)
|
||||||
|
// uni.setTabBarBadge({ //显示数字
|
||||||
|
// index: 0, //tabbar下标
|
||||||
|
// text: '100' //数字
|
||||||
|
// })
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/* #ifdef MP-WEIXIN */
|
||||||
|
this.WxSilentLogin()
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
/* #ifdef APP-PLUS */
|
||||||
|
uni.redirectTo({
|
||||||
|
url: '../login/login'
|
||||||
|
})
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
chooseImage() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '../index/SetUp2'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
click(id) {
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case "0":
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '../index/MyProject'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "1":
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '../index/SetUp'
|
||||||
|
});
|
||||||
|
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: '../index/DeviceException?sid=994d75b6-eb29-4733-bd48-dcfdf9f7dd47'
|
||||||
|
// });
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
break;
|
||||||
|
case "5":
|
||||||
|
break;
|
||||||
|
case "6":
|
||||||
|
break;
|
||||||
|
case "7":
|
||||||
|
APPUpdate(true);
|
||||||
|
break;
|
||||||
|
case "8":
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '../index/interestAccount'
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.page {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
.top {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
padding: 15px 25px;
|
||||||
|
|
||||||
|
.img {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top_right {
|
||||||
|
margin-top: 10px;
|
||||||
|
flex: 1;
|
||||||
|
margin-left: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.top_right_text1 {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 800;
|
||||||
|
font-family: sans-serif;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.top_right_text2 {
|
||||||
|
margin-top: 5px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-item-bg {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
margin-top: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user