301 lines
9.7 KiB
JavaScript
301 lines
9.7 KiB
JavaScript
import util from '../../utils/util'
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
baseURl: "https://passport.gter.net",
|
|
tab: 'usertype',
|
|
// tab: 'cooperationCcontact',
|
|
topTitle: '请完善个人信息后再继续操作',
|
|
info: {},
|
|
nickname: "",
|
|
token: "",
|
|
startyear: [],
|
|
tabListUse: [],
|
|
tabList: [
|
|
[
|
|
"regstage",
|
|
"applyentryseasonyear",
|
|
"applyentryseason",
|
|
"planningstudycountry",
|
|
"feelinterest",
|
|
],
|
|
["regregion", "startyear"],
|
|
["regidentity", "cooperationCcontact"],
|
|
], // 完善个人信息的 流程 数据
|
|
submitList: ['planningstudycountry', 'feelinterest', 'startyear', 'cooperationCcontact'], // 最后一步的 tab
|
|
nextStepList: ['planningstudycountry', 'feelinterest', 'startyear', 'cooperationCcontact'], // 切换下一步的 tab 数据
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
init() {
|
|
let that = this
|
|
util.wxpost("/miniprogram/Userdata").then(res => {
|
|
if (res.data.code = 200) {
|
|
// res.data.config[0].feelinterest = [{
|
|
// id: 1,
|
|
// value: '哈哈'
|
|
// }]
|
|
let data = res.data
|
|
that.setData({
|
|
config: data.config[0],
|
|
info: data.info,
|
|
nickname: data.nickname,
|
|
token: data.token
|
|
})
|
|
let planningstudycountry = that.data.config.planningstudycountry
|
|
let feelinterest = that.data.config.feelinterest
|
|
for (let i = 0; i < planningstudycountry.length; i++) {
|
|
planningstudycountry[i]['state'] = 0
|
|
}
|
|
if (feelinterest.length == 0) {
|
|
let index1 = that.data.submitList.indexOf("feelinterest")
|
|
let index2 = that.data.nextStepList.indexOf("feelinterest")
|
|
that.data.submitList.splice(index1, 1)
|
|
that.data.nextStepList.splice(index1, 1)
|
|
let index = that.data.tabList[0].indexOf('feelinterest')
|
|
that.data.tabList[0].splice(index, 1)
|
|
} else {
|
|
let index1 = that.data.submitList.indexOf("planningstudycountry")
|
|
let index2 = that.data.nextStepList.indexOf("planningstudycountry")
|
|
that.data.submitList.splice(index1, 1)
|
|
that.data.nextStepList.splice(index2, 1)
|
|
for (let i = 0; i < feelinterest.length; i++) {
|
|
feelinterest[i]["state"] = 0
|
|
}
|
|
that.data.feelinterest = feelinterest
|
|
}
|
|
that.setData({
|
|
planningstudycountry,
|
|
feelinterest,
|
|
startyear: that.data.config.startyear.slice(12)
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
// 分流程
|
|
flow(e) {
|
|
let index = e.currentTarget.dataset.index
|
|
let value = e.currentTarget.dataset.value
|
|
let that = this
|
|
if (index == 1) {
|
|
this.setData({
|
|
tabListUse: this.data.tabList[0]
|
|
})
|
|
} else if (index == 5) {
|
|
this.setData({
|
|
tabListUse: this.data.tabList[2]
|
|
})
|
|
} else {
|
|
this.setData({
|
|
tabListUse: this.data.tabList[1]
|
|
})
|
|
}
|
|
|
|
this.collect('usertype', value).then(res => {
|
|
if (res.code == 200) {
|
|
that.setData({
|
|
tab: this.data.tabListUse[0]
|
|
})
|
|
}
|
|
})
|
|
|
|
this.data.info['usertype'] = value
|
|
|
|
},
|
|
// 单项
|
|
selectInfo(e) {
|
|
let {
|
|
key,
|
|
value,
|
|
step
|
|
} = e.currentTarget.dataset
|
|
if (value) {
|
|
// this.data.info[key] = value
|
|
let index = 'info.' + key
|
|
this.setData({
|
|
[index]: value
|
|
})
|
|
}
|
|
|
|
if (
|
|
(key == "startyear" && value.length == 0) ||
|
|
(key == "regidentity" && value.length == 0)
|
|
) {
|
|
return;
|
|
}
|
|
if (
|
|
(this.data.tab == "planningstudycountry" &&
|
|
this.data.info.planningstudycountry.length == 0) ||
|
|
(this.data.tab == "feelinterest" && this.data.info.feelinterest.length == 0)
|
|
) {
|
|
wx.showToast({
|
|
title: '请选择选项',
|
|
icon: 'error',
|
|
})
|
|
return;
|
|
}
|
|
|
|
// 提交数据 并且 切换数据
|
|
this.collect(key, value).then(res => {
|
|
if (res.code == 200) {
|
|
if (this.data.info[key] == undefined || this.data.info[key].length != 0) {
|
|
for (let i = 0; i < this.data.tabListUse.length; i++) {
|
|
if (this.data.tab === this.data.tabListUse[i]) {
|
|
this.setData({
|
|
tab: this.data.tabListUse[i + 1]
|
|
})
|
|
break;
|
|
}
|
|
}
|
|
if (this.data.submitList.indexOf(key) != -1) {
|
|
this.skip()
|
|
}
|
|
|
|
// 判断 是否需要修改头部的 title
|
|
if (this.data.nextStepList.indexOf(this.data.tab) != -1) {
|
|
this.amendTopTitle()
|
|
}
|
|
|
|
} else {
|
|
// this.$swal("请选择选项", "", "info");
|
|
wx.showToast({
|
|
title: '请选择选项',
|
|
icon: 'error'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
},
|
|
// 1.多项
|
|
multipleChoice(e) {
|
|
let {
|
|
key,
|
|
value,
|
|
} = e.currentTarget.dataset
|
|
let keyList = e.currentTarget.dataset.keylist
|
|
|
|
// 判断是否已经选中
|
|
if (!value.state) {
|
|
this.data.info[key].push(value);
|
|
} else {
|
|
for (let i = 0; i < this.data.info[key].length; i++) {
|
|
if (this.data.info[key][i].id == value.id) {
|
|
this.data.info[key].splice(i, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (keyList) {
|
|
for (let i = 0; i < this.data[keyList].length; i++) {
|
|
if (this.data[keyList][i].value == value.value) {
|
|
this.data[keyList][i]["state"] = this.data[keyList][i].state ? 0 : 1
|
|
this.setData({
|
|
[keyList]: this.data[keyList]
|
|
})
|
|
}
|
|
}
|
|
}
|
|
this.setData({
|
|
info: this.data.info
|
|
})
|
|
|
|
},
|
|
|
|
bindPickerChange(e) {
|
|
this.setData({
|
|
'info.startyear': this.data.config.startyear[e.detail.value * 1 + 12].id
|
|
})
|
|
},
|
|
|
|
// 提交数据
|
|
submit() {},
|
|
|
|
bindInput(e) {
|
|
let value = e.detail.value
|
|
let key = e.target.dataset.key
|
|
let index = 'info.' + key
|
|
this.setData({
|
|
[index]: value
|
|
})
|
|
},
|
|
|
|
// 提示选项没选
|
|
promptOption() {
|
|
wx.showToast({
|
|
title: '请选择对应的选项',
|
|
icon: 'none'
|
|
})
|
|
},
|
|
|
|
// 点击跳转页面
|
|
skip() {
|
|
util.wxpost("/miniprogram/userdata/success", {
|
|
token: this.data.token
|
|
}).then(res => {
|
|
console.log(res);
|
|
})
|
|
wx.setNavigationBarColor({
|
|
backgroundColor: '#ffffff',
|
|
frontColor: '#000000',
|
|
})
|
|
wx.showToast({
|
|
title: '已完成,感谢操作!',
|
|
icon: 'none',
|
|
})
|
|
this.triggerEvent("revampInformationState")
|
|
},
|
|
|
|
// 判断是否是最后一步 需要修改 头部 topTitle
|
|
amendTopTitle() {
|
|
this.setData({
|
|
topTitle: '感谢你的操作,这是最后一步'
|
|
})
|
|
},
|
|
|
|
//
|
|
collect(step, value) {
|
|
return new Promise((resolve, reject) => {
|
|
util.wxpost("/miniprogram/Userdata/collect", {
|
|
token: this.data.token,
|
|
step: step,
|
|
value: value
|
|
}).then(res => {
|
|
resolve(res)
|
|
}).catch(res => {
|
|
reject(res)
|
|
})
|
|
})
|
|
},
|
|
copy() {
|
|
util.copy(this.data.config.cooperation.email, "复制成功")
|
|
}
|
|
|
|
|
|
},
|
|
|
|
// 生命周期
|
|
lifetimes: {
|
|
attached() {
|
|
this.init()
|
|
wx.setNavigationBarColor({
|
|
backgroundColor: '#ffffff',
|
|
frontColor: '#ffffff',
|
|
})
|
|
}
|
|
}
|
|
}) |