create.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view v-if="!loading">
  3. <view class="form">
  4. <view class="li ddflex">
  5. <view class="label">头像</view>
  6. <view class="photo ddflex flex" @tap="uploadImgs()">
  7. <image :src="avatar ? avatar : '../../static/images/userimg.png'" mode="aspectFill" class="userimg"></image>
  8. <image src="../../static/images/rico.png" class="rico"></image>
  9. </view>
  10. </view>
  11. <view class="li ddflex">
  12. <view class="label">姓名</view>
  13. <input v-model="realName" :disabled="true" placeholder="请填写你的真实姓名" placeholder-class="placeholder" class="ipt flex" />
  14. </view>
  15. <view class="li ddflex">
  16. <view class="label">工号</view>
  17. <input v-model="jobNumber" :disabled="true" placeholder="请输入工号" placeholder-class="placeholder" class="ipt flex" />
  18. </view>
  19. <view class="li ddflex">
  20. <view class="label">个人简介</view>
  21. <input v-if="!brief" @tap="jumpUrl('/card/editDesc/editDesc')" :disabled="true" maxlength="11" type="number" placeholder="请作简单自我介绍" placeholder-class="placeholder" class="ipt flex" />
  22. <view class="fflex" v-else style="color: #47C776;" @tap="jumpUrl('/card/editDesc/editDesc')">已完善</view>
  23. <image src="../../static/images/rico.png" class="rico"></image>
  24. </view>
  25. <view class="li ddflex">
  26. <view class="label">执业证书</view>
  27. <input v-model="certificateNo" :disabled="true" placeholder="请输入执业证书编号" placeholder-class="placeholder" class="ipt flex" />
  28. </view>
  29. </view>
  30. <view class="form">
  31. <view class="tit ddflex"><view class="flex">联系信息</view></view>
  32. <view class="li ddflex">
  33. <view class="label">手机</view>
  34. <input v-model="phone" maxlength="11" type="number" placeholder="请填写手机号" placeholder-class="placeholder" class="ipt flex" />
  35. <!-- <view class="tong ddflex" @click="intWechatNumber"><image src="../static/images/wxth.png"></image>微信同号</view> -->
  36. </view>
  37. <view class="li ddflex">
  38. <view class="label">微信号</view>
  39. <input v-model="wechat" placeholder="请填写微信号" placeholder-class="placeholder" class="ipt flex" />
  40. </view>
  41. <!-- <view class="li ddflex">
  42. <view class="label">邮箱</view>
  43. <input v-model="email" placeholder="请填写邮箱地址" placeholder-class="placeholder" class="ipt flex" />
  44. </view> -->
  45. <view class="li dflex">
  46. <view class="label">微信二维码</view>
  47. <view v-if="!wechatCode" class="upload-box ddflex" @tap="uploadWechat()">
  48. <image src="../static/images/pic.png"></image>
  49. <view>点击上传</view>
  50. </view>
  51. <view v-else class="upload-box-image ddflex" @tap="uploadWechat()">
  52. <image class="upload-image" :src="wechatCode"></image>
  53. <image class="upload-close" src="../../static/pages/images/close3.png" @click.stop="wechatCode=''"></image>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="form">
  58. <view class="li dflex">
  59. <view class="label">所获荣誉</view>
  60. <view class="ddflex upload-group flex">
  61. <view class="upload-box-image ddflex" v-for="item,index in honorImgUrls" @click="uploadHonor('change',index)">
  62. <image class="upload-image" :src="item"></image>
  63. <image class="upload-close" src="../../static/pages/images/close3.png" @click.stop="deleteHonor(index)"></image>
  64. </view>
  65. <view class="upload-box ddflex" @tap="uploadHonor()" v-if="honorImgUrls.length<9">
  66. <image src="../static/images/pic.png"></image>
  67. <view>点击上传</view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="li dflex">
  72. <view class="label">个人风采</view>
  73. <view class="ddflex upload-group flex">
  74. <view class="upload-box-image ddflex" v-for="item,index in styleImgUrls" @click="uploadStyle('change',index)">
  75. <image class="upload-image" :src="item"></image>
  76. <image class="upload-close" src="../../static/pages/images/close3.png" @click.stop="deleteStyle(index)"></image>
  77. </view>
  78. <view class="upload-box ddflex" @tap="uploadStyle()" v-if="styleImgUrls.length<9">
  79. <image src="../static/images/pic.png"></image>
  80. <view>点击上传</view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="form">
  86. <view class="tit ddflex"><view class="flex">公司信息</view></view>
  87. <view class="li ddflex">
  88. <view class="label">公司</view>
  89. <input v-model="companyName" :disabled="true" placeholder="请填写公司名称" placeholder-class="placeholder" class="ipt flex" />
  90. </view>
  91. <view class="li ddflex">
  92. <view class="label">公司简介</view>
  93. <input v-if="!companyIntroduction" @tap="jumpUrl('/card/editDesc/editDesc?isCompanyIntroduction=true')" :disabled="true" maxlength="11" type="number" placeholder="请填写公司简介" placeholder-class="placeholder" class="ipt flex" />
  94. <view class="fflex" v-else style="color: #47C776;" @tap="jumpUrl('/card/editDesc/editDesc?isCompanyIntroduction=true')">已完善</view>
  95. <image src="../../static/images/rico.png" class="rico"></image>
  96. </view>
  97. <view class="li ddflex">
  98. <view class="label">入司时间</view>
  99. <picker mode="date" v-model="inDate" :disabled="true" @change="inDateChange">
  100. {{inDate?inDate:'请填写公司名称'}}
  101. </picker>
  102. <!-- <input v-model="companyName" :disabled="true" placeholder="请填写公司名称" placeholder-class="placeholder" class="ipt flex" /> -->
  103. </view>
  104. <view class="li ddflex">
  105. <view class="label">职位</view>
  106. <input v-model="job" :disabled="true" placeholder="请填写职位" placeholder-class="placeholder" class="ipt flex" />
  107. </view>
  108. <!-- <view class="li ddflex" @click="jumpUrl('/card/industry/industry?isPoistion=true')">
  109. <view class="label">行业</view>
  110. <view :class="'flex' + (industryName ? '' :' placeholder')">{{industryName ? industryName : '请填写行业'}}</view>
  111. <image src="../../static/images/rico.png" class="rico"></image>
  112. </view> -->
  113. <view class="li ddflex">
  114. <view class="label">所在地区</view>
  115. <view :class="['item flex', city ? 'active' : '']" @click="chooseLocation()">
  116. <!-- <pickerAddress class="picker flex" @change="bindAddressChange" :disabled="true" @click="chooseLocation()"> -->
  117. <view :class="city?'':'placeholder'">{{ city ? city : '请选择地区' }}</view>
  118. <!-- </pickerAddress> -->
  119. </view>
  120. <image src="../../static/images/rico.png" class="rico"></image>
  121. <!-- <picker class="picker flex">
  122. <view class="placeholder">请选择省份城市</view>
  123. <image src="../../static/images/rico.png" class="rico"></image>
  124. </picker> -->
  125. </view>
  126. <view class="li ddflex">
  127. <view class="label">地址</view>
  128. <input v-model="address" placeholder="填写街道地址" placeholder-class="placeholder" class="ipt flex" />
  129. </view>
  130. </view>
  131. <view class="bot">
  132. <view class="btn" @click="submitCard()">{{ isEdit ? '保存' : '确认创建' }}</view>
  133. </view>
  134. </view>
  135. </template>
  136. <script>
  137. const req = require('../../utils/request.js');
  138. const util = require('../../utils/util.js');
  139. var QQMapWX = require('../../utils/qqmap.js');
  140. var app = getApp();
  141. import pickerAddress from '../../components/wangding-pickerAddress/wangding-pickerAddress.vue';
  142. export default {
  143. components: { pickerAddress },
  144. data() {
  145. return {
  146. avatar: '',
  147. realName: '',
  148. phone: '',
  149. jobNumber:'',
  150. wechat: '',
  151. wechatCode:'',
  152. email: '',
  153. companyName: '',
  154. job:'',//职业
  155. industryName: '',//行业
  156. tradeId: '',//行业id
  157. message: '',
  158. isEdit: false,
  159. id: '' ,//名片id
  160. nums: 0,
  161. brief:'',//简介
  162. address:'',//详细地址
  163. inDate:'',//入司时间
  164. companyIntroduction:'',//公司简介
  165. honorImgUrls:[],//荣誉
  166. styleImgUrls:[],//风采
  167. city: '',
  168. areaCode: '',
  169. morCity: [],
  170. location:{},
  171. longitude:'',
  172. latitude:'',
  173. userCard:null,//用户IP名片
  174. employmentInfo:'',
  175. saleNo:null,
  176. certificateNo:null,
  177. loading:true
  178. };
  179. },
  180. async onLoad(opt) {
  181. this.isEdit = opt.isEdit?true:false;
  182. this.id = opt.id;
  183. this.saleNo = opt.saleNo
  184. await req.silenceLogin(opt.saleNo)
  185. console.log('getUserCard')
  186. this.getUserCard()
  187. this.getEmploymentInfo()
  188. },
  189. methods: {
  190. getUserInfo(){
  191. return new Promise((resolve,reject)=>{
  192. req.getRequest('/api/user/info',{},res=>{
  193. this.avatar = res.avatar;
  194. this.phone = res.mobile;
  195. resolve();
  196. })
  197. })
  198. },
  199. getEmploymentInfo(){
  200. return new Promise((resolve,reject)=>{
  201. req.getRequest('/api/visiting/card/employmentInfo',{jobNumber:req.getStorage('userInfo').saleNo},res=>{
  202. if(res.name){
  203. this.employmentInfo = res;
  204. this.realName = this.employmentInfo.name;
  205. this.certificateNo = this.employmentInfo.professionalCertificateNo
  206. this.jobNumber = this.employmentInfo.salesNo
  207. this.companyName = this.employmentInfo.branchName
  208. this.job = this.employmentInfo.actrankName
  209. this.inDate = this.employmentInfo.inDate
  210. }
  211. else return req.msg("员工信息不存在")
  212. resolve();
  213. })
  214. })
  215. },
  216. // 用户名片信息
  217. getUserCard(){
  218. req.getRequest('/api/visiting/card/userInfo', {}, res => {
  219. console.log('getUserCard',res)
  220. this.userCard = res
  221. if(!res){
  222. this.isEdit = true
  223. this.getUserInfo()
  224. }else{
  225. if(!this.isEdit){
  226. if(res.auditState==0){
  227. // 待审核
  228. uni.redirectTo({
  229. url:'/card/success/success?state=0'
  230. })
  231. return false
  232. }else if(res.auditState==1){
  233. // 审核成功
  234. uni.redirectTo({
  235. url:'/card/success/success?state=1'
  236. })
  237. return false
  238. }else if(res.auditState==2){
  239. // 审核失败
  240. uni.redirectTo({
  241. url:'/card/success/success?state=2&&msg='+res.auditFailReason
  242. })
  243. }
  244. }
  245. this.id = res.id
  246. this.avatar = res.avatar;
  247. this.realName = res.realName;
  248. this.jobNumber = res.jobNumber;
  249. this.brief = res.brief;
  250. this.phone = res.phone;
  251. this.wechat = res.wechat;
  252. this.wechatCode = res.wechatCode;
  253. this.email = res.email;
  254. this.companyName = res.companyName;
  255. this.companyIntroduction = res.companyIntroduction
  256. this.industryName = res.industryName;
  257. this.tradeId = res.tradeId;
  258. this.address = res.address;
  259. this.job = res.job;
  260. this.morCity = [res.areaCode.substring(0,2)+'0000',res.areaCode.substring(0,4)+'00',res.areaCode]
  261. this.city = res.areaCodeName
  262. this.areaCode = this.morCity[2];
  263. this.latitude = res.latitude
  264. this.longitude = res.longitude
  265. }
  266. this.loading = false
  267. this.getEmploymentInfo()
  268. });
  269. },
  270. jumpUrl(url) {
  271. uni.navigateTo({
  272. url: url
  273. });
  274. },
  275. uploadImgs() {
  276. let that = this;
  277. uni.chooseImage({
  278. count: 1,
  279. sizeType: ['original', 'compressed'],
  280. sourceType: ['album', 'camera'],
  281. success: function({ tempFilePaths }) {
  282. var promise = Promise.all(
  283. tempFilePaths.map(tempFilePath => {
  284. return new Promise(function(resolve, reject) {
  285. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  286. that.avatar = res.src;
  287. });
  288. });
  289. })
  290. );
  291. promise
  292. .then(function(results) {
  293. console.log(results);
  294. })
  295. .catch(function(err) {
  296. console.log(err);
  297. });
  298. }
  299. });
  300. },
  301. uploadWechat() {
  302. let that = this;
  303. uni.chooseImage({
  304. count: 1,
  305. sizeType: ['original', 'compressed'],
  306. sourceType: ['album', 'camera'],
  307. success: function({ tempFilePaths }) {
  308. var promise = Promise.all(
  309. tempFilePaths.map(tempFilePath => {
  310. return new Promise(function(resolve, reject) {
  311. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  312. that.wechatCode = res.src;
  313. });
  314. });
  315. })
  316. );
  317. promise
  318. .then(function(results) {
  319. console.log(results);
  320. })
  321. .catch(function(err) {
  322. console.log(err);
  323. });
  324. }
  325. });
  326. },
  327. uploadHonor(type,index){
  328. let that = this;
  329. uni.chooseImage({
  330. count: type=='change'?1:(9-that.honorImgUrls.length),
  331. sizeType: ['original', 'compressed'],
  332. sourceType: ['album', 'camera'],
  333. success: function({ tempFilePaths }) {
  334. var promise = Promise.all(
  335. tempFilePaths.map(tempFilePath => {
  336. return new Promise(function(resolve, reject) {
  337. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  338. if(type=='change'){
  339. that.honorImgUrls[index] = res.src
  340. that.honorImgUrls = JSON.parse(JSON.stringify(that.honorImgUrls))
  341. }else{
  342. that.honorImgUrls = that.honorImgUrls.concat(res.src)
  343. }
  344. });
  345. });
  346. })
  347. );
  348. promise
  349. .then(function(results) {
  350. console.log(results);
  351. })
  352. .catch(function(err) {
  353. console.log(err);
  354. });
  355. }
  356. });
  357. },
  358. deleteHonor(index){
  359. this.honorImgUrls.splice(index,1)
  360. },
  361. // 个人风采
  362. uploadStyle(type,index){
  363. let that = this;
  364. uni.chooseImage({
  365. count: type=='change'?1:(9-that.styleImgUrls.length),
  366. sizeType: ['original', 'compressed'],
  367. sourceType: ['album', 'camera'],
  368. success: function({ tempFilePaths }) {
  369. var promise = Promise.all(
  370. tempFilePaths.map(tempFilePath => {
  371. return new Promise(function(resolve, reject) {
  372. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  373. if(type=='change'){
  374. that.styleImgUrls[index] = res.src
  375. that.styleImgUrls = JSON.parse(JSON.stringify(that.styleImgUrls))
  376. }else{
  377. that.styleImgUrls = that.styleImgUrls.concat(res.src)
  378. }
  379. });
  380. });
  381. })
  382. );
  383. promise
  384. .then(function(results) {
  385. console.log(results);
  386. })
  387. .catch(function(err) {
  388. console.log(err);
  389. });
  390. }
  391. });
  392. },
  393. deleteStyle(index){
  394. this.styleImgUrls.splice(index,1)
  395. },
  396. intMessage(e){
  397. this.nums = e.detail.value.length
  398. },
  399. intWechatNumber(){
  400. this.wechat = this.phone
  401. },
  402. bindCity: function(e) {
  403. this.morCity = e.detail.code;
  404. this.city = e.detail.value.join().replace(/[,]/g, '');
  405. this.areaCode = e.detail.code[2];
  406. },
  407. bindAddressChange(data) {
  408. this.morCity = data.ids;
  409. this.city = data.data[0] + data.data[1] + data.data[2];
  410. this.areaCode = data.ids[2];
  411. },
  412. chooseLocation() {
  413. var tha = this;
  414. uni.chooseLocation({
  415. success: function(res) {
  416. if (res.name) {
  417. tha.address = res.name;
  418. tha.reverseGeocoder(res);
  419. console.log('地址数据》》》:', res);
  420. }
  421. }
  422. });
  423. },
  424. reverseGeocoder(location) {
  425. // #ifdef H5
  426. location = location.latitude + ',' + location.longitude
  427. let url = 'https://apis.map.qq.com/ws/geocoder/v1/?address=';
  428. this.$jsonp(url, {
  429. key: req.public.mapLBSKEY,
  430. location: location,
  431. output: 'jsonp'
  432. }).then(data => {
  433. console.log('解析后的地址地址数据:', data);
  434. data = data.result
  435. this.city = data.ad_info.province+data.ad_info.city+data.ad_info.district
  436. this.areaCode = data.ad_info.adcode;
  437. this.morCity = [this.areaCode.substring(0,2)+'0000',this.areaCode.substring(0,4)+'00',this.areaCode]
  438. this.longitude = data.ad_info.location.lng
  439. this.latitude = data.ad_info.location.lat
  440. }).catch(err => {
  441. console.log(err);
  442. });
  443. // #endif
  444. // #ifndef H5
  445. QQMapWX.initMap();
  446. QQMapWX.reverseGeocoder(location, data => {
  447. console.log('解析后的地址地址数据:', data);
  448. this.city = data.ad_info.province+data.ad_info.city+data.ad_info.district
  449. this.areaCode = data.ad_info.adcode;
  450. this.morCity = [this.areaCode.substring(0,2)+'0000',this.areaCode.substring(0,4)+'00',this.areaCode]
  451. this.longitude = data.ad_info.location.lng
  452. this.latitude = data.ad_info.location.lat
  453. });
  454. //#endif
  455. },
  456. inDateChange(e){
  457. console.log(e.detail.value)
  458. this.inDate = e.detail.value
  459. },
  460. /**
  461. * 提交名片
  462. */
  463. submitCard() {
  464. let that = this;
  465. if (!this.avatar) return req.msg('请上传头像');
  466. if (!this.realName) return req.msg('请填写你的真实姓名');
  467. if (!this.jobNumber) return req.msg('请填写你的工号');
  468. if (!this.brief) return req.msg('请填写个人简介');
  469. if (!this.phone) return req.msg('请填写手机号');
  470. if (!this.wechat) return req.msg('请填写微信号');
  471. if (!this.wechatCode) return req.msg('请上传微信二维码');
  472. if (!this.companyName) return req.msg('请填写公司名称');
  473. if (!this.companyIntroduction) return req.msg('请填写公司简介');
  474. if (!this.job) return req.msg('请填写职位')
  475. if (!this.areaCode) return req.msg('请选择所在地区');
  476. if (!this.address) return req.msg('请填写详细地址');
  477. if (!this.inDate) return req.msg("请选择入司时间")
  478. var dataP = {};
  479. dataP.avatar = this.avatar;
  480. dataP.realName = this.realName;
  481. dataP.brief = this.brief;
  482. dataP.phone = this.phone;
  483. dataP.wechat = this.wechat;
  484. dataP.wechatCode = this.wechatCode;
  485. dataP.companyName = this.companyName;
  486. dataP.companyIntroduction = this.companyIntroduction;
  487. dataP.job = this.employmentInfo.actrank;
  488. dataP.inDate = this.inDate;
  489. // dataP.areaCode = {
  490. // id:this.areaCode,
  491. // name :this.city
  492. // };
  493. dataP.areaCode = this.areaCode
  494. dataP.areaCodeName = this.city
  495. dataP.address = this.address;
  496. dataP.longitude = this.longitude;
  497. dataP.latitude = this.latitude;
  498. dataP.jobNumber = this.jobNumber;
  499. dataP.honorImg = this.honorImgUrls.join(',');
  500. dataP.styleImg = this.styleImgUrls.join(',');
  501. var url = '';
  502. if (this.id) {
  503. dataP.id = this.id;
  504. uni.showModal({
  505. title:'提示',
  506. content:'重新提交将会重新审核信息,确定提交?',
  507. success: (con) => {
  508. if(con.confirm){
  509. req.postRequest(
  510. '/api/visiting/card/saveOrUpdate',
  511. dataP,
  512. json => {
  513. if (that.id) {
  514. uni.reLaunch({
  515. url:'/card/success/success'
  516. })
  517. // req.msg('修改成功');
  518. // setTimeout(function() {
  519. // uni.navigateBack({
  520. // delta: 1
  521. // });
  522. // }, 1500);
  523. } else {
  524. uni.reLaunch({
  525. url:'/card/success/success'
  526. })
  527. // req.msg('名片创建成功');
  528. // setTimeout(function() {
  529. // that.jumpUrl('/card/index/index');
  530. // }, 1500);
  531. }
  532. },
  533. true
  534. );
  535. }
  536. }
  537. })
  538. } else{
  539. req.postRequest(
  540. '/api/visiting/card/saveOrUpdate',
  541. dataP,
  542. json => {
  543. if (that.id) {
  544. uni.reLaunch({
  545. url:'/card/success/success'
  546. })
  547. // req.msg('修改成功');
  548. // setTimeout(function() {
  549. // uni.navigateBack({
  550. // delta: 1
  551. // });
  552. // }, 1500);
  553. } else {
  554. uni.reLaunch({
  555. url:'/card/success/success'
  556. })
  557. // req.msg('名片创建成功');
  558. // setTimeout(function() {
  559. // that.jumpUrl('/card/index/index');
  560. // }, 1500);
  561. }
  562. },
  563. true
  564. );
  565. }
  566. }
  567. }
  568. };
  569. </script>
  570. <style>
  571. @import './create.css';
  572. </style>