适配我的学生界面

This commit is contained in:
Saturneric 2021-04-03 00:35:01 +08:00
parent e385779469
commit 82473c8d1f
4 changed files with 92 additions and 41 deletions

View File

@ -94,3 +94,13 @@ export const searchStudents = (numbering) => {
}
})
}
export const getUserProfileSupervisor = (documentId) => {
return request({
url: "/document/profile/supervisor",
method: "get",
data: {
documentId
}
})
}

View File

@ -1,4 +1,6 @@
// pages/account-doc-info/account-doc-info.js
import {getUserProfileSupervisor} from '../../api/document'
const app = getApp()
Page({
@ -10,36 +12,51 @@ Page({
hasUserDocument: false,
userInfo: null,
userDocuement: null,
admin: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
console.log(options)
if(options.admin === "true") {
const eventChannel = this.getOpenerEventChannel()
let that = this
eventChannel.on('acceptDataFromOpenerPage', function(data) {
console.log(data)
that.setData({
hasUserInfo: false,
userInfo: {}
})
that.setUserDocument(data.userDocument)
if(data.userDocument.connected) {
getUserProfileSupervisor(data.userDocument.id).then(res => {
console.log(res)
that.setData({
hasUserInfo: true,
userInfo: res
})
})
}
})
} else {
if(app.globalData.userInfo){
let userInfo = app.globalData.userInfo
this.setData({
hasUserInfo: true,
userInfo: userInfo
userInfo: app.globalData.userInfo
})
}
if(app.globalData.userDocument){
let userDocument = app.globalData.userDocument
this.setUserDocument(app.globalData.userDocument)
}
}
},
setUserDocument(document) {
let userDocument = document
switch(userDocument.gender) {
case 'F':
userDocument.gender = '女'
@ -66,7 +83,21 @@ Page({
hasUserDocument: true,
userDocument: userDocument
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**

View File

@ -8,7 +8,8 @@ Page({
*/
data: {
inputShowed: false,
inputVal: ""
inputVal: "",
searchStudentsList: []
},
/**
@ -86,6 +87,27 @@ Page({
});
},
onClickShowDocument(e) {
let showIndex = e.currentTarget.dataset['index']
let userDocument = this.data.searchStudentsList[showIndex]
wx.navigateTo({
url: '../account-doc-info/account-doc-info?admin=true',
events: {
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
acceptDataFromOpenedPage: function(data) {
console.log(data)
},
someEvent: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('acceptDataFromOpenerPage', { userDocument: userDocument })
}
})
},
inputTyping: function (e) {
let inputVal = e.detail.value
this.setData({
@ -93,6 +115,9 @@ Page({
});
searchStudents(inputVal).then(res => {
console.log(res)
this.setData({
searchStudentsList: res
})
})
}
})

View File

@ -20,24 +20,9 @@
<view class="weui-search-bar__cancel-btn" bindtap="hideInput">取消</view>
</view>
<view class="weui-cells searchbar-result" wx:if="{{inputVal.length > 0}}">
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell weui-cell_active weui-cell_access" wx:for="{{searchStudentsList}}" wx:key="index" data-index="{{index}}" bindtap="onClickShowDocument">
<view class="weui-cell__bd weui-cell_primary">
<view>实时搜索文本</view>
</view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>实时搜索文本</view>
</view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>实时搜索文本</view>
</view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>实时搜索文本</view>
<view>[{{item.numbering}}] {{item.realName}}</view>
</view>
</view>
</view>