Commit 93a3d0cb authored by wangxuelai's avatar wangxuelai

'切换学生身份'

parent 1870bf28
...@@ -21,6 +21,10 @@ import { ...@@ -21,6 +21,10 @@ import {
getAccountList, getAccountList,
getMemberMe getMemberMe
} from '../../../service/common.js'; } from '../../../service/common.js';
import {
studentidentity,
identityswitch,
} from "../../../service/customer/signup.js";
import apis from '../../../constants/api.js'; import apis from '../../../constants/api.js';
import permissionUtils from '../../../utilities/permission.js'; import permissionUtils from '../../../utilities/permission.js';
var app = getApp(); var app = getApp();
...@@ -51,6 +55,7 @@ Page({ ...@@ -51,6 +55,7 @@ Page({
page: 1, page: 1,
perPage: 10, perPage: 10,
currole: 1, // 1从个人中心进入 标记学生身份 2从工作台切换身份 标记老师身份 currole: 1, // 1从个人中心进入 标记学生身份 2从工作台切换身份 标记老师身份
studentId: 0,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
...@@ -210,6 +215,7 @@ Page({ ...@@ -210,6 +215,7 @@ Page({
this.setData({ this.setData({
studentSchoolList: res.data.list studentSchoolList: res.data.list
}) })
this.userShow();
} }
}).catch(() => { }).catch(() => {
wx.hideLoading(); wx.hideLoading();
...@@ -232,6 +238,22 @@ Page({ ...@@ -232,6 +238,22 @@ Page({
}); });
return _length; return _length;
}, },
userShow() {
studentidentity({
school_id: this.data.sid
})
.then(res => {
const { data, code } = res;
if (code == 200 && data) {
this.setData({
studentId: data.student_id
})
} else {
}
})
.catch(err => {
});
},
getHistorySchoolList(type) { getHistorySchoolList(type) {
if (!this.data.hasmore) { if (!this.data.hasmore) {
return; return;
...@@ -243,8 +265,8 @@ Page({ ...@@ -243,8 +265,8 @@ Page({
listLoading: true listLoading: true
}); });
historySchoolList({ historySchoolList({
page: 1, page: this.data.page,
perPage: 10 perPage: this.data.perPage
}).then(res => { }).then(res => {
const { code, data } = res; const { code, data } = res;
this.setData({ this.setData({
...@@ -333,10 +355,36 @@ Page({ ...@@ -333,10 +355,36 @@ Page({
const { const {
item item
} = e.currentTarget.dataset; } = e.currentTarget.dataset;
console.log(item) identityswitch({
wx.reLaunch({ school_id: item.school_id,
url: `/ucenter/index?sid=${item.school_id}` student_id: item.id
}) })
.then(res => {
const { data, code } = res;
if (code == 200) {
const visitor = LocalStorage.getItem("visitor");
Object.assign(visitor, {
studentId: item.id
});
LocalStorage.setItem("visitor", visitor);
wx.reLaunch({
url: `/ucenter/index?sid=${item.school_id}`
})
} else {
wx.showToast({
title: "切换失败",
icon: "none",
duration: 2000
});
}
})
.catch(res => {
wx.showToast({
title: "切换失败",
icon: "none",
duration: 2000
});
});
}, },
goWebsite(e) { goWebsite(e) {
const { const {
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<view class="rolebox" wx:for="{{studentSchoolList}}" wx:key="id" wx:for-item="studentschool" data-item="{{studentschool}}" bindtap="goUcenter"> <view class="rolebox" wx:for="{{studentSchoolList}}" wx:key="id" wx:for-item="studentschool" data-item="{{studentschool}}" bindtap="goUcenter">
<view class="leftbox"> <view class="leftbox">
<image class="schoolavatar" src="{{filter.imagify(studentschool.avatar)}}" /> <image class="schoolavatar" src="{{filter.imagify(studentschool.avatar)}}" />
<view class="schoolname {{currole == 1 && sid == studentschool.school_id ? 'short' : ''}}"> <view class="schoolname {{currole == 1 && sid == studentschool.school_id && studentId == studentschool.id ? 'short' : ''}}">
<view class="schoolnametext"> <view class="schoolnametext">
{{studentschool.school.title}} {{studentschool.school.title}}
</view> </view>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="currenttag" wx:if="{{currole == 1 && sid == studentschool.school_id}}">您当前身份</view> <view class="currenttag" wx:if="{{currole == 1 && sid == studentschool.school_id && studentId == studentschool.id}}">您当前身份</view>
</view> </view>
</view> </view>
<view class="boxwrap operatebox" bindtap="goLogin"> <view class="boxwrap operatebox" bindtap="goLogin">
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</view> </view>
<view class="info-box"> <view class="info-box">
<view class="name">{{nickName}}</view> <view class="name">{{nickName}}</view>
<view class="roletag" wx:if="{{type == 1}}">老师</view> <view class="roletag {{type == 1 ? 'teacher' : ''}}" wx:if="{{type == 1}}">老师</view>
<view class="roletag" wx:if="{{type == 2}}">校长</view> <view class="roletag" wx:if="{{type == 2}}">校长</view>
</view> </view>
<view class="right"> <view class="right">
......
...@@ -55,6 +55,11 @@ page{ ...@@ -55,6 +55,11 @@ page{
display: inline-block; display: inline-block;
padding: 0 7rpx; padding: 0 7rpx;
} }
.header-box .top-box .info-box .roletag.teacher {
color: #FF9F49;
background-color: #FFF2E7;
border: 1px solid rgba(255,159,73,1);
}
.header-box .top-box .info-box .name{ .header-box .top-box .info-box .name{
font-size:28rpx; font-size:28rpx;
font-family:PingFang SC; font-family:PingFang SC;
......
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