create.vue 14 KB

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