create.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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(1)">
  7. <image :src="avatar ? avatar : '../../static/pages/images/userimg.png'" mode="aspectFill" class="userimg"></image>
  8. <image src="../../static/pages/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="msg" 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/pages/images/rico.png" class="rico"></image>
  24. </view> -->
  25. </view>
  26. <view class="form">
  27. <view class="tit ddflex"><view class="flex">联系信息</view></view>
  28. <view class="li ddflex">
  29. <view class="label">手机</view>
  30. <input v-model="phone" maxlength="11" type="number" placeholder="请填写手机号" placeholder-class="placeholder" class="ipt flex" />
  31. <view class="tong ddflex" @click="intWechatNumber"><image src="../static/images/wxth.png"></image>微信同号</view>
  32. </view>
  33. <view class="li ddflex">
  34. <view class="label">邮箱</view>
  35. <input v-model="email" placeholder="请填写邮箱地址" placeholder-class="placeholder" class="ipt flex" />
  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>
  42. <view class="form">
  43. <view class="tit ddflex"><view class="flex">公司信息</view></view>
  44. <view class="li ddflex">
  45. <view class="label">公司</view>
  46. <input v-model="companyName" placeholder="请填写公司名称" placeholder-class="placeholder" class="ipt flex" />
  47. </view>
  48. <view class="li ddflex">
  49. <view class="label">职位</view>
  50. <input v-model="job" placeholder="请填写职位" placeholder-class="placeholder" class="ipt flex" />
  51. <view class="ddflex" style="padding: 30rpx 0 30rpx 90rpx;"
  52. @click="jumpUrl('/card/industry/industry?isPoistion=true')">
  53. <view class="tong ddflex" style="margin-right: 10rpx;">
  54. 常用职位
  55. </view>
  56. <image src="../../static/pages/images/rico.png" class="rico"></image>
  57. </view>
  58. </view>
  59. <!-- <view class="li ddflex" @click="jumpUrl('/card/industry/industry?isPoistion=true')">
  60. <view class="label">行业</view>
  61. <view :class="'flex' + (industryName ? '' :' placeholder')">{{industryName ? industryName : '请填写行业'}}</view>
  62. <image src="../../static/pages/images/rico.png" class="rico"></image>
  63. </view> -->
  64. <view class="li ddflex">
  65. <view class="label">所在地区</view>
  66. <view :class="['item flex', city ? 'active' : '']">
  67. <!-- #ifdef MP-WEIXIN -->
  68. <picker class="picker flex" mode="region" :value="morCity" @change="bindCity">
  69. <view :class="city?'':'placeholder'">{{ city ? city : '请选择地区' }}</view>
  70. </picker>
  71. <!-- #endif -->
  72. <!-- #ifdef APP-PLUS -->
  73. <pickerAddress class="picker flex" @change="bindAddressChange">
  74. <view :class="city?'':'placeholder'">{{ city ? city : '请选择地区' }}</view>
  75. </pickerAddress>
  76. <!-- #endif -->
  77. </view>
  78. <image src="../../static/pages/images/rico.png" class="rico"></image>
  79. <!-- <picker class="picker flex">
  80. <view class="placeholder">请选择省份城市</view>
  81. <image src="../../static/images/rico.png" class="rico"></image>
  82. </picker> -->
  83. </view>
  84. <view class="li ddflex">
  85. <view class="label">地址</view>
  86. <input v-model="address" placeholder="填写街道地址" placeholder-class="placeholder" class="ipt flex" />
  87. </view>
  88. <!-- <view class="li ddflex">
  89. <view class="label">公司LOGO</view>
  90. <view class="photo ddflex flex" @tap="uploadImgs(2)">
  91. <image :src="companyLogo ? companyLogo : ''" mode="aspectFit" class="userimg"></image>
  92. <image src="../../static/pages/images/rico.png" class="rico"></image>
  93. </view>
  94. </view> -->
  95. </view>
  96. <view class="bot">
  97. <view class="btn" @click="submitCard()">{{ isEdit ? '保存' : '确认创建' }}</view>
  98. </view>
  99. </view>
  100. </template>
  101. <script>
  102. const req = require('../../utils/request.js');
  103. const api = require('../../utils/api.js');
  104. const util = require('../../utils/util.js');
  105. var app = getApp();
  106. import pickerAddress from '../components/wangding-pickerAddress/wangding-pickerAddress.vue';
  107. export default {
  108. components: { pickerAddress },
  109. data() {
  110. return {
  111. avatar: '',
  112. realName: '',
  113. phone: '',
  114. wechat: '',
  115. email: '',
  116. companyName: '',
  117. job:'',//职业
  118. industryName: '',//行业
  119. tradeId: '',//行业id
  120. message: '',
  121. isEdit: false,
  122. id: '' ,//名片id
  123. nums: 0,
  124. msg: '',
  125. brief:'',//简介
  126. address:'',//详细地址
  127. companyLogo: '',
  128. city: '',
  129. areaCode: '',
  130. morCity: [],
  131. userCard:null,//用户IP名片
  132. };
  133. },
  134. onLoad(opt) {
  135. this.isEdit = opt.isEdit;
  136. this.id = opt.id;
  137. console.log('getUserCard')
  138. this.getUserCard()
  139. },
  140. methods: {
  141. getUserInfo(){
  142. return new Promise((resolve,reject)=>{
  143. req.getRequest('/api/user/info',{},res=>{
  144. this.avatar = res.avatar;
  145. this.realName = res.realName ? res.realName : res.nickName;
  146. this.phone = res.mobile;
  147. resolve();
  148. })
  149. })
  150. },
  151. // 用户名片信息
  152. getUserCard(){
  153. req.getRequest(api.card_userInfo, {}, res => {
  154. console.log('getUserCard',res)
  155. this.userCard = res
  156. if(!res){
  157. this.getCompanyData()
  158. this.getUserInfo()
  159. }else{
  160. this.id = res.id
  161. this.avatar = res.avatar;
  162. this.realName = res.realName;
  163. this.msg = res.msg;
  164. this.brief = res.brief;
  165. this.phone = res.phone;
  166. this.wechat = res.wechat;
  167. this.email = res.email;
  168. this.companyName = res.companyName;
  169. this.industryName = res.industryName;
  170. this.tradeId = res.tradeId;
  171. this.address = res.address;
  172. this.companyLogo = res.companyLogo;
  173. this.job = res.job;
  174. res.areaCode = JSON.parse(res.areaCode)
  175. this.morCity = [res.areaCode.id.substring(0,2)+'0000',res.areaCode.id.substring(0,4)+'00',res.areaCode.id]
  176. this.city = res.areaCode.name
  177. this.areaCode = this.morCity[2];
  178. }
  179. });
  180. },
  181. getCompanyData(){
  182. req.getRequest('/api/CKBCompany/info',{},res=>{
  183. if(res){
  184. this.companyName = res.title
  185. this.industryName = res.trade
  186. this.tradeId = res.industryId
  187. this.address = res.address
  188. this.morCity = JSON.parse(res.areaCode).map(item=>{return item.id})
  189. this.areaCode = JSON.parse(res.areaCode).map(item=>{return item.id})[2]
  190. this.city = JSON.parse(res.areaCode).map(item=>{return item.name}).join('')
  191. }
  192. })
  193. },
  194. jumpUrl(url) {
  195. uni.navigateTo({
  196. url: url
  197. });
  198. },
  199. uploadImgs(type) {
  200. let that = this;
  201. uni.chooseImage({
  202. count: 1,
  203. sizeType: ['original', 'compressed'],
  204. sourceType: ['album', 'camera'],
  205. success: function({ tempFilePaths }) {
  206. uni.showLoading({
  207. title: '正在上传'
  208. })
  209. var promise = Promise.all(
  210. tempFilePaths.map(tempFilePath => {
  211. return new Promise(function(resolve, reject) {
  212. req.uploadFile('/api/upload', tempFilePath, res => {
  213. if(type == 1){
  214. that.avatar = res.src;
  215. }else{
  216. that.companyLogo = res.src;
  217. }
  218. uni.hideLoading();
  219. });
  220. });
  221. })
  222. );
  223. promise
  224. .then(function(results) {
  225. console.log(results);
  226. })
  227. .catch(function(err) {
  228. console.log(err);
  229. });
  230. }
  231. });
  232. },
  233. intMessage(e){
  234. this.nums = e.detail.value.length
  235. },
  236. intWechatNumber(){
  237. this.wechat = this.phone
  238. },
  239. bindCity: function(e) {
  240. this.morCity = e.detail.code;
  241. this.city = e.detail.value.join().replace(/[,]/g, '');
  242. this.areaCode = e.detail.code[2];
  243. },
  244. bindAddressChange(data) {
  245. this.morCity = data.ids;
  246. this.city = data.data[0] + data.data[1] + data.data[2];
  247. this.areaCode = data.ids[2];
  248. },
  249. /**
  250. * 提交名片
  251. */
  252. submitCard() {
  253. let that = this;
  254. if (!this.avatar) return req.msg('请上传头像');
  255. if (!this.realName) return req.msg('请填写你的真实姓名');
  256. if (!this.msg) return req.msg('请填写你的服务寄语');
  257. // if (!this.brief) return req.msg('请填写个人简介');
  258. if (!this.phone) return req.msg('请填写手机号');
  259. if (!this.wechat) return req.msg('请填写微信号');
  260. if (!this.email) return req.msg('请填写邮箱地址');
  261. if (!this.companyName) return req.msg('请填写公司名称');
  262. if (!this.job) return req.msg('请填写职位')
  263. // if (!this.industryName) return req.msg('请填写行业');
  264. if (!this.areaCode) return req.msg('请选择所在地区');
  265. if (!this.address) return req.msg('请填写详细地址');
  266. // if (!this.companyLogo) return req.msg('请上传公司LOGO');
  267. var dataP = {};
  268. dataP.avatar = this.avatar;
  269. dataP.realName = this.realName;
  270. dataP.msg = this.msg;
  271. // dataP.brief = this.brief;
  272. dataP.phone = this.phone;
  273. dataP.wechat = this.wechat;
  274. dataP.email = this.email;
  275. dataP.companyName = this.companyName;
  276. dataP.job = this.job;
  277. // dataP.industryName = this.industryName;
  278. // dataP.tradeId = this.tradeId;
  279. dataP.areaCode = {
  280. id:this.areaCode,
  281. name :this.city
  282. };
  283. dataP.areaCode = JSON.stringify(dataP.areaCode)
  284. dataP.address = this.address;
  285. // dataP.companyLogo = this.companyLogo;
  286. var url = '';
  287. if (this.id) {
  288. dataP.id = this.id;
  289. }
  290. req.postRequest(
  291. api.card_saveOrUpdate,
  292. dataP,
  293. json => {
  294. if (that.id) {
  295. req.msg('保存成功');
  296. setTimeout(function() {
  297. uni.navigateBack({
  298. delta: 1
  299. });
  300. }, 1500);
  301. } else {
  302. req.msg('名片创建成功');
  303. setTimeout(function() {
  304. uni.redirectTo({
  305. url: '/card/index/index'
  306. })
  307. }, 1500);
  308. }
  309. },
  310. true
  311. );
  312. }
  313. }
  314. };
  315. </script>
  316. <style>
  317. @import './create.css';
  318. </style>