| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- <template>
- <view style="padding: 30rpx;">
- <view style="display: flex;align-items: center;justify-content: space-between;">
- <view class="tip">
- 请填写真实信息,以便我们后续为您提供完善的
- <br />
- 个人职业成长定制服务!
- </view>
- <view style="display: flex;align-items: center;">
- <view class="btn" style="margin-right: 5rpx;" :style="form.certified === 1 ? isStatus : ''" @click="form.certified === 0 ? certification() : iscertification()">
- {{ form.certified === 0 ? '认证' : '已认证' }}
- </view>
- <view class="btn">编辑</view>
- </view>
- </view>
- <view class="form">
- <u-form :model="form" ref="uForm">
- <u-form-item label="姓名" prop="realname"><u-input :disabled="form.certified === 1" v-model="userInfo.realname" /></u-form-item>
- <u-form-item label="手机号码" prop="telphone" :label-width="auto"><u-input :disabled="form.certified === 1" v-model="form.telphone" /></u-form-item>
- <u-form-item label="身份证号" prop="idCard" :label-width="auto"><u-input :disabled="form.certified === 1" v-model="form.idCard" /></u-form-item>
- <u-form-item label="性别" prop="sex">
- <picker @change="bindPickerChangeSex" :value="form.sex" :range="array_sex">
- <view class="picker">{{ array_sex[form.sex] }}</view>
- </picker>
- </u-form-item>
- <u-form-item label="邮箱" prop="email" :label-width="auto"><u-input v-model="form.email" /></u-form-item>
- <u-form-item label="出生日期" prop="userBirth" :label-width="auto">
- <picker mode="date" :value="form.userBirth" @change="bindDateChange">
- <view class="picker">{{ form.userBirth }}</view>
- </picker>
- </u-form-item>
- <!-- <u-form-item label="身份"></u-form-item> -->
- <u-form-item label="户籍">
- <pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
- <view class="picker">{{ form.houseProvince }} {{ form.houseCity }} {{ form.houseDistrict }}</view>
- </pick-regions>
- </u-form-item>
- <u-form-item label="婚姻状况" prop="marry" :label-width="auto">
- <picker @change="bindPickerChangeMarry" :value="form.marry" :range="array_marry">
- <view class="picker">{{ array_marry[form.marry] }}</view>
- </picker>
- </u-form-item>
- <u-form-item label="所在城市" :label-width="auto">
- <pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion2">
- <view class="picker">{{ form.province }} {{ form.city }} {{ form.district }}</view>
- </pick-regions>
- </u-form-item>
- <u-form-item label="政治面貌" :label-width="auto" prop="politic">
- <picker @change="bindPickerChangePolitic" :value="form.politic" :range="array_politic">
- <view class="picker">{{ array_politic[form.politic] }}</view>
- </picker>
- </u-form-item>
- <u-form-item label="一寸头像" prop="fileList" :label-width="auto" label-position="top">
- <u-upload
- :auto-upload="false"
- custom-btn="true"
- :action="action"
- :file-list="fileList"
- width="120"
- height="169"
- size-type="['compressed']"
- max-count="1"
- @on-list-change="changePhotoListHeader"
- >
- <template v-slot:addBtn>
- <image :src="form.oneInchPhotos ? $method.splitImgHost( form.oneInchPhotos) : '/static/info_1.png'" style="width: 120rpx; height: 169rpx;"></image>
- </template>
- </u-upload>
- </u-form-item>
- <!-- <u-form-item label="身份证人像面" :label-width="auto" label-position="top">
- <u-upload
- :auto-upload="false"
- custom-btn="true"
- :action="action"
- :file-list="fileList1"
- width="120"
- height="82"
- size-type="['compressed']"
- max-count="1"
- @on-list-change="changePhotoListZ"
- >
- <template v-slot:addBtn>
- <image src="/static/info_2.png" style="width: 120rpx; height: 82rpx;"></image>
- </template>
- </u-upload>
- </u-form-item>
- <u-form-item label="身份证国徽面" :label-width="auto" label-position="top">
- <u-upload
- :auto-upload="false"
- custom-btn="true"
- :action="action"
- :file-list="fileList2"
- width="120"
- height="82"
- size-type="['compressed']"
- max-count="1"
- @on-list-change="changePhotoListF"
- >
- <template v-slot:addBtn>
- <image src="/static/info_3.png" style="width: 120rpx; height: 82rpx;"></image>
- </template>
- </u-upload>
- </u-form-item> -->
- </u-form>
- </view>
- <button @click="resultForm" class="submit_btn">提交</button>
- </view>
- </template>
- <script>
- import {mapGetters} from 'vuex';
- export default {
- data() {
- return {
- isStatus: 'background-color:#a8a8a8;',
- BizToken: '',
- action: '33',
- fileList: [],
- defaultRegionCode: '440112',
- form: {
- realname: '',
- telphone: '',
- idCard: '',
- email: '',
- sex: 0,
- marry: 0,
- politic: 0,
- userBirth: '1990-01-01',
- houseProvince: '', //户籍省
- houseCity: '', //户籍市
- houseDistrict: '', //户籍区
- province: '', //城市省
- city: '', //市
- district: '', //区
- // region1: ['广东省', '广州市', '天河区'],
- // region2: ['广东省', '广州市', '天河区'],
- oneInchPhotos: ''
- },
- // index_sex: 0,
- array_sex: ['男', '女'],
- array_marry: ['未婚', '已婚'],
- array_politic: ['群众', '团员', '党员'],
- rules: {
- realname: [
- {
- required: true,
- message: '请输入姓名',
- trigger: ['blur', 'change']
- }
- ],
- telphone: [
- {
- required: true,
- message: '请输入手机号码',
- // 可以单个或者同时写两个触发验证方式
- trigger: 'blur'
- }
- ],
- idCard: [
- {
- required: true,
- message: '请输入身份证号码',
- // 可以单个或者同时写两个触发验证方式
- trigger: 'blur'
- }
- ],
- width: 0,
- height: 0
- }
- };
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- this.form = this.userInfo
-
- },
- onLoad(option) {
- const Verify = require('@/wxcomponents/verify_mpsdk/main.js');
- Verify.init();
-
- },
- methods: {
- getUserInfos() {
- this.$api.getInfo().then(res => {
- this.form = res.data.data;
- });
- },
- changePhotoListHeader(lists, name) {
- this.fileList = lists;
- },
- resultForm() {
- this.$refs.uForm.validate(valid => {
- if (valid) {
- this.submitForm();
- } else {
- console.log('验证失败');
- }
- });
- },
- iscertification() {},
- async certification() {
- var self = this;
- const faceBiz = await self.$api.faceBizToken();
- self.BizToken = faceBiz.data.data.bizToken;
- wx.startVerify({
- data: {
- token: self.BizToken
- },
- success: result => {
- setTimeout(() => {
- self.$api.facecertification(self.BizToken).then(faceRec => {
- //刷新用户信息
- self.$api.refreshUserInfo()
- });
- }, 500);
- },
- fail: err => {
- setTimeout(() => {
- uni.showModal({
- title: '提示',
- content: err,
- showCancel: false
- });
- }, 500);
- }
- });
- },
- imageInfos() {
- var self = this
- return new Promise((resolve, reject) => {
- uni.getImageInfo({
- src: self.fileList[0].url,
- success: async res => {
- let canvasWidth = res.width; //图片原始长宽
- let canvasHeight = res.height;
- if (canvasWidth > 1000 || canvasHeight > 1000) {
- uni.compressImage({
- src: self.fileList[0].url,
- quality: 75,
- width: '50%',
- height: '50%',
- success: async rest => {
- const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
- resolve()
- }
- });
- } else {
- console.log('无需压缩');
- const waitUpload = await self.uploadFile(self.fileList[0].url, 0);
- resolve()
- }
- }
- });
- });
- },
- async submitForm() {
- var self = this;
- if (this.fileList.length > 0) {
- const waitYS = await this.imageInfos();
- }
- var data = {
- userId: this.form.userId,
- email: this.form.email,
- houseProvince: this.form.houseProvince, //户籍省份
- idCard: this.form.idCard,
- houseCity: this.form.houseCity,
- houseDistrict: this.form.houseDistrict,
- province: this.form.province, //城市省份
- city: this.form.city, //城市
- district: this.form.district, //区
- realname: this.form.realname, //姓名
- sex: this.form.sex, //性别
- telphone: this.form.telphone, //手机号
- userBirth: this.form.userBirth, //出生日期
- marry: this.form.marry, //结婚状态
- politic: this.form.politic, //政治面貌
- oneInchPhotos: this.form.oneInchPhotos //一寸照
- };
- this.$api.appuserInfo(data).then(res => {
- if (res.data.code === 200) {
- uni.showToast({
- title: '提交成功',
- icon: 'none'
- });
- self.$api.refreshUserInfo()
- }
- });
- },
- uploadFile(options, int) {
- return new Promise((resolve, reject) => {
- var self = this;
- var data = {
- imageStatus: int
- };
- this.$api.aliyunpolicy(data).then(res => {
- console.log(res);
- var ossToken = res.data.data.resultContent;
- uni.uploadFile({
- url: ossToken.host,
- name: 'file',
- filePath: options,
- fileType: 'image',
- header: {
- AuthorizationToken: 'WX ' + uni.getStorageSync('token')
- },
- formData: {
- key: ossToken.dir,
- OSSAccessKeyId: ossToken.accessid,
- policy: ossToken.policy,
- Signature: ossToken.signature,
- callback: ossToken.callback,
- success_action_status: 200
- },
- success: result => {
- if (result.statusCode === 200) {
- self.form.oneInchPhotos = ossToken.dir;
- resolve();
- } else {
- uni.showToast({
- title: '一寸头像上传失败',
- icon: 'none'
- });
- return;
- }
- },
- fail: error => {
- uni.showToast({
- title: '上传接口报错',
- icon: 'none'
- });
- return;
- }
- });
- });
- });
- },
- bindPickerChangeSex(e) {
- this.form.sex = e.detail.value;
- },
- bindPickerChangePolitic(e) {
- this.form.politic = e.detail.value;
- },
- bindPickerChangeMarry(e) {
- this.form.marry = e.detail.value;
- },
- //城市
- handleGetRegion2(region) {
- this.form.province = region[0].name;
- this.form.city = region[1].name;
- this.form.district = region[2].name;
- },
- // 籍贯获取选择的地区
- handleGetRegion(region) {
- this.form.houseProvince = region[0].name;
- this.form.houseCity = region[1].name;
- this.form.houseDistrict = region[2].name;
- },
- bindDateChange(e) {
- console.log(e.detail.value);
- this.form.userBirth = e.detail.value;
- // var year = this.form.userBirth.substr(0, 4);
- // var month = this.userBirth.substr(5, 2);
- // var day = this.userBirth.substr(8, 2);
- },
- actionSheetCallback(index) {
- uni.hideKeyboard();
- this.form.sex_text = this.actionSheetList[index].text;
- }
- },
- computed: {...mapGetters(['userInfo'])},
- watch:{
- userInfo(val, oldVal){
- this.form = val
- }
- }
- };
- </script>
- <style scope>
- .submit_btn{
- background-color: #32467B !important;
- border-color: #32467B !important;
- color: #FFFFFF;
- font-size: 30rpx;
- padding: 5rpx;
- }
- .u-form-item__message.data-v-5e7216f1 {
- padding: 0px !important;
- }
- .picker {
- text-align: right;
- }
- input {
- text-align: right;
- }
- .form {
- background: #ffffff;
- box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
- border-radius: 32rpx;
- margin: 20rpx 0;
- padding: 15rpx;
- }
- .btn {
- width: 96rpx;
- height: 48rpx;
- background: #32467b;
- border-radius: 16rpx;
- font-size: 24rpx;
- color: #ffffff;
- line-height: 48rpx;
- text-align: center;
- }
- page {
- background: #fdfdfd;
- }
- .tip {
- width: 70%;
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #32467b;
- }
- </style>
|