添加档案绑定有关交互逻辑;

This commit is contained in:
Saturneric 2021-03-22 01:38:11 +08:00
parent d59a124e8e
commit 5c29a7239d
4 changed files with 197 additions and 8 deletions

View File

@ -8,4 +8,15 @@ export const getDocument = openid => {
openid
}
})
}
export const searchDocument = (userRole, documentCode) => {
return request({
url: "/document/search",
method: "get",
data: {
userRole,
documentCode
}
})
}

View File

@ -1,4 +1,7 @@
// pages/bind-document.js
import {searchDocument} from '../../api/document'
Page({
/**
@ -9,8 +12,14 @@ Page({
radioItems: [
{ name: '1', value: '学生', checked: 'true'},
{ name: '2', value: '家长'},
{ name: '2', value: '辅导员'},
{ name: '3', value: '辅导员'},
],
userRoleType: '1',
currentValue: '',
document: null,
showDocument: false,
warnToast: false,
hideWarnToast: true
},
/**
@ -67,5 +76,97 @@ Page({
*/
onShareAppMessage: function () {
},
radioChange(res) {
console.log(res.detail.value)
this.setData({
userRoleType: res.detail.value
})
},
onCurrentInput(res) {
this.setData({
currentValue: res.detail.value
})
},
onReset() {
this.setData({
document: null,
showDocument: false
})
},
onBind() {
},
onConfirm() {
let documentCode = this.data.currentValue
let userRoleName;
switch(this.data.userRoleType) {
case '1':
userRoleName = 'Student'
break;
case '2':
userRoleName = 'Parent'
break;
case '3':
userRoleName = 'Supervisor'
break;
}
searchDocument(userRoleName, documentCode).then(res => {
console.log(res)
let document = res
// 转换部分字段
switch(document.gender) {
case 'M':
document.gender = '男'
break;
case 'F':
document.gender = '女'
break;
case 'U':
document.gender = '未知'
break;
}
switch(document.role) {
case 'ROLE_STUDENT':
document.role = '学生'
break;
case 'ROLE_PARENT':
document.role = '家长'
break;
case 'ROLE_SUPERVISOR':
document.role = '辅导员'
break;
}
this.setData({
document: document,
showDocument: true
})
}).catch(err => {
console.log(err)
this.setData({
warnToast: true
});
setTimeout(() => {
this.setData({
hidewarnToast: true
});
setTimeout(() => {
this.setData({
warnToast: false,
hidewarnToast: false,
});
}, 300);
}, 3000);
})
}
})

View File

@ -1,11 +1,17 @@
<view class="container">
<view class="weui-form__text-area">
<h2 class="weui-form__title">绑定您的个人档案</h2>
<view wx:if="{{!showDocument}}">
<h2 class="weui-form__title">绑定您的个人档案</h2>
<view class="weui-form__desc">在这里将您的账户与您在学院留存的档案绑定,以便确认您的身份。绑定完成后,系统将通过档案获知您的账号与其他账号的关系。</view>
</view>
<view wx:if="{{showDocument}}">
<h2 class="weui-form__title">确认您的档案信息</h2>
<view class="weui-form__desc">您的档案已找到,请确认这是属于您的档案。确认无误后,点击绑定按钮完成绑定流程。 如果有误的,请重新查询。</view>
</view>
</view>
<view class="weui-form">
<view class="weui-form__control-area">
<view class="weui-cells__group weui-cells__group_form">
<view class="weui-cells__group weui-cells__group_form" wx:if="{{!showDocument}}">
<view class="weui-cells__title">账号类型</view>
<view class="weui-cells weui-cells_radio">
<radio-group class="radio-group" bindchange="radioChange">
@ -25,21 +31,92 @@
</radio-group>
</view>
</view>
<view class="weui-cells__group weui-cells__group_form">
<view class="weui-cells__group weui-cells__group_form" wx:if="{{!showDocument}}">
<view class="weui-cells__title">档案口令</view>
<view class="weui-cells weui-cells_form">
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"><label class="weui-label">口令码</label></view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="学院下发的档案口令码" placeholder-class="weui-input__placeholder" />
<input class="weui-input" placeholder="学院下发的档案口令码" placeholder-class="weui-input__placeholder" bindinput="onCurrentInput" />
</view>
</view>
</view>
</view>
<view class="weui-cells__group weui-cells__group_form" wx:if="{{showDocument}}">
<view class="weui-cells__title">档案信息</view>
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"><label class="weui-label">真实姓名</label></view>
<view class="weui-cell__bd weui-flex">
<input
class="weui-input"
type="text"
value="{{document.realName}}"
placeholder-class="weui-input__placeholder"
/>
</view>
</view>
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"><label class="weui-label">性别</label></view>
<view class="weui-cell__bd weui-flex">
<input
class="weui-input"
type="text"
value="{{document.gender}}"
placeholder-class="weui-input__placeholder"
/>
</view>
</view>
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"><label class="weui-label">角色</label></view>
<view class="weui-cell__bd weui-flex">
<input
class="weui-input"
type="text"
value="{{document.role}}"
placeholder-class="weui-input__placeholder"
/>
</view>
</view>
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"><label class="weui-label">行政班号</label></view>
<view class="weui-cell__bd weui-flex">
<input
class="weui-input"
type="text"
value="{{document.className}}"
placeholder-class="weui-input__placeholder"
/>
</view>
</view>
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"><label class="weui-label">入学年份</label></view>
<view class="weui-cell__bd weui-flex">
<input
class="weui-input"
type="text"
value="{{document.gradeYear}}"
placeholder-class="weui-input__placeholder"
/>
</view>
</view>
</view>
</view>
</view>
<view>
<a class="weui-btn weui-btn_primary">查询档案</a>
<view wx:if="{{!showDocument}}">
<a class="weui-btn weui-btn_primary" bindtap="onConfirm">查询档案</a>
</view>
<view wx:if="{{showDocument}}">
<a class="weui-btn weui-btn_disabled weui-btn_default" bindtap="onReset">重新查询</a>
<a class="weui-btn weui-btn_primary" bindtap="onConfirm">绑定</a>
</view>
<view class="fadeIn {{hideWarnToast ? 'fadeOut' : ''}}" wx:if="{{warnToast}}">
<view class="weui-mask_transparent"></view>
<view class="weui-toast">
<i class="weui-icon-warn weui-icon_toast"></i>
<view class="weui-toast__content">未找到对应档案</view>
</view>
</view>
</view>

View File

@ -7,5 +7,5 @@
<view class="weui-btn-area">
<button open-type="getUserInfo" type="primary" bindgetuserinfo="bindGetUserInfo" >授权</button>
</view>
</view>
</view>
</view>