继续适配

This commit is contained in:
Saturneric 2021-04-01 22:16:23 +08:00
parent f50335b4dd
commit e385779469
9 changed files with 291 additions and 10 deletions

View File

@ -84,3 +84,13 @@ export const getSupervisors = () => {
} }
}) })
} }
export const searchStudents = (numbering) => {
return request({
url: "/document/students/search",
method: "get",
data: {
numbering
}
})
}

21
api/honor.js Normal file
View File

@ -0,0 +1,21 @@
import request from '../utils/request.js'
export const createHonor = (honor) => {
return request({
url: "/honor",
method: "post",
data: {
...honor
}
})
}
export const getHonors = (openid) => {
return request({
url: "/honor/user",
method: "get",
data: {
openid
}
})
}

View File

@ -22,9 +22,16 @@ Page({
onLoad: function (options) { onLoad: function (options) {
getGrade().then(res => { getGrade().then(res => {
console.log(res) console.log(res)
this.setData({ if(res.failedCourse === 0 && res.passedCourse === 0) {
this.setData({
recordNotFound: true
})
}
else {
this.setData({
gradeInfo: res gradeInfo: res
}) })
}
}).then(res => { }).then(res => {
return getSemesters().then(res => { return getSemesters().then(res => {
console.log(res) console.log(res)

View File

@ -1,3 +1,5 @@
{ {
"usingComponents": {} "usingComponents": {
"i-spin": "../../dist/spin/index"
}
} }

View File

@ -119,5 +119,7 @@
</view> </view>
</view> </view>
<i-spin size="large" fix wx:if="{{ recordNotFound }}" custom><view>未找到您的成绩记录</view></i-spin>
</view> </view>

View File

@ -1,18 +1,41 @@
// pages/my-honors/my-honors.js // pages/my-honors/my-honors.js
import {createHonor, getHonors} from '../../api/honor'
const app = getApp()
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
showHonor: false,
showCreate: false,
targetHonorInfo: {},
honorsInfo: [],
honorDescription: "",
honorClass: "",
honorCategory: "",
honorTitle: "",
toast: false,
hideToast: true,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({
userDocument: app.globalData.userDocument
})
console.log(this.data)
getHonors(app.globalData.userBaseInfo.openid)
.then(res => {
console.log(res)
this.setData({
honorsInfo: res
})
})
}, },
/** /**
@ -62,5 +85,79 @@ Page({
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
} },
onTitleInput(res) {
this.setData({
honorTitle: res.detail.value
})
},
onCategoryInput(res) {
this.setData({
honorCategory: res.detail.value
})
},
onDescriptionInput(res) {
this.setData({
honorDescription: res.detail.value
})
},
onClassInput(res) {
this.setData({
honorClass: res.detail.value
})
},
onClickAdd() {
this.setData({
showHonor: false,
showCreate: true,
})
},
showHonorsList() {
this.setData({
showHonor: false,
showCreate: false,
})
},
createHonor() {
console.log(this.data)
createHonor({
title: this.data.honorTitle,
description: this.data.honorDescription,
honorClass: this.data.honorClass,
category: this.data.honorCategory
}).then(res => {
let that = this
console.log(res)
if(res != null) {
that.setData({
toast: true,
hideToast: false
});
that.setData({
hideToast: true,
honorTitle: "",
honorCategory: "",
honorsInfo: "",
honorDescription: "",
honorClass: ""
});
setTimeout(() => {
that.setData({
toast: false,
hideToast: true,
});
}, 3000);
}
})
},
}) })

View File

@ -1,2 +1,112 @@
<!--pages/my-honors/my-honors.wxml--> <view class="page" data-weui-theme="{{theme}}">
<text>pages/my-honors/my-honors.wxml</text> <view class="page__hd" wx:if="{{!showHonor}}">
<view class="page__title">我的荣誉</view>
<view class="page__desc">科研竞赛社会工作等情况</view>
</view>
<view class="page__bd" wx:if="{{showCreate}}">
<view class="weui-form__control-area">
<view class="weui-cells__group weui-cells__group_form">
<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" bindinput="onTitleInput" value="{{honorTitle}}"/>
</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">
<input class="weui-input" placeholder="科研、竞赛、社会工作" placeholder-class="weui-input__placeholder" bindinput="onCategoryInput" value="{{honorCategory}}"/>
</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">
<input class="weui-input" placeholder="校级、省级、国家级、国际级" type="number" placeholder-class="weui-input__placeholder" bindinput="onClassInput" value="{{honorClass}}"/>
</view>
</view>
</view>
</view>
<view class="weui-cells__group weui-cells__group_form">
<view class="weui-cells__title">荣誉描述</view>
<view class="weui-cells weui-cells_form">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea class="weui-textarea" placeholder="请描述你获得的荣誉" placeholder-class="weui-input__placeholder" rows="3" bindinput="onDescriptionInput" value="{{honorDescription}}"></textarea>
<view class="weui-textarea-counter"><span>0</span>/200</view>
</view>
</view>
</view>
</view>
</view>
<view class="weui-form__opr-area">
<a class="weui-btn weui-btn_primary" bindtap="createHonor">确定</a>
<a class="weui-btn weui-btn_disabled weui-btn_default" bindtap="showHonorsList">返回列表</a>
</view>
</view>
<view class="page__bd" wx:if="{{!showHonor && !showCreate}}" >
<view class="page__bd">
<view class="weui-form-preview">
<view class="weui-form-preview__hd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">姓名</label>
<em class="weui-form-preview__value">{{userDocument.realName}}</em>
</view>
</view>
<view class="weui-form-preview__bd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">荣誉数目</label>
<text class="weui-form-preview__value">{{honorsInfo.length}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">已认证荣誉数目</label>
<text class="weui-form-preview__value">0</text>
</view>
</view>
<view class="weui-form-preview__ft">
<a class="weui-form-preview__btn weui-form-preview__btn_primary" bindtap="onClickAdd">添加荣誉</a>
</view>
</view>
</view>
<view class="weui-panel">
<view class="weui-panel__hd">荣誉列表</view>
<view class="weui-panel__bd" wx:for="{{honorsInfo}}" wx:key="index" bindtap="onClickMessage" data-index="{{index}}">
<view class="weui-media-box weui-media-box_text">
<h4 class="weui-media-box__title">{{item.title}}</h4>
<view class="weui-media-box__desc">{{item.category}}</view>
<view class="weui-media-box__info">
<view class="weui-media-box__info__meta">创建时间 {{item.creationTime}}</view>
<view class="weui-media-box__info__meta">等级 {{item.honorClass}}</view>
<view class="weui-media-box__info__meta weui-media-box__info__meta_extra">认证 {{item.read ? "已认证" : "未认证"}}</view>
</view>
</view>
</view>
</view>
</view>
<view wx:if="{{!showHonor && !showCreate}}">
<view class="page__bd">
<view class="weui-article">
<view class="weui-article__section">
<view class="weui-article__section">
<view class="weui-article__p">
{{honorsInfo[showIndex].context}}
</view>
</view>
</view>
</view>
</view>
</view>
<view class="fadeIn {{hideToast ? 'fadeOut' : ''}}" wx:if="{{toast}}">
<view class="weui-mask_transparent"></view>
<view class="weui-toast">
<i class="weui-icon-success-no-circle weui-icon_toast"></i>
<view class="weui-toast__content">添加成功</view>
</view>
</view>
</view>

View File

@ -1,11 +1,14 @@
// pages/my-student/my-students.js // pages/my-student/my-students.js
import {searchStudents} from '../../api/document'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
inputShowed: false,
inputVal: ""
}, },
/** /**
@ -62,5 +65,34 @@ Page({
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
},
showInput: function () {
this.setData({
inputShowed: true
});
},
hideInput: function () {
this.setData({
inputVal: "",
inputShowed: false
});
},
clearInput: function () {
this.setData({
inputVal: ""
});
},
inputTyping: function (e) {
let inputVal = e.detail.value
this.setData({
inputVal
});
searchStudents(inputVal).then(res => {
console.log(res)
})
} }
}) })

View File

@ -14,7 +14,7 @@
</view> </view>
<label class="weui-search-bar__label" bindtap="showInput"> <label class="weui-search-bar__label" bindtap="showInput">
<i class="weui-icon-search"></i> <i class="weui-icon-search"></i>
<span class="weui-search-bar__text">输入学号搜索</span> <span class="weui-search-bar__text">输入学号搜索</span>
</label> </label>
</form> </form>
<view class="weui-search-bar__cancel-btn" bindtap="hideInput">取消</view> <view class="weui-search-bar__cancel-btn" bindtap="hideInput">取消</view>