// pages/newEnroll/index.js const app = getApp(); var dateTimePicker = require("../../../utils/dateTimePicker.js"); var dateUtil = require("../../../utils/dateUtil.js"); import { nationArray } from "../../../utils/commonUtil"; import { customRequest } from '../../../utils/request.js'; const mydate = new Date(); Page({ /** * 页面的初始数据 */ data: { id: '', showUpload: true, name: "", drawerShow: false, loading: false, idInfo: {}, index: -1, agentArray: [], // jobIndex: -1, jobArray: [ // { // id: 1, // name: "GG", // }, ], storeIndex: -1, storeArray: [ // { // id: 1, // name: "GG", // }, ], dateTimeArray1: null, dateTime1: null, startYear: 2022, endYear: new Date().getFullYear(), currentTime: dateUtil.formatDateYMD(mydate.toLocaleDateString()) + " " + "12:00", currentTime2: dateUtil.formatDateYMD(mydate.toLocaleDateString()) + " " + "12:00", searchListShow: false, searchKeys: "", searchKeysA: "", inputShowed: false, inputVal: "", inputShowedA: false, inputValA: "", storeId: "", agentId: "", agentName: "", storeJobId: "", policy: "", currentImg: "", nationIndex: -1, // 民族的索引 managerRoleClassify: false, // 管理员权限 nationArray, currentUser: {}, jobName: "", switch1Checked: false, policyList: [], policyStr: '', storeJobPolicyId: '', zhengceTextList: [] }, radioChange2 (e) { const items = this.data.policyList for (let i = 0, len = items.length; i < len; ++i) { if (items[i].id == e.detail.value) { items[i].checked = true; console.log(i) this.data.policyStr = i this.data.storeJobPolicyId = items[i].id; } else { items[i].checked = false } } console.log(this.data.policyStr); this.setData({ policyStr: this.data.policyStr, storeJobPolicyId: this.data.storeJobPolicyId, policyList: items }) }, showPolicy () { console.log(123); this.setData({ drawerShow: true }) console.log(this.data.drawerShow); }, getAgencyList () { let that = this customRequest("/yishoudan/store/job/getPolicyListByStoreJobId?storeJobId=" + this.data.storeJobId, { header: 'headers', method: 'GET', data: {} }).then(({data}) => { if (data.status == 200) { that.setData({ policyList: data.data || [] }) that.data.policyList.forEach((item, index) => { if (item.policy == that.data.policy) { that.setData({ policyStr: index, storeJobPolicyId: item.id }) } }); } }) // wx.request({ // url: app.globalData.ip + "/yishoudan/store/job/getPolicyListByStoreJobId?storeJobId=" + this.data.storeJobId, // header: app.globalData.headers, // method: "get", // success ({ data }) { // console.log(data); // } // }) }, getJobDetail (id) { let that = this return new Promise((resolve) => { customRequest("/overall/store/job/getStoreJobDetailById?storeJobId=" + id, { header: 'headers', method: 'POST', data: {} }).then(({data}) => { if (data.status == 200) { console.log(data.data.storeJob); let list = [] for (let i = 0; i < data.data.storeJob.policyNum; i++) { let pickerStr if (i <= 9) { switch (i) { case 0: pickerStr = '政策一' break; case 1: pickerStr = '政策二' break; case 2: pickerStr = '政策三' break; case 3: pickerStr = '政策四' break; case 4: pickerStr = '政策五' break; case 5: pickerStr = '政策六' break; case 6: pickerStr = '政策七' break; case 7: pickerStr = '政策八' break; case 8: pickerStr = '政策九' break; case 9: pickerStr = '政策十' break; default: pickerStr = '政策' + (index + 1) break; } list[i] = { value: i + 1, name: pickerStr } } } console.log(list); that.setData({ // policy: res.data.data, // isShowZhedie: true, zhengceTextList: list }); // resolve(); } }) // wx.request({ // // url: app.globalData.ip + "/store/job/getStoreJobDetailById?storeJobId=" + that.data.searchForm.storeJobId, // url: app.globalData.ip + "/overall/store/job/getStoreJobDetailById?storeJobId=" + id, // method: "POST", // header: app.globalData.headers, // success: function ({ data }) { // console.log(data); // }, // fail: function (res) { // // console.log(res); // // reject(); // }, // }) }) }, policyChange (e) { console.log(e.detail.value); const items = this.data.zhengceTextList console.log(items); this.data.policyStr = e.detail.value this.data.policyIdx = items[e.detail.value].value; // console.log(this.data.policyStr); this.setData({ policyStr: this.data.policyStr, policyIdx: this.data.policyIdx, // policyList: items }) }, shrink: function () { wx.navigateBack({ delta: -1, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that = this; // console.log(JSON.parse(options.info)); console.log(options); // 获取缓存的报名人信息 let info = wx.getStorageSync("storeJobInfoBill"); console.log(info); if (app.isNotEmptyCheck(info)) { // 统一给代理岗位相关的字段赋值 that.setData({ id: info.id, storeJobId: info.storeJobId, jobName: info.storeJobName, storeName: info.storeName, agentId: info.agentId, agentName: info.agentName, currentImg: info.currentImg, currentTime: dateUtil.formatDateYMDHM(info.createTime), currentTime2: info.currentTime2, policy: info.policy, policyStr: info.policyIdx, policyIdx: info.policyIdx }); } if (app.isNotEmptyCheck(options.info)) { // 如果随路由传过来的信息有更新,赋值新的数据 console.log(JSON.parse(options.info)); this.setData({ storeJobId: JSON.parse(options.info).id, jobName: JSON.parse(options.info).jobName, storeName: JSON.parse(options.info).storeName || JSON.parse(options.info).aliasName, }); } that.setData({ managerRoleClassify: app.globalData.loginUserInfo.managerRoleClassify, }); }, toJobAndAgencySelect (e) { console.log(e); console.log(this.data.userInfo); // this.setStorage().then(() => { // console.log('--------','isIntonavigation'); wx.navigateTo({ url: `../../recordChoice/index?type=${e.currentTarget.dataset.type}`, }); // }); }, showImg () { wx.previewImage({ current: this.data.currentImg, // 当前显示图片的 http 链接 urls: [this.data.currentImg], // 需要预览的图片 http 链接列表 }); }, deleteImg () { var that = this; wx.showModal({ title: "提示", content: "确定要删除图片吗?", confirmColor: "#1890ff", success (res) { if (res.confirm) { that.setData({ imgSrc: "", showUpload: true, }); } else if (res.cancel) { console.log("用户点击取消"); } }, }); }, hidedrawershow (e) { console.log(e); this.setData({ [e.detail.type]: false }) console.log(this.data.drawerShow); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { // let src = wx.getStorageSync("src"); // console.log(src); }, bothwayBind (e) { console.log(e); let type = `userInfo.${e.currentTarget.dataset.type}`; this.setData({ [type]: e.detail.value, }); }, beforeFormSubmit: function (e) { var that = this; console.log(that.data.id); that.setData({ loading: true, }); setTimeout(() => { that.formSubmit(e); }, 1); // if (!that.data.switch1Checked) { // wx.showToast({ // title: "请先阅读并同意《服务协议》及《隐私政策》", // icon: "none", // duration: 2000, // }); // } else if (app.isEmptyCheck(e.detail.value.userName)) { // wx.showToast({ // duration: 2000, // title: "请输入姓名", // icon: "none", // mask: true, // }); // that.setData({ // loading: false, // }); // } else if (app.isEmptyCheck(e.detail.value.sex)) { // wx.showToast({ // duration: 2000, // title: "请选择性别", // icon: "none", // mask: true, // }); // that.setData({ // loading: false, // }); // } else if (app.isEmptyCheck(e.detail.value.age)) { // wx.showToast({ // duration: 2000, // title: "请输入年龄", // icon: "none", // mask: true, // }); // that.setData({ // loading: false, // }); // } else { // setTimeout(() => { // that.formSubmit(e); // }, 1); // } }, setStorage () { let that = this; // wx.removeStorageSync('townsManInfoJob') // return new Promise((resolve, reject) => { // console.log(that.data.storeJobId); // let data = { currentTime: that.data.currentTime,currentTime2: that.data.currentTime2, storeJobId: that.data.storeJobId, jobName: that.data.jobName, agentId: that.data.agentId, agentName: that.data.agentName }; // console.log(data); // wx.setStorage({ // key: "townsManInfoJob", // data, // }); // console.log(wx.getStorageSync("townsManInfoJob")); // resolve(); // }); }, formSubmit: function (e) { var that = this; console.log(e); that.setData({ loading: true, }); wx.showLoading({ title: "提交中...", mask: true, }); // if (that.data.index == -1) { // wx.showToast({ // duration: 2000, // title: '请选择代理', // icon: 'none', // mask: true // }) // that.setData({ // loading: false // }) // } else // if (that.data.jobIndex == -1) { // wx.showToast({ // duration: 2000, // title: "请选择岗位", // icon: "none", // mask: true, // }); // that.setData({ // loading: false, // }); // } else { console.log(that.data.idInfo); new Promise(function (resolve, reject) { var paramData = {}; paramData["storeJobId"] = that.data.storeJobId; paramData["orderId"] = that.data.id; // paramData["storeJobPolicyId"] = that.data.storeJobPolicyId; paramData["policyIdx"] = that.data.policyIdx; resolve(paramData); }).then(function (paramData) { console.log(paramData); new Promise((resolve, reject) => { customRequest("/yishoudan/user/apply/order/updateOrder", { header: 'headers', method: 'POST', data: paramData }).then((res) => { if (res.data.status == 200) { // that.setData({ // storeArray: res.data.data, // }); } }) // wx.request({ // url: app.globalData.ip + "/yishoudan/user/apply/order/updateOrder", // data: paramData, // header: app.globalData.headers, // method: "POST", // success: function (res) { // console.log(res); // if (res.data.status == 200) { // // that.setData({ // // storeArray: res.data.data, // // }); // } // }, // fail: function (res) { }, // }); resolve(); }).then(() => { wx.redirectTo({ url: '../../billDetail/index?id=' + that.data.id, }) }); wx.hideLoading({ success: (res) => { }, }) }); // } }, inputTyping: function (e) { this.setData({ inputVal: e.detail.value, }); if (e.detail.value.length > 0) { this.setData({ searchListShow: true, }); this.getStoreList(e.detail.value); } else { this.setData({ searchListShow: false, }); } }, getStoreList: function (searchKeys) { console.log(searchKeys); var that = this; that.data.searchKeys = searchKeys; // 60秒后重新获取验证码 customRequest("/store/getAllStoreAliasName", { header: 'headers', method: 'GET', data: { keys: searchKeys, } }).then((res) => { if (res.data.status == 200) { that.setData({ storeArray: res.data.data, }); } }) // wx.request({ // url: app.globalData.ip + "/store/getAllStoreAliasName", // data: { // keys: searchKeys, // }, // header: app.globalData.headers, // method: "GET", // success: function (res) { // console.log(res); // }, // fail: function (res) { }, // }); }, setValue: function (e) { let str = e.currentTarget.dataset.name; let storeId = e.currentTarget.dataset.id; console.log(storeId); this.setData({ inputVal: str, storeId: storeId, searchListShow: false, }); this.getJobList(storeId); }, getJobList: function (storeId) { var that = this; return new Promise((resolve, reject) => { customRequest("/store/job/getJobNameByStoreId", { header: 'headers', method: 'GET', data: { storeId: storeId } }).then((res) => { if (res.data.status == 200) { that.setData({ jobArray: res.data.data, }); resolve(); } }) // wx.request({ // url: app.globalData.ip + "/store/job/getJobNameByStoreId", // data: { // storeId: storeId, // }, // header: app.globalData.headers, // method: "GET", // success: function (res) { // console.log(res); // }, // fail: function (res) { }, // }); }); }, // bindPickerChangeJob: function (e) { // var that = this; // console.log("picker发送选择改变,携带值为", e.detail.value); // var storeJobId = that.data.jobArray[e.detail.value].id; // console.log(storeJobId); // that.getPolicyByStoreJobId(storeJobId); // this.setData({ // jobIndex: e.detail.value, // }); // }, bindPickerChangeNation (e) { let that = this; console.log("picker发送选择改变,携带值为", e.detail.value); var nationName = that.data.nationArray[e.detail.value].name; this.setData({ nationIndex: e.detail.value, ["userInfo.nationality"]: nationName, }); }, getPolicyByStoreJobId: function (storeJobId) { var that = this; // 60秒后重新获取验证码 customRequest("/store/job/getPolicyByStoreJobId", { header: 'headers', method: 'GET', data: { storeJobId: storeJobId } }).then((res) => { if (res.data.status == 200) { that.setData({ policy: res.data.data, }); } }) // wx.request({ // url: app.globalData.ip + "/store/job/getPolicyByStoreJobId", // data: { // storeJobId: storeJobId, // }, // header: app.globalData.headers, // method: "GET", // success: function (res) { // console.log(res); // }, // fail: function (res) { // console.log(res); // }, // }); }, changeDateTime (e) { var dateTimeArray = this.data.dateTimeArray, dateTime = e.detail.value; this.setData({ // dateTime: e.detail.value, currentTime: dateTimeArray[0][dateTime[0]].replace("年", "") + "-" + dateTimeArray[1][dateTime[1]].replace("月", "") + "-" + dateTimeArray[2][dateTime[2]].replace("日", "") + " " + dateTimeArray[3][dateTime[3]], }); console.log(this.data.dateTimeArray); }, changeDateTimeColumn (e) { var arr = this.data.dateTime, dateArr = this.data.dateTimeArray; arr[e.detail.column] = e.detail.value; dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]); for (let index = 0; index < dateArr[2].length; index++) { dateArr[2][index] = dateArr[2][index] + "日"; } // .replace("年",'').replace("月",'').replace("日",'') this.setData({ dateTimeArray: dateArr, dateTime: arr, }); }, changeDateTime2 (e) { var dateTimeArray = this.data.dateTimeArray, dateTime = e.detail.value; this.setData({ // dateTime: e.detail.value, currentTime2: dateTimeArray[0][dateTime[0]].replace("年", "") + "-" + dateTimeArray[1][dateTime[1]].replace("月", "") + "-" + dateTimeArray[2][dateTime[2]].replace("日", "") + " " + dateTimeArray[3][dateTime[3]], }); console.log(this.data.dateTimeArray); }, changeDateTimeColumn2 (e) { var arr = this.data.dateTime2, dateArr = this.data.dateTimeArray; arr[e.detail.column] = e.detail.value; dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]); for (let index = 0; index < dateArr[2].length; index++) { dateArr[2][index] = dateArr[2][index] + "日"; } // .replace("年",'').replace("月",'').replace("日",'') this.setData({ dateTimeArray: dateArr, dateTime2: arr, }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear, this.data.currentTime); console.log(obj.dateTimeArray); for (let index = 0; index < obj.dateTimeArray[0].length; index++) { obj.dateTimeArray[0][index] = obj.dateTimeArray[0][index] + "年"; } for (let index = 0; index < obj.dateTimeArray[1].length; index++) { obj.dateTimeArray[1][index] = obj.dateTimeArray[1][index] + "月"; } for (let index = 0; index < obj.dateTimeArray[2].length; index++) { obj.dateTimeArray[2][index] = obj.dateTimeArray[2][index] + "日"; } this.setData({ dateTimeArray: obj.dateTimeArray, dateTime: obj.dateTime, dateTimeArray2: obj.dateTimeArray, dateTime2: obj.dateTime, }); this.getAgencyList() this.getJobDetail(this.data.storeJobId).then(function () { let data = { currentTime: that.data.currentTime, currentTime2: that.data.currentTime2, storeJobId: that.data.storeJobId, jobName: that.data.jobName, agentName: that.data.agentName, policy: that.data.policy }; console.log(data); wx.setStorage({ key: "townsManInfoJob", data, }); }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function (e) { console.log("isHide"); console.log(e); // this.setData({ // userInfo: { // name: "", // address: "", // age: "", // nationality: "", // sex: "", // num: "", // idCardImageUrl: "", // }, // }); }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { wx.removeStorageSync("storeJobInfoBill") wx.removeStorageSync("townsManInfo"); wx.removeStorageSync('townsManInfoJob') // wx.switchTab({ // url: "../firstBill/index", // }); // console.log(wx.getStorageSync("townsManInfo")); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage() { return app.sharePageImage() }, });