From 54b082f093d051d7ba105af42bb7f11833978ec5 Mon Sep 17 00:00:00 2001 From: wangyx <2838268875@qq.com> Date: Wed, 14 May 2025 18:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- app.json | 12 +- package-lock.json | 20 + pages/mine/mine.js | 7 + pages/mine/mine.wxml | 2 +- project.config.json | 5 +- project.private.config.json | 16 +- subpages/mine/editUser/editUser.js | 553 +++++++++++++++++++++++++++ subpages/mine/editUser/editUser.json | 19 + subpages/mine/editUser/editUser.wxml | 44 +++ subpages/mine/editUser/editUser.wxss | 95 +++++ 11 files changed, 766 insertions(+), 11 deletions(-) create mode 100644 package-lock.json create mode 100644 subpages/mine/editUser/editUser.js create mode 100644 subpages/mine/editUser/editUser.json create mode 100644 subpages/mine/editUser/editUser.wxml create mode 100644 subpages/mine/editUser/editUser.wxss diff --git a/.gitignore b/.gitignore index 5bab9b4..ea097c5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ .idea /node_modules/ project.config.json -project.private.config.json \ No newline at end of file +project.private.config.json +node_modules/ +.history \ No newline at end of file diff --git a/app.json b/app.json index 67a1580..71c125f 100644 --- a/app.json +++ b/app.json @@ -14,6 +14,13 @@ "pages": [ "pages/index/index" ] + }, + { + "root":"subpages/mine", + "name":"mine", + "pages":[ + "editUser/editUser" + ] } ], "window": { @@ -67,8 +74,5 @@ "version": "3.1.3", "provider": "wx4418e3e031e551be" } - }, - "componentFramework": "glass-easel", - "sitemapLocation": "sitemap.json", - "lazyCodeLoading": "requiredComponents" + } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..05d08bb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "epmet-apartment-mp", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "epmet-apartment-mp", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@vant/weapp": "^1.11.7" + } + }, + "node_modules/@vant/weapp": { + "version": "1.11.7", + "license": "MIT" + } + } +} diff --git a/pages/mine/mine.js b/pages/mine/mine.js index 1129054..9f4b166 100644 --- a/pages/mine/mine.js +++ b/pages/mine/mine.js @@ -18,6 +18,13 @@ Page({ navigationHeight: app.globalData.deviceInfo.navigationHeight, }); }, + // 跳转到修改信息页 + goToEdit() { + console.log("点击了修改信息"); + wx.navigateTo({ + url: "/subpages/mine/editUser/editUser", + }); + }, /** * 生命周期函数--监听页面初次渲染完成 diff --git a/pages/mine/mine.wxml b/pages/mine/mine.wxml index d590752..5a01ce3 100644 --- a/pages/mine/mine.wxml +++ b/pages/mine/mine.wxml @@ -5,7 +5,7 @@ - + 五月的风 diff --git a/project.config.json b/project.config.json index 0d189d7..b3405bc 100644 --- a/project.config.json +++ b/project.config.json @@ -21,5 +21,8 @@ "include": [] }, "appid": "wxaf87b420b87e2d79", - "editorSetting": {} + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index 531939f..fae420e 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,5 +1,5 @@ { - "libVersion": "3.8.2", + "libVersion": "development", "projectname": "epmet-apartment-mp", "setting": { "urlCheck": true, @@ -14,12 +14,19 @@ "condition": { "miniprogram": { "list": [ + { + "name": "subpages/mine/editUser/editUser", + "pathName": "subpages/mine/editUser/editUser", + "query": "", + "launchMode": "default", + "scene": null + }, { "name": "pages/register/register", "pathName": "pages/register/register", "query": "", - "scene": null, - "launchMode": "default" + "launchMode": "default", + "scene": null }, { "name": "身份证识别", @@ -30,5 +37,6 @@ } ] } - } + }, + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" } \ No newline at end of file diff --git a/subpages/mine/editUser/editUser.js b/subpages/mine/editUser/editUser.js new file mode 100644 index 0000000..1979580 --- /dev/null +++ b/subpages/mine/editUser/editUser.js @@ -0,0 +1,553 @@ +// 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: [], + }); + }, +}); diff --git a/subpages/mine/editUser/editUser.json b/subpages/mine/editUser/editUser.json new file mode 100644 index 0000000..8857561 --- /dev/null +++ b/subpages/mine/editUser/editUser.json @@ -0,0 +1,19 @@ +{ + "usingComponents": { + "van-field": "@vant/weapp/field/index", + "van-icon": "@vant/weapp/icon/index", + "van-button": "@vant/weapp/button/index", + "van-cell-group": "@vant/weapp/cell-group/index", + "van-cell": "@vant/weapp/cell/index", + "van-checkbox": "@vant/weapp/checkbox/index", + "van-checkbox-group": "@vant/weapp/checkbox-group/index", + "van-uploader": "@vant/weapp/uploader/index", + "van-picker": "@vant/weapp/picker/index", + "van-action-sheet": "@vant/weapp/action-sheet/index", + "van-cascader": "@vant/weapp/cascader/index", + "van-popup": "@vant/weapp/popup/index", + "van-image":"@vant/weapp/image/index", + "van-divider": "@vant/weapp/divider/index" + }, + "navigationBarTitleText": "修改个人信息" + } \ No newline at end of file diff --git a/subpages/mine/editUser/editUser.wxml b/subpages/mine/editUser/editUser.wxml new file mode 100644 index 0000000..46ad6c1 --- /dev/null +++ b/subpages/mine/editUser/editUser.wxml @@ -0,0 +1,44 @@ + + + + + + + + + + + + 基本信息 + + + + + + + + + + + + 重新获取 + + + + + + + + + + + + 提交 + + + + + + + + \ No newline at end of file diff --git a/subpages/mine/editUser/editUser.wxss b/subpages/mine/editUser/editUser.wxss new file mode 100644 index 0000000..4c64def --- /dev/null +++ b/subpages/mine/editUser/editUser.wxss @@ -0,0 +1,95 @@ +page { + height: 100vh; + display: flex; + flex-direction: column; + background-color: #f7f7f7; + } + + .black { + color: #333333; + } + + .gray { + color: #646566; + } + + + .author { + width: 100%; + background-color: #fff; + /* height: 140rpx; + padding: 15rpx 40rpx; + box-sizing: border-box; */ + } + + .author image { + width: 110rpx; + height: 110rpx; + } + + .card { + margin: 0 auto; + margin-top: 12rpx; + width: calc(100% - 40rpx); + } + + .card .title { + font-weight: 600; + font-size: 32rpx; + } + + .card .van-cell__title { + color: #646566; + } + + .tip { + margin: 0 auto; + margin-top: 12rpx; + width: calc(100% - 40rpx); + font-size: 26rpx; + } + + .tip .van-checkbox__label { + color: #aaaaaa; + } + + .tip text { + color: #333333; + } + + .bot-btn { + text-align: center; + max-width: 400rpx; + margin: 0 auto; + } + + .bot-btn .van-button--primary { + width: calc(100% - 40rpx); + } + + .van-field__label { + font-size: 30rpx; + } + + .van-field__control { + font-size: 30rpx; + } + + .van-cell { + padding: 20rpx 0 !important; + } + .cus-avatar{ + padding: 0 20rpx !important; +} + .van-cell--required:before { + left: var(--padding-xs, -7px) !important; + } + + .van-cell__title { + font-size: 30rpx; + } + + .van-cell__value { + font-size: 30rpx; + } + \ No newline at end of file