info.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <view style="display: flex;align-items: center;justify-content: space-between;">
  4. <view class="tip">
  5. 请填写真实信息,以便我们后续为您提供完善的
  6. <br />
  7. 个人职业成长定制服务!
  8. </view>
  9. <view style="display: flex;align-items: center;">
  10. <view class="btn" style="margin-right: 5rpx;" :style="form.certified === 1 ? isStatus : ''" @click="form.certified === 0 ? certification() : iscertification()">
  11. {{ form.certified === 0 ? '认证' : '已认证' }}
  12. </view>
  13. <view class="btn">编辑</view>
  14. </view>
  15. </view>
  16. <view class="form">
  17. <u-form :model="form" ref="uForm">
  18. <u-form-item label="姓名" prop="realname"><u-input :disabled="form.certified === 1" v-model="userInfo.realname" /></u-form-item>
  19. <u-form-item label="手机号码" prop="telphone" :label-width="auto"><u-input :disabled="form.certified === 1" v-model="form.telphone" /></u-form-item>
  20. <u-form-item label="身份证号" prop="idCard" :label-width="auto"><u-input :disabled="form.certified === 1" v-model="form.idCard" /></u-form-item>
  21. <u-form-item label="性别" prop="sex">
  22. <picker @change="bindPickerChangeSex" :value="form.sex" :range="array_sex">
  23. <view class="picker">{{ array_sex[form.sex] }}</view>
  24. </picker>
  25. </u-form-item>
  26. <u-form-item label="邮箱" prop="email" :label-width="auto"><u-input v-model="form.email" /></u-form-item>
  27. <u-form-item label="出生日期" prop="userBirth" :label-width="auto">
  28. <picker mode="date" :value="form.userBirth" @change="bindDateChange">
  29. <view class="picker">{{ form.userBirth }}</view>
  30. </picker>
  31. </u-form-item>
  32. <!-- <u-form-item label="身份"></u-form-item> -->
  33. <u-form-item label="户籍">
  34. <pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
  35. <view class="picker">{{ form.houseProvince }} {{ form.houseCity }} {{ form.houseDistrict }}</view>
  36. </pick-regions>
  37. </u-form-item>
  38. <u-form-item label="婚姻状况" prop="marry" :label-width="auto">
  39. <picker @change="bindPickerChangeMarry" :value="form.marry" :range="array_marry">
  40. <view class="picker">{{ array_marry[form.marry] }}</view>
  41. </picker>
  42. </u-form-item>
  43. <u-form-item label="所在城市" :label-width="auto">
  44. <pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion2">
  45. <view class="picker">{{ form.province }} {{ form.city }} {{ form.district }}</view>
  46. </pick-regions>
  47. </u-form-item>
  48. <u-form-item label="政治面貌" :label-width="auto" prop="politic">
  49. <picker @change="bindPickerChangePolitic" :value="form.politic" :range="array_politic">
  50. <view class="picker">{{ array_politic[form.politic] }}</view>
  51. </picker>
  52. </u-form-item>
  53. <u-form-item label="一寸头像" prop="fileList" :label-width="auto" label-position="top">
  54. <u-upload
  55. :auto-upload="false"
  56. custom-btn="true"
  57. :action="action"
  58. :file-list="fileList"
  59. width="120"
  60. height="169"
  61. size-type="['compressed']"
  62. max-count="1"
  63. @on-list-change="changePhotoListHeader"
  64. >
  65. <template v-slot:addBtn>
  66. <image :src="form.oneInchPhotos ? $method.splitImgHost( form.oneInchPhotos) : '/static/info_1.png'" style="width: 120rpx; height: 169rpx;"></image>
  67. </template>
  68. </u-upload>
  69. </u-form-item>
  70. <!-- <u-form-item label="身份证人像面" :label-width="auto" label-position="top">
  71. <u-upload
  72. :auto-upload="false"
  73. custom-btn="true"
  74. :action="action"
  75. :file-list="fileList1"
  76. width="120"
  77. height="82"
  78. size-type="['compressed']"
  79. max-count="1"
  80. @on-list-change="changePhotoListZ"
  81. >
  82. <template v-slot:addBtn>
  83. <image src="/static/info_2.png" style="width: 120rpx; height: 82rpx;"></image>
  84. </template>
  85. </u-upload>
  86. </u-form-item>
  87. <u-form-item label="身份证国徽面" :label-width="auto" label-position="top">
  88. <u-upload
  89. :auto-upload="false"
  90. custom-btn="true"
  91. :action="action"
  92. :file-list="fileList2"
  93. width="120"
  94. height="82"
  95. size-type="['compressed']"
  96. max-count="1"
  97. @on-list-change="changePhotoListF"
  98. >
  99. <template v-slot:addBtn>
  100. <image src="/static/info_3.png" style="width: 120rpx; height: 82rpx;"></image>
  101. </template>
  102. </u-upload>
  103. </u-form-item> -->
  104. </u-form>
  105. </view>
  106. <button @click="resultForm" class="submit_btn">提交</button>
  107. </view>
  108. </template>
  109. <script>
  110. import {mapGetters} from 'vuex';
  111. export default {
  112. data() {
  113. return {
  114. isStatus: 'background-color:#a8a8a8;',
  115. BizToken: '',
  116. action: '33',
  117. fileList: [],
  118. defaultRegionCode: '440112',
  119. form: {
  120. realname: '',
  121. telphone: '',
  122. idCard: '',
  123. email: '',
  124. sex: 0,
  125. marry: 0,
  126. politic: 0,
  127. userBirth: '1990-01-01',
  128. houseProvince: '', //户籍省
  129. houseCity: '', //户籍市
  130. houseDistrict: '', //户籍区
  131. province: '', //城市省
  132. city: '', //市
  133. district: '', //区
  134. // region1: ['广东省', '广州市', '天河区'],
  135. // region2: ['广东省', '广州市', '天河区'],
  136. oneInchPhotos: ''
  137. },
  138. // index_sex: 0,
  139. array_sex: ['男', '女'],
  140. array_marry: ['未婚', '已婚'],
  141. array_politic: ['群众', '团员', '党员'],
  142. rules: {
  143. realname: [
  144. {
  145. required: true,
  146. message: '请输入姓名',
  147. trigger: ['blur', 'change']
  148. }
  149. ],
  150. telphone: [
  151. {
  152. required: true,
  153. message: '请输入手机号码',
  154. // 可以单个或者同时写两个触发验证方式
  155. trigger: 'blur'
  156. }
  157. ],
  158. idCard: [
  159. {
  160. required: true,
  161. message: '请输入身份证号码',
  162. // 可以单个或者同时写两个触发验证方式
  163. trigger: 'blur'
  164. }
  165. ],
  166. width: 0,
  167. height: 0,
  168. }
  169. };
  170. },
  171. onReady() {
  172. this.$refs.uForm.setRules(this.rules);
  173. if(this.form.houseProvince === ''){
  174. this.form.houseProvince = '广东省'
  175. }
  176. if(this.form.houseCity === ''){
  177. this.form.houseCity = '广州市'
  178. }
  179. if(this.form.houseDistrict === ''){
  180. this.form.houseDistrict = '天河区'
  181. }
  182. if(this.form.province === ''){
  183. this.form.province = '广东省'
  184. }
  185. if(this.form.city === ''){
  186. this.form.city = '广州市'
  187. }
  188. if(this.form.district === ''){
  189. this.form.district = '天河区'
  190. }
  191. },
  192. onLoad(option) {
  193. const Verify = require('@/wxcomponents/verify_mpsdk/main.js');
  194. Verify.init();
  195. },
  196. methods: {
  197. // getUserInfos() {
  198. // this.$api.getInfo().then(res => {
  199. // this.form = res.data.data;
  200. // });
  201. // },
  202. changePhotoListHeader(lists, name) {
  203. this.fileList = lists;
  204. },
  205. resultForm() {
  206. this.$refs.uForm.validate(valid => {
  207. if (valid) {
  208. this.submitForm();
  209. } else {
  210. console.log('验证失败');
  211. }
  212. });
  213. },
  214. iscertification() {},
  215. async certification() {
  216. var self = this;
  217. const faceBiz = await self.$api.faceBizToken();
  218. self.BizToken = faceBiz.data.data.bizToken;
  219. wx.startVerify({
  220. data: {
  221. token: self.BizToken
  222. },
  223. success: result => {
  224. setTimeout(() => {
  225. self.$api.facecertification(self.BizToken).then(faceRec => {
  226. //刷新用户信息
  227. self.$api.refreshUserInfo()
  228. });
  229. }, 500);
  230. },
  231. fail: err => {
  232. setTimeout(() => {
  233. uni.showModal({
  234. title: '提示',
  235. content: err,
  236. showCancel: false
  237. });
  238. }, 500);
  239. }
  240. });
  241. },
  242. imageInfos() {
  243. var self = this
  244. return new Promise((resolve, reject) => {
  245. uni.getImageInfo({
  246. src: self.fileList[0].url,
  247. success: async res => {
  248. let canvasWidth = res.width; //图片原始长宽
  249. let canvasHeight = res.height;
  250. if (canvasWidth > 1000 || canvasHeight > 1000) {
  251. uni.compressImage({
  252. src: self.fileList[0].url,
  253. quality: 75,
  254. width: '50%',
  255. height: '50%',
  256. success: async rest => {
  257. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  258. resolve()
  259. }
  260. });
  261. } else {
  262. console.log('无需压缩');
  263. const waitUpload = await self.uploadFile(self.fileList[0].url, 0);
  264. resolve()
  265. }
  266. }
  267. });
  268. });
  269. },
  270. async submitForm() {
  271. var self = this;
  272. if (this.fileList.length > 0) {
  273. const waitYS = await this.imageInfos();
  274. }
  275. var data = {
  276. userId: this.form.userId,
  277. email: this.form.email,
  278. houseProvince: this.form.houseProvince, //户籍省份
  279. idCard: this.form.idCard,
  280. houseCity: this.form.houseCity,
  281. houseDistrict: this.form.houseDistrict,
  282. province: this.form.province, //城市省份
  283. city: this.form.city, //城市
  284. district: this.form.district, //区
  285. realname: this.form.realname, //姓名
  286. sex: this.form.sex, //性别
  287. telphone: this.form.telphone, //手机号
  288. userBirth: this.form.userBirth, //出生日期
  289. marry: this.form.marry, //结婚状态
  290. politic: this.form.politic, //政治面貌
  291. oneInchPhotos: this.form.oneInchPhotos //一寸照
  292. };
  293. this.$api.appuserInfo(data).then(res => {
  294. if (res.data.code === 200) {
  295. uni.showToast({
  296. title: '提交成功',
  297. icon: 'none'
  298. });
  299. self.$api.refreshUserInfo()
  300. }
  301. });
  302. },
  303. uploadFile(options, int) {
  304. return new Promise((resolve, reject) => {
  305. var self = this;
  306. var data = {
  307. imageStatus: int
  308. };
  309. this.$api.aliyunpolicy(data).then(res => {
  310. console.log(res);
  311. var ossToken = res.data.data.resultContent;
  312. uni.uploadFile({
  313. url: ossToken.host,
  314. name: 'file',
  315. filePath: options,
  316. fileType: 'image',
  317. header: {
  318. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  319. },
  320. formData: {
  321. key: ossToken.dir,
  322. OSSAccessKeyId: ossToken.accessid,
  323. policy: ossToken.policy,
  324. Signature: ossToken.signature,
  325. callback: ossToken.callback,
  326. success_action_status: 200
  327. },
  328. success: result => {
  329. if (result.statusCode === 200) {
  330. self.form.oneInchPhotos = ossToken.dir;
  331. resolve();
  332. } else {
  333. uni.showToast({
  334. title: '一寸头像上传失败',
  335. icon: 'none'
  336. });
  337. return;
  338. }
  339. },
  340. fail: error => {
  341. uni.showToast({
  342. title: '上传接口报错',
  343. icon: 'none'
  344. });
  345. return;
  346. }
  347. });
  348. });
  349. });
  350. },
  351. bindPickerChangeSex(e) {
  352. this.form.sex = e.detail.value;
  353. },
  354. bindPickerChangePolitic(e) {
  355. this.form.politic = e.detail.value;
  356. },
  357. bindPickerChangeMarry(e) {
  358. this.form.marry = e.detail.value;
  359. },
  360. //城市
  361. handleGetRegion2(region) {
  362. this.form.province = region[0].name;
  363. this.form.city = region[1].name;
  364. this.form.district = region[2].name;
  365. },
  366. // 籍贯获取选择的地区
  367. handleGetRegion(region) {
  368. console.log(region)
  369. this.form.houseProvince = region[0].name;
  370. this.form.houseCity = region[1].name;
  371. this.form.houseDistrict = region[2].name;
  372. },
  373. bindDateChange(e) {
  374. console.log(e.detail.value);
  375. this.form.userBirth = e.detail.value;
  376. // var year = this.form.userBirth.substr(0, 4);
  377. // var month = this.userBirth.substr(5, 2);
  378. // var day = this.userBirth.substr(8, 2);
  379. },
  380. actionSheetCallback(index) {
  381. uni.hideKeyboard();
  382. this.form.sex_text = this.actionSheetList[index].text;
  383. }
  384. },
  385. computed: {...mapGetters(['userInfo'])},
  386. watch:{
  387. userInfo(val, oldVal){
  388. this.form = val
  389. }
  390. }
  391. };
  392. </script>
  393. <style scope>
  394. .submit_btn{
  395. background-color: #32467B !important;
  396. border-color: #32467B !important;
  397. color: #FFFFFF;
  398. font-size: 30rpx;
  399. padding: 5rpx;
  400. }
  401. .u-form-item__message.data-v-5e7216f1 {
  402. padding: 0px !important;
  403. }
  404. .picker {
  405. text-align: right;
  406. }
  407. input {
  408. text-align: right;
  409. }
  410. .form {
  411. background: #ffffff;
  412. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  413. border-radius: 32rpx;
  414. margin: 20rpx 0;
  415. padding: 15rpx;
  416. }
  417. .btn {
  418. width: 96rpx;
  419. height: 48rpx;
  420. background: #32467b;
  421. border-radius: 16rpx;
  422. font-size: 24rpx;
  423. color: #ffffff;
  424. line-height: 48rpx;
  425. text-align: center;
  426. }
  427. page {
  428. background: #fdfdfd;
  429. }
  430. .tip {
  431. width: 70%;
  432. font-size: 20rpx;
  433. font-family: PingFang SC;
  434. font-weight: 400;
  435. color: #32467b;
  436. }
  437. </style>