mymodel.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. <template>
  2. <view class="content ">
  3. <view class="item-name">
  4. 上传头像
  5. </view>
  6. <view class="con_box">
  7. <view class="con_image">
  8. <image class="img" @click="navCroper(400,400,'one')" :src="updata.avatar||`../../../static/image/upImg.png`">
  9. </image>
  10. </view>
  11. </view>
  12. <view class="item-name">
  13. 基本信息
  14. </view>
  15. <view class="listBox">
  16. <view class="list">
  17. <view class="flex listItem">
  18. <view class="flex titleBox">
  19. <text class="font-color-red font-size-sm">✲</text> <text class="title">真实姓名</text>
  20. </view>
  21. <view class="right flex">
  22. <input class="input" v-model="updata.name" type="text" placeholder="请填写真实姓名"
  23. placeholder-class="placeholder" />
  24. </view>
  25. </view>
  26. <view class="flex listItem">
  27. <view class="flex titleBox">
  28. <text class="font-color-red font-size-sm">✲</text><text class="title">手机号</text>
  29. </view>
  30. <view class="right flex">
  31. <input class="input" v-model="updata.phone" type="text" placeholder="请填写手机号"
  32. placeholder-class="placeholder" />
  33. </view>
  34. </view>
  35. <view class="flex listItem">
  36. <view class="flex titleBox">
  37. <text class="font-color-red font-size-sm">✲</text><text class="title">身份证号</text>
  38. </view>
  39. <view class="right flex">
  40. <input class="input" v-model="updata.cardId" type="text" placeholder="请填写身份证号"
  41. placeholder-class="placeholder" />
  42. </view>
  43. </view>
  44. <view class="flex listItem">
  45. <view class="flex titleBox">
  46. <text class="title">从业时长</text>
  47. </view>
  48. <view class="right flex">
  49. <input class="input" v-model="updata.work_year" type="number" placeholder="请填写从业时长"
  50. placeholder-class="placeholder" />
  51. </view>
  52. </view>
  53. <view class="flex listItem">
  54. <view class="flex titleBox">
  55. <text class="title">籍贯</text>
  56. </view>
  57. <view class="right flex">
  58. <input class="input" v-model="updata.ancestral_place" type="number" placeholder="请填写籍贯"
  59. placeholder-class="placeholder" />
  60. </view>
  61. </view>
  62. <view class="flex listItem">
  63. <view class="flex titleBox">
  64. <text class="title">学历</text>
  65. </view>
  66. <view class="right flex">
  67. <input class="input" v-model="updata.education" type="number" placeholder="请填写学历"
  68. placeholder-class="placeholder" />
  69. </view>
  70. </view>
  71. <view class="flex listItem">
  72. <view class="flex titleBox">
  73. <text class="title">民族</text>
  74. </view>
  75. <view class="right flex">
  76. <input class="input" v-model="updata.minority" type="number" placeholder="请填写民族"
  77. placeholder-class="placeholder" />
  78. </view>
  79. </view>
  80. <view class="flex listItem">
  81. <view class="flex titleBox">
  82. <text class="title">出生日期</text>
  83. </view>
  84. <view class="right flex">
  85. <picker class="input" value='2000-01-01' mode="date" @change="changetime">
  86. <view>
  87. {{updata.time||'请选择日期'}}
  88. </view>
  89. </picker>
  90. </view>
  91. </view>
  92. <view class="flex listItem">
  93. <view class="flex titleBox">
  94. <text class="font-color-red font-size-sm">✲</text><text class="title">职业</text>
  95. </view>
  96. <view class="right flex">
  97. <picker class="input" :range='workTypeList' range-key='title' mode="selector"
  98. @change="changeWorkType">
  99. <view>
  100. {{updata.word.title||'选择职业'}}
  101. </view>
  102. </picker>
  103. </view>
  104. </view>
  105. <view class="flex listItem">
  106. <view class="flex titleBox">
  107. <text class="font-color-red font-size-sm">✲</text><text class="title">收费类型</text>
  108. </view>
  109. <view class="right flex">
  110. <picker class="input" :range='timeTypeList' range-key='title' mode="selector"
  111. @change="changetimetype">
  112. <view>
  113. {{updata.timetype.title||'收费时间类型'}}
  114. </view>
  115. </picker>
  116. </view>
  117. </view>
  118. <view class="flex listItem">
  119. <view class="flex titleBox">
  120. <text class="font-color-red font-size-sm">✲</text><text class="title">最低价</text>
  121. </view>
  122. <view class="right flex">
  123. <input class="input" v-model="updata.minMoney" type="number" placeholder="请输入最低收费价"
  124. placeholder-class="placeholder" />
  125. </view>
  126. </view>
  127. <view class="flex listItem">
  128. <view class="flex titleBox">
  129. <text class="font-color-red font-size-sm">✲</text><text class="title">最高价</text>
  130. </view>
  131. <view class="right flex">
  132. <input class="input" v-model="updata.maxMoney" type="number" placeholder="请输入最高收费价"
  133. placeholder-class="placeholder" />
  134. </view>
  135. </view>
  136. <view class="flex listItem">
  137. <view class="flex titleBox">
  138. <text class="font-color-red font-size-sm">✲</text><text class="title">服务区域</text>
  139. </view>
  140. <view class="right">
  141. <view class="citylist">
  142. <view class="flex margin-b-20" v-for="(item,ind) in updata.onCity" :key="ind">
  143. <view></view>
  144. <view>
  145. {{item.province+item.city+item.district}}
  146. <text class="margin-l-10 del" @click="updata.onCity.splice(ind,1)">
  147. 删除
  148. </text>
  149. </view>
  150. </view>
  151. <view class="flex">
  152. <view></view>
  153. <pickerAddress class="buttom" @change="onCityClick">添加地区</pickerAddress>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. <view class="flex listItem">
  159. <view class="flex titleBox">
  160. <text class="font-color-red font-size-sm">✲</text><text class="title">服务内容</text>
  161. </view>
  162. <view class="right">
  163. <checkbox-group @change="checkTypeChange">
  164. <label class="flex timetype margin-b-10" v-for="(item,ind) in typeList" :key="item.id">
  165. <view class="margin-r-10">{{item.title}}</view>
  166. <view>
  167. <checkbox :value="`${item.id}`" :checked="item.checked" />
  168. </view>
  169. </label>
  170. </checkbox-group>
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. <view class="item-name">
  176. 自评
  177. </view>
  178. <view class="listBox">
  179. <view class="list">
  180. <view class="listItem">
  181. <textarea auto-height :maxlength='-1' v-model="updata.mymask" type="text" placeholder="请填写自评内容"
  182. placeholder-class="placeholder" />
  183. </view>
  184. </view>
  185. <view class="con_box">
  186. <view class="con_image" v-for="(item,ind) in updata.imageList">
  187. <image class="img" @click="navCroper(400,400,'tab',ind)"
  188. :src="item"></image>
  189. <image @click="updata.imageList.splice(ind,1)" class="tip" src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  190. </view>
  191. <view class="con_image">
  192. <image class="img" @click="navCroper(400,400,'all')"
  193. src="../../../static/image/upImg.png"></image>
  194. </view>
  195. </view>
  196. </view>
  197. <view class="item-name">
  198. 我的证书
  199. </view>
  200. <view class="listBox">
  201. <view class="con_box">
  202. <view class="con_image" v-for="(item,ind) in updata.service_audit_imgs">
  203. <image class="img" @click="navCroper(400,400,'audit',ind)"
  204. :src="item"></image>
  205. <image @click="updata.service_audit_imgs.splice(ind,1)" class="tip" src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  206. </view>
  207. <view class="con_image">
  208. <image class="img" @click="navCroper(400,400,'auditall')"
  209. src="../../../static/image/upImg.png"></image>
  210. </view>
  211. </view>
  212. </view>
  213. <view class="item-name">
  214. 服务展示
  215. </view>
  216. <view class="listBox">
  217. <view class="con_box">
  218. <view class="con_image" v-for="(item,ind) in updata.service_imgs">
  219. <image class="img" @click="navCroper(400,400,'service',ind)"
  220. :src="item"></image>
  221. <image @click="updata.service_imgs.splice(ind,1)" class="tip" src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  222. </view>
  223. <view class="con_image">
  224. <image class="img" @click="navCroper(400,400,'serviceall')"
  225. src="../../../static/image/upImg.png"></image>
  226. </view>
  227. </view>
  228. </view>
  229. <view class="base-buttom" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</view>
  230. </view>
  231. </template>
  232. <script>
  233. import {
  234. getServiceTimeTypeList,
  235. getServiceTypeList,
  236. subInfoAudit,
  237. getUserWorkTypeList
  238. } from '@/api/model.js';
  239. import {
  240. isCardNo
  241. } from '@/utils/rocessor.js';
  242. import {
  243. mapState
  244. } from "vuex"
  245. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  246. export default {
  247. components: {
  248. pickerAddress
  249. },
  250. data() {
  251. return {
  252. // 上传数据
  253. updata:{
  254. avatar: '', //用户头像
  255. name: '', //用户名称
  256. phone: '', //手机号
  257. cardId: '', //身份证号
  258. minMoney: '',//最低价
  259. maxMoney: '',//最高价
  260. checkedType: [], //选中的服务类型
  261. time: '', //出生日期
  262. timetype: {
  263. title: '',
  264. code:''
  265. }, //选中的时间类型
  266. onCity: [], //选中的城市
  267. mymask:'',//自评
  268. imageList: [], //自评上传图片列表
  269. ancestral_place:'',//籍贯
  270. education:'',//学历
  271. ancestral_place:'',//籍贯
  272. minority:'',//民族
  273. work_year:'',//从业时长
  274. word: {
  275. title: '',
  276. id:''
  277. },
  278. service_audit_imgs: [], //我的证书
  279. service_imgs: [], //服务展示
  280. },
  281. typeList: [], //服务类型
  282. timeTypeList: [], //时间类型
  283. workTypeList: [], //工作类型
  284. loding: false, //是否载入中
  285. };
  286. },
  287. onLoad(options) {
  288. this.init()
  289. },
  290. computed: {
  291. // #ifdef H5
  292. ...mapState(['urlFile']),
  293. // #endif
  294. ...mapState(['baseURL']),
  295. },
  296. methods: {
  297. // 初始化
  298. init() {
  299. const that = this;
  300. getServiceTimeTypeList().then(
  301. (res) => {
  302. that.timeTypeList = res.data.list
  303. that.updata.timetype=that.timeTypeList[0];
  304. console.log(res);
  305. }
  306. ).catch(
  307. (res) => {
  308. console.log(res);
  309. }
  310. )
  311. getServiceTypeList().then(
  312. (res) => {
  313. that.typeList = res.data.list
  314. console.log(res);
  315. }
  316. ).catch(
  317. (res) => {
  318. console.log(res);
  319. }
  320. )
  321. getUserWorkTypeList().then(
  322. (res) => {
  323. console.log(res);
  324. that.workTypeList = res.data.list
  325. that.updata.word=that.workTypeList[0]
  326. }
  327. ).catch(
  328. (res) => {
  329. console.log(res);
  330. }
  331. )
  332. },
  333. // 选中的服务类型
  334. checkTypeChange(type) {
  335. this.updata.checkedType = type.detail.value;
  336. console.log(type)
  337. },
  338. // 选中的工作类型
  339. changeWorkType(type){
  340. this.updata.word = this.workTypeList[type.detail.value];
  341. console.log(this.updata.word)
  342. },
  343. // 选择时间类型
  344. changetimetype(res) {
  345. this.updata.timetype = this.timeTypeList[res.detail.value];
  346. },
  347. // 时间选择
  348. changetime(time) {
  349. this.updata.time = time.detail.value;
  350. console.log(time);
  351. },
  352. // 选择省市区
  353. onCityClick({
  354. data
  355. }) {
  356. let address = {};
  357. address.province = data[0];
  358. address.city = data[1];
  359. address.district = data[2];
  360. this.updata.onCity.push(address)
  361. console.log(this.onCity, 'cs');
  362. },
  363. upLoad(path) {
  364. // #ifdef H5
  365. console.log(path, 'h5');
  366. // #endif
  367. uni.showLoading({
  368. title: '图片上传中',
  369. mask: true
  370. });
  371. return new Promise((resolve, error) => {
  372. uni.uploadFile({
  373. url: this.baseURL + '/api/user/qiniuUpload', //仅为示例,非真实的接口地址
  374. filePath: path,
  375. name: 'file',
  376. header: {
  377. "token": uni.getStorageSync('token')
  378. },
  379. success: (uploadFileRes) => {
  380. if ("string" === typeof uploadFileRes.data) {
  381. resolve(JSON.parse(uploadFileRes.data).data)
  382. } else {
  383. resolve(uploadFileRes.data.data)
  384. }
  385. },
  386. complete() {
  387. uni.hideLoading()
  388. }
  389. });
  390. })
  391. },
  392. // 图片裁切
  393. /**
  394. * @param {Number} w 裁切宽度比例
  395. * @param {Number} h 裁切高度比例
  396. * @param {Number} mw 图片最小宽度
  397. * @param {Number} mh 图片最小高度
  398. * @param {String} url url修改
  399. */
  400. navCroper(w, h, type, ind) {
  401. let that = this;
  402. let tt = (type == 'upimg' ? 2 : 1)
  403. this.onImg(tt).then((url) => {
  404. uni.navigateTo({
  405. url: `../realName/cropper?width=${w}&height=${h}`,
  406. events: {
  407. uploadSuccess(res) {
  408. that.upLoad(res).then((urldata) => {
  409. console.log(urldata);
  410. if (type == 'one') {
  411. that.updata.avatar = urldata.img
  412. } else if (type == 'all') {
  413. that.updata.imageList.push(urldata.img)
  414. } else if (type == 'tab') {
  415. that.updata.imageList.splice(ind, 1, urldata.img)
  416. }else if (type == 'audit') {
  417. that.updata.service_audit_imgs.splice(ind, 1, urldata.img)
  418. }else if (type == 'auditall') {
  419. that.updata.service_audit_imgs.push( urldata.img)
  420. }else if (type == 'service') {
  421. that.updata.service_imgs.splice(ind, 1, urldata.img)
  422. }else if (type == 'serviceall') {
  423. that.updata.service_imgs.push( urldata.img)
  424. }
  425. })
  426. }
  427. },
  428. success: function(res) {
  429. // 通过eventChannel向被打开页面传送数据
  430. res.eventChannel.emit('urlNext', {
  431. url
  432. })
  433. }
  434. })
  435. })
  436. },
  437. onImg(type) {
  438. const _this = this
  439. return new Promise((ok, erro) => {
  440. // 判断是否需要选择
  441. if (type == 1) {
  442. uni.showActionSheet({
  443. itemList: ['拍照', '选择一张照片'],
  444. success: function(res) {
  445. _this.chooseImage(res.tapIndex).then((url) => {
  446. ok(url)
  447. }).catch((res) => {
  448. erro(res)
  449. })
  450. },
  451. fail: function(res) {
  452. erro(res)
  453. console.log(res.errMsg);
  454. }
  455. });
  456. }
  457. // 判断是否只需要拍照
  458. if (type == 2) {
  459. _this.chooseImage(0).then((url) => {
  460. ok(url)
  461. }).catch((res) => {
  462. erro(res)
  463. })
  464. }
  465. })
  466. },
  467. chooseImage: function(index) {
  468. const _this = this
  469. return new Promise((ok, error) => {
  470. // 从相册/相机选择
  471. // 如需直接开相机或直接选相册,请只使用一个选项
  472. const sourceType = index === 0 ? ['camera'] : ['album']
  473. uni.chooseImage({
  474. count: 1, //默认9
  475. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  476. sourceType: sourceType,
  477. success: function(res) {
  478. ok(res.tempFilePaths[0])
  479. },
  480. fail(e) {
  481. uni.showModal({
  482. title: '文件打开错误',
  483. content: '请设置授权文件存储权限',
  484. showCancel: false,
  485. });
  486. error(e)
  487. }
  488. });
  489. })
  490. },
  491. // 实名认证
  492. confirm(e) {
  493. const that = this;
  494. if (!that.updata.avatar) {
  495. uni.showModal({
  496. title: '错误',
  497. content: '请上传头像',
  498. showCancel: false,
  499. });
  500. return
  501. }
  502. if (!that.updata.name) {
  503. uni.showModal({
  504. title: '错误',
  505. content: '请填写姓名',
  506. showCancel: false,
  507. });
  508. return
  509. }
  510. if (!that.updata.cardId) {
  511. uni.showModal({
  512. title: '错误',
  513. content: '请填写身份证号',
  514. showCancel: false,
  515. });
  516. return
  517. }else if(!isCardNo(that.updata.cardId)){
  518. uni.showModal({
  519. title: '错误',
  520. content: '请填写正确的身份证号',
  521. showCancel: false,
  522. });
  523. return
  524. }
  525. if (!that.updata.phone) {
  526. uni.showModal({
  527. title: '错误',
  528. content: '请填写手机号',
  529. showCancel: false,
  530. });
  531. return
  532. }
  533. if (!that.updata.timetype.code) {
  534. uni.showModal({
  535. title: '错误',
  536. content: '请选择收费时间类型',
  537. showCancel: false,
  538. });
  539. return
  540. }
  541. if (!that.updata.minMoney) {
  542. uni.showModal({
  543. title: '错误',
  544. content: '请填写最低收费价',
  545. showCancel: false,
  546. });
  547. return
  548. }
  549. if (!that.updata.maxMoney) {
  550. uni.showModal({
  551. title: '错误',
  552. content: '请填写最高收费价',
  553. showCancel: false,
  554. });
  555. return
  556. }
  557. if (that.updata.onCity.length==0) {
  558. uni.showModal({
  559. title: '错误',
  560. content: '请选择服务区域',
  561. showCancel: false,
  562. });
  563. return
  564. }
  565. if (that.updata.checkedType.length==0) {
  566. uni.showModal({
  567. title: '错误',
  568. content: '请选择服务内容',
  569. showCancel: false,
  570. });
  571. return
  572. }
  573. that.loding = true;
  574. subInfoAudit({
  575. avatar:that.updata.avatar,
  576. name:that.updata.name,
  577. mobile:that.updata.phone,
  578. idcard:that.updata.cardId,
  579. service_type:that.updata.timetype.code,
  580. service_min_price:that.updata.minMoney,
  581. service_max_price:that.updata.maxMoney,
  582. service_area:that.updata.onCity.map((arr)=>{
  583. return arr.district
  584. }),
  585. service_project:that.updata.checkedType,
  586. service_intro_content:that.updata.mymask,
  587. service_intro_imgs:that.updata.imageList,
  588. work_year:that.updata.work_year,
  589. ancestral_place:that.updata.ancestral_place,
  590. education:that.updata.education,
  591. minority:that.updata.minority,
  592. service_audit_imgs:that.updata.service_audit_imgs,
  593. service_imgs:that.updata.service_imgs,
  594. user_work_type_id:that.updata.word.id,
  595. })
  596. .then((e) => {
  597. that.loding = false;
  598. this.$api.msg(e.msg);
  599. })
  600. .catch(err => {
  601. this.loding = false;
  602. console.log(err);
  603. });
  604. }
  605. }
  606. };
  607. </script>
  608. <style lang="scss">
  609. .content,
  610. page {
  611. min-height: 100%;
  612. }
  613. .content {
  614. padding-bottom: 150rpx;
  615. }
  616. .item-name {
  617. margin: $page-row-spacing;
  618. font-size: $font-lg;
  619. font-weight: bold;
  620. color: $font-color-dark;
  621. }
  622. .con_box {
  623. margin: $page-row-spacing;
  624. .con_image {
  625. width: 150rpx;
  626. height: 150rpx;
  627. display: inline-block;
  628. margin-right: 20rpx;
  629. position: relative;
  630. .img {
  631. width: 100%;
  632. height: 100%;
  633. }
  634. .tip {
  635. position: absolute;
  636. top: -10rpx;
  637. right: -10rpx;
  638. width: 30rpx;
  639. height: 30rpx;
  640. background-color: #FFF;
  641. border-radius: 99rpx;
  642. }
  643. }
  644. }
  645. .listBox {
  646. margin: $page-row-spacing;
  647. margin-top: 30rpx;
  648. border-radius: 20rpx;
  649. overflow: hidden;
  650. background-color: #FFFFFF;
  651. }
  652. .list {
  653. .input {
  654. text-align: right;
  655. font-size: $font-base;
  656. color: $color-gray;
  657. width: 100%;
  658. }
  659. .listItem {
  660. padding: 35rpx 40rpx;
  661. border-bottom: 1px solid $page-color-light;
  662. }
  663. .listIconImg {
  664. width: 36rpx;
  665. }
  666. .right {
  667. color: $font-color-light;
  668. font-size: $font-base;
  669. flex-grow: 1;
  670. justify-content: flex-end;
  671. .timetype {
  672. width: 100%;
  673. justify-content: flex-end;
  674. }
  675. .citylist {
  676. .del {
  677. color: $color-red;
  678. font-size: $font-sm;
  679. border: 1px solid $color-red;
  680. border-radius: 10rpx;
  681. line-height: 1;
  682. padding: 5rpx 15rpx;
  683. }
  684. }
  685. .img {
  686. width: 26rpx;
  687. }
  688. .buttom {
  689. color: $base-color;
  690. border: 1px solid $base-color;
  691. border-radius: 10rpx;
  692. line-height: 1;
  693. padding: 10rpx 20rpx;
  694. }
  695. }
  696. .titleBox {
  697. .title {
  698. color: $font-color-base;
  699. font-size: $font-base;
  700. }
  701. }
  702. }
  703. .bg-gray {
  704. background-color: $color-gray;
  705. }
  706. .base-buttom {
  707. position: fixed;
  708. bottom: 30rpx;
  709. right: 0rpx;
  710. left: 0rpx;
  711. }
  712. </style>