create.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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?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. uni.showLoading({
  293. title:'上传中'
  294. })
  295. var promise =Promise.all(
  296. tempFilePaths.map(tempFilePath => {
  297. return new Promise(function(resolve, reject) {
  298. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  299. that.avatar = res.src;
  300. resolve()
  301. });
  302. });
  303. })
  304. );
  305. promise
  306. .then(function(results) {
  307. console.log(results);
  308. uni.hideLoading()
  309. })
  310. .catch(function(err) {
  311. console.log(err);
  312. uni.hideLoading()
  313. });
  314. }
  315. });
  316. },
  317. uploadWechat() {
  318. let that = this;
  319. uni.chooseImage({
  320. count: 1,
  321. sizeType: ['original', 'compressed'],
  322. sourceType: ['album', 'camera'],
  323. success: function({ tempFilePaths }) {
  324. uni.showLoading({
  325. title:'上传中'
  326. })
  327. var promise = Promise.all(
  328. tempFilePaths.map(tempFilePath => {
  329. return new Promise(function(resolve, reject) {
  330. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  331. that.wechatCode = res.src;
  332. resolve()
  333. });
  334. });
  335. })
  336. );
  337. promise
  338. .then(function(results) {
  339. console.log(results);
  340. uni.hideLoading()
  341. })
  342. .catch(function(err) {
  343. console.log(err);
  344. uni.hideLoading()
  345. });
  346. }
  347. });
  348. },
  349. uploadHonor(type,index){
  350. let that = this;
  351. uni.chooseImage({
  352. count: type=='change'?1:(9-that.honorImgUrls.length),
  353. sizeType: ['original', 'compressed'],
  354. sourceType: ['album', 'camera'],
  355. success: function({ tempFilePaths }) {
  356. uni.showLoading({
  357. title:'上传中'
  358. })
  359. var promise = Promise.all(
  360. tempFilePaths.map(tempFilePath => {
  361. return new Promise(function(resolve, reject) {
  362. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  363. if(type=='change'){
  364. that.honorImgUrls[index] = res.src
  365. that.honorImgUrls = JSON.parse(JSON.stringify(that.honorImgUrls))
  366. }else{
  367. that.honorImgUrls = that.honorImgUrls.concat(res.src)
  368. }
  369. resolve()
  370. });
  371. });
  372. })
  373. );
  374. promise
  375. .then(function(results) {
  376. console.log(results);
  377. uni.hideLoading()
  378. })
  379. .catch(function(err) {
  380. console.log(err);
  381. uni.hideLoading()
  382. });
  383. }
  384. });
  385. },
  386. deleteHonor(index){
  387. this.honorImgUrls.splice(index,1)
  388. },
  389. // 个人风采
  390. uploadStyle(type,index){
  391. let that = this;
  392. uni.chooseImage({
  393. count: type=='change'?1:(9-that.styleImgUrls.length),
  394. sizeType: ['original', 'compressed'],
  395. sourceType: ['album', 'camera'],
  396. success: function({ tempFilePaths }) {
  397. uni.showLoading({
  398. title:'上传中'
  399. })
  400. var promise = Promise.all(
  401. tempFilePaths.map(tempFilePath => {
  402. return new Promise(function(resolve, reject) {
  403. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  404. if(type=='change'){
  405. that.styleImgUrls[index] = res.src
  406. that.styleImgUrls = JSON.parse(JSON.stringify(that.styleImgUrls))
  407. }else{
  408. that.styleImgUrls = that.styleImgUrls.concat(res.src)
  409. }
  410. resolve()
  411. });
  412. });
  413. })
  414. );
  415. promise
  416. .then(function(results) {
  417. console.log(results);
  418. uni.hideLoading()
  419. })
  420. .catch(function(err) {
  421. console.log(err);
  422. uni.hideLoading()
  423. });
  424. }
  425. });
  426. },
  427. deleteStyle(index){
  428. this.styleImgUrls.splice(index,1)
  429. },
  430. intMessage(e){
  431. this.nums = e.detail.value.length
  432. },
  433. intWechatNumber(){
  434. this.wechat = this.phone
  435. },
  436. bindCity: function(e) {
  437. this.morCity = e.detail.code;
  438. this.city = e.detail.value.join().replace(/[,]/g, '');
  439. this.areaCode = e.detail.code[2];
  440. },
  441. bindAddressChange(data) {
  442. this.morCity = data.ids;
  443. this.city = data.data[0] + data.data[1] + data.data[2];
  444. this.areaCode = data.ids[2];
  445. },
  446. chooseLocation() {
  447. var tha = this;
  448. uni.chooseLocation({
  449. success: function(res) {
  450. if (res.name) {
  451. tha.address = res.name;
  452. tha.reverseGeocoder(res);
  453. console.log('地址数据》》》:', res);
  454. }
  455. }
  456. });
  457. },
  458. reverseGeocoder(location) {
  459. // #ifdef H5
  460. location = location.latitude + ',' + location.longitude
  461. let url = 'https://apis.map.qq.com/ws/geocoder/v1/?address=';
  462. this.$jsonp(url, {
  463. key: req.public.mapLBSKEY,
  464. location: location,
  465. output: 'jsonp'
  466. }).then(data => {
  467. console.log('解析后的地址地址数据:', data);
  468. data = data.result
  469. this.city = data.ad_info.province+data.ad_info.city+data.ad_info.district
  470. this.areaCode = data.ad_info.adcode;
  471. this.morCity = [this.areaCode.substring(0,2)+'0000',this.areaCode.substring(0,4)+'00',this.areaCode]
  472. this.longitude = data.location.lng
  473. this.latitude = data.location.lat
  474. }).catch(err => {
  475. console.log(err);
  476. });
  477. // #endif
  478. // #ifndef H5
  479. QQMapWX.initMap();
  480. QQMapWX.reverseGeocoder(location, data => {
  481. console.log('解析后的地址地址数据:', data);
  482. this.city = data.ad_info.province+data.ad_info.city+data.ad_info.district
  483. this.areaCode = data.ad_info.adcode;
  484. this.morCity = [this.areaCode.substring(0,2)+'0000',this.areaCode.substring(0,4)+'00',this.areaCode]
  485. this.longitude = data.location.lng
  486. this.latitude = data.location.lat
  487. });
  488. //#endif
  489. },
  490. inDateChange(e){
  491. console.log(e.detail.value)
  492. this.inDate = e.detail.value
  493. },
  494. /**
  495. * 提交名片
  496. */
  497. submitCard() {
  498. let that = this;
  499. if (!this.avatar) return req.msg('请上传头像');
  500. if (!this.realName) return req.msg('请填写你的真实姓名');
  501. if (!this.jobNumber) return req.msg('请填写你的工号');
  502. if (!this.brief) return req.msg('请填写个人简介');
  503. if (!this.phone) return req.msg('请填写手机号');
  504. // if (!this.wechat) return req.msg('请填写微信号');
  505. // if (!this.wechatCode) return req.msg('请上传微信二维码');
  506. if (!this.companyName) return req.msg('请填写公司名称');
  507. // if (!this.companyIntroduction) return req.msg('请填写公司简介');
  508. if (!this.job) return req.msg('请填写职位')
  509. if (!this.areaCode) return req.msg('请选择所在地区');
  510. if (!this.address) return req.msg('请填写详细地址');
  511. if (!this.inDate) return req.msg("请选择入司时间")
  512. var dataP = {};
  513. dataP.avatar = this.avatar;
  514. dataP.realName = this.realName;
  515. dataP.brief = this.brief;
  516. dataP.phone = this.phone;
  517. dataP.wechat = this.wechat;
  518. dataP.wechatCode = this.wechatCode;
  519. dataP.companyName = this.companyName;
  520. dataP.companyIntroduction = this.companyIntroduction;
  521. dataP.job = this.employmentInfo.actrank;
  522. dataP.inDate = this.inDate;
  523. // dataP.areaCode = {
  524. // id:this.areaCode,
  525. // name :this.city
  526. // };
  527. dataP.areaCode = this.areaCode
  528. dataP.areaCodeName = this.city
  529. dataP.address = this.address;
  530. dataP.longitude = this.longitude;
  531. dataP.latitude = this.latitude;
  532. dataP.jobNumber = this.jobNumber;
  533. dataP.honorImg = this.honorImgUrls.join(',');
  534. dataP.styleImg = this.styleImgUrls.join(',');
  535. dataP.companyCode = this.companyCode
  536. var url = '';
  537. if (this.id) {
  538. dataP.id = this.id;
  539. uni.showModal({
  540. title:'提示',
  541. content:'重新提交将会重新审核信息,确定提交?',
  542. success: (con) => {
  543. if(con.confirm){
  544. req.postRequest(
  545. '/api/visiting/card/saveOrUpdate',
  546. dataP,
  547. json => {
  548. if (that.id) {
  549. uni.reLaunch({
  550. url:'/card/success/success'
  551. })
  552. // req.msg('修改成功');
  553. // setTimeout(function() {
  554. // uni.navigateBack({
  555. // delta: 1
  556. // });
  557. // }, 1500);
  558. } else {
  559. uni.reLaunch({
  560. url:'/card/success/success'
  561. })
  562. // req.msg('名片创建成功');
  563. // setTimeout(function() {
  564. // that.jumpUrl('/card/index/index');
  565. // }, 1500);
  566. }
  567. },
  568. true
  569. );
  570. }
  571. }
  572. })
  573. } else{
  574. req.postRequest(
  575. '/api/visiting/card/saveOrUpdate',
  576. dataP,
  577. json => {
  578. if (that.id) {
  579. uni.reLaunch({
  580. url:'/card/success/success'
  581. })
  582. // req.msg('修改成功');
  583. // setTimeout(function() {
  584. // uni.navigateBack({
  585. // delta: 1
  586. // });
  587. // }, 1500);
  588. } else {
  589. uni.reLaunch({
  590. url:'/card/success/success'
  591. })
  592. // req.msg('名片创建成功');
  593. // setTimeout(function() {
  594. // that.jumpUrl('/card/index/index');
  595. // }, 1500);
  596. }
  597. },
  598. true
  599. );
  600. }
  601. }
  602. }
  603. };
  604. </script>
  605. <style>
  606. @import './create.css';
  607. </style>