Browse Source

修改个人信息

epass
wangyx 3 months ago
parent
commit
54b082f093
  1. 4
      .gitignore
  2. 12
      app.json
  3. 20
      package-lock.json
  4. 7
      pages/mine/mine.js
  5. 2
      pages/mine/mine.wxml
  6. 5
      project.config.json
  7. 16
      project.private.config.json
  8. 553
      subpages/mine/editUser/editUser.js
  9. 19
      subpages/mine/editUser/editUser.json
  10. 44
      subpages/mine/editUser/editUser.wxml
  11. 95
      subpages/mine/editUser/editUser.wxss

4
.gitignore

@ -2,4 +2,6 @@
.idea .idea
/node_modules/ /node_modules/
project.config.json project.config.json
project.private.config.json project.private.config.json
node_modules/
.history

12
app.json

@ -14,6 +14,13 @@
"pages": [ "pages": [
"pages/index/index" "pages/index/index"
] ]
},
{
"root":"subpages/mine",
"name":"mine",
"pages":[
"editUser/editUser"
]
} }
], ],
"window": { "window": {
@ -67,8 +74,5 @@
"version": "3.1.3", "version": "3.1.3",
"provider": "wx4418e3e031e551be" "provider": "wx4418e3e031e551be"
} }
}, }
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
} }

20
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"
}
}
}

7
pages/mine/mine.js

@ -18,6 +18,13 @@ Page({
navigationHeight: app.globalData.deviceInfo.navigationHeight, navigationHeight: app.globalData.deviceInfo.navigationHeight,
}); });
}, },
// 跳转到修改信息页
goToEdit() {
console.log("点击了修改信息");
wx.navigateTo({
url: "/subpages/mine/editUser/editUser",
});
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成

2
pages/mine/mine.wxml

@ -5,7 +5,7 @@
</view> </view>
</view> </view>
<view class="body"> <view class="body">
<view class="userInfo flex flex-sb items-center"> <view class="userInfo flex flex-sb items-center" bindtap="goToEdit">
<image src="../../images/zixun.png" class="avatar" mode="" /> <image src="../../images/zixun.png" class="avatar" mode="" />
<view class="name flex-1">五月的风</view> <view class="name flex-1">五月的风</view>
<van-icon name="arrow" /> <van-icon name="arrow" />

5
project.config.json

@ -21,5 +21,8 @@
"include": [] "include": []
}, },
"appid": "wxaf87b420b87e2d79", "appid": "wxaf87b420b87e2d79",
"editorSetting": {} "editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
}
} }

16
project.private.config.json

@ -1,5 +1,5 @@
{ {
"libVersion": "3.8.2", "libVersion": "development",
"projectname": "epmet-apartment-mp", "projectname": "epmet-apartment-mp",
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
@ -14,12 +14,19 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "subpages/mine/editUser/editUser",
"pathName": "subpages/mine/editUser/editUser",
"query": "",
"launchMode": "default",
"scene": null
},
{ {
"name": "pages/register/register", "name": "pages/register/register",
"pathName": "pages/register/register", "pathName": "pages/register/register",
"query": "", "query": "",
"scene": null, "launchMode": "default",
"launchMode": "default" "scene": null
}, },
{ {
"name": "身份证识别", "name": "身份证识别",
@ -30,5 +37,6 @@
} }
] ]
} }
} },
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
} }

553
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: [],
});
},
});

19
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": "修改个人信息"
}

44
subpages/mine/editUser/editUser.wxml

@ -0,0 +1,44 @@
<view class="author ">
<van-cell is-link center custom-class="cus-avatar">
<view slot="title">
<van-image width="55" height="55" round src="https://img.yzcdn.cn/vant/cat.jpeg" />
</view>
</van-cell>
<!-- <van-uploader style="margin-top: 15rpx;" file-list="{{ fileList }}" bind:delete="deleteImg" bind:after-read="afterRead" max-count="1" /> -->
</view>
<view class="card">
<view class="title">
基本信息
</view>
<van-cell-group>
<van-field model:value="{{ nickName }}" placeholder="请输入" input-align="right" label="昵称" />
<!-- <van-divider /> -->
<van-field model:value="{{ name }}" input-align="right" label="姓名" required placeholder="请输入" />
<!-- <van-divider /> -->
<van-field model:value="{{ idCard }}" label="身份证" input-align="right" type="idcard" required placeholder="实名认证请输入身份证" border="{{ false }}" />
<!-- <van-divider /> -->
<van-field model:value="{{ mobile }}" center clearable label="手机号" required placeholder="请输入" border="{{ false }}" use-button-slot>
<van-button slot="button" size="small" type="primary" round color="#f53e1f" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
重新获取
</van-button>
</van-field>
<!-- 住房剩余天数 -->
<van-field model:value="{{ housingDays }}" label="住房剩余天数" input-align="right" type="digit" placeholder="请输入" border="{{ false }}" />
</van-cell-group>
</view>
<view style="width: 100%; text-align: center;margin-top: 20rpx;">
<view class="bot-btn">
<van-button slot="button" type="primary" round color="#f53e1f" bind:tap="submit">
提交
</van-button>
</view>
</view>
<van-popup show="{{ showAgency }}" round position="bottom">
<van-cascader wx:if="{{showAgency}}" field-names="{{ {text: 'label',value: 'value',children: 'children'} }}" value="{{ cascaderValue }}" title="请选择所在地区" options="{{ agencyList }}" bind:close="onCancelAgency" bind:change="onChangeAgency" bind:finish="onConfirmAgency" />
</van-popup>
<van-action-sheet cancel-text="确定" bind:cancel="onClose" close-on-click-action="{{false}}" show="{{ showIdentity }}" actions="{{ identityList }}" bind:select="onChangeIdentity" />
<van-action-sheet cancel-text="确定" bind:cancel="onCloseV" close-on-click-action="{{false}}" show="{{ showVolunOrg }}" actions="{{ volunOrgList }}" bind:select="onChangeVolunOrg" />

95
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;
}
Loading…
Cancel
Save