modelrz.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. <template>
  2. <view class="content ">
  3. <view class="errorIf" v-if="dataInitError">
  4. 初始化数据失败请重新填写数据
  5. </view>
  6. <view class="table flex">
  7. <text class="table-text" @click="updata.modelType=0" :class="{action:updata.modelType==0}">
  8. 图文模式
  9. </text>
  10. <text class="table-text" @click="updata.modelType=1" :class="{action:updata.modelType==1}">
  11. 纯图模式
  12. </text>
  13. </view>
  14. <template v-if="updata.modelType==0">
  15. <view class="item-name">
  16. 上传头像
  17. </view>
  18. <view class="con_box">
  19. <view class="con_image">
  20. <image class="img" @click="navCroper(400,400,'one')"
  21. :src="updata.avatar||`../../../static/image/upImg.png`">
  22. </image>
  23. </view>
  24. </view>
  25. <view class="item-name">
  26. 基本信息
  27. </view>
  28. <view class="listBox">
  29. <view class="list">
  30. <view class="flex listItem">
  31. <view class="flex titleBox">
  32. <text class="font-color-red font-size-sm">✲</text> <text class="title">真实姓名</text>
  33. </view>
  34. <view class="right flex">
  35. <input class="input" v-model="updata.name" type="text" placeholder="请填写真实姓名"
  36. placeholder-class="placeholder" />
  37. </view>
  38. </view>
  39. <view class="flex listItem">
  40. <view class="flex titleBox">
  41. <text class="font-color-red font-size-sm">✲</text><text class="title">手机号</text>
  42. </view>
  43. <view class="right flex">
  44. <input class="input" v-model="updata.phone" type="text" placeholder="请填写手机号"
  45. placeholder-class="placeholder" />
  46. </view>
  47. </view>
  48. <view class="flex listItem">
  49. <view class="flex titleBox">
  50. <text class="font-color-red font-size-sm">✲</text><text class="title">身份证号</text>
  51. </view>
  52. <view class="right flex">
  53. <input class="input" v-model="updata.cardId" type="text" placeholder="请填写身份证号"
  54. placeholder-class="placeholder" />
  55. </view>
  56. </view>
  57. <view class="flex listItem">
  58. <view class="flex titleBox">
  59. <text class="title">从业时长</text>
  60. </view>
  61. <view class="right flex">
  62. <input class="input" v-model="updata.work_year" type="number" placeholder="请填写从业时长"
  63. placeholder-class="placeholder" />
  64. </view>
  65. </view>
  66. <view class="flex listItem">
  67. <view class="flex titleBox">
  68. <text class="title">籍贯</text>
  69. </view>
  70. <!-- <view class="right flex">
  71. <pickerAddress @change="changeAncestralPlace">
  72. {{
  73. updata.ancestral_place||'请选择籍贯'
  74. }}
  75. </pickerAddress>
  76. </view> -->
  77. <view class="right flex">
  78. <picker class="input" :range='jgList' mode="selector" @change="changeAncestralPlace"
  79. range-key="name">
  80. <view>
  81. {{updata.ancestral_place||'选择籍贯'}}
  82. </view>
  83. </picker>
  84. </view>
  85. </view>
  86. <view class="flex listItem">
  87. <view class="flex titleBox">
  88. <text class="title">学历</text>
  89. </view>
  90. <view class="right flex">
  91. <picker class="input" :range='educationList' mode="selector" @change="changeEducation">
  92. <view>
  93. {{updata.education||'选择学历'}}
  94. </view>
  95. </picker>
  96. </view>
  97. </view>
  98. <view class="flex listItem">
  99. <view class="flex titleBox">
  100. <text class="title">民族</text>
  101. </view>
  102. <view class="right flex">
  103. <input class="input" v-model="updata.minority" type="text" placeholder="请填写民族"
  104. placeholder-class="placeholder" />
  105. </view>
  106. </view>
  107. <view class="flex listItem">
  108. <view class="flex titleBox">
  109. <text class="title">身高</text>
  110. </view>
  111. <view class="right flex">
  112. <input class="input" v-model="updata.height" type="number" placeholder="请填写身高"
  113. placeholder-class="placeholder" />
  114. <text class="margin-l-10 flex-shrink-false">厘米</text>
  115. </view>
  116. </view>
  117. <view class="flex listItem">
  118. <view class="flex titleBox">
  119. <text class="title">体重</text>
  120. </view>
  121. <view class="right flex">
  122. <input class="input" v-model="updata.weight" type="number" placeholder="请填写体重"
  123. placeholder-class="placeholder" />
  124. <text class="margin-l-10">kg</text>
  125. </view>
  126. </view>
  127. <!-- <view class="flex listItem">
  128. <view class="flex titleBox">
  129. <text class="title">出生日期</text>
  130. </view>
  131. <view class="right flex">
  132. <picker class="input" value='2000-01-01' mode="date" @change="changetime">
  133. <view>
  134. {{updata.time||'请选择日期'}}
  135. </view>
  136. </picker>
  137. </view>
  138. </view> -->
  139. <view class="flex listItem">
  140. <view class="flex titleBox">
  141. <text class="font-color-red font-size-sm">✲</text><text class="title">职业</text>
  142. </view>
  143. <view class="right flex">
  144. <picker class="input" :range='workTypeList' range-key='title' mode="selector"
  145. @change="changeWorkType">
  146. <view>
  147. {{updata.word.title||'选择职业'}}
  148. </view>
  149. </picker>
  150. </view>
  151. </view>
  152. <view class="flex listItem">
  153. <view class="flex titleBox">
  154. <text class="font-color-red font-size-sm">✲</text><text class="title">收费类型</text>
  155. </view>
  156. <view class="right flex">
  157. <picker class="input" :value="updata.timetype.ind" :range='timeTypeList' range-key='title'
  158. mode="selector" @change="changetimetype">
  159. <view>
  160. {{updata.timetype.title||'收费时间类型'}}
  161. </view>
  162. </picker>
  163. </view>
  164. </view>
  165. <view class="flex listItem">
  166. <view class="flex titleBox">
  167. <text class="font-color-red font-size-sm">✲</text><text class="title">最低价</text>
  168. </view>
  169. <view class="right flex">
  170. <input class="input" v-model="updata.minMoney" type="number" placeholder="请输入最低收费价"
  171. placeholder-class="placeholder" />
  172. </view>
  173. </view>
  174. <view class="flex listItem">
  175. <view class="flex titleBox">
  176. <text class="font-color-red font-size-sm">✲</text><text class="title">最高价</text>
  177. </view>
  178. <view class="right flex">
  179. <input class="input" v-model="updata.maxMoney" type="number" placeholder="请输入最高收费价"
  180. placeholder-class="placeholder" />
  181. </view>
  182. </view>
  183. <view class="flex listItem">
  184. <view class="flex titleBox">
  185. <text class="font-color-red font-size-sm">✲</text><text class="title">服务次数</text>
  186. </view>
  187. <view class="right flex">
  188. <input class="input" v-model="updata.service_count" type="number" placeholder="请输入已经服务的数量"
  189. placeholder-class="placeholder" />
  190. </view>
  191. </view>
  192. <view class="flex listItem">
  193. <view class="flex titleBox">
  194. <text class="title">服务区域</text>
  195. </view>
  196. <view class="right flex">
  197. <picker class="input" range-key='title' :range='areaType' mode="selector"
  198. @change="changeAreaType">
  199. <view>
  200. {{areaType[actionAreaType].title}}
  201. </view>
  202. </picker>
  203. </view>
  204. </view>
  205. <view class="flex listItem" v-if="actionAreaType==1">
  206. <view class="flex titleBox">
  207. <text class="font-color-red font-size-sm">✲</text><text class="title">服务区域</text>
  208. </view>
  209. <view class="right">
  210. <view class="citylist">
  211. <view class="flex margin-b-20" v-for="(item,ind) in updata.onCity" :key="ind">
  212. <view></view>
  213. <view>
  214. {{item.province+item.city+item.district}}
  215. <text class="margin-l-10 del" @click="updata.onCity.splice(ind,1)">
  216. 删除
  217. </text>
  218. </view>
  219. </view>
  220. <view class="flex">
  221. <view></view>
  222. <pickerAddress class="buttom" @change="onCityClick">添加地区</pickerAddress>
  223. </view>
  224. </view>
  225. </view>
  226. </view>
  227. <view class="flex listItem">
  228. <view class="flex titleBox">
  229. <text class="font-color-red font-size-sm">✲</text><text class="title">服务内容</text>
  230. </view>
  231. <view class="right">
  232. <checkbox-group @change="checkTypeChange">
  233. <label class="flex timetype margin-b-10" v-for="(item,ind) in typeList" :key="item.id">
  234. <view class="margin-r-10">{{item.title}}</view>
  235. <view>
  236. <checkbox :value="`${item.id}`" :checked="item.checked" />
  237. </view>
  238. </label>
  239. </checkbox-group>
  240. </view>
  241. </view>
  242. </view>
  243. </view>
  244. <view class="item-name">
  245. 自我展示
  246. </view>
  247. <view class="listBox">
  248. <view class="list">
  249. <view class="listItem">
  250. <editor id='editor' class="textarea" auto-height :maxlength='-1' @input='changeMyask' type="text"
  251. placeholder="自我评价\n\n本人从业***年,已经服务***名客户\n成长经历:\n从事母婴工作之前是做***行业的,于***年经过专业培训后进入母婴行业;先后学习了***\n性格特征:\n本人性格直爽,具有很强的服务意识,做事认真负责,擅长……类工作\n服务格言:\n全心全意服务好每一位客户">
  252. </editor>
  253. </view>
  254. </view>
  255. <view class="con_box">
  256. <view class="con_image" v-for="(item,ind) in updata.imageList">
  257. <image class="img" @click="navCroper(400,400,'tab',ind)" :src="item"></image>
  258. <image @click="updata.imageList.splice(ind,1)" class="tip" src="../../../static/icon/goodsExit.png"
  259. mode="scaleToFill"></image>
  260. </view>
  261. <view class="con_image">
  262. <image class="img" @click="navCroper(400,400,'all')" src="../../../static/image/upImg.png"></image>
  263. </view>
  264. </view>
  265. </view>
  266. <view class="item-name">
  267. 我的证书
  268. </view>
  269. <view class="listBox">
  270. <view class="con_box">
  271. <view class="con_image" v-for="(item,ind) in updata.service_audit_imgs">
  272. <image class="img" @click="navCroper(400,400,'audit',ind)" :src="item"></image>
  273. <image @click="updata.service_audit_imgs.splice(ind,1)" class="tip"
  274. src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  275. </view>
  276. <view class="con_image">
  277. <image class="img" @click="navCroper(400,400,'auditall')" src="../../../static/image/upImg.png">
  278. </image>
  279. </view>
  280. </view>
  281. </view>
  282. <view class="item-name">
  283. 服务展示
  284. </view>
  285. <view class="listBox">
  286. <view class="con_box">
  287. <view class="con_image" v-for="(item,ind) in updata.service_imgs">
  288. <image class="img" @click="navCroper(400,400,'service',ind)" :src="item"></image>
  289. <image @click="updata.service_imgs.splice(ind,1)" class="tip"
  290. src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  291. </view>
  292. <view class="con_image">
  293. <image class="img" @click="navCroper(400,400,'serviceall')" src="../../../static/image/upImg.png">
  294. </image>
  295. </view>
  296. </view>
  297. </view>
  298. </template>
  299. <template v-else-if="updata.modelType==1">
  300. <view class="item-name">
  301. 展示图片
  302. </view>
  303. <view class="listBox">
  304. <view class="con_box">
  305. <view class="con_image" v-for="(item,ind) in updata.model_imgs">
  306. <image class="img" @click="navCroper(400,400,'model',ind)" :src="item"></image>
  307. <image @click="updata.model_imgs.splice(ind,1)" class="tip"
  308. src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  309. </view>
  310. <view class="con_image">
  311. <image class="img" @click="navCroper(400,400,'modelall')" src="../../../static/image/upImg.png">
  312. </image>
  313. </view>
  314. </view>
  315. </view>
  316. </template>
  317. <view class="base-buttom flex">
  318. <view class="updata flex flex-center" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">
  319. 提交
  320. </view>
  321. <view class="ylan flex flex-center" @click="look">
  322. 预览
  323. </view>
  324. </view>
  325. </view>
  326. </template>
  327. <script>
  328. import AllAddress from '@/components/wangding-pickerAddress/data.js'
  329. import {
  330. getServiceTimeTypeList,
  331. getServiceTypeList,
  332. subInfoAudit,
  333. getUserWorkTypeList,
  334. getUserCardInfo
  335. } from '@/api/model.js';
  336. import {
  337. isCardNo
  338. } from '@/utils/rocessor.js';
  339. import {
  340. getAstro,
  341. getShengXiao,
  342. IdCard
  343. } from '@/utils/twelve.js';
  344. import {
  345. mapState
  346. } from "vuex"
  347. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  348. export default {
  349. components: {
  350. pickerAddress
  351. },
  352. data() {
  353. return {
  354. // 初始化数据失败
  355. dataInitError: false,
  356. jgList: AllAddress,
  357. // 上传数据
  358. updata: {
  359. modelType:0,//模板类型0为老类型,1为纯图片
  360. is_global: 0, //是否全国0是否1是是
  361. is_wm: '', //是否海外
  362. avatar: '', //用户头像
  363. name: '', //用户名称
  364. phone: '', //手机号
  365. cardId: '', //身份证号
  366. minMoney: '', //最低价
  367. maxMoney: '', //最高价
  368. height: '', //身高
  369. weight: '', //体重
  370. checkedType: [], //选中的服务类型
  371. time: '', //出生日期
  372. timetype: {
  373. title: '',
  374. code: '',
  375. ind: 0 //默认0
  376. }, //选中的时间类型
  377. onCity: [], //选中的城市
  378. mymask: '', //自评
  379. imageList: [], //自评上传图片列表
  380. ancestral_place: '', //籍贯
  381. education: '', //学历
  382. minority: '', //民族
  383. work_year: '', //从业时长
  384. word: {
  385. title: '',
  386. id: ''
  387. },
  388. service_audit_imgs: [], //我的证书
  389. service_imgs: [], //服务展示
  390. model_imgs: [], //服务展示
  391. no: '',
  392. },
  393. typeList: [], //服务类型
  394. timeTypeList: [], //时间类型
  395. workTypeList: [], //工作类型
  396. loding: false, //是否载入中
  397. type: 0, //0为新增,1为修改2为商品页进入注册
  398. userModelData: {}, //保存获取的用户模板
  399. modelid: '', //保存要预览的模板id
  400. educationList: ['小学', '初中', '高中', '大专', '本科', '研究生', '博士'], //学历列表
  401. areaList: ['是', '否'], //保存是否国内国外
  402. areaType: [{
  403. title: '国外',
  404. type: 2
  405. },
  406. {
  407. title: '国内',
  408. type: 1
  409. },
  410. {
  411. title: '全国',
  412. type: 3
  413. }
  414. ],
  415. editorCtx: '',//保存详情页面数据
  416. actionAreaType: 1
  417. };
  418. },
  419. async onLoad(options) {
  420. this.modelid = options.modelid
  421. if (options.type == 1) {
  422. this.type = 1;
  423. } else if (options.type == 2) {
  424. this.type = 0
  425. }
  426. },
  427. onReady() {
  428. const that = this;
  429. // 保存对象
  430. uni.createSelectorQuery().select('#editor').context(async (res) => {
  431. that.editorCtx = res.context
  432. // console.log(that.editorCtx,'that.editorCtx');
  433. if (that.type == 1) {
  434. await that.getUserCardInfo()
  435. }
  436. that.init()
  437. }).exec();
  438. },
  439. computed: {
  440. // #ifdef H5
  441. ...mapState(['urlFile']),
  442. // #endif
  443. ...mapState(['baseURL']),
  444. },
  445. methods: {
  446. changeMyask({
  447. detail
  448. }) {
  449. this.updata.mymask = detail.html;
  450. },
  451. // 选择学历
  452. changeEducation(res) {
  453. this.updata.education = this.educationList[res.detail.value];
  454. // console.log(res);
  455. },
  456. //修改地区类型
  457. changeAreaType(re) {
  458. this.actionAreaType = re.detail.value * 1;
  459. if (re.detail.value == '1') {
  460. this.updata.is_wm = this.areaList[1];
  461. return
  462. } else {
  463. this.updata.is_wm = this.areaList[0];
  464. }
  465. },
  466. // 初始化
  467. init() {
  468. const that = this;
  469. getServiceTimeTypeList().then(
  470. (res) => {
  471. that.timeTypeList = res.data.list.map((arr) => {
  472. return arr
  473. })
  474. if (that.type == 0) {
  475. that.updata.timetype = that.timeTypeList[0];
  476. } else
  477. if (that.type == 1) {
  478. for (let i = 0; i < that.timeTypeList.length; i++) {
  479. if (that.timeTypeList[i].code == that.userModelData.service_type) {
  480. that.updata.timetype = that.timeTypeList[i]
  481. that.updata.timetype.ind = i;
  482. break
  483. }
  484. }
  485. }
  486. }
  487. ).catch(
  488. (res) => {
  489. console.log(res);
  490. }
  491. )
  492. getServiceTypeList().then(
  493. (res) => {
  494. that.typeList = res.data.list
  495. if (that.type == 1) {
  496. try {
  497. if (that.userModelData.service_project_ar) {
  498. for (let i = 0; i < that.userModelData.service_project_ar.length; i++) {
  499. for (let a = 0; a < that.typeList.length; a++) {
  500. if (+that.typeList[a].id == +that.userModelData.service_project_ar[i].id) {
  501. that.typeList[a].checked = true;
  502. that.updata.checkedType.push('' + that.typeList[a].id)
  503. }
  504. }
  505. }
  506. }
  507. } catch (e) {
  508. //TODO handle the exception
  509. }
  510. }
  511. }
  512. ).catch(
  513. (res) => {
  514. console.log(res);
  515. }
  516. )
  517. getUserWorkTypeList().then(
  518. (res) => {
  519. that.workTypeList = res.data.list
  520. if (that.type == 0) {
  521. that.updata.word = that.workTypeList[0];
  522. } else if (that.type == 1) {
  523. try {
  524. if (that.userModelData.user_work_type_id) {
  525. for (let i = 0; i < that.workTypeList.length; i++) {
  526. if (that.workTypeList[i].id == that.userModelData.user_work_type_id) {
  527. that.updata.word = that.workTypeList[i];
  528. break
  529. }
  530. }
  531. } else {
  532. that.updata.word = that.workTypeList[0];
  533. }
  534. } catch (e) {
  535. that.updata.word = that.workTypeList[0];
  536. }
  537. }
  538. }
  539. ).catch(
  540. (res) => {
  541. console.log(res);
  542. }
  543. )
  544. },
  545. // 跳转查看预览页面
  546. look() {
  547. const that = this;
  548. if (!that.rendl()) {
  549. return
  550. }
  551. uni.showLoading({
  552. title: "生成预览中。。。",
  553. mask: true
  554. })
  555. setTimeout(function() {
  556. uni.hideLoading()
  557. // 获取生日
  558. const birthday = IdCard('' + that.updata.cardId, 1);
  559. // 复制选中的服务数组
  560. let arr = [...that.updata.checkedType]
  561. let pushar = [];
  562. that.typeList.forEach(
  563. (re) => {
  564. for (let i = 0; i < arr.length; i++) {
  565. if (+arr[i] == +re.id) {
  566. // 删除已选中的对象
  567. arr.splice(i, 1)
  568. pushar.push(re)
  569. break
  570. }
  571. }
  572. }
  573. )
  574. let data = {
  575. is_china: that.actionAreaType,
  576. name: that.updata.name,
  577. avatar: that.updata.avatar,
  578. age: IdCard(that.updata.cardId, 3),
  579. twelve: getShengXiao(birthday),
  580. work_year: that.updata.work_year,
  581. constellation: getAstro(...(birthday.split('-'))),
  582. ancestral_place: that.updata.ancestral_place,
  583. minority: that.updata.minority,
  584. education: that.updata.education,
  585. service_area_all: that.actionAreaType == 0 ? that.updata.onCity.map(
  586. (item) => {
  587. return item.province + item.city + item.district
  588. }
  589. ) : (that.actionAreaType == 1 ? ['海外,海外,海外'] : ['全国,全国,全国']),
  590. service_min_price: that.updata.minMoney,
  591. service_max_price: that.updata.maxMoney,
  592. service_time_type_title: that.updata.timetype.title,
  593. service_intro_content: that.updata.mymask,
  594. service_intro_imgs: that.updata.imageList,
  595. service_audit_imgs: that.updata.service_audit_imgs,
  596. service_project_ar: pushar,
  597. service_imgs: that.updata.service_imgs,
  598. model_imgs: that.updata.model_imgs,
  599. no: that.updata.no,
  600. user_work_type_title: that.updata.word.title,
  601. service_count: that.updata.service_count,
  602. weight: that.updata.weight,
  603. height: that.updata.height
  604. }
  605. uni.setStorageSync('modeldata', data)
  606. uni.navigateTo({
  607. url: '/pages/user/model/model?mtype=' + that.modelid + '&type=1'
  608. })
  609. }, 1000);
  610. },
  611. // 获取用户提交数据
  612. getUserCardInfo() {
  613. const that = this;
  614. return new Promise((resolve, reject) => {
  615. getUserCardInfo().then(
  616. (data) => {
  617. try {
  618. const res = data.data;
  619. // 存储返回用户数据
  620. that.userModelData = res;
  621. that.actionAreaType =res.is_china;
  622. let onCity = [];
  623. if (res.is_china == 1) {
  624. for (let i = 0; i < res.service_area_all.length; i++) {
  625. let arr = res.service_area_all[i];
  626. if (arr.length > 0) {
  627. onCity.push({
  628. province: arr[0].name,
  629. city: arr[1].name,
  630. district: arr[2] ? arr[2].name : '市辖区'
  631. })
  632. }
  633. }
  634. };
  635. that.updata = Object.assign(that.updata, {
  636. modelType:res.modelType==null?0:res.modelType,//保存模板类型
  637. is_wm: res.is_china == 0 ? '是' : '否',//是否海外
  638. avatar: res.avatar, //用户头像
  639. name: res.name, //用户名称
  640. phone: res.mobile, //手机号
  641. cardId: res.idcard, //身份证号
  642. minMoney: res.service_min_price, //最低价
  643. maxMoney: res.service_max_price, //最高价
  644. time: res.birthday, //出生日期
  645. onCity: onCity, //选中的城市
  646. mymask: res.service_intro_content, //自评
  647. imageList: res.service_intro_imgs, //自评上传图片列表
  648. ancestral_place: res.ancestral_place, //籍贯
  649. education: res.education, //学历
  650. minority: res.minority, //民族
  651. work_year: res.work_year, //从业时长
  652. service_audit_imgs: res.service_audit_imgs, //我的证书
  653. service_imgs: res.service_imgs, //服务展示
  654. model_imgs: res.model_imgs, //服务展示
  655. no: res.no,
  656. service_count: res.service_count,
  657. weight: res.weight * 1,
  658. height: res.height
  659. })
  660. that.editorCtx.setContents({
  661. html: res.service_intro_content
  662. })
  663. resolve('初始化数据成功')
  664. } catch (e) {
  665. console.log(e, 'eeee')
  666. that.dataInitError = true;
  667. //TODO handle the exception
  668. }
  669. }
  670. ).catch(
  671. (res) => {
  672. that.dataInitError = true;
  673. reject(res)
  674. }
  675. )
  676. })
  677. },
  678. // 选中的服务类型
  679. checkTypeChange(type) {
  680. this.updata.checkedType = type.detail.value;
  681. },
  682. // 选中的工作类型
  683. changeWorkType(type) {
  684. this.updata.word = this.workTypeList[type.detail.value];
  685. },
  686. // 选择时间类型
  687. changetimetype(res) {
  688. this.updata.timetype = this.timeTypeList[res.detail.value];
  689. },
  690. // 时间选择
  691. changetime(time) {
  692. this.updata.time = time.detail.value;
  693. },
  694. // 选择籍贯
  695. changeAncestralPlace(val) {
  696. this.updata.ancestral_place = this.jgList[val.detail.value].name;
  697. },
  698. // 选择省市区
  699. onCityClick({
  700. data
  701. }) {
  702. let address = {};
  703. address.province = data[0];
  704. address.city = data[1];
  705. address.district = data[2];
  706. this.updata.onCity.push(address)
  707. },
  708. upLoad(path) {
  709. uni.showLoading({
  710. title: '图片上传中',
  711. mask: true
  712. });
  713. return new Promise((resolve, error) => {
  714. uni.uploadFile({
  715. url: this.baseURL + '/api/user/qiniuUpload', //仅为示例,非真实的接口地址
  716. filePath: path,
  717. name: 'file',
  718. header: {
  719. "token": uni.getStorageSync('token')
  720. },
  721. success: (uploadFileRes) => {
  722. if ("string" === typeof uploadFileRes.data) {
  723. resolve(JSON.parse(uploadFileRes.data).data)
  724. } else {
  725. resolve(uploadFileRes.data.data)
  726. }
  727. },
  728. complete() {
  729. uni.hideLoading()
  730. }
  731. });
  732. })
  733. },
  734. // 图片裁切
  735. /**
  736. * @param {Number} w 裁切宽度比例
  737. * @param {Number} h 裁切高度比例
  738. * @param {Number} mw 图片最小宽度
  739. * @param {Number} mh 图片最小高度
  740. * @param {String} url url修改
  741. */
  742. navCroper(w, h, type, ind) {
  743. let that = this;
  744. let tt = (type == 'upimg' ? 2 : 1)
  745. this.onImg(tt).then((url) => {
  746. uni.navigateTo({
  747. url: `../realName/cropper?width=${w}&height=${h}`,
  748. events: {
  749. uploadSuccess(res) {
  750. that.upLoad(res).then((urldata) => {
  751. if (type == 'one') {
  752. that.updata.avatar = urldata.img
  753. } else if (type == 'all') {
  754. that.updata.imageList.push(urldata.img)
  755. } else if (type == 'tab') {
  756. that.updata.imageList.splice(ind, 1, urldata.img)
  757. } else if (type == 'audit') {
  758. that.updata.service_audit_imgs.splice(ind, 1, urldata.img)
  759. } else if (type == 'auditall') {
  760. that.updata.service_audit_imgs.push(urldata.img)
  761. } else if (type == 'service') {
  762. that.updata.service_imgs.splice(ind, 1, urldata.img)
  763. } else if (type == 'serviceall') {
  764. that.updata.service_imgs.push(urldata.img)
  765. }else if (type == 'model') {
  766. that.updata.model_imgs.splice(ind, 1, urldata.img)
  767. } else if (type == 'modelall') {
  768. that.updata.model_imgs.push(urldata.img)
  769. }
  770. })
  771. }
  772. },
  773. success: function(res) {
  774. // 通过eventChannel向被打开页面传送数据
  775. res.eventChannel.emit('urlNext', {
  776. url
  777. })
  778. }
  779. })
  780. })
  781. },
  782. onImg(type) {
  783. const _this = this
  784. return new Promise((ok, erro) => {
  785. // 判断是否需要选择
  786. if (type == 1) {
  787. uni.showActionSheet({
  788. itemList: ['拍照', '选择一张照片'],
  789. success: function(res) {
  790. _this.chooseImage(res.tapIndex).then((url) => {
  791. ok(url)
  792. }).catch((res) => {
  793. erro(res)
  794. })
  795. },
  796. fail: function(res) {
  797. erro(res)
  798. }
  799. });
  800. }
  801. // 判断是否只需要拍照
  802. if (type == 2) {
  803. _this.chooseImage(0).then((url) => {
  804. ok(url)
  805. }).catch((res) => {
  806. erro(res)
  807. })
  808. }
  809. })
  810. },
  811. chooseImage: function(index) {
  812. const _this = this
  813. return new Promise((ok, error) => {
  814. // 从相册/相机选择
  815. // 如需直接开相机或直接选相册,请只使用一个选项
  816. const sourceType = index === 0 ? ['camera'] : ['album'];
  817. // #ifdef MP
  818. uni.chooseMedia({
  819. count: 1,
  820. mediaType: ['image'],
  821. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  822. sourceType: sourceType,
  823. success(res) {
  824. // 缓存文件路径
  825. ok(res.tempFiles[0])
  826. },
  827. fail(err) {
  828. uni.showModal({
  829. title: '文件打开错误',
  830. content: '请设置授权文件存储权限',
  831. showCancel: false,
  832. });
  833. error(e)
  834. }
  835. })
  836. // #endif
  837. // #ifndef MP
  838. uni.chooseImage({
  839. count: 1, //默认9
  840. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  841. sourceType: sourceType,
  842. success: function(res) {
  843. ok(res.tempFilePaths[0])
  844. },
  845. fail(e) {
  846. uni.showModal({
  847. title: '文件打开错误',
  848. content: '请设置授权文件存储权限',
  849. showCancel: false,
  850. });
  851. error(e)
  852. }
  853. });
  854. // #endif
  855. })
  856. },
  857. // 实名认证
  858. confirm(e) {
  859. const that = this;
  860. if (!that.rendl()) {
  861. return
  862. }
  863. that.loding = true;
  864. subInfoAudit({
  865. modelType:that.updata.modelType,
  866. is_china: that.actionAreaType,
  867. avatar: that.updata.avatar,
  868. name: that.updata.name,
  869. mobile: that.updata.phone,
  870. idcard: that.updata.cardId,
  871. service_type: that.updata.timetype.code,
  872. service_min_price: that.updata.minMoney,
  873. service_max_price: that.updata.maxMoney,
  874. service_area: that.updata.is_wm == '是' ? ["海外,海外1,海外2"] : that.updata.onCity.map((item) => {
  875. return item.province + ',' + item.city + ',' + item.district;
  876. }),
  877. service_project: that.updata.checkedType,
  878. service_intro_content: that.updata.mymask,
  879. service_intro_imgs: that.updata.imageList,
  880. work_year: that.updata.work_year,
  881. ancestral_place: that.updata.ancestral_place,
  882. education: that.updata.education,
  883. minority: that.updata.minority,
  884. service_audit_imgs: that.updata.service_audit_imgs,
  885. service_imgs: that.updata.service_imgs,
  886. model_imgs: that.updata.model_imgs,
  887. user_work_type_id: that.updata.word.id,
  888. service_count: that.updata.service_count,
  889. weight: that.updata.weight,
  890. height: that.updata.height
  891. })
  892. .then((e) => {
  893. if (e.msg == '提交成功,数据已通过审核') {
  894. this.$api.msg(e.msg);
  895. setTimeout(
  896. () => {
  897. uni.switchTab({
  898. url: "/pages/userhome/user",
  899. fail(re) {
  900. console.log(re)
  901. }
  902. })
  903. }, 1000
  904. )
  905. } else {
  906. this.$api.msg(e.msg);
  907. }
  908. that.loding = false;
  909. })
  910. .catch(err => {
  911. this.loding = false;
  912. console.log(err);
  913. });
  914. },
  915. // 认证
  916. rendl() {
  917. const that = this;
  918. if(that.updata.modelType==0){
  919. if (!that.updata.avatar) {
  920. uni.showModal({
  921. title: '错误',
  922. content: '请上传头像',
  923. showCancel: false,
  924. });
  925. return false
  926. }
  927. if (!that.updata.name) {
  928. uni.showModal({
  929. title: '错误',
  930. content: '请填写姓名',
  931. showCancel: false,
  932. });
  933. return false
  934. }
  935. if (!that.updata.cardId) {
  936. uni.showModal({
  937. title: '错误',
  938. content: '请填写身份证号',
  939. showCancel: false,
  940. });
  941. return
  942. } else if (!isCardNo(that.updata.cardId)) {
  943. uni.showModal({
  944. title: '错误',
  945. content: '请填写正确的身份证号',
  946. showCancel: false,
  947. });
  948. return false
  949. }
  950. if (!that.updata.phone) {
  951. uni.showModal({
  952. title: '错误',
  953. content: '请填写手机号',
  954. showCancel: false,
  955. });
  956. return false
  957. }
  958. if (!that.updata.timetype.code) {
  959. uni.showModal({
  960. title: '错误',
  961. content: '请选择收费时间类型',
  962. showCancel: false,
  963. });
  964. return false
  965. }
  966. if (!that.updata.minMoney) {
  967. uni.showModal({
  968. title: '错误',
  969. content: '请填写最低收费价',
  970. showCancel: false,
  971. });
  972. return false
  973. }
  974. if (!that.updata.maxMoney) {
  975. uni.showModal({
  976. title: '错误',
  977. content: '请填写最高收费价',
  978. showCancel: false,
  979. });
  980. return false
  981. }
  982. if (!that.updata.is_wm) {
  983. uni.showModal({
  984. title: '错误',
  985. content: '请选择服务区域是否海外',
  986. showCancel: false,
  987. });
  988. return
  989. }
  990. if (that.actionAreaType == 1 && that.updata.onCity.length == 0) {
  991. uni.showModal({
  992. title: '错误',
  993. content: '请选择服务区域',
  994. showCancel: false,
  995. });
  996. return false
  997. }
  998. if (that.updata.checkedType.length == 0) {
  999. uni.showModal({
  1000. title: '错误',
  1001. content: '请选择服务内容',
  1002. showCancel: false,
  1003. });
  1004. return false
  1005. }
  1006. }else if(that.updata.modelType==1){
  1007. if (that.updata.model_imgs.length == 0) {
  1008. uni.showModal({
  1009. title: '错误',
  1010. content: '请上传展示图片',
  1011. showCancel: false,
  1012. });
  1013. return false
  1014. }
  1015. }
  1016. return true
  1017. }
  1018. }
  1019. };
  1020. </script>
  1021. <style lang="scss">
  1022. .content,
  1023. page {
  1024. min-height: 100%;
  1025. }
  1026. .content {
  1027. padding-bottom: 150rpx;
  1028. }
  1029. .item-name {
  1030. margin: $page-row-spacing;
  1031. font-size: $font-lg;
  1032. font-weight: bold;
  1033. color: $font-color-dark;
  1034. }
  1035. .con_box {
  1036. margin: $page-row-spacing;
  1037. .con_image {
  1038. width: 150rpx;
  1039. height: 150rpx;
  1040. display: inline-block;
  1041. margin-right: 20rpx;
  1042. position: relative;
  1043. .img {
  1044. width: 100%;
  1045. height: 100%;
  1046. }
  1047. .tip {
  1048. position: absolute;
  1049. top: -10rpx;
  1050. right: -10rpx;
  1051. width: 30rpx;
  1052. height: 30rpx;
  1053. background-color: #FFF;
  1054. border-radius: 99rpx;
  1055. }
  1056. }
  1057. }
  1058. .listBox {
  1059. margin: $page-row-spacing;
  1060. margin-top: 30rpx;
  1061. border-radius: 20rpx;
  1062. overflow: hidden;
  1063. background-color: #FFFFFF;
  1064. }
  1065. .list {
  1066. .input {
  1067. text-align: right;
  1068. font-size: $font-base;
  1069. color: $color-gray;
  1070. width: 100%;
  1071. }
  1072. .listItem {
  1073. padding: 35rpx 40rpx;
  1074. border-bottom: 1px solid $page-color-light;
  1075. .ql-editor.ql-blank:before {
  1076. font-style: normal;
  1077. }
  1078. .textarea {
  1079. font-size: $font-base;
  1080. width: 100%;
  1081. word-wrap: break-word;
  1082. white-space: pre-line;
  1083. min-height: 9rem;
  1084. }
  1085. }
  1086. .listIconImg {
  1087. width: 36rpx;
  1088. }
  1089. .right {
  1090. color: $font-color-light;
  1091. font-size: $font-base;
  1092. flex-grow: 1;
  1093. justify-content: flex-end;
  1094. .timetype {
  1095. width: 100%;
  1096. justify-content: flex-end;
  1097. }
  1098. .citylist {
  1099. .del {
  1100. color: $color-red;
  1101. font-size: $font-sm;
  1102. border: 1px solid $color-red;
  1103. border-radius: 10rpx;
  1104. line-height: 1;
  1105. padding: 5rpx 15rpx;
  1106. }
  1107. }
  1108. .img {
  1109. width: 26rpx;
  1110. }
  1111. .buttom {
  1112. color: $base-color;
  1113. border: 1px solid $base-color;
  1114. border-radius: 10rpx;
  1115. line-height: 1;
  1116. padding: 10rpx 20rpx;
  1117. }
  1118. }
  1119. .titleBox {
  1120. .title {
  1121. color: $font-color-base;
  1122. font-size: $font-base;
  1123. }
  1124. }
  1125. }
  1126. .bg-gray {
  1127. background-color: $color-gray;
  1128. }
  1129. .base-buttom {
  1130. position: fixed;
  1131. bottom: 0rpx;
  1132. right: 0rpx;
  1133. left: 0rpx;
  1134. margin: 0;
  1135. padding: 0;
  1136. height: 100rpx;
  1137. border-radius: 0;
  1138. .updata,
  1139. .ylan {
  1140. width: 50%;
  1141. height: 100%;
  1142. justify-content: center;
  1143. }
  1144. .ylan {
  1145. background-color: #FFF;
  1146. color: $font-color-dark;
  1147. }
  1148. }
  1149. .errorIf {
  1150. font-size: $font-lg;
  1151. color: #F65486;
  1152. padding: 30rpx;
  1153. }
  1154. .table{
  1155. .table-text{
  1156. color:#F65486;
  1157. text-align: center;
  1158. flex-grow: 1;
  1159. padding: 30rpx;
  1160. border: 1px solid #F65486;
  1161. &.action{
  1162. background-color: #F65486;
  1163. color: #FFFFFF;
  1164. }
  1165. }
  1166. }
  1167. </style>