info.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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="form.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. <u-button type="success" @click="resultForm">提交</u-button>
  107. </view>
  108. </template>
  109. <script>
  110. export default {
  111. data() {
  112. return {
  113. isStatus: 'background-color:#a8a8a8;',
  114. BizToken: '',
  115. action: '33',
  116. fileList: [],
  117. defaultRegionCode: '440112',
  118. form: {
  119. realname: '',
  120. telphone: '',
  121. idCard: '',
  122. email: '',
  123. sex: 0,
  124. marry: 0,
  125. politic: 0,
  126. userBirth: '1990-01-01',
  127. houseProvince: '', //户籍省
  128. houseCity: '', //户籍市
  129. houseDistrict: '', //户籍区
  130. province: '', //城市省
  131. city: '', //市
  132. district: '', //区
  133. // region1: ['广东省', '广州市', '天河区'],
  134. // region2: ['广东省', '广州市', '天河区'],
  135. oneInchPhotos: ''
  136. },
  137. // index_sex: 0,
  138. array_sex: ['男', '女'],
  139. array_marry: ['未婚', '已婚'],
  140. array_politic: ['群众', '团员', '党员'],
  141. rules: {
  142. realname: [
  143. {
  144. required: true,
  145. message: '请输入姓名',
  146. trigger: ['blur', 'change']
  147. }
  148. ],
  149. telphone: [
  150. {
  151. required: true,
  152. message: '请输入手机号码',
  153. // 可以单个或者同时写两个触发验证方式
  154. trigger: 'blur'
  155. }
  156. ],
  157. idCard: [
  158. {
  159. required: true,
  160. message: '请输入身份证号码',
  161. // 可以单个或者同时写两个触发验证方式
  162. trigger: 'blur'
  163. }
  164. ],
  165. width: 0,
  166. height: 0
  167. }
  168. };
  169. },
  170. onReady() {
  171. this.$refs.uForm.setRules(this.rules);
  172. },
  173. onLoad(option) {
  174. const Verify = require('@/wxcomponents/verify_mpsdk/main.js');
  175. Verify.init();
  176. this.getUserInfos();
  177. },
  178. methods: {
  179. getUserInfos() {
  180. this.$api.getInfo().then(res => {
  181. this.form = res.data.data;
  182. });
  183. },
  184. changePhotoListHeader(lists, name) {
  185. this.fileList = lists;
  186. },
  187. resultForm() {
  188. this.$refs.uForm.validate(valid => {
  189. if (valid) {
  190. this.submitForm();
  191. } else {
  192. console.log('验证失败');
  193. }
  194. });
  195. },
  196. iscertification() {},
  197. async certification() {
  198. var self = this;
  199. const faceBiz = await self.$api.faceBizToken();
  200. self.BizToken = faceBiz.data.data.bizToken;
  201. wx.startVerify({
  202. data: {
  203. token: self.BizToken
  204. },
  205. success: result => {
  206. setTimeout(() => {
  207. self.getUserInfos();
  208. }, 500);
  209. },
  210. fail: err => {
  211. setTimeout(() => {
  212. uni.showModal({
  213. title: '提示',
  214. content: err,
  215. showCancel: false
  216. });
  217. }, 500);
  218. }
  219. });
  220. },
  221. imageInfos() {
  222. var self = this
  223. return new Promise((resolve, reject) => {
  224. uni.getImageInfo({
  225. src: self.fileList[0].url,
  226. success: async res => {
  227. let canvasWidth = res.width; //图片原始长宽
  228. let canvasHeight = res.height;
  229. if (canvasWidth > 1000 || canvasHeight > 1000) {
  230. uni.compressImage({
  231. src: self.fileList[0].url,
  232. quality: 75,
  233. width: '50%',
  234. height: '50%',
  235. success: async rest => {
  236. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  237. resolve()
  238. }
  239. });
  240. } else {
  241. console.log('无需压缩');
  242. const waitUpload = await self.uploadFile(self.fileList[0].url, 0);
  243. resolve()
  244. }
  245. }
  246. });
  247. });
  248. },
  249. async submitForm() {
  250. var self = this;
  251. if (this.fileList.length > 0) {
  252. const waitYS = await this.imageInfos();
  253. }
  254. var data = {
  255. userId: this.form.userId,
  256. email: this.form.email,
  257. houseProvince: this.form.houseProvince, //户籍省份
  258. idCard: this.form.idCard,
  259. houseCity: this.form.houseCity,
  260. houseDistrict: this.form.houseDistrict,
  261. province: this.form.province, //城市省份
  262. city: this.form.city, //城市
  263. district: this.form.district, //区
  264. realname: this.form.realname, //姓名
  265. sex: this.form.sex, //性别
  266. telphone: this.form.telphone, //手机号
  267. userBirth: this.form.userBirth, //出生日期
  268. marry: this.form.marry, //结婚状态
  269. politic: this.form.politic, //政治面貌
  270. oneInchPhotos: this.form.oneInchPhotos //一寸照
  271. };
  272. this.$api.appuserInfo(data).then(res => {
  273. if (res.data.code === 200) {
  274. uni.showToast({
  275. title: '提交成功',
  276. icon: 'none'
  277. });
  278. self.getUserInfos();
  279. }
  280. });
  281. },
  282. uploadFile(options, int) {
  283. return new Promise((resolve, reject) => {
  284. var self = this;
  285. var data = {
  286. imageStatus: int
  287. };
  288. this.$api.aliyunpolicy(data).then(res => {
  289. console.log(res);
  290. var ossToken = res.data.data.resultContent;
  291. uni.uploadFile({
  292. url: ossToken.host,
  293. name: 'file',
  294. filePath: options,
  295. fileType: 'image',
  296. header: {
  297. AuthorizationToken: 'WX ' + self.$store.state.token
  298. },
  299. formData: {
  300. key: ossToken.dir,
  301. OSSAccessKeyId: ossToken.accessid,
  302. policy: ossToken.policy,
  303. Signature: ossToken.signature,
  304. callback: ossToken.callback,
  305. success_action_status: 200
  306. },
  307. success: result => {
  308. if (result.statusCode === 200) {
  309. self.form.oneInchPhotos = ossToken.dir;
  310. resolve();
  311. } else {
  312. uni.showToast({
  313. title: '一寸头像上传失败',
  314. icon: 'none'
  315. });
  316. return;
  317. }
  318. },
  319. fail: error => {
  320. uni.showToast({
  321. title: '上传接口报错',
  322. icon: 'none'
  323. });
  324. return;
  325. }
  326. });
  327. });
  328. });
  329. },
  330. bindPickerChangeSex(e) {
  331. this.form.sex = e.detail.value;
  332. },
  333. bindPickerChangePolitic(e) {
  334. this.form.politic = e.detail.value;
  335. },
  336. bindPickerChangeMarry(e) {
  337. this.form.marry = e.detail.value;
  338. },
  339. //城市
  340. handleGetRegion2(region) {
  341. this.form.province = region[0].name;
  342. this.form.city = region[1].name;
  343. this.form.district = region[2].name;
  344. },
  345. // 籍贯获取选择的地区
  346. handleGetRegion(region) {
  347. this.form.houseProvince = region[0].name;
  348. this.form.houseCity = region[1].name;
  349. this.form.houseDistrict = region[2].name;
  350. },
  351. bindDateChange(e) {
  352. console.log(e.detail.value);
  353. this.form.userBirth = e.detail.value;
  354. // var year = this.form.userBirth.substr(0, 4);
  355. // var month = this.userBirth.substr(5, 2);
  356. // var day = this.userBirth.substr(8, 2);
  357. },
  358. actionSheetCallback(index) {
  359. uni.hideKeyboard();
  360. this.form.sex_text = this.actionSheetList[index].text;
  361. }
  362. }
  363. };
  364. </script>
  365. <style scope>
  366. .u-form-item__message.data-v-5e7216f1 {
  367. padding: 0px !important;
  368. }
  369. .picker {
  370. text-align: right;
  371. }
  372. input {
  373. text-align: right;
  374. }
  375. .form {
  376. background: #ffffff;
  377. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  378. border-radius: 32rpx;
  379. margin: 20rpx 0;
  380. padding: 15rpx;
  381. }
  382. .btn {
  383. width: 96rpx;
  384. height: 48rpx;
  385. background: #32467b;
  386. border-radius: 16rpx;
  387. font-size: 24rpx;
  388. color: #ffffff;
  389. line-height: 48rpx;
  390. text-align: center;
  391. }
  392. page {
  393. background: #fdfdfd;
  394. }
  395. .tip {
  396. width: 70%;
  397. font-size: 20rpx;
  398. font-family: PingFang SC;
  399. font-weight: 400;
  400. color: #32467b;
  401. }
  402. </style>