Commit 34e39f16 authored by 罗超's avatar 罗超

完成用户鉴权

parent 6532eef2
......@@ -17,4 +17,11 @@ export function getSudentsByClassInAccount(data) {
method: 'post',
data
})
}
export function setStudentClassInAccount(data) {
return request({
url: '/AppletCenter/SetStudentClassInAccount',
method: 'post',
data
})
}
\ No newline at end of file
......@@ -54,7 +54,19 @@ export function getWeChatOpenId(data) {
*/
export function phoneLogin(data) {
return request({
url: '/AppletLogin/LoginByAccount',
url: '/Login/LoginByAccount',
method: 'post',
data
})
}
/**
* 手机号登录
* @param {JSON参数} data
*/
export function getStudentByAccount(data) {
return request({
url: '/Login/GetStudentByAccount',
method: 'post',
data
})
......
......@@ -16,20 +16,31 @@
<van-popup
:show="showChange"
round
catch:touchstart
custom-style="height: 650rpx;width:650rpx"
@close="closeChangeUserHandler"
>
<view class="user-change-box">
<view class="icon">
<van-icon class-prefix='iconfont' name='icon-qiehuan1'></van-icon>
</view>
<view class="title">
切换学员
</view>
<view class="close">
<van-icon name='cross' @click="showChange=false"></van-icon>
<view class="title-box">
<view class="icon">
<van-icon class-prefix="iconfont" name="icon-qiehuan1"></van-icon>
</view>
<view class="title">
切换学员
</view>
<view class="close">
<van-icon name='cross' @click="closeChangeUserHandler"></van-icon>
</view>
</view>
<scroll-view style="overflow-y: auto; height: 1px; flex:1;margin-top:50rpx">
<view class="user-item" @click="changeErpUserHandler(x)" v-for="(x,i) in erpUsers">
<view class="avatar" :style="{background:x.bgColor}">{{x.AccountName.substring(0,1)}}</view>
<view class="uname">
{{x.AccountName}}
</view>
<view class="check" v-if="x.AccountId==currentErpUser.AccountId">
<van-icon name="success" />
</view>
</view>
</scroll-view>
</view>
</van-popup>
</view>
......@@ -49,7 +60,14 @@
data.currentErpUser=uni.getStorageSync('erpUserInfo')
let methods = {
closeChangeUserHandler(){
console.log('in....')
data.showChange=false
},
changeErpUserHandler(x){
uni.setStorageSync("erpUserInfo",x)
uni.reLaunch({
url:'/pages/index/index'
})
},
initColor(){
if(data.erpUsers){
......@@ -79,7 +97,7 @@
},
};
</script>
<style scoped>
<style>
.index-header-userCard text{
font-size: 26rpx;
font-weight: bold;
......@@ -115,29 +133,64 @@
font-weight: 500;
color: #B8B8B8;
}
.userCard-box .user-change-box{
.userCard-box .user-change-box {
padding: 50rpx;
box-sizing: border-box;
height: 100%;
display: flex;
flex-direction: column;
}
.userCard-box .user-change-box .title-box {
display: flex;
flex-direction: row;
align-items: center;
}
.userCard-box .user-change-box .icon{
.userCard-box .user-change-box .title-box .icon{
font-size: 22rpx;
color:#282828;
margin-right: 8rpx;
}
.userCard-box .user-change-box .title{
.userCard-box .user-change-box .title-box .title{
font-size: 36rpx;
font-weight: bold;
color: #000000;
width: 1px;
flex:1;
}
.userCard-box .user-change-box .title .close{
.userCard-box .user-change-box .title-box .close{
width: 26rpx;
height: 26rpx;
color:#282828;
}
.userCard-box .user-item{
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 36rpx;
}
.userCard-box .user-item .avatar{
width: 60rpx;
height: 60rpx;
background: #9ADBC5;
border-radius: 50%;
font-size: 38rpx;
font-weight: 500;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
}
.userCard-box .user-item .uname{
font-size: 28rpx;
margin-left: 32rpx;
font-weight: 500;
color: #000000;
width:1px;
flex: 1;
}
.userCard-box .user-item .check{
color: #000000;
font-size: 36rpx;
}
</style>
\ No newline at end of file
......@@ -126,7 +126,7 @@
uni.setStorageSync("ErpStus",r.Data)
let account=[]
r.Data.forEach(x=>{
account.push(x.RealPhone)
account.push(x.ClassInAccount)
})
methods.setAccountsLogin(`'${account.join("','")}'`)
}else{
......@@ -141,7 +141,7 @@
if(r.Data && r.Data.length>0){
let erpStus=uni.getStorageSync('ErpStus')
erpStus.forEach(x=>{
if(x.RealPhone==r.Data[0].UserMobile){
if(x.ClassInAccount==r.Data[0].Account){
uni.setStorageSync('erpUserInfo',x)
}
})
......@@ -235,7 +235,7 @@
if(r.Data && r.Data.length>0){
uni.setStorageSync("ErpStus",r.Data)
r.Data.forEach(x=>{
if(x.RealPhone==u.Account){
if(x.ClassInAccount==u.Account){
uni.setStorageSync('erpUserInfo',x)
}
})
......
......@@ -16,28 +16,53 @@
<!-- <signOut :AccountType="0"></signOut> -->
<userCard></userCard>
</navbar>
<view style="margin: 40rpx 0 10rpx 0;">
<view style="padding:0 50rpx;font-weight: 800;color: #282828;">
<view style="font-size: 36rpx;">Hello,{{userData.AccountName}}</view>
<view style="font-size: 50rpx;">您的学情反馈已准备好</view>
<view v-if="userData">
<view style="margin: 40rpx 0 10rpx 0;">
<view style="padding:0 50rpx;font-weight: 800;color: #282828;">
<view style="font-size: 36rpx;">Hello,{{userData.AccountName}}</view>
<view style="font-size: 50rpx;">您的学情反馈已准备好</view>
</view>
</view>
<course-card :stuCourseList="stuCourseList" @changePopStatus='changePopStatusHandler' @change="changeCourseHandler"></course-card>
<view class="index-student-title flex">
<text>学情反馈</text>
<view>(共{{workList!=null&&workList.length>0?workList.length:0}}条)</view>
</view>
<view class="index-student-information" v-if="workList && workList.length>0">
<template v-for="(item,index) in workList">
<JobComponents v-if="item.ResultType==1" :jobData="item"></JobComponents>
<examComponents v-if="item.ResultType==2" :jobData="item"></examComponents>
<commentsComponents v-if="item.ResultType==3" :jobData="item"></commentsComponents>
</template>
</view>
<view class="index-student-information" v-else>
<view class="noData">
<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653902791000_806.png" mode="widthFix"></image>
<view>暂无反馈信息</view>
</view>
</view>
</view>
<course-card :stuCourseList="stuCourseList" @changePopStatus='changePopStatusHandler' @change="changeCourseHandler"></course-card>
<view class="index-student-title flex">
<text>学情反馈</text>
<view>(共{{workList!=null&&workList.length>0?workList.length:0}}条)</view>
</view>
<view class="index-student-information" v-if="workList && workList.length>0">
<template v-for="(item,index) in workList">
<JobComponents v-if="item.ResultType==1" :jobData="item"></JobComponents>
<examComponents v-if="item.ResultType==2" :jobData="item"></examComponents>
<commentsComponents v-if="item.ResultType==3" :jobData="item"></commentsComponents>
</template>
</view>
<view class="index-student-information" v-else>
<view class="noData">
<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653902791000_806.png" mode="widthFix"></image>
<view>暂无反馈信息</view>
<view class="unbind-box" v-else>
<view class="title">
未绑定学员ClassIn账号
</view>
<view class="search-box">
<input type="text" :disabled="submiting" maxlength="11" placeholder-style="font-size:28rpx;" @blur="changeSearchKeyHandler" auto-focus v-model="searchBindKey" placeholder="输入学员ClassIn账号进行绑定" />
</view>
<view class="result-box" v-if="searchResult">
<view class="avatar-result">
{{searchResult.AccountName.substring(0,1)}}
</view>
<view class="name-result">
{{searchResult.AccountName}}
</view>
<view style="margin-top: 50rpx;">
<van-button size="large" @click="setBindHandler" :loading="submiting" custom-style="border-radius:10rpx;" color="#C81727">
立即绑定
</van-button>
</view>
</view>
</view>
<tabbar active-name='home'></tabbar>
......@@ -67,11 +92,13 @@
} from "vue";
import {
getSweepCode
getSweepCode,
getStudentByAccount
} from '../../api/index.js'
import {
getImageColor
} from '../../utils/index.js'
import {setStudentClassInAccount} from '../../api/erp.js'
import userCard from '../../components/user-card.vue'
import indexassembly from './components/indexassembly.vue'
import navbar from '../../components/navbar.vue'
......@@ -101,10 +128,23 @@
courseId: 0,
},
showPopu:false,
searchBindKey:'',
searchResult:null,
submiting:false,
workList: [],//学员作业、考试、评语数据
});
let methods = {
changeSearchKeyHandler(){
if(data.searchBindKey.length!=11){
uni.showToast({
title:'请输入正确手机号码'
})
}else{
console.log('in...')
methods.searchHandler()
}
},
changePopStatusHandler(status){
data.showPopu=status==1
},
......@@ -136,6 +176,53 @@
uni.hideLoading()
})
},
searchHandler() {
uni.showLoading({
title:'正在查询'
})
getStudentByAccount({
Account:data.searchBindKey
}).then(r=>{
data.searchResult=r.Data
uni.hideLoading()
}).catch(e=>{
uni.hideLoading()
})
},
setBindHandler(){
data.submiting=true
uni.showLoading({
title:'正在绑定'
})
setStudentClassInAccount({account:data.searchResult.Account}).then(r=>{
if(r.Code==1){
let users=uni.getStorageSync("users")
users.push(data.searchResult)
uni.setStorageSync('users',users)
uni.setStorageSync('userInfo',data.searchResult)
let erpUsers=uni.getStorageSync("ErpStus")
let currentErpUser=uni.getStorageSync("erpUserInfo")
erpUsers.forEach(x=>{
if(x.AccountId==currentErpUser.AccountId){
x.ClassInAccount=data.searchResult.Account
currentErpUser.ClassInAccount=data.searchResult.Account
}
})
uni.setStorageSync('ErpStus',erpUsers)
uni.setStorageSync('erpUserInfo',currentErpUser)
}
data.submiting=false
uni.hideLoading()
uni.reLaunch({
url:'/pages/index/index'
})
}).catch(e=>{
data.submiting=false
uni.hideLoading()
})
},
//定义更新方法
VersionUpdate() {
// 判断应用的 getUpdateManager 是否在当前版本可用
......@@ -339,4 +426,65 @@
top: 0;
z-index: 9;
}
.unbind-box{
min-height: calc(100vh - 300rpx);
box-sizing: border-box;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
background-color: #FFF;
margin-top: 200rpx;
padding:50rpx;
}
.unbind-box .title{
font-size: 36rpx;
font-weight: 500;
color: #282828;
}
.unbind-box .search-box{
margin-top: 50rpx;
}
.unbind-box .search-box input{
height: 100rpx;
width: 100%;
box-sizing: border-box;
padding: 0 50rpx;
line-height: 100rpx;
color: #282828;
outline: none;
border-radius: 100rpx;
font-size: 40rpx;
border: 4rpx solid #999;
font-weight: bolder;
}
.unbind-box .search-box input:focus,
.unbind-box .search-box input:active{
border: 4rpx solid #C81727 !important;
}
.unbind-box .search-box .placeholder {
color: #C81727;
font-size: 28rpx;
opacity: .2;
}
.unbind-box .result-box{
margin-top: 50rpx;
}
.unbind-box .result-box .avatar-result{
width:160rpx;
height: 160rpx;
text-align: center;
background-color: coral;
border-radius: 10rpx;
line-height: 160rpx;
font-size: 60rpx;
color:#FFF;
font-weight: 400;
}
.unbind-box .result-box .name-result{
width:160rpx;
text-align: center;
font-size: 32rpx;
color:#282828;
margin-top: 10rpx;
}
</style>
......@@ -200,7 +200,7 @@
if(r.Data && r.Data.length>0){
uni.setStorageSync("ErpStus",r.Data)
r.Data.forEach(x=>{
if(x.RealPhone==u.Account){
if(x.ClassInAccount==u.Account){
uni.setStorageSync('erpUserInfo',x)
}
})
......
......@@ -27,16 +27,21 @@ let request = (param) => {
resolve(res.data)
} else {
if (res.data.Code==10001 || res.data.Code == 10000) {
uni.showToast({
title: "用户凭证失效,请重新授权",
duration: 2000,
icon: "none",
});
uni.removeStorageSync('userInfo');
uni.reLaunch({
url:"/pages/login/login"
})
reject()
if(!uni.getStorageSync('erpUserInfo')){
console.log('in....')
uni.showToast({
title: "用户凭证失效,请重新授权",
duration: 2000,
icon: "none",
});
uni.removeStorageSync('userInfo');
uni.reLaunch({
url:"/pages/login/login"
})
reject()
}else{
resolve(res.data)
}
}else{
uni.showToast({
title: res.data.Message,
......
......@@ -17,7 +17,7 @@ let request = (param) => {
method: param.method || "Post",
header: param.header || {
'content-type': "application/json",
'Authorization': token || ""
'token': token || ""
},
data: {
Msg: param.data,
......@@ -27,16 +27,16 @@ let request = (param) => {
resolve(res.data)
} else {
if (res.data.Code==10001 || res.data.Code == 10000) {
uni.showToast({
title: "用户凭证失效,请重新授权",
duration: 2000,
icon: "none",
});
uni.removeStorageSync('erpUserInfo');
uni.reLaunch({
url:"/pages/login/login"
})
reject()
// uni.showToast({
// title: "用户凭证失效,请重新授权",
// duration: 2000,
// icon: "none",
// });
// uni.removeStorageSync('erpUserInfo');
// uni.reLaunch({
// url:"/pages/login/login"
// })
// reject()
} else {
uni.showToast({
title: res.data.Message,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment