123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651 |
- const app = getApp();
- const api = app.api;
- import WxValidate from '../../../utils/WxValidate'
- Page({
-
- data: {
-
-
-
- sexPickList:[
- {
- name:"男",
- value:1,
- },
- {
- name:"女",
- value:2,
- }
- ],
- sexPickListValue:'',
-
- EducationPickList:[],
- EducationPickValue:null,
-
- EducationStatePickList:[],
- EducationStatePickValue:null,
- upFileInfo:null,
- referrerFileInfo:null,
-
- showHistory:{
- id:"",
- name:"",
- organ:"",
- time:"",
- },
-
- awardHistory:{
- id:"",
- organ:"",
- prize:"",
- time:"",
- },
-
- formData:{
- type:0,
- photoId:"",
- name:"",
- artistName:"",
- sex:"",
- birthday:"",
- nationality:"",
- referrerName:"",
- referrerPosition:"",
- referrerFileId:"",
- mobile:"",
- email:"",
- address:"",
- weixinNo:"",
- highestDegreeOrg:"",
- highestDegreeStartTime:"",
- highestDegreeEndTime:"",
- highestDegree:"",
- highestDegreeStatus:"",
- awardHistoryList:[],
- showHistoryList:[],
- },
- rules: {
- photoId:{
- required: true,
- },
- name:{
- required: true,
- cnAndEg: true
- },
- artistName:{
- required: true,
- cnAndEg: true
- },
- sex:{
- required: true,
- },
- birthday:{
- required: true,
- },
-
-
-
-
-
-
-
-
-
-
-
-
- mobile: {
- required: true,
- tel:true,
- },
- email: {
- required: true,
- email:true,
- },
- highestDegreeOrg:{
- required: true
- },
- highestDegreeStartTime:{
- required: true
- },
- highestDegreeEndTime:{
- required: true
- },
- highestDegree:{
- required: true
- },
- highestDegreeStatus:{
- required: true
- }
- },
- awardRules:{
- organ:{
- required: true,
- },
- prize:{
- required: true,
- },
- time:{
- required: true,
- },
- },
- awardMessages:{
- organ:{
- required:'请输入奖项名称'
- },
- prize:{
- required:'请输入奖项机构'
- },
- time:{
- required:'请输入获奖时间'
- }
- },
- showRules:{
- name:{
- required: true,
- },
- organ:{
- required: true,
- },
- time:{
- required: true,
- },
- },
- showMessages:{
- name:{
- required: '请输入展展览名称',
- },
- organ:{
- required: '请输入展展览机构',
- },
- time:{
- required: '请输入展览时间',
- },
- },
- messages: {
- photoId:{
- required: '请上传个人形象照',
- },
- name:{
- required: '请输入姓名',
- cnAndEg: '只能输入英文和中文'
- },
- artistName:{
- required: '请输入艺名',
- cnAndEg: '只能输入英文和中文'
- },
- sex:{
- required: '请选择性别',
- },
- birthday:{
- required: '请选择出生日期',
- },
- nationality:{
- required: '请选择国籍',
- },
-
-
-
-
-
-
-
-
-
- mobile: {
- required: '请输入手机号',
- tel:"请输入正确的手机号"
- },
- email: {
- required: '请输入邮箱地址',
- tel:"请输入正确的邮箱"
- },
- address:{
- required: '请输入地址',
- },
- weixinNo:{
- required: '请输入微信号',
- },
- highestDegreeOrg:{
- required: '请输入最高学历机构'
- },
- highestDegreeStartTime:{
- required: '请输入最高学历开始时间'
- },
- highestDegreeEndTime:{
- required: '请输入最高学历结束时间'
- },
- highestDegree:{
- required: '请选择最高学历',
- },
- highestDegreeStatus:{
- required: '请选择最高学历状态'
- }
- },
- isValidate:false,
- isSubmit:false
- },
-
- onLoad: function (options) {
- const type=options.type||0
- const {
- formData,
- rules,
- messages,
- showHistory,
- awardHistory,
- awardRules,
- awardMessages,
- showRules,
- showMessages
- }
- = this.data;
- this.WxValidate = new WxValidate(rules, messages);
- this.awardValidate = new WxValidate(awardRules, awardMessages);
- this.showValidate = new WxValidate(showRules, showMessages);
- if(formData.awardHistoryList.length==0){
- this.setData({
- 'formData.awardHistoryList':[{...awardHistory}]
- })
- }
- if(formData.showHistoryList.length==0){
- this.setData({
- 'formData.showHistoryList':[{...showHistory}]
- })
- }
-
- formData.type=type
- Promise.all([
- this.findByCode('education'),
- this.findByCode('education_status')
- ]).then((res)=>{
- const EducationPickList=res[0].data.dicInfoList;
- const EducationStatePickList=res[1].data.dicInfoList;
- this.setData({
- EducationPickList:EducationPickList,
- EducationStatePickList:EducationStatePickList
- },()=>{
-
-
-
- });
- });
- },
-
- onReady: function () {
- },
-
- onShow: function () {
- },
- getData(){
- const {formData}=this.data;
- app.post(api.getPersonalSettledInfo).then(res=>{
- console.log(res);
- const saveData=res.data;
- Object.keys(saveData).forEach(key=>{
- if(saveData[key]==null){
- delete saveData[key]
- }
- })
- const formDataNew=Object.assign(formData,res.data);
- formDataNew.photoId=formDataNew.photoInfo?formDataNew.photoInfo.id:"";
- formDataNew.referrerFileId=formDataNew.referrerFile?formDataNew.referrerFile.id:"";
- this.setData({
- formData:formDataNew,
- upFileInfo:formDataNew.photoInfo,
- referrerFileInfo:formDataNew.referrerFile,
- sexPickListValue:formDataNew.sex==1?0:1,
- EducationPickValue:formDataNew.highestDegree,
- EducationStatePickValue:formDataNew.highestDegreeStatus
- },()=>{
- this.validateForm()
- });
- });
- },
- validateForm(showInfo=false){
-
- const {formData} = this.data;
- let flag=true;
-
-
- if (!this.WxValidate.checkForm(formData)) {
- flag=false
- if(showInfo===true) {
- const error = this.WxValidate.errorList[0];
- wx.showToast({
- title: error.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- this.setData({
- isValidate:flag
- });
- return flag
-
- },
- saveData() {
- const {formData,isSubmit} = this.data;
- if(isSubmit){
- return
- }
- let flag=this.validateForm(true);
- if(!flag){
- return;
- }
- const submit=function(){
- this.setData({
- isSubmit:true
- })
- app.post(api.addPersonalDetails, formData).then(res => {
- console.log(res);
- this.setData({
- isSubmit:false,
- });
- wx.navigateTo({
- url:`/pages/user/success/success?type=${formData.type}`,
- })
- }).catch(()=>{
- this.setData({
- isSubmit:false
- })
- })
- }.bind(this);
-
- if(formData.type==2){
- wx.requestSubscribeMessage({
- tmplIds: [
- 'EnF59db6rv1QhwUc67GuKNQBw-R-VZNAB5xVXyP40A4',
- ],
- success: (res)=> {
- submit()
- }
- });
- }else{
- submit()
- }
- },
- changeInput(e){
- console.log(e);
- const id = e.currentTarget.id;
- const value = e.detail.value;
- this.setData({
- [id]: value
- });
- },
- changePicker(e){
- console.log(e);
- const id = e.currentTarget.id;
- const value = e.detail.value;
- this.setData({
- [id]: value
- });
- },
-
- chooseFile(){
- app.uploadFile({
- extension:['jpg','png','jpeg'],
- validate:(imgInfo)=>{
- console.log('validate',imgInfo)
- return true;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }).then(res=>{
- console.log(res)
- const data=JSON.parse(res.data);
- this.setData({
- upFileInfo:data,
- 'formData.photoId':data.id,
- })
- }).catch(error=>{
- console.log(error)
- });
- },
-
- removeChooseFile(){
- this.setData({
- upFileInfo:null,
- 'formData.photoId':''
- })
- },
-
- chooseReferrerFile(){
- app.uploadFile({
- extension:['jpg','png','jpeg']
- }).then(res=>{
- console.log(res)
- const data=JSON.parse(res.data);
- this.setData({
- referrerFileInfo:data,
- 'formData.referrerFileId':data.id
- })
- }).catch(error=>{
- console.log(error)
- });
- },
-
- removeReferrerFile(){
- this.setData({
- referrerFileInfo:null,
- 'formData.referrerFileId':''
- })
- },
- findByCode(code){
- return app.post(api.findByCode,{
- "code": code
- })
- },
-
- addAward() {
- const awardHistoryList=this.data.formData.awardHistoryList;
- awardHistoryList.push(this.data.awardHistory)
- this.setData({
- 'formData.awardHistoryList':awardHistoryList
- })
- },
-
- removeAward(e) {
- const {index}=e.currentTarget.dataset;
- const awardHistoryList=this.data.formData.awardHistoryList;
- awardHistoryList.splice(index,1);
- this.setData({
- 'formData.awardHistoryList':awardHistoryList
- })
- },
-
- addShow() {
- const showHistoryList=this.data.formData.showHistoryList;
- showHistoryList.push(this.data.showHistory);
- this.setData({
- 'formData.showHistoryList':showHistoryList
- })
- },
-
- removeShow(e) {
- const {index}=e.currentTarget.dataset;
- const showHistoryList=this.data.formData.showHistoryList;
- showHistoryList.splice(index,1);
- this.setData({
- 'formData.showHistoryList':showHistoryList
- })
- },
-
- sexPickHandler(e){
- const {value}=e.detail;
- const {sexPickList}=this.data;
- this.setData({
- sexPickListValue:value,
- 'formData.sex':sexPickList[value].value
- },()=>{
- this.validateForm()
- });
- },
-
- educationPickHandler(e){
- const {value}=e.detail;
- const {EducationPickList}=this.data;
- this.setData({
- EducationPickValue:value,
- 'formData.highestDegree':EducationPickList[value].code
- },()=>{
- this.validateForm()
- })
- },
-
- educationStatePickHandler(e){
- const {value}=e.detail;
- const {EducationStatePickList}=this.data;
- this.setData({
- EducationStatePickValue:value,
- 'formData.highestDegreeStatus':EducationStatePickList[value].code,
- },()=>{
- this.validateForm()
- })
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- }
- })
|