info.vue 10 KB

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