create.vue 20 KB

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