123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- // pages/kids_information/kids_information.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal, formatDateTime, formateNumber,curatorName,formatEncrypt } from '../../utils/util.js'
- import { StudentDetail,ModifyStudentInfo,BindLibAudit} from '../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, saveUserInfo, getWxloginCode, checkStatus } = getApp()
- const { baseImgUrl, thumbnail } = globalData
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- options: {},
- baseImgUrl,
- isShowPickerModel: false,
- phone:'',
- patriarchName:'',
- homeAddress:'',
- studyPlanName:'',
- isAddChild:0,
- studentImg:'',
- isAdd:false,
- imgUrl:'',
- school: '',
- childName: '',
- parentName: '',
- sex: 0,
- grade: '',
- parentRole:'',
- isReview:0,
- refuseModel:false,
- pickerData: [
- {
- actIndex: 0,
- list: ['一年级', '二年级', '三年级', '四年级', '五年级', '六年级']
- },
- {
- actIndex: 0,
- list: ['语文', '数学', '英文']
- },
- {
- actIndex: 0,
- list: ['男', '女']
- }
-
- ],
- pickerIndex: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData(options)
- if (options.isReview==1){
- wx.setNavigationBarTitle({
- title: '详情',
- })
- }
- const {isReview}=this.data
- if(isReview==0){
- this.getInformation()
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- const obj = { navigateTo, redirectTo, navigateBack, viewImage }
- for (const i in obj) {
- this[i] = obj[i]
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 路由跳转
- */
- redirectCtl: app.redirectCtl,
- /**
- * 路由跳转
- */
- navigateCtl: app.navigateCtl,
- /**
- * 提示框隐藏
- */
- allShowModel: function () {
- this.setData({refuseModel:false })
- },
- /**
- * 拒绝审核弹框
- */
- refuseShow: function (e) {
- const { type } = e.currentTarget.dataset;
- this.setData({ refuseType: Number(type)})
- if(type==2){
- this.setData({ refuseModel: true})
- }else{
- this.selectRefuse()
- }
- },
- /**
- * 通过拒绝审核
- */
- selectRefuse: function (cb) {
- const continuousFn = { fn: this.selectRefuse, param: { ...arguments } }
- const { vipId,refuseType} = this.data;
- BindLibAudit({ data:{vipId,type:refuseType}, continuousFn }).then(res => {
- if(refuseType==1){
- wx.showToast({
- title: '通过审核',
- icon: 'none'
- })
- }else{
- wx.showToast({
- title: '拒绝成功',
- icon: 'none'
- })
- }
- this.allShowModel()
- setTimeout(function(){
- wx.navigateBack({})
- },1500)
- if (isFn(cb)) cb()
- }).catch(res => {
- if (isFn(cb)) cb()
- })
- },
-
- /**
- * 上传头像
- */
- uploadHeadIconCtl: function () {
- wx.chooseImage({
- count: 1,
- success: res => {
- this.uploadImage(res.tempFilePaths[0])
- },
- fail: res => {
- // wx.showToast({
- // title: '选择拍照或者相册失败',
- // icon: 'none'
- // })
- }
- })
- },
- /**
- * 上传头像接口
- */
- uploadImage: function (file) {
- app.uploadFile('/api/common/common/uploadForm', file, {}).then(res => {
- let { filePath } = JSON.parse(res).data.pics[0];
- console.log(filePath);
- this.setData({ imgUrl: filePath})
- // this.updateInfor({
- // imageKey: filePath
- // }, 1)
- })
- },
- /**
- * input
- */
- inputCtl: function (e) {
- const mobileExp = /^1[0-9]{10}$/;
- const { temp = {}, type } = e.currentTarget.dataset
- const { value } = e.detail
- temp[type] = value;
- const { parentName, family,phone,childName } = temp;
- // console.log(parentName)
- if (type == 'phone') {
- if (value != '') {
- if (!mobileExp.test(value)) {
- wx.showToast({
- title: '手机号码位数不对',
- icon: 'none',
- duration: 2000
- })
- return this.setData({ phone})
- } else {
- return this.setData({ phone })
- }
- }
- } else if (type == 'childName') {
- return this.setData({ childName })
- }
- },
- /**
- * picker
- */
- pickerCtl: function (e) {
- const { temp = {}, type, index } = e.currentTarget.dataset
- console.log(index)
- this.setData({
- pickerIndex: index,
- isShowPickerModel: true
- })
- },
- /**
- * 取消
- */
- cancel:function(){
- wx.navigateBack({})
- },
- /**
- * picker选择列
- */
- checkPickerModel: function (e) {
- const { index } = e.currentTarget.dataset
- let { temp = {}, pickerIndex, pickerData } = this.data
- let { actIndex, list } = pickerData[pickerIndex]
- let str = `pickerData[${pickerIndex}].actIndex`;
- console.log(index, pickerIndex)
- // if (index < 0) {
- if (pickerIndex == 0) {
- // if (this.data['grade'] != list[actIndex]) {
- temp['grade'] = list[index]
- // }
- } else if (pickerIndex == 1) {
- if (this.data['courseName'] != list[actIndex]) {
- temp['courseName'] = list[index]
- }
- } else if (pickerIndex == 2) {
- temp['sex'] = Number(index) + 1
- } else if (pickerIndex == 3) {
- if (this.data['studyPlan'] != list[actIndex]) {
- temp['studyPlan'] = list[index]
- }
- } else if (pickerIndex == 4) {
- if (this.data['parentRole'] != list[actIndex]) {
- temp['parentRole'] = list[index]
- }
- }
- temp['isShowPickerModel'] = false
- this.setData(temp)
- },
- /**
- * 获取个人信息
- */
- getInformation: function (cb) {
- const continuousFn = { fn: this.getInformation, param: { ...arguments } }
- const { vipId, school } = this.data
- StudentDetail({ data: {vipId}, continuousFn }).then(res => {
- const listTemp = (res => {
- if(res.school.length>10){
- res.school=res.school.slice(0,10)+'...'
- }
- return res
- })(res.data)
- this.setData({ ...res.data })
- if (school && school != '' && res.data.school != school) {
- this.setData({ school:school })
- }
- if (isFn(cb)) cb()
- }).catch(res => {
- if (isFn(cb)) cb()
- })
- },
- /**
- * 修改信息
- */
- amendChildren:function(cb){
- const continuousFn = { fn: this.amendChildren, param: { ...arguments } }
- var that = this;
- const { childName,grade, school, imgUrl, sex,vipId } = this.data;
- // console.log(childName,grade, school, imgUrl, sex,vipId);
- if (!childName) {
- wx.showToast({
- title: '请输入学生姓名',
- icon: 'none'
- })
- return
- }
- if (!grade) {
- wx.showToast({
- title: '请输入年级',
- icon: 'none'
- })
- return
- }
- if (!school) {
- wx.showToast({
- title: '请输入在读学校',
- icon: 'none'
- })
- return
- }
- ModifyStudentInfo({ data: {
- childName:formatEncrypt(childName),
- grade,
- school:formatEncrypt(school),
- imgUrl,
- sex:Number(sex),
- vipId
- }, continuousFn }).then(res => {
- wx.showToast({
- title: '修改成功',
- duration: 1000
- })
- this.getInformation()
- // setTimeout((function callback() {
- // wx.navigateBack({
- // delta: 2
- // })
- // }).bind(this), 1000);
- if (isFn(cb)) cb()
- }).catch(res => {
- if (isFn(cb)) cb()
- })
- },
-
- })
|