create.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view>
  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-model="job" :disabled="true" placeholder="请填写职位" placeholder-class="placeholder" class="ipt flex" />
  94. </view>
  95. <!-- <view class="li ddflex" @click="jumpUrl('/card/industry/industry?isPoistion=true')">
  96. <view class="label">行业</view>
  97. <view :class="'flex' + (industryName ? '' :' placeholder')">{{industryName ? industryName : '请填写行业'}}</view>
  98. <image src="../../static/images/rico.png" class="rico"></image>
  99. </view> -->
  100. <view class="li ddflex">
  101. <view class="label">所在地区</view>
  102. <view :class="['item flex', city ? 'active' : '']">
  103. <pickerAddress class="picker flex" @change="bindAddressChange">
  104. <view :class="city?'':'placeholder'">{{ city ? city : '请选择地区' }}</view>
  105. </pickerAddress>
  106. </view>
  107. <image src="../../static/images/rico.png" class="rico"></image>
  108. <!-- <picker class="picker flex">
  109. <view class="placeholder">请选择省份城市</view>
  110. <image src="../../static/images/rico.png" class="rico"></image>
  111. </picker> -->
  112. </view>
  113. <view class="li ddflex">
  114. <view class="label">地址</view>
  115. <input v-model="address" placeholder="填写街道地址" placeholder-class="placeholder" class="ipt flex" />
  116. </view>
  117. </view>
  118. <view class="bot">
  119. <view class="btn" @click="submitCard()">{{ isEdit ? '保存' : '确认创建' }}</view>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. const req = require('../../utils/request.js');
  125. const util = require('../../utils/util.js');
  126. var app = getApp();
  127. import pickerAddress from '../../components/wangding-pickerAddress/wangding-pickerAddress.vue';
  128. export default {
  129. components: { pickerAddress },
  130. data() {
  131. return {
  132. avatar: '',
  133. realName: '',
  134. phone: '',
  135. jobNumber:'',
  136. wechat: '',
  137. wechatCode:'',
  138. email: '',
  139. companyName: '',
  140. job:'',//职业
  141. industryName: '',//行业
  142. tradeId: '',//行业id
  143. message: '',
  144. isEdit: false,
  145. id: '' ,//名片id
  146. nums: 0,
  147. brief:'',//简介
  148. address:'',//详细地址
  149. honorImgUrls:[],//荣誉
  150. styleImgUrls:[],//风采
  151. city: '',
  152. areaCode: '',
  153. morCity: [],
  154. userCard:null,//用户IP名片
  155. employmentInfo:'',
  156. saleNo:null,
  157. certificateNo:null
  158. };
  159. },
  160. async onLoad(opt) {
  161. this.isEdit = opt.isEdit;
  162. this.id = opt.id;
  163. this.saleNo = opt.saleNo
  164. await req.silenceLogin(opt.saleNo)
  165. console.log('getUserCard')
  166. this.getUserCard()
  167. this.getEmploymentInfo()
  168. },
  169. methods: {
  170. getUserInfo(){
  171. return new Promise((resolve,reject)=>{
  172. req.getRequest('/api/user/info',{},res=>{
  173. this.avatar = res.avatar;
  174. this.phone = res.mobile;
  175. resolve();
  176. })
  177. })
  178. },
  179. getEmploymentInfo(){
  180. return new Promise((resolve,reject)=>{
  181. req.getRequest('/api/visiting/card/employmentInfo',{jobNumber:this.saleNo},res=>{
  182. if(res.name){
  183. this.employmentInfo = res;
  184. this.realName = this.employmentInfo.name;
  185. this.certificateNo = this.employmentInfo.professionalCertificateNo
  186. this.jobNumber = this.employmentInfo.salesNo
  187. this.companyName = this.employmentInfo.branchName
  188. this.job = this.employmentInfo.actrankName
  189. }
  190. else return req.msg("员工信息不存在")
  191. resolve();
  192. })
  193. })
  194. },
  195. // 用户名片信息
  196. getUserCard(){
  197. req.getRequest('/api/visiting/card/userInfo', {}, res => {
  198. console.log('getUserCard',res)
  199. this.userCard = res
  200. if(!res){
  201. this.getUserInfo()
  202. }else{
  203. this.id = res.id
  204. this.avatar = res.avatar;
  205. this.realName = res.realName;
  206. this.jobNumber = res.jobNumber;
  207. this.brief = res.brief;
  208. this.phone = res.phone;
  209. this.wechat = res.wechat;
  210. this.wechatCode = res.wechatCode;
  211. this.email = res.email;
  212. this.companyName = res.companyName;
  213. this.industryName = res.industryName;
  214. this.tradeId = res.tradeId;
  215. this.address = res.address;
  216. this.job = res.job;
  217. res.areaCode = JSON.parse(res.areaCode)
  218. this.morCity = [res.areaCode.id.substring(0,2)+'0000',res.areaCode.id.substring(0,4)+'00',res.areaCode.id]
  219. this.city = res.areaCode.name
  220. this.areaCode = this.morCity[2];
  221. }
  222. });
  223. },
  224. jumpUrl(url) {
  225. uni.navigateTo({
  226. url: url
  227. });
  228. },
  229. uploadImgs() {
  230. let that = this;
  231. uni.chooseImage({
  232. count: 1,
  233. sizeType: ['original', 'compressed'],
  234. sourceType: ['album', 'camera'],
  235. success: function({ tempFilePaths }) {
  236. var promise = Promise.all(
  237. tempFilePaths.map(tempFilePath => {
  238. return new Promise(function(resolve, reject) {
  239. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  240. that.avatar = res.src;
  241. });
  242. });
  243. })
  244. );
  245. promise
  246. .then(function(results) {
  247. console.log(results);
  248. })
  249. .catch(function(err) {
  250. console.log(err);
  251. });
  252. }
  253. });
  254. },
  255. uploadWechat() {
  256. let that = this;
  257. uni.chooseImage({
  258. count: 1,
  259. sizeType: ['original', 'compressed'],
  260. sourceType: ['album', 'camera'],
  261. success: function({ tempFilePaths }) {
  262. var promise = Promise.all(
  263. tempFilePaths.map(tempFilePath => {
  264. return new Promise(function(resolve, reject) {
  265. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  266. that.wechatCode = res.src;
  267. });
  268. });
  269. })
  270. );
  271. promise
  272. .then(function(results) {
  273. console.log(results);
  274. })
  275. .catch(function(err) {
  276. console.log(err);
  277. });
  278. }
  279. });
  280. },
  281. uploadHonor(type,index){
  282. let that = this;
  283. uni.chooseImage({
  284. count: type=='change'?1:(9-that.honorImgUrls.length),
  285. sizeType: ['original', 'compressed'],
  286. sourceType: ['album', 'camera'],
  287. success: function({ tempFilePaths }) {
  288. var promise = Promise.all(
  289. tempFilePaths.map(tempFilePath => {
  290. return new Promise(function(resolve, reject) {
  291. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  292. if(type=='change'){
  293. that.honorImgUrls[index] = res.src
  294. that.honorImgUrls = JSON.parse(JSON.stringify(that.honorImgUrls))
  295. }else{
  296. that.honorImgUrls = that.honorImgUrls.concat(res.src)
  297. }
  298. });
  299. });
  300. })
  301. );
  302. promise
  303. .then(function(results) {
  304. console.log(results);
  305. })
  306. .catch(function(err) {
  307. console.log(err);
  308. });
  309. }
  310. });
  311. },
  312. deleteHonor(index){
  313. this.honorImgUrls.splice(index,1)
  314. },
  315. // 个人风采
  316. uploadStyle(type,index){
  317. let that = this;
  318. uni.chooseImage({
  319. count: type=='change'?1:(9-that.styleImgUrls.length),
  320. sizeType: ['original', 'compressed'],
  321. sourceType: ['album', 'camera'],
  322. success: function({ tempFilePaths }) {
  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. if(type=='change'){
  328. that.styleImgUrls[index] = res.src
  329. that.styleImgUrls = JSON.parse(JSON.stringify(that.styleImgUrls))
  330. }else{
  331. that.styleImgUrls = that.styleImgUrls.concat(res.src)
  332. }
  333. });
  334. });
  335. })
  336. );
  337. promise
  338. .then(function(results) {
  339. console.log(results);
  340. })
  341. .catch(function(err) {
  342. console.log(err);
  343. });
  344. }
  345. });
  346. },
  347. deleteStyle(index){
  348. this.styleImgUrls.splice(index,1)
  349. },
  350. intMessage(e){
  351. this.nums = e.detail.value.length
  352. },
  353. intWechatNumber(){
  354. this.wechat = this.phone
  355. },
  356. bindCity: function(e) {
  357. this.morCity = e.detail.code;
  358. this.city = e.detail.value.join().replace(/[,]/g, '');
  359. this.areaCode = e.detail.code[2];
  360. },
  361. bindAddressChange(data) {
  362. this.morCity = data.ids;
  363. this.city = data.data[0] + data.data[1] + data.data[2];
  364. this.areaCode = data.ids[2];
  365. },
  366. /**
  367. * 提交名片
  368. */
  369. submitCard() {
  370. let that = this;
  371. if (!this.avatar) return req.msg('请上传头像');
  372. if (!this.realName) return req.msg('请填写你的真实姓名');
  373. if (!this.jobNumber) return req.msg('请填写你的工号');
  374. if (!this.brief) return req.msg('请填写个人简介');
  375. if (!this.phone) return req.msg('请填写手机号');
  376. if (!this.wechat) return req.msg('请填写微信号');
  377. if (!this.wechatCode) return req.msg('请上传微信二维码');
  378. if (!this.companyName) return req.msg('请填写公司名称');
  379. if (!this.job) return req.msg('请填写职位')
  380. if (!this.areaCode) return req.msg('请选择所在地区');
  381. if (!this.address) return req.msg('请填写详细地址');
  382. var dataP = {};
  383. dataP.avatar = this.avatar;
  384. dataP.realName = this.realName;
  385. dataP.brief = this.brief;
  386. dataP.phone = this.phone;
  387. dataP.wechat = this.wechat;
  388. dataP.wechatCode = this.wechatCode;
  389. dataP.companyName = this.companyName;
  390. dataP.job = this.employmentInfo.actrank;
  391. dataP.areaCode = {
  392. id:this.areaCode,
  393. name :this.city
  394. };
  395. dataP.areaCode = JSON.stringify(dataP.areaCode)
  396. dataP.address = this.address;
  397. dataP.jobNumber = this.jobNumber;
  398. dataP.honorImg = this.honorImgUrls.join(',');
  399. dataP.styleImg = this.styleImgUrls.join(',');
  400. var url = '';
  401. if (this.id) {
  402. dataP.id = this.id;
  403. }
  404. req.postRequest(
  405. '/api/visiting/card/saveOrUpdate',
  406. dataP,
  407. json => {
  408. if (that.id) {
  409. req.msg('保存成功');
  410. setTimeout(function() {
  411. uni.navigateBack({
  412. delta: 1
  413. });
  414. }, 1500);
  415. } else {
  416. req.msg('名片创建成功');
  417. setTimeout(function() {
  418. that.jumpUrl('/card/index/index');
  419. }, 1500);
  420. }
  421. },
  422. true
  423. );
  424. }
  425. }
  426. };
  427. </script>
  428. <style>
  429. @import './create.css';
  430. </style>