// import { // initTree, // volunteerInfoSave, // getwxphone, // volunteerOrg, // volunteerInfo, // } from "../../../../api/user"; // import { checkContentStatus } from "../../../../api/audit"; // const QQMapWX = require("../../../../utils/qqmap-wx-jssdk"); // const config = require("../../../../utils/config"); const app = getApp(); Page({ /** * 页面的初始数据 */ data: { name: null, nickName: null, idCard: null, mobile: null, fileList: [ { url: "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20240830/de2ccb0304eb4bab9513d11472fb3454.png", type: "image", name: "image", }, ], showIdentity: false, identityList: [ { name: "医疗急救", key: "0" }, { name: "体育竞技", key: "1" }, { name: "驾驶运输", key: "2" }, { name: "法律服务", key: "3" }, { name: "信息技术", key: "4" }, { name: "经营管理", key: "5" }, { name: "公共关系", key: "6" }, { name: "教育培训", key: "7" }, { name: "电器维修", key: "8" }, { name: "安全保卫", key: "9" }, { name: "财会金融", key: "10" }, { name: "设计创意", key: "11" }, { name: "客服接待", key: "12" }, { name: "物业养护", key: "13" }, { name: "新闻写作", key: "14" }, { name: "精通外语", key: "15" }, { name: "音乐", key: "16" }, { name: "心理咨询", key: "17" }, { name: "护理照护", key: "18" }, { name: "手工制作", key: "19" }, { name: "文化艺术", key: "20" }, { name: "网络技术", key: "21" }, { name: "摄像摄影", key: "22" }, ], identityName: [], identityKey: [], showAgency: false, volunOrgName: [], volunOrgKey: [], volunOrgList: [], showVolunOrg: false, traceId: "", }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { // this.data.qqMapWX = new QQMapWX({ // key: "CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ", // }); // this.reverseLocation(); // this.initTree(); // this.volunteerOrg(); // console.log(app.globalData.userInfo, " app.globalData.userInfo"); // let { // nickName, // name, // agencyName, // idCard, // mobile, // identityType, // headImgUrl, // agencyId, // identityTypeList, // orgName, // userId, // } = app.globalData.userInfo; // let identityName = []; // if (identityType && identityType.length != 0) { // identityName = this.data.identityList // .filter((item) => identityType.includes(item.key)) // .map((item) => item.name); // } // this.setData({ // userId, // agencyNameStr: agencyName, // fileList: headImgUrl ? [{ url: headImgUrl }] : this.data.fileList, // identityKey: identityType, // identityType, // identityNameStr: identityTypeList ? identityTypeList.join() : "", // identityName, // volunOrgIdNameStr: orgName, // }); // this.volunteerInfo(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { let volunteerOrgName = []; // let { volunteerOrgId } = app.globalData.userInfo; // if (volunteerOrgId) { // volunteerOrgName = this.data.volunOrgList // .filter((item) => volunteerOrgId.split(",").includes(item.key)) // .map((item) => item.name); // } }, /** * 生命周期函数--监听页面显示 */ onShow() {}, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {}, volunteerInfo() { let parm = { id: app.globalData.userInfo.id, }; volunteerInfo(parm).then((res) => { let { nickName, name, agencyName, idCard, mobile, identityType, headImgUrl, agencyId, identityTypeList, orgName, userId, volunteerOrgId, } = res.data; console.log( nickName, name, agencyName, idCard, mobile, identityType, headImgUrl, agencyId, identityTypeList, orgName, userId, "dslidfjlsdfj" ); console.log(res, "sd;lfk;lsfdl"); this.setData({ nickName, name, agencyId, volunteerOrgId, userId, idCard: res.data.idCard, mobile, }); }); }, volunteerOrg() { let parm = { orgName: "", serviceType: "", // userId:app.globalData.userInfo.userId, status: "pass", pageNo: 1, pageSize: 20, }; volunteerOrg(parm) .then((res) => { if (res.code === 0) { console.log(res); this.setData({ volunOrgList: res.data.list.map((item) => ({ name: item.orgName, key: item.id, })), }); } }) .catch((err) => { console.log(err); }); }, handelShowIdentity() { this.setData({ showIdentity: true, identityKey: [], identityName: [], identityName: [], }); }, onClose() { this.setData({ showIdentity: false, }); }, onChangeIdentity(e) { // this.setData({ // identityKey:[], // identityName:[], // identityName:[] // }); console.log( this.data.identityKey, this.data.identityName, this.data.identityList, "dsfijlslkfjslkjflksfjlks" ); console.log(e, "dsfijlslkfjslkjflksfjlks"); const name = e.detail.name; const key = e.detail.key; let identityName = this.data.identityName || []; let identityKey = this.data.identityKey || []; let identityList = this.data.identityList || []; const nameIndex = identityName.indexOf(name); if (nameIndex > -1) { identityName.splice(nameIndex, 1); } else { identityName.push(name); } const keyIndex = identityKey.indexOf(key); if (keyIndex > -1) { identityKey.splice(keyIndex, 1); const obj = identityList.find((item) => item.key === key); if (obj) { delete obj.color; } } else { identityKey.push(key); // 添加 color 属性 const obj = identityList.find((item) => item.key === key); if (obj) { obj.color = "#1cd66c"; } } this.setData({ identityName: identityName, identityNameStr: identityName.join(","), identityType: identityKey, identityList, }); }, afterRead(event) { const { file } = event.detail; console.log(file); let than = this; // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 wx.uploadFile({ url: `${config.BASEURL()}oss/file/uploadWxFile`, filePath: file.url, name: "file", header: { "Content-type": "multipart/form-data", Authorization: wx.getStorageSync("token"), }, success(res) { let { data } = JSON.parse(res.data); // 上传完成需要更新 fileList const { fileList = [] } = than.data; fileList.push({ ...file, url: data.url }); console.log(fileList); than.setData({ fileList }); // 图片开始审核 than.setData({ traceId: data.traceId, }); }, catch(err) { console.log(err); }, }); }, // 逆地址解析 reverseLocation() { const _this = this; // this.data.qqMapWX.reverseGeocoder({ // success(res) { // _this.setData({ // street: res.result.address_reference.town.title, // }); // _this.initTree(); // }, // fail(err) { // console.debug(err); // }, // }); }, // initTree() { // let parm = { // organizationName: "市北区", // }; // initTree(parm) // .then((res) => { // this.setData({ // agencyList: [{ label: "市北区", value: "", children: res.data }], // }); // }) // .catch((err) => { // console.log(err); // }); // }, handelShowAgency() { this.setData({ showAgency: true, }); }, handelShowVolunOrg() { this.setData({ showVolunOrg: true, }); }, onCloseV() { this.setData({ showVolunOrg: false, }); }, onChangeVolunOrg(e) { const name = e.detail.name; const key = e.detail.key; let volunOrgName = this.data.volunOrgName || []; let volunOrgKey = this.data.volunOrgKey || []; let volunOrgList = this.data.volunOrgList || []; const nameIndex = volunOrgName.indexOf(name); if (nameIndex > -1) { volunOrgName.splice(nameIndex, 1); } else { volunOrgName.push(name); } const keyIndex = volunOrgKey.indexOf(key); if (keyIndex > -1) { volunOrgKey.splice(keyIndex, 1); const obj = volunOrgList.find((item) => item.key === key); if (obj) { delete obj.color; } } else { volunOrgKey.push(key); // 添加 color 属性 const obj = volunOrgList.find((item) => item.key === key); if (obj) { obj.color = "#1cd66c"; } } this.setData({ volunOrgName: volunOrgName, volunOrgIdNameStr: volunOrgName.join(","), volunteerOrgId: volunOrgKey.join(","), volunOrgList, }); }, onChangeAgency(e) { const { value, selectedOptions } = e.detail; const orgId = selectedOptions[selectedOptions.length - 1].value; const organizationName = selectedOptions[selectedOptions.length - 1].label; const level = selectedOptions[selectedOptions.length - 1].level; const agencyNameStr = selectedOptions.map((item) => item.label).join(","); this.setData({ searchOrgIdPath: orgId, agencyNameStr, selectedOptions, organizationName, }); if (level === "community") { this.setData({ showAgency: false, }); return false; } // initTree({ organizationName }).then((res) => { // if (res.data.length > 0) { // const data = res.data.map((item) => { // return { // ...item, // children: [], // }; // }); // const arr = this.getTreeFun(value, this.data.agencyList, data); // this.setData({ // agencyList: arr, // }); // } else { // const arr = this.getTreeFun(value, this.data.agencyList, null); // this.setData({ // agencyList: arr, // }); // } // }); }, getTreeFun(value, arr, data) { return arr.map((item) => { if (value == item.value) { return { ...item, children: data, }; } if (item.children && item.children.length > 0) { return { ...item, children: this.getTreeFun(value, item.children, data), }; } return item; }); }, onConfirmAgency() { this.setData({ showAgency: false, }); }, onCancelAgency() { this.setData({ showAgency: false, }); }, submit() { if (!this.data.traceId) { // 没有要审核的图片 this.doSubmit(); } else { let params = { traceId: this.data.traceId, }; checkContentStatus(params) .then((res) => { let data = res.data; if (data.checkFlag == -1) { wx.showToast({ title: "头像不合规", icon: "none", }); } else if (data.checkFlag == 0) { // 图像审核中 wx.showToast({ title: "头像审核中", icon: "none", }); } else { // 审核通过 this.doSubmit(); } }) .catch((err) => { console.log(err); }); } }, doSubmit() { if (!this.data.name) { wx.showToast({ title: "请填写姓名", icon: "none", }); return false; } if (!this.data.idCard) { wx.showToast({ title: "请填写身份证号", icon: "none", }); return false; } if (!this.data.mobile) { wx.showToast({ title: "请填写手机号", icon: "none", }); return false; } let parm = { nickName: this.data.nickName, name: this.data.name, idCard: this.data.idCard, mobile: this.data.mobile, agencyId: this.data.searchOrgIdPath, identityType: this.data.identityType, headImgUrl: this.data.fileList[0] ? this.data.fileList[0].url : "", volunteerOrgId: this.data.volunteerOrgId || "", }; volunteerInfoSave(parm) .then((res) => { wx.showToast({ title: "修改成功", duration: 2000, success: () => { setTimeout(() => { wx.navigateBack(); }, 2000); }, }); }) .catch((err) => { console.log(err); }); }, getPhoneNumber(e) { getwxphone(e.detail.code) .then((res) => { if (res.code === 0) { this.setData({ mobile: res.data, }); } }) .catch((err) => { console.log(err); }); }, deleteImg() { console.log(11); this.setData({ fileList: [], }); }, });