hehuo.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view>
  3. <view class="hehuo_view">
  4. <image class="background_image" src="/static/image/high_zmjs.png"></image>
  5. <view class="text_view">
  6. <view class="item_view">
  7. <view class="item_title">服务城市 </view>
  8. <input @click="goCity" type="text" v-model="city" placeholder="请输入服务城市 " />
  9. <view class="xian"></view>
  10. </view>
  11. <view class="item_view">
  12. <view class="item_title">姓名</view>
  13. <input type="text" v-model="userName" placeholder="请输入姓名" />
  14. <view class="xian"></view>
  15. </view>
  16. <view class="item_view">
  17. <view class="item_title">联系电话</view>
  18. <input type="number" v-model="phone" maxlength="11" placeholder="请输入联系电话" />
  19. <view class="xian"></view>
  20. </view>
  21. <view class="item_view">
  22. <view class="item_title">年龄</view>
  23. <input type="number" v-model="age" maxlength="11" placeholder="请输入年龄" />
  24. <view class="xian"></view>
  25. </view>
  26. <view class="item_view">
  27. <view class="item_title">地址</view>
  28. <input type="text" v-model="address" placeholder="请输入地址" />
  29. <view class="xian"></view>
  30. </view>
  31. <view class="item_view">
  32. <view class="item_title">身份证号码</view>
  33. <input type="text" v-model="idNumber" placeholder="请输入身份证号码" />
  34. <view class="xian"></view>
  35. </view>
  36. <view class="item_view" @click="openBirthdatePicker">
  37. <view class="item_title">出生日期</view>
  38. <input type="text" v-model="birthdate" placeholder="请选择出生日期" disabled />
  39. <view class="xian"></view>
  40. </view>
  41. <view class="item_view" @click="openSexPicker">
  42. <view class="item_title">性别</view>
  43. <input type="text" v-model="sexText" placeholder="请选择性别" disabled />
  44. <view class="xian"></view>
  45. </view>
  46. <view class="flex justify-between">
  47. <view class="item_view">
  48. <view class="item_title">头像上传</view>
  49. <view class="flex" style="overflow: hidden;flex-direction: initial;">
  50. <view v-if="headImg.length">
  51. <view class="margin-top flex margin-right-sm">
  52. <view class="flex"
  53. style="width: 150upx;height: 150upx;margin-right: 10rpx;position: relative;">
  54. <image :src="headImg" style="width: 100%;height: 100%;"></image>
  55. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  56. @click="headImgremove(index)">
  57. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="margin-top" @click="addImage('head')" v-if="headImg.length<=0">
  63. <view style="width: 150upx;height: 150upx;background: #F5F5F5;"
  64. class="flex justify-center align-center">
  65. <view>
  66. <view class="text-center">
  67. <image src="../../static/images/my/add.png"
  68. style="width: 54upx;height: 47upx;position: relative;">
  69. </image>
  70. </view>
  71. <view class="text-center text-xs margin-top-xs">上传图片</view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="item_view">
  78. <view class="item_title">身份证正面</view>
  79. <view class="flex" style="overflow: hidden;flex-direction: initial;">
  80. <view v-if="front.length">
  81. <view class="margin-top flex margin-right-sm">
  82. <view class="flex"
  83. style="width: 150upx;height: 150upx;margin-right: 10rpx;position: relative;">
  84. <image :src="front" style="width: 100%;height: 100%;"></image>
  85. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  86. @click="frontRemove">
  87. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="margin-top" @click="addImage('front')" v-if="front.length<=0">
  93. <view style="width: 150upx;height: 150upx;background: #F5F5F5;"
  94. class="flex justify-center align-center">
  95. <view>
  96. <view class="text-center">
  97. <image src="../../static/images/my/add.png"
  98. style="width: 54upx;height: 47upx;position: relative;"></image>
  99. </view>
  100. <view class="text-center text-xs margin-top-xs">上传图片</view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="item_view">
  107. <view class="item_title">身份证反面</view>
  108. <view class="flex" style="overflow: hidden;flex-direction: initial;">
  109. <view v-if="back.length">
  110. <view class="margin-top flex margin-right-sm">
  111. <view class="flex"
  112. style="width: 150upx;height: 150upx;margin-right: 10rpx;position: relative;">
  113. <image :src="back" style="width: 100%;height: 100%;"></image>
  114. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  115. @click="backRemove">
  116. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="margin-top" @click="addImage('back')" v-if="back.length<=0">
  122. <view style="width: 150upx;height: 150upx;background: #F5F5F5;"
  123. class="flex justify-center align-center">
  124. <view>
  125. <view class="text-center">
  126. <image src="../../static/images/my/add.png"
  127. style="width: 54upx;height: 47upx;position: relative;"></image>
  128. </view>
  129. <view class="text-center text-xs margin-top-xs">上传图片</view>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <!-- <view class="audit_message" v-if="auditContent != '' && bb == 3">拒绝原因:{{auditContent}}</view> -->
  137. <view class="save_btn" @tap="save" v-if="bb !=0">提交申请</view>
  138. <!-- <view class="save_btn" v-if="status == 0">审核中</view> -->
  139. </view>
  140. </view>
  141. <u-action-sheet :list="sexOptions" v-model="showSex" @click="handleSexSelect"></u-action-sheet>
  142. <u-picker v-model="showBirthdate" :params="dateParams" @confirm="handleBirthdateConfirm"></u-picker>
  143. </view>
  144. </template>
  145. <script>
  146. import configdata from '../../common/config.js';
  147. export default {
  148. data() {
  149. return {
  150. hotCitys: ['杭州', '天津', '北京', '上海', '深圳', '广州', '成都', '重庆', '厦门'],
  151. locationValue: '正在定位...',
  152. // auditContent: '',
  153. city: '',
  154. money: '',
  155. teamNumber: '',
  156. userName: '',
  157. phone: '',
  158. age: '',
  159. address: '',
  160. idNumber: '',
  161. birthdate: '',
  162. sex: '',
  163. sexText: '',
  164. front: '',
  165. back: '',
  166. showSex: false,
  167. sexOptions: [{
  168. text: '男'
  169. }, {
  170. text: '女'
  171. }],
  172. showBirthdate: false,
  173. dateParams: {
  174. year: true,
  175. month: true,
  176. day: true,
  177. hour: false,
  178. minute: false,
  179. second: false
  180. },
  181. headImg: [],
  182. bb: true,
  183. }
  184. },
  185. onLoad() {
  186. this.getChannel();
  187. },
  188. methods: {
  189. // 本人近期照删除
  190. headImgremove(index) {
  191. this.headImg = ''
  192. },
  193. // 身份证正面删除
  194. frontRemove() {
  195. this.front = ''
  196. },
  197. // 身份证反面删除
  198. backRemove() {
  199. this.back = ''
  200. },
  201. openBirthdatePicker() {
  202. this.showBirthdate = true
  203. },
  204. handleBirthdateConfirm(value) {
  205. this.birthdate = value.year + '-' + value.month + '-' + value.day
  206. },
  207. openSexPicker() {
  208. this.showSex = true
  209. },
  210. handleSexSelect(index) {
  211. this.sex = index
  212. this.sexText = this.sexOptions[index].text
  213. },
  214. getChannel() {
  215. let userId = this.$queue.getData('userId');
  216. this.$Request.getT('/app/artificer/selectAgencyById?userId=' + userId).then(res => {
  217. if (res.code == 0) {
  218. if (res.data == null) {
  219. this.bb = 1;
  220. } else {
  221. this.bb = res.data.status;
  222. this.city = res.data.city;
  223. this.age = res.data.age;
  224. this.headImg = res.data.img;
  225. this.userName = res.data.name;
  226. this.phone = res.data.phone;
  227. // this.userCertification = res.data.userCertification
  228. this.sex = res.data.userCertification.sex
  229. this.back = res.data.userCertification.back? res.data.userCertification.back:''
  230. this.front = res.data.userCertification.front ? res.data.userCertification.front:''
  231. this.idNumber = res.data.userCertification.idNumber
  232. this.birthdate = res.data.userCertification.birthdate
  233. this.address = res.data.userCertification.address
  234. this.sexText = res.data.userCertification.sex==0?'男':'女'
  235. }
  236. console.log(this.bb)
  237. // this.auditContent = res.data.auditContent;
  238. }
  239. });
  240. },
  241. //获取省市区
  242. Getcity(latitude, longitude) {
  243. this.$Request.get("/app/Login/selectCity", {
  244. lat: latitude,
  245. lng: longitude
  246. }).then(res => {
  247. console.log(res)
  248. this.city = res.data.city
  249. console.log(this.address)
  250. });
  251. },
  252. goCity() {
  253. let that = this
  254. uni.chooseLocation({
  255. success: function(res) {
  256. console.log('位置名称:' + res.name);
  257. console.log('详细地址:' + res.address);
  258. console.log('纬度:' + res.latitude);
  259. console.log('经度:' + res.longitude);
  260. // that.city = res.address || '郑州'
  261. that.Getcity(res.latitude, res.longitude)
  262. }
  263. });
  264. // uni.getLocation({
  265. // type: 'wgs84',
  266. // geocode: true,
  267. // success: function(res) {
  268. // console.log('当前位置:' + res.address.city);
  269. // that.city = res.address.city || '郑州'
  270. // }
  271. // });
  272. },
  273. save() {
  274. // let isStudent = this.$queue.getData("isStudent");
  275. // if (isStudent != 2) {
  276. // uni.showModal({
  277. // title: '温馨提示',
  278. // content: '您还没有进行实名认证,请认证完成之后再来操作吧!',
  279. // showCancel: true,
  280. // cancelText: '取消',
  281. // confirmText: '确认',
  282. // success: res => {
  283. // if (res.confirm) {
  284. // uni.navigateTo({
  285. // url: '/offlinetask/pages/public/authentication'
  286. // });
  287. // }
  288. // }
  289. // });
  290. // return;
  291. // }
  292. // this.form.headImg = this.headImg
  293. // this.headImg = this.headImg.toString();
  294. if (this.city === '') {
  295. this.$queue.showToast('请输入服务城市 ')
  296. return;
  297. }
  298. if (this.userName === '') {
  299. this.$queue.showToast('请输入姓名')
  300. return;
  301. }
  302. if (this.phone === '' || this.phone.length != 11) {
  303. this.$queue.showToast('请输入正确的手机号!')
  304. return;
  305. }
  306. if (this.age === '') {
  307. this.$queue.showToast('请输入年龄')
  308. return;
  309. }
  310. if (this.headImg == '') {
  311. this.$queue.showToast('请上传头像')
  312. return;
  313. }
  314. if (this.address === '') {
  315. this.$queue.showToast('请输入地址')
  316. return;
  317. }
  318. if (this.idNumber === '') {
  319. this.$queue.showToast('请输入身份证号码')
  320. return;
  321. }
  322. let idNumberReg =
  323. /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  324. if (!idNumberReg.test(this.idNumber)) {
  325. this.$queue.showToast('请输入正确的身份证号码')
  326. return;
  327. }
  328. if (this.birthdate === '') {
  329. this.$queue.showToast('请选择出生日期')
  330. return;
  331. }
  332. if (this.sex === '') {
  333. this.$queue.showToast('请选择性别')
  334. return;
  335. }
  336. if (this.front === '') {
  337. this.$queue.showToast('请上传身份证正面')
  338. return;
  339. }
  340. if (this.back === '') {
  341. this.$queue.showToast('请上传身份证反面')
  342. return;
  343. }
  344. let userId = this.$queue.getData('userId');
  345. let agencyData = {
  346. userId: userId,
  347. name: this.userName,
  348. phone: this.phone,
  349. age: this.age,
  350. city: this.city,
  351. img: this.headImg,
  352. }
  353. this.$Request.postJson('/app/artificer/insertAgency', agencyData).then(res => {
  354. if (res.code == 0) {
  355. let certificationBody = {
  356. back: this.back,
  357. front: this.front,
  358. idNumber: this.idNumber,
  359. name: this.userName,
  360. userId: userId
  361. }
  362. let certificationQuery = [
  363. ['address', this.address],
  364. ['birthdate', this.birthdate],
  365. ['classify', 1],
  366. ['phone', this.phone],
  367. ['sex', this.sex],
  368. ['back',this.back],
  369. ['front',this.front],
  370. ['idNumber',this.idNumber],
  371. ['userName',this.userName],
  372. ['userId',this.userId],
  373. ].map(item => item[0] + '=' + encodeURIComponent(item[1])).join('&')
  374. let certificationUrl = '/app/userCertification/insert?' + certificationQuery
  375. this.$Request.postJson(certificationUrl, certificationBody).then(certificationRes => {
  376. uni.hideLoading()
  377. if (certificationRes.code == 0) {
  378. this.$queue.showToast('提交成功!')
  379. setTimeout(() => {
  380. uni.navigateBack()
  381. }, 1000)
  382. } else {
  383. this.$queue.showToast(certificationRes.msg || '实名认证提交失败')
  384. }
  385. }).catch(() => {
  386. uni.hideLoading()
  387. this.$queue.showToast('网络请求失败,请稍后重试')
  388. })
  389. } else {
  390. uni.hideLoading()
  391. this.$queue.showToast(res.msg || '提交申请失败')
  392. }
  393. }).catch(() => {
  394. uni.hideLoading()
  395. this.$queue.showToast('网络请求失败,请稍后重试')
  396. })
  397. },
  398. config: function(name) {
  399. var info = null;
  400. if (name) {
  401. var name2 = name.split("."); //字符分割
  402. if (name2.length > 1) {
  403. info = configdata[name2[0]][name2[1]] || null;
  404. } else {
  405. info = configdata[name] || null;
  406. }
  407. if (info == null) {
  408. let web_config = cache.get("web_config");
  409. if (web_config) {
  410. if (name2.length > 1) {
  411. info = web_config[name2[0]][name2[1]] || null;
  412. } else {
  413. info = web_config[name] || null;
  414. }
  415. }
  416. }
  417. }
  418. return info;
  419. },
  420. addImage(type) {
  421. let that = this
  422. uni.chooseImage({
  423. count: 1,
  424. sourceType: ['album', 'camera'],
  425. success: res => {
  426. for (let i = 0; i < 1; i++) {
  427. that.$queue.showLoading("上传中...");
  428. uni.uploadFile({ // 上传接口
  429. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  430. filePath: res.tempFilePaths[i],
  431. name: 'file',
  432. success: (uploadFileRes) => {
  433. try {
  434. let imageUrl = JSON.parse(uploadFileRes.data).data
  435. if (!imageUrl) {
  436. throw new Error('上传结果缺少图片地址')
  437. }
  438. if (type === 'front') {
  439. that.front = imageUrl
  440. } else if (type === 'back') {
  441. that.back = imageUrl
  442. } else {
  443. that.headImg = imageUrl
  444. }
  445. } catch (error) {
  446. that.$queue.showToast('图片上传失败')
  447. }
  448. uni.hideLoading()
  449. },
  450. fail: () => {
  451. uni.hideLoading()
  452. that.$queue.showToast('图片上传失败')
  453. }
  454. });
  455. }
  456. }
  457. })
  458. },
  459. }
  460. }
  461. </script>
  462. <style lang="less">
  463. @import '../../static/less/index.less';
  464. @import '../../static/css/index.css';
  465. .hehuo_view {
  466. width: 750rpx;
  467. height: 2900upx;
  468. .background_image {
  469. width: 750rpx;
  470. height: 2900upx;
  471. background-size: 100%;
  472. position: absolute;
  473. }
  474. .text_view {
  475. position: absolute;
  476. z-index: 1;
  477. width: 84%;
  478. margin: 1000rpx 50rpx 30rpx;
  479. .audit_message {
  480. color: red;
  481. width: 650rpx;
  482. height: 50rpx;
  483. margin-top: 50rpx;
  484. }
  485. .save_btn {
  486. width: 650rpx;
  487. height: 88rpx;
  488. background: #FFFFFF;
  489. border-radius: 10rpx;
  490. text-align: center;
  491. line-height: 88rpx;
  492. /* #ifdef MP-WEIXIN */
  493. margin-top: 150rpx;
  494. /* #endif */
  495. /* #ifdef H5 */
  496. margin-top: 100rpx;
  497. /* #endif */
  498. /* #ifdef APP-PLUS */
  499. margin-top: 180rpx;
  500. /* #endif */
  501. }
  502. .save_btn1 {
  503. width: 650rpx;
  504. height: 88rpx;
  505. background: #FFFFFF;
  506. border-radius: 10rpx;
  507. margin-top: 100rpx;
  508. text-align: center;
  509. line-height: 88rpx;
  510. }
  511. .item_view {
  512. margin-top: 30rpx;
  513. .item_title {
  514. font-size: 28rpx;
  515. font-family: PingFang SC Heavy, PingFang SC Heavy-Heavy;
  516. font-weight: 800;
  517. color: #333333;
  518. }
  519. input {
  520. margin-top: 20rpx;
  521. height: 40rpx;
  522. font-size: 24rpx;
  523. font-family: PingFang SC Regular, PingFang SC Regular-Regular;
  524. font-weight: 400;
  525. color: #333333;
  526. }
  527. .xian {
  528. width: 630rpx;
  529. height: 1rpx;
  530. border: 1rpx solid #77D7B0;
  531. margin-top: 10rpx;
  532. }
  533. }
  534. }
  535. }
  536. </style>