Commit 6532eef2 authored by 罗超's avatar 罗超

提交登陆问题

parent 093892bf
import request from '../utils/requestErp.js'
/**
* 账号密码登录
* @param {JSON参数} data
*/
export function loginByUnionId(data) {
return request({
url: '/AppletLogin/LoginByUnionId',
method: 'post',
data
})
}
export function getSudentsByClassInAccount(data) {
return request({
url: '/AppletLogin/GetStudentsByClassInAccount',
method: 'post',
data
})
}
\ No newline at end of file
......@@ -12,6 +12,14 @@ export function login(data) {
})
}
export function getWeChatOpenId(data) {
return request({
url: '/Login/getWeChatOpenId',
method: 'post',
data
})
}
/**
* 解密手机号
* @param {JSON参数} data
......@@ -52,6 +60,18 @@ export function phoneLogin(data) {
})
}
/**
* 手机号登录
* @param {JSON参数} data
*/
export function getLoginAccounts(data) {
return request({
url: '/Login/LoginByAccounts',
method: 'post',
data
})
}
/**
* 获取首页信息
* @param {JSON参数} data
......
......@@ -41,6 +41,7 @@
gridCount: 3,
opacity: 0.8,
max: 100,
min: -5,
gridColor:"#fcebed",
labelColor:'#CE8086',
}
......@@ -66,6 +67,19 @@
let avgRate =[];//平均得分率
let sumRate=[]
props.ModuleList && props.ModuleList.forEach(item=>{
if(item.ScoreRate==0) return;
if(item.Module.length>6){
cate.push(item.Module.substring(0,6)+'...');
}else{
cate.push(item.Module);
}
grRate.push((item.ScoreRate * 100).toFixed(0));
avgRate.push((item.AvgScoreRate * 100).toFixed(0));
sumRate.push(100)
});
props.ModuleList && props.ModuleList.forEach(item=>{
if(item.ScoreRate>0) return;
if(item.Module.length>6){
cate.push(item.Module.substring(0,6)+'...');
}else{
......
<template>
<van-tabbar :active="active" @change="changeTabbarHandler" active-color="#282828" nactive-color="#929292">
<van-tabbar-item name="home">
<image
slot="icon"
src="../static/image/home_active.png"
mode="aspectFit"
style="width: 44rpx; height: 44rpx;"
/>
<image
slot="icon-active"
src="../static/image/home.png"
mode="aspectFit"
style="width: 44rpx; height: 44rpx;"
/>
首页
</van-tabbar-item>
<van-tabbar-item name="classtime">
<image
slot="icon"
src="../static/image/classtime.png"
mode="aspectFit"
style="width: 44rpx; height: 44rpx;"/>
<image
slot="icon-active"
src="../static/image/classtion_active.png"
mode="aspectFit"
style="width: 44rpx; height: 44rpx;"/>
课表</van-tabbar-item>
<van-tabbar-item name="usercenter">
<image
slot="icon"
src="../static/image/center.png"
mode="aspectFit"
style="width: 44rpx; height: 44rpx;"/>
<image
slot="icon-active"
src="../static/image/center_active.png"
mode="aspectFit"
style="width: 44rpx; height: 44rpx;"/>
我的
</van-tabbar-item>
</van-tabbar>
</template>
<script>
import {
ref,
reactive,
toRefs,
toRef,
getCurrentInstance,
watch,
computed,
onMounted,
} from "vue";
export default {
props:{
activeName:{
type:String,
default:""
}
},
setup(props) {
let data = reactive({
active:props.activeName
});
const os = uni.getSystemInfoSync();
console.log(os)
//data.statusBarHeight = os.statusBarHeight
let methods={
changeTabbarHandler(e){
data.active=e.detail
}
}
return {
...toRefs(data),
...methods
};
},
};
</script>
<style scoped>
.navbar {
height: 100rpx;
background:#F6F6F6;
}
.sticky {
position: sticky;
top: 0;
z-index: 2;
}
</style>
<template>
<view class="userCard-box" v-if="currentErpUser">
<view class="index-header-userCard flex" @click="showChange=true">
<view class="user-avatar" :style="{background:currentErpUser.bgColor}">
{{currentErpUser.AccountName.substring(0,1)}}
</view>
<view>
<view class="user-name">
{{currentErpUser.AccountName}}
</view>
<view class="user-change-text">
点击切换学员
</view>
</view>
</view>
<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>
</view>
</van-popup>
</view>
</template>
<script>
import { reactive, toRefs, onMounted } from "vue";
export default {
components: {},
setup() {
let data = reactive({
colors:['#9ADBC5','#87DDEA','#FE8D6F','#F986AA','#FDC453'],
currentErpUser:null,
erpUsers:[],
showChange:false,
});
data.erpUsers=uni.getStorageSync('ErpStus')
data.currentErpUser=uni.getStorageSync('erpUserInfo')
let methods = {
closeChangeUserHandler(){
},
initColor(){
if(data.erpUsers){
let i=0
data.erpUsers.forEach(x=>{
x.bgColor=data.colors[i]
i++;
if(i==data.colors.length){
i=0
}
if(x.AccountId==data.currentErpUser.AccountId){
data.currentErpUser.bgColor=x.bgColor
}
})
}
}
};
onMounted(() => {
//data.changePasswordShow = props.AccountType
methods.initColor()
});
return {
...toRefs(data),
...methods,
};
},
};
</script>
<style scoped>
.index-header-userCard text{
font-size: 26rpx;
font-weight: bold;
color: #282828;
margin-left: 20rpx;
letter-spacing: 2rpx;
}
.index-header-userCard{
align-items: center;
}
.userCard-box{
padding: 0 30rpx 0 38rpx;
}
.userCard-box .user-avatar{
width:60rpx;
height: 60rpx;
border-radius: 60rpx;
font-size: 38rpx;
font-weight: 500;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
margin-right: 25rpx;
}
.userCard-box .user-name{
font-size: 28rpx;
font-weight: bold;
color: #282828;
}
.userCard-box .user-change-text{
font-size: 18rpx;
font-weight: 500;
color: #B8B8B8;
}
.userCard-box .user-change-box{
padding: 50rpx;
box-sizing: border-box;
height: 100%;
display: flex;
align-items: center;
}
.userCard-box .user-change-box .icon{
font-size: 22rpx;
color:#282828;
margin-right: 8rpx;
}
.userCard-box .user-change-box .title{
font-size: 36rpx;
font-weight: bold;
color: #000000;
width: 1px;
flex:1;
}
.userCard-box .user-change-box .title .close{
width: 26rpx;
height: 26rpx;
color:#282828;
}
</style>
\ No newline at end of file
{
"name" : "进阶成长数",
"name" : "小程序",
"appid" : "__UNI__C97C820",
"description" : "甲鹤小程序学生端",
"versionName" : "1.0.0",
......
......@@ -174,7 +174,9 @@
"van-tab": "/wxcomponents/vant/tab/index", //
"van-tabs": "/wxcomponents/vant/tabs/index", //
"van-tree-select": "/wxcomponents/vant/tree-select/index", //
"van-count-down": "/wxcomponents/vant/count-down/index"
"van-count-down": "/wxcomponents/vant/count-down/index",
"van-tabbar":"/wxcomponents/vant/tabbar/index",
"van-tabbar-item":"/wxcomponents/vant/tabbar-item/index"
}
}
}
......@@ -17,7 +17,7 @@
<image :src="obj.Photo" style="width: 120rpx;height: 120rpx;border-radius: 50%;margin-top: 15px;">
</image>
<text style="margin-top: 15px;font-size: 18px;font-weight: bold;color: #111111;">{{obj.Name}}</text>
<text style="margin-top: 5px;font-size: 13px;color: #111111;">申请获取您微信绑定的手机号码</text>
<view style="margin-top: 5px;font-size: 13px;color: #111111;padding:0 40rpx; line-height:1.5;text-align:center">未匹配到学员信息,希望根据微信绑定手机进行匹配</view>
<view class="btn">获取手机号
<button type="default" open-type="getPhoneNumber" v-if="showLogin == true"
style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;"
......@@ -39,8 +39,11 @@
import {
login,
phoneLogin,
parsePhone
parsePhone,
getWeChatOpenId,
getLoginAccounts
} from "../../../api/index";
import { loginByUnionId} from '../../../api/erp.js'
export default {
name: "",
......@@ -72,6 +75,7 @@
Photo: '',
},
showPhone: false,
userAuth:null,
showLogin: true, //多次点击
});
let methods = {
......@@ -84,12 +88,18 @@
wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (info) => {
uni.setStorageSync('userWxInfo',info)
data.obj.Name = info.userInfo.nickName;
data.obj.Photo = info.userInfo.avatarUrl;
data.showPhone = true; //显示获取手机号码弹窗
if (currentRoute == "pages/index/index") {
uni.hideTabBar() //手机授权弹窗出现 隐藏tabbar
}
wx.login({
//成功放回
success:(res)=>{
uni.showLoading({
title:'尝试授权直接登陆'
})
methods.loginByOpenCode(res.code)
}
})
},
fail: () => {
uni.showToast({
......@@ -99,6 +109,54 @@
},
});
},
loginByOpenCode(Code){
getWeChatOpenId({Code}).then(r=>{
uni.setStorageSync('wxUserAuthInfo',r.Data)
data.userAuth=r.Data
if(r.Data.unionid){
methods.setUserLoginByUnionId(r.Data.unionid)
}else{
methods.showPhoneBox()
}
}).catch(e=>{methods.showPhoneBox()})
},
setUserLoginByUnionId(uid){
loginByUnionId({uid}).then(r=>{
if(r.Data && r.Data.length>0){
uni.setStorageSync("ErpStus",r.Data)
let account=[]
r.Data.forEach(x=>{
account.push(x.RealPhone)
})
methods.setAccountsLogin(`'${account.join("','")}'`)
}else{
methods.showPhoneBox()
}
}).catch(x=>{
methods.showPhoneBox()
})
},
setAccountsLogin(Accounts){
getLoginAccounts({Accounts}).then(r=>{
if(r.Data && r.Data.length>0){
let erpStus=uni.getStorageSync('ErpStus')
erpStus.forEach(x=>{
if(x.RealPhone==r.Data[0].UserMobile){
uni.setStorageSync('erpUserInfo',x)
}
})
uni.setStorageSync("userInfo", r.Data[0]);
uni.setStorageSync("users",r.Data)
console.log(r.Data && r.Data.length>0)
uni.reLaunch({
url:'/pages/index/index'
})
}
}).catch(e=>{
console.log(e)
methods.showPhoneBox()
})
},
decryptPhoneNumber(e) { //授权手机号码
if (e.detail.errMsg == 'getPhoneNumber:fail user deny') { //用户点击拒绝
uni.showToast({
......@@ -155,20 +213,8 @@
})
console.log(res)
if (res && res.Data.UserMobile) {
// console.log('dsadas', res)
// data.obj.phoneNum = res.Data.UserMobile
// that.phoneNumLogin()
// let obj = {
// Account: data.obj.phoneNum,
// WeChatName: data.obj.Name,
// WeChatPhoto: data.obj.Photo,
// OpenId: data.obj.openid,
// unionid: data.obj.unionid,
// }
uni.setStorageSync("userInfo", res.Data);
uni.reLaunch({
url:'/pages/index/index'
})
methods.getErpStudentBindInfo(res.Data)
} else {
Toast.fail("授权失败,请重新授权")
......@@ -176,41 +222,36 @@
uni.hideLoading();
}
},
//手机号授权登录
// async phoneNumLogin() {
// let res = await phoneLogin({
// Account: data.obj.phoneNum,
// OpenId: data.obj.openid,
// unionid: data.obj.unionid,
// })
// if (res.Code == 1) {
// uni.hideLoading();
// data.showLogin = true; //防止多次点击登录
// res.Data.Account = data.obj.phoneNum;
// uni.setStorageSync("userInfo", res.Data);
// Toast.success("登录成功");
// setTimeout(()=>{
// emit('success')
// },1000)
// data.showPhone = false
// uni.showTabBar()
// } else {
// data.showLogin = true; //防止多次点击登录
// data.showPhone = false
// if (currentRoute == "pages/index/index") {
// uni.showTabBar() //手机授权弹窗出现 隐藏tabbar
// }
// uni.hideLoading();
// if (res.Data.Error == -1) { //如果没找到电话号码 就跳入登录
// // setTimeout(() => {
// // uni.reLaunch({
// // url: '/pages/login/login'
// // });
// // }, 1000);
// }
// }
// }
getErpStudentBindInfo(u){
let userWxInfo=uni.getStorageSync('userWxInfo')
getSudentsByClassInAccount({
Account:u.Account,
WName:userWxInfo.userInfo.nickName,
WImage:userWxInfo.userInfo.avatarUrl,
UnionId:data.userAuth.unionid
}).then(r=>{
console.log(r)
if(r.Data && r.Data.length>0){
uni.setStorageSync("ErpStus",r.Data)
r.Data.forEach(x=>{
if(x.RealPhone==u.Account){
uni.setStorageSync('erpUserInfo',x)
}
})
uni.reLaunch({
url:'/pages/index/index'
})
}
})
},
showPhoneBox(){
uni.hideLoading()
data.showPhone = true; //显示获取手机号码弹窗
if (currentRoute == "pages/index/index") {
uni.hideTabBar() //手机授权弹窗出现 隐藏tabbar
}
}
};
onMounted(() => {
......
......@@ -13,7 +13,8 @@
<view class="index-header-name">{{userData.AccountName}}</view>
</view>
</view> -->
<signOut :AccountType="0"></signOut>
<!-- <signOut :AccountType="0"></signOut> -->
<userCard></userCard>
</navbar>
<view style="margin: 40rpx 0 10rpx 0;">
<view style="padding:0 50rpx;font-weight: 800;color: #282828;">
......@@ -29,7 +30,7 @@
<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>
<examComponents v-if="item.ResultType==2" :jobData="item"></examComponents>
<commentsComponents v-if="item.ResultType==3" :jobData="item"></commentsComponents>
</template>
</view>
......@@ -39,7 +40,9 @@
<view>暂无反馈信息</view>
</view>
</view>
<tabbar active-name='home'></tabbar>
</view>
</page-meta>
</template>
......@@ -48,7 +51,8 @@
import JobComponents from '@/components/index/JobComponents'
import examComponents from '@/components/index/examComponents'
import commentsComponents from '@/components/index/commentsComponents'
import signOut from "@/components/signOut";
// import signOut from "@/components/signOut";
import tabbar from '@/components/tabbar'
import vue, {
ref,
reactive,
......@@ -68,6 +72,7 @@
import {
getImageColor
} from '../../utils/index.js'
import userCard from '../../components/user-card.vue'
import indexassembly from './components/indexassembly.vue'
import navbar from '../../components/navbar.vue'
import bottom from '../../components/bottom.vue'
......@@ -80,7 +85,9 @@
JobComponents,
examComponents,
commentsComponents,
signOut
//signOut,
tabbar,
userCard
},
setup(props) {
let {
......
......@@ -75,8 +75,11 @@
import {
login,
phoneLogin,
parsePhone
parsePhone,
getWeChatOpenId,
getLoginAccounts
} from "../../api/index";
import {getSudentsByClassInAccount} from '../../api/erp.js'
import {
Dialog
} from '../../wxcomponents/vant/dialog/index';
......@@ -100,10 +103,23 @@
code: "",
show: false,
userLoginType:1, //1为学员,2为老师
loading:false
loading:false,
userAuth:null
});
wx.login({
//成功放回
success:(res)=>{
methods.loginByOpenCode(res.code)
}
})
let methods = {
loginByOpenCode(Code){
getWeChatOpenId({Code}).then(r=>{
uni.setStorageSync('wxUserAuthInfo',r.Data)
data.userAuth=r.Data
})
},
changeTypeHandler(t){
data.userLoginType=t
if(t==1){
......@@ -151,7 +167,13 @@
setTimeout(() => {
let data = uni.getStorageSync("userInfo");
if (data) {
that.jumpPage();
if(data.userLoginType==2){
that.jumpPage();
}else{
uni.setStorageSync("users",[res.Data])
that.getErpStudentBindInfo(res.Data)
}
}
}, 1000);
}else{
......@@ -165,6 +187,27 @@
data.loading=false
})
},
getErpStudentBindInfo(u){
let userWxInfo=uni.getStorageSync('userWxInfo')
getSudentsByClassInAccount({
Account:u.Account,
WName:userWxInfo.userInfo.nickName,
WImage:userWxInfo.userInfo.avatarUrl,
UnionId:data.userAuth.unionid
}).then(r=>{
console.log(r)
if(r.Data && r.Data.length>0){
uni.setStorageSync("ErpStus",r.Data)
r.Data.forEach(x=>{
if(x.RealPhone==u.Account){
uni.setStorageSync('erpUserInfo',x)
}
})
methods.jumpPage()
}
})
}
};
onMounted(() => {});
let that = methods;
......
......@@ -6,7 +6,7 @@
<van-image width="398rpx" height="398rpx" fit="cover"
src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653448851000_616.png" />
</view>
<view class="btnBox" @click="login">
<view class="btnBox" open-type="getUserInfo" @tap="getUserProfile">
账号登录
</view>
<view class="flex_center_center">
......@@ -31,17 +31,35 @@
indexassembly
},
setup(props, context) {
uni.clearStorageSync()
let methods = {
login() {
uni.navigateTo({
url: '/pages/login/accountLogin'
url: '/pages/login/accountLogin'
});
},
againdata() {
uni.reLaunch({
url: '/pages/index/index'
url: '/pages/index/index'
});
},
getUserProfile() {
//新的获取用户资料
var that = this;
wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (info) => {
console.log(info)
uni.setStorageSync('userWxInfo',info)
methods.login()
},
fail: () => {
uni.showToast({
title: "微信登录授权失败",
icon: "none",
});
},
});
},
};
......
......@@ -4,7 +4,7 @@ if (process.env.NODE_ENV === "development") {
//host = 'http://localhost:5004/api'
host = 'https://jjswapi.oytour.com/api'
//host = 'http://192.168.10.11:8082/api'
// host = 'http://192.168.10.36:8082/api'
host = 'http://192.168.10.206:5004/api'
} else {
host = 'https://jjswapi.oytour.com/api'
}
......@@ -26,8 +26,7 @@ let request = (param) => {
if (res.data.Code === 1) {
resolve(res.data)
} else {
if (res.data.Message.indexOf('用户凭证为空') != -1 || res.data
.Message.indexOf('用户凭证失效') != -1) {
if (res.data.Code==10001 || res.data.Code == 10000) {
uni.showToast({
title: "用户凭证失效,请重新授权",
duration: 2000,
......@@ -48,7 +47,6 @@ let request = (param) => {
resolve(res.data)
}else{
reject()
}
}
});
......
//请求教育接口
let host = ''
if (process.env.NODE_ENV === "development") {
//host = 'http://localhost:5004/api'
//host = 'https://jjswapi.oytour.com/api'
host = 'http://192.168.10.206:5005/api'
// host = 'http://192.168.10.36:8082/api'
} else {
host = 'https://jjswapi.oytour.com/api'
}
import Toast from '../wxcomponents/vant/toast/toast';
let request = (param) => {
return new Promise((resolve, reject) => {
let token = uni.getStorageSync('erpUserInfo').Token;
uni.request({
url: host + param.url,
method: param.method || "Post",
header: param.header || {
'content-type': "application/json",
'Authorization': token || ""
},
data: {
Msg: param.data,
},
success: res => {
if (res.data.Code === 1) {
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()
} else {
uni.showToast({
title: res.data.Message,
duration: 2000,
icon: "none",
success() {
if(res.data.Code === 0){
resolve(res.data)
}else{
reject()
}
}
});
}
}
},
fail: (err) => {
console.warn("fail:" + JSON.stringify(err));
uni.showToast({
title: '网络请求失败',
duration: 2000,
icon: "error",
});
reject()
}
});
})
}
export default request
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