create.vue 17 KB

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