create.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. companyCode:'',
  171. location:{},
  172. longitude:'',
  173. latitude:'',
  174. userCard:null,//用户IP名片
  175. employmentInfo:'',
  176. saleNo:null,
  177. certificateNo:null,
  178. loading:true
  179. };
  180. },
  181. async onLoad(opt) {
  182. this.isEdit = opt.isEdit?true:false;
  183. this.id = opt.id;
  184. // if(opt.saleNo){
  185. // console.log(opt.saleNo)
  186. // this.saleNo = opt.saleNo
  187. // req.setStorage('saleNo',this.saleNo)
  188. // }else{
  189. // console.log(req.getStorage('saleNo'))
  190. // opt.saleNo = req.getStorage('saleNo')
  191. // this.saleNo = opt.saleNo
  192. // }
  193. await req.silenceLogin()
  194. console.log('getUserCard')
  195. this.getUserCard()
  196. this.getEmploymentInfo()
  197. },
  198. methods: {
  199. getUserInfo(){
  200. return new Promise((resolve,reject)=>{
  201. req.getRequest('/api/user/info',{},res=>{
  202. this.avatar = res.avatar;
  203. this.phone = res.mobile;
  204. resolve();
  205. })
  206. })
  207. },
  208. getEmploymentInfo(){
  209. return new Promise((resolve,reject)=>{
  210. req.getRequest('/api/visiting/card/employmentInfo',{jobNumber:req.getStorage('userInfo').saleNo},res=>{
  211. if(res.name){
  212. this.employmentInfo = res;
  213. this.realName = this.employmentInfo.name;
  214. this.certificateNo = this.employmentInfo.professionalCertificateNo
  215. this.jobNumber = this.employmentInfo.salesNo
  216. this.companyName = this.employmentInfo.branchName
  217. this.job = this.employmentInfo.actrankName
  218. this.inDate = this.employmentInfo.inDate
  219. this.companyCode = this.employmentInfo.branchNo
  220. }
  221. else return req.msg("员工信息不存在")
  222. resolve();
  223. })
  224. })
  225. },
  226. // 用户名片信息
  227. getUserCard(){
  228. req.getRequest('/api/visiting/card/userInfo', {}, res => {
  229. console.log('getUserCard',res)
  230. this.userCard = res
  231. if(!res){
  232. this.isEdit = true
  233. this.getUserInfo()
  234. }else{
  235. if(!this.isEdit){
  236. if(res.auditState==0){
  237. // 待审核
  238. uni.redirectTo({
  239. url:'/card/success/success?state=0'
  240. })
  241. return false
  242. }else if(res.auditState==1){
  243. // 审核成功
  244. uni.redirectTo({
  245. url:'/card/success/success?state=1'
  246. })
  247. return false
  248. }else if(res.auditState==2){
  249. // 审核失败
  250. uni.redirectTo({
  251. url:'/card/success/success?state=2&&msg='+res.auditFailReason
  252. })
  253. }
  254. }
  255. this.id = res.id
  256. this.avatar = res.avatar;
  257. this.realName = res.realName;
  258. this.jobNumber = res.jobNumber;
  259. this.brief = res.brief;
  260. this.phone = res.phone;
  261. this.wechat = res.wechat;
  262. this.wechatCode = res.wechatCode;
  263. this.email = res.email;
  264. this.companyName = res.companyName;
  265. this.companyIntroduction = res.companyIntroduction
  266. this.industryName = res.industryName;
  267. this.tradeId = res.tradeId;
  268. this.address = res.address;
  269. this.job = res.job;
  270. this.morCity = [res.areaCode.substring(0,2)+'0000',res.areaCode.substring(0,4)+'00',res.areaCode]
  271. this.city = res.areaCodeName
  272. this.areaCode = this.morCity[2];
  273. this.latitude = res.latitude
  274. this.longitude = res.longitude
  275. }
  276. this.loading = false
  277. this.getEmploymentInfo()
  278. });
  279. },
  280. jumpUrl(url) {
  281. uni.navigateTo({
  282. url: url
  283. });
  284. },
  285. uploadImgs() {
  286. let that = this;
  287. uni.chooseImage({
  288. count: 1,
  289. sizeType: ['original', 'compressed'],
  290. sourceType: ['album', 'camera'],
  291. success: function({ tempFilePaths }) {
  292. var promise = Promise.all(
  293. tempFilePaths.map(tempFilePath => {
  294. return new Promise(function(resolve, reject) {
  295. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  296. that.avatar = res.src;
  297. });
  298. });
  299. })
  300. );
  301. promise
  302. .then(function(results) {
  303. console.log(results);
  304. })
  305. .catch(function(err) {
  306. console.log(err);
  307. });
  308. }
  309. });
  310. },
  311. uploadWechat() {
  312. let that = this;
  313. uni.chooseImage({
  314. count: 1,
  315. sizeType: ['original', 'compressed'],
  316. sourceType: ['album', 'camera'],
  317. success: function({ tempFilePaths }) {
  318. var promise = Promise.all(
  319. tempFilePaths.map(tempFilePath => {
  320. return new Promise(function(resolve, reject) {
  321. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  322. that.wechatCode = res.src;
  323. });
  324. });
  325. })
  326. );
  327. promise
  328. .then(function(results) {
  329. console.log(results);
  330. })
  331. .catch(function(err) {
  332. console.log(err);
  333. });
  334. }
  335. });
  336. },
  337. uploadHonor(type,index){
  338. let that = this;
  339. uni.chooseImage({
  340. count: type=='change'?1:(9-that.honorImgUrls.length),
  341. sizeType: ['original', 'compressed'],
  342. sourceType: ['album', 'camera'],
  343. success: function({ tempFilePaths }) {
  344. var promise = Promise.all(
  345. tempFilePaths.map(tempFilePath => {
  346. return new Promise(function(resolve, reject) {
  347. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  348. if(type=='change'){
  349. that.honorImgUrls[index] = res.src
  350. that.honorImgUrls = JSON.parse(JSON.stringify(that.honorImgUrls))
  351. }else{
  352. that.honorImgUrls = that.honorImgUrls.concat(res.src)
  353. }
  354. });
  355. });
  356. })
  357. );
  358. promise
  359. .then(function(results) {
  360. console.log(results);
  361. })
  362. .catch(function(err) {
  363. console.log(err);
  364. });
  365. }
  366. });
  367. },
  368. deleteHonor(index){
  369. this.honorImgUrls.splice(index,1)
  370. },
  371. // 个人风采
  372. uploadStyle(type,index){
  373. let that = this;
  374. uni.chooseImage({
  375. count: type=='change'?1:(9-that.styleImgUrls.length),
  376. sizeType: ['original', 'compressed'],
  377. sourceType: ['album', 'camera'],
  378. success: function({ tempFilePaths }) {
  379. var promise = Promise.all(
  380. tempFilePaths.map(tempFilePath => {
  381. return new Promise(function(resolve, reject) {
  382. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  383. if(type=='change'){
  384. that.styleImgUrls[index] = res.src
  385. that.styleImgUrls = JSON.parse(JSON.stringify(that.styleImgUrls))
  386. }else{
  387. that.styleImgUrls = that.styleImgUrls.concat(res.src)
  388. }
  389. });
  390. });
  391. })
  392. );
  393. promise
  394. .then(function(results) {
  395. console.log(results);
  396. })
  397. .catch(function(err) {
  398. console.log(err);
  399. });
  400. }
  401. });
  402. },
  403. deleteStyle(index){
  404. this.styleImgUrls.splice(index,1)
  405. },
  406. intMessage(e){
  407. this.nums = e.detail.value.length
  408. },
  409. intWechatNumber(){
  410. this.wechat = this.phone
  411. },
  412. bindCity: function(e) {
  413. this.morCity = e.detail.code;
  414. this.city = e.detail.value.join().replace(/[,]/g, '');
  415. this.areaCode = e.detail.code[2];
  416. },
  417. bindAddressChange(data) {
  418. this.morCity = data.ids;
  419. this.city = data.data[0] + data.data[1] + data.data[2];
  420. this.areaCode = data.ids[2];
  421. },
  422. chooseLocation() {
  423. var tha = this;
  424. uni.chooseLocation({
  425. success: function(res) {
  426. if (res.name) {
  427. tha.address = res.name;
  428. tha.reverseGeocoder(res);
  429. console.log('地址数据》》》:', res);
  430. }
  431. }
  432. });
  433. },
  434. reverseGeocoder(location) {
  435. // #ifdef H5
  436. location = location.latitude + ',' + location.longitude
  437. let url = 'https://apis.map.qq.com/ws/geocoder/v1/?address=';
  438. this.$jsonp(url, {
  439. key: req.public.mapLBSKEY,
  440. location: location,
  441. output: 'jsonp'
  442. }).then(data => {
  443. console.log('解析后的地址地址数据:', data);
  444. data = data.result
  445. this.city = data.ad_info.province+data.ad_info.city+data.ad_info.district
  446. this.areaCode = data.ad_info.adcode;
  447. this.morCity = [this.areaCode.substring(0,2)+'0000',this.areaCode.substring(0,4)+'00',this.areaCode]
  448. this.longitude = data.ad_info.location.lng
  449. this.latitude = data.ad_info.location.lat
  450. }).catch(err => {
  451. console.log(err);
  452. });
  453. // #endif
  454. // #ifndef H5
  455. QQMapWX.initMap();
  456. QQMapWX.reverseGeocoder(location, data => {
  457. console.log('解析后的地址地址数据:', data);
  458. this.city = data.ad_info.province+data.ad_info.city+data.ad_info.district
  459. this.areaCode = data.ad_info.adcode;
  460. this.morCity = [this.areaCode.substring(0,2)+'0000',this.areaCode.substring(0,4)+'00',this.areaCode]
  461. this.longitude = data.ad_info.location.lng
  462. this.latitude = data.ad_info.location.lat
  463. });
  464. //#endif
  465. },
  466. inDateChange(e){
  467. console.log(e.detail.value)
  468. this.inDate = e.detail.value
  469. },
  470. /**
  471. * 提交名片
  472. */
  473. submitCard() {
  474. let that = this;
  475. if (!this.avatar) return req.msg('请上传头像');
  476. if (!this.realName) return req.msg('请填写你的真实姓名');
  477. if (!this.jobNumber) return req.msg('请填写你的工号');
  478. if (!this.brief) return req.msg('请填写个人简介');
  479. if (!this.phone) return req.msg('请填写手机号');
  480. if (!this.wechat) return req.msg('请填写微信号');
  481. if (!this.wechatCode) return req.msg('请上传微信二维码');
  482. if (!this.companyName) return req.msg('请填写公司名称');
  483. if (!this.companyIntroduction) return req.msg('请填写公司简介');
  484. if (!this.job) return req.msg('请填写职位')
  485. if (!this.areaCode) return req.msg('请选择所在地区');
  486. if (!this.address) return req.msg('请填写详细地址');
  487. if (!this.inDate) return req.msg("请选择入司时间")
  488. var dataP = {};
  489. dataP.avatar = this.avatar;
  490. dataP.realName = this.realName;
  491. dataP.brief = this.brief;
  492. dataP.phone = this.phone;
  493. dataP.wechat = this.wechat;
  494. dataP.wechatCode = this.wechatCode;
  495. dataP.companyName = this.companyName;
  496. dataP.companyIntroduction = this.companyIntroduction;
  497. dataP.job = this.employmentInfo.actrank;
  498. dataP.inDate = this.inDate;
  499. // dataP.areaCode = {
  500. // id:this.areaCode,
  501. // name :this.city
  502. // };
  503. dataP.areaCode = this.areaCode
  504. dataP.areaCodeName = this.city
  505. dataP.address = this.address;
  506. dataP.longitude = this.longitude;
  507. dataP.latitude = this.latitude;
  508. dataP.jobNumber = this.jobNumber;
  509. dataP.honorImg = this.honorImgUrls.join(',');
  510. dataP.styleImg = this.styleImgUrls.join(',');
  511. dataP.companyCode = this.companyCode
  512. var url = '';
  513. if (this.id) {
  514. dataP.id = this.id;
  515. uni.showModal({
  516. title:'提示',
  517. content:'重新提交将会重新审核信息,确定提交?',
  518. success: (con) => {
  519. if(con.confirm){
  520. req.postRequest(
  521. '/api/visiting/card/saveOrUpdate',
  522. dataP,
  523. json => {
  524. if (that.id) {
  525. uni.reLaunch({
  526. url:'/card/success/success'
  527. })
  528. // req.msg('修改成功');
  529. // setTimeout(function() {
  530. // uni.navigateBack({
  531. // delta: 1
  532. // });
  533. // }, 1500);
  534. } else {
  535. uni.reLaunch({
  536. url:'/card/success/success'
  537. })
  538. // req.msg('名片创建成功');
  539. // setTimeout(function() {
  540. // that.jumpUrl('/card/index/index');
  541. // }, 1500);
  542. }
  543. },
  544. true
  545. );
  546. }
  547. }
  548. })
  549. } else{
  550. req.postRequest(
  551. '/api/visiting/card/saveOrUpdate',
  552. dataP,
  553. json => {
  554. if (that.id) {
  555. uni.reLaunch({
  556. url:'/card/success/success'
  557. })
  558. // req.msg('修改成功');
  559. // setTimeout(function() {
  560. // uni.navigateBack({
  561. // delta: 1
  562. // });
  563. // }, 1500);
  564. } else {
  565. uni.reLaunch({
  566. url:'/card/success/success'
  567. })
  568. // req.msg('名片创建成功');
  569. // setTimeout(function() {
  570. // that.jumpUrl('/card/index/index');
  571. // }, 1500);
  572. }
  573. },
  574. true
  575. );
  576. }
  577. }
  578. }
  579. };
  580. </script>
  581. <style>
  582. @import './create.css';
  583. </style>