companyImg.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <view class="company">
  3. <nav-bar title="公司认证" color="#000"></nav-bar>
  4. <view class="company-content">
  5. <!-- 营业执照上传 -->
  6. <view class="company-title">上传公司营业执照</view>
  7. <view class="company-desc">请上传“{{ companyName }}”的营业执照</view>
  8. <view class="form-item">
  9. <view class="form-label"><text class="required">*</text>营业执照</view>
  10. <view class="upload-img">
  11. <image v-if="filePath" :src="filePath" mode="aspectFit"
  12. style="height:100%; width:100%; border-radius:8rpx"></image>
  13. <view v-else class="text-item" @click="chooseImage">
  14. <u-icon name="plus" color="#999" size="40" style="margin-bottom: 8rpx;"></u-icon>
  15. 上传营业执照
  16. </view>
  17. <view v-if="filePath" class="delete-btn" @click="deleteImage">×</view>
  18. </view>
  19. <view class="warning-title">注意事项</view>
  20. <view class="warning-desc">1.请上传所填公司一致的营业执照上传</view>
  21. <view class="warning-desc">2.营业执照信息和公章清晰可辨</view>
  22. <view class="warning-desc">3.公司信息可通过图片一键识别</view>
  23. </view>
  24. <view class="form-item">
  25. <view class="form-label"><text class="required">*</text>企业名称</view>
  26. <view class="form-content">
  27. <input v-model="companyName" placeholder="请输入企业名称" placeholder-class="placeholder" />
  28. </view>
  29. </view>
  30. <view class="form-item">
  31. <view class="form-label"><text class="required">*</text>企业法人</view>
  32. <view class="form-content">
  33. <input v-model="companyLegalPerson" placeholder="请输入企业法人" placeholder-class="placeholder" />
  34. </view>
  35. </view>
  36. <view class="form-item">
  37. <view class="form-label"><text class="required">*</text>企业信用代码</view>
  38. <view class="form-content">
  39. <input v-model="companyDutyParagraph" placeholder="请输入企业信用代码" placeholder-class="placeholder" />
  40. </view>
  41. </view>
  42. <view class="form-item">
  43. <view class="form-label">注册时间</view>
  44. <view class="form-content" @click="showDateModal = true">
  45. <template v-if="companyCreateTime">{{ companyCreateTime }}</template>
  46. <text v-else>请选择注册时间</text>
  47. </view>
  48. </view>
  49. <view class="form-item">
  50. <view class="form-label">注册资本</view>
  51. <view class="form-content">
  52. <input v-model="companyRegisteredFund" placeholder="请输入注册资本" placeholder-class="placeholder" />
  53. </view>
  54. </view>
  55. <!-- 在职证明上传 -->
  56. <view class="form-item">
  57. <view class="form-label"><text class="required">*</text>在职证明</view>
  58. <view class="upload-img">
  59. <view v-if="pdfFilePath" class="text-item">
  60. <template v-if="isImageFile(pdfFilePath)">
  61. <image
  62. :src="pdfFilePath"
  63. mode="aspectFill"
  64. class="preview-img"
  65. ></image>
  66. <view class="delete-btn" @click="deletePDF">×</view>
  67. </template>
  68. <template v-else>
  69. <u-icon name="file-text" color="#016bf6" size="40"></u-icon>
  70. <text style="margin-top: 8rpx;">已选择 PDF</text>
  71. <view class="delete-btn" @click="deletePDF">×</view>
  72. </template>
  73. </view>
  74. <fileSelector v-else :isShowStyle="false" title="上传在职证明" allowType=".pdf,image/*" @fileSelected="choosePDF" />
  75. </view>
  76. <!-- 模板下载部分 -->
  77. <view class="warning-title" style="margin-top: 20rpx;">
  78. <text style="color: #016bf6; margin-left: 8rpx;" @click="downloadTemplate">下载亿职赞模板</text>
  79. </view>
  80. <view class="warning-title">注意事项</view>
  81. <view class="warning-desc">1.请上传加盖公章的在职证明</view>
  82. </view>
  83. <!-- 公司证明上传 -->
  84. <view class="form-item">
  85. <view class="form-label"><text class="required">*</text>公司证明</view>
  86. <view class="upload-group">
  87. <view v-for="(img, index) in companyProofList" :key="index" class="upload-img">
  88. <image :src="img" mode="aspectFill" style="width:100%;height:100%;border-radius:8rpx;"></image>
  89. <view class="delete-btn" @click="deleteCompanyProof(index)">×</view>
  90. </view>
  91. <view v-if="companyProofList.length < 4" class="upload-img text-item" @click="chooseCompanyProof">
  92. <u-icon name="plus" color="#999" size="40" style="margin-bottom: 8rpx;"></u-icon>
  93. 上传公司证明
  94. </view>
  95. </view>
  96. <view class="warning-title">注意事项</view>
  97. <view class="warning-desc">1.请上传清晰且完整的公司前台LOGO照1-2张</view>
  98. <view class="warning-desc">2.请上传公司办公区照片1-2张</view>
  99. </view>
  100. </view>
  101. <u-calendar v-model="showDateModal" mode="date" @change="handleChangeDate"></u-calendar>
  102. <view class="button-section">
  103. <view class="link-btn" @click="handleAfterVerify">稍后认证</view>
  104. <view class="submit-btn" @click="goUnderReview">确认并提交</view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import navBar from "@/components/nav-bar/index.vue";
  110. import configdata from '../../common/config.js';
  111. // 引入组件
  112. import fileSelector from '@/uni_modules/zhouquan-fileSelector/components/zhouquan-fileSelector/file-selector.vue';
  113. export default {
  114. data() {
  115. return {
  116. companyName: "",
  117. companyId: "",
  118. companyLegalPerson: '', // 企业法人
  119. companyDutyParagraph: '', // 信用代码
  120. companyCreateTime: '', // 注册时间
  121. companyRegisteredFund: '', // 注册资本
  122. filePath: "", // 营业执照本地路径
  123. licenseUrl: "", // 营业执照上传后URL
  124. pdfFilePath: "", // 在职证明本地路径
  125. employmentVerification: "", // PDF 上传后URL
  126. companyProofList: [], // 公司证明本地预览图
  127. companyProofUrls: [], // 上传后URL列表
  128. action: configdata.APIHOST1 + '/alioss/upload',
  129. actionBusinessLicense: configdata.APIHOST1 + '/alioss/uploadBusinessLicense',
  130. showDateModal: false
  131. };
  132. },
  133. components: { navBar,fileSelector},
  134. onLoad(options) {
  135. if (options.companyName) this.companyName = decodeURIComponent(options.companyName);
  136. if (options.companyId) this.companyId = options.companyId;
  137. },
  138. methods: {
  139. // 判断是否为图片
  140. isImageFile(path) {
  141. return /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(path) || path.startsWith('data:image/')
  142. },
  143. // 下载模板
  144. downloadTemplate() {
  145. const url = 'https://h5.bosszan.com/员工在职证明-亿职赞模板.docx';
  146. uni.showLoading({ title: '正在下载模板...' });
  147. uni.downloadFile({
  148. url,
  149. success: (res) => {
  150. if (res.statusCode === 200) {
  151. uni.openDocument({
  152. filePath: res.tempFilePath,
  153. showMenu: true,
  154. success: () => {
  155. uni.hideLoading();
  156. },
  157. fail: () => {
  158. uni.hideLoading();
  159. uni.showToast({ title: '打开失败', icon: 'none' });
  160. }
  161. });
  162. } else {
  163. uni.hideLoading();
  164. uni.showToast({ title: '下载失败', icon: 'none' });
  165. }
  166. },
  167. fail: () => {
  168. uni.hideLoading();
  169. uni.showToast({ title: '网络异常', icon: 'none' });
  170. }
  171. });
  172. },
  173. // 通用上传
  174. async uploadSingleFile(path, url) {
  175. return new Promise((resolve, reject) => {
  176. uni.uploadFile({
  177. url: url ? url : this.action,
  178. filePath: path,
  179. name: 'file',
  180. formData: {
  181. isBusinessLicense: url ? true : false
  182. },
  183. success: (res) => {
  184. const data = JSON.parse(res.data);
  185. if (data.code === 0 && data.data) {
  186. if (data.data.src) {
  187. this.companyName = data.data.companyName
  188. this.companyCreateTime = data.data.companyCreateTime?.slice(0, 10)
  189. this.companyDutyParagraph = data.data.companyDutyParagraph
  190. this.companyLegalPerson = data.data.companyLegalPerson
  191. this.companyLegalPerson = data.data.companyLegalPerson
  192. }
  193. let imgUrl = url ? data.data.src : data.data
  194. resolve(imgUrl);
  195. } else {
  196. reject(data.msg || '上传失败');
  197. }
  198. },
  199. fail: (err) => reject(err)
  200. });
  201. });
  202. },
  203. // ======= 营业执照上传 =======
  204. async chooseImage() {
  205. uni.chooseImage({
  206. count: 1,
  207. success: async (res) => {
  208. let tempFilePath = res.tempFilePaths[0];
  209. // HEIC 转换
  210. if (tempFilePath.toLowerCase().endsWith('.heic')) {
  211. try {
  212. tempFilePath = await this.convertHeicToJpg(tempFilePath);
  213. } catch (e) {
  214. return uni.showToast({ title: 'HEIC 转换失败,请使用 JPG/PNG', icon: 'none' });
  215. }
  216. }
  217. this.filePath = tempFilePath;
  218. // 自动上传
  219. uni.showLoading({ title: '上传营业执照中...' });
  220. try {
  221. this.licenseUrl = await this.uploadSingleFile(tempFilePath, this.actionBusinessLicense);
  222. uni.showToast({ title: '上传成功', icon: 'success' });
  223. } catch (e) {
  224. uni.showToast({ title: '上传失败', icon: 'none' });
  225. } finally {
  226. uni.hideLoading();
  227. }
  228. }
  229. });
  230. },
  231. deleteImage() {
  232. this.filePath = "";
  233. this.licenseUrl = "";
  234. },
  235. // ======= 在职证明上传 (PDF) =======
  236. async choosePDF(e) {
  237. var that = this
  238. const validExtensions = ['pdf', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
  239. const ext = e.name.split('.').pop().toLowerCase();
  240. if (!validExtensions.includes(ext)) {
  241. this.$queue.showToast('仅支持PDF或图片格式');
  242. return;
  243. }
  244. uni.getFileInfo({
  245. filePath: e.path,
  246. success: (info) => {
  247. let attachment_size = (info.size / 1024).toFixed(1)
  248. that.$queue.uploadFile(e.path, function (path) {
  249. if (path){
  250. that.pdfFilePath = path;
  251. that.employmentVerification = path;
  252. }else
  253. that.$queue.showToast('文件上传失败')
  254. })
  255. },
  256. fail: (err) => {
  257. console.error('获取失败', err);
  258. }
  259. });
  260. },
  261. deletePDF() {
  262. this.pdfFilePath = "";
  263. this.employmentVerification = "";
  264. },
  265. // ======= 公司证明上传(多图) =======
  266. async chooseCompanyProof() {
  267. if (this.companyProofList.length >= 4) {
  268. return uni.showToast({ title: '最多上传4张图片', icon: 'none' });
  269. }
  270. uni.chooseImage({
  271. count: 4 - this.companyProofList.length,
  272. success: async (res) => {
  273. const imgs = res.tempFilePaths;
  274. for (let img of imgs) {
  275. this.companyProofList.push(img);
  276. uni.showLoading({ title: '上传中...' });
  277. try {
  278. const url = await this.uploadSingleFile(img);
  279. this.companyProofUrls.push(url);
  280. } catch (e) {
  281. uni.showToast({ title: '部分图片上传失败', icon: 'none' });
  282. } finally {
  283. uni.hideLoading();
  284. }
  285. }
  286. }
  287. });
  288. },
  289. deleteCompanyProof(index) {
  290. this.companyProofList.splice(index, 1);
  291. this.companyProofUrls.splice(index, 1);
  292. },
  293. // ======= HEIC 转 JPG =======
  294. convertHeicToJpg(path) {
  295. return new Promise((resolve, reject) => {
  296. uni.getImageInfo({
  297. src: path,
  298. success: (img) => {
  299. const ctx = uni.createCanvasContext('myCanvas', this);
  300. ctx.drawImage(path, 0, 0, img.width, img.height);
  301. ctx.draw(false, () => {
  302. uni.canvasToTempFilePath({
  303. canvasId: 'myCanvas',
  304. fileType: 'jpg',
  305. quality: 0.9,
  306. success: (res) => resolve(res.tempFilePath),
  307. fail: (err) => reject(err)
  308. }, this);
  309. });
  310. },
  311. fail: (err) => reject(err)
  312. });
  313. });
  314. },
  315. // ======= 提交 =======
  316. async goUnderReview() {
  317. if (!this.licenseUrl) return uni.showToast({ title: '请上传营业执照', icon: 'none' });
  318. if (!this.companyName) return uni.showToast({ title: '请输入企业名称', icon: 'none' });
  319. if (!this.companyLegalPerson) return uni.showToast({ title: '请输入企业法人', icon: 'none' });
  320. if (!this.companyDutyParagraph) return uni.showToast({ title: '请输入企业信用代码', icon: 'none' });
  321. if (!this.employmentVerification) return uni.showToast({ title: '请上传在职证明PDF或者图片', icon: 'none' });
  322. if (this.companyProofUrls.length === 0) return uni.showToast({ title: '请上传公司证明图片', icon: 'none' });
  323. const data = {
  324. companyId: this.companyId,
  325. companyName: this.companyName,
  326. companyLegalPerson: this.companyLegalPerson,
  327. companyDutyParagraph: this.companyDutyParagraph,
  328. companyCreateTime: this.companyCreateTime,
  329. companyRegisteredFund: this.companyRegisteredFund,
  330. companyCertification: this.licenseUrl,
  331. employmentVerification: this.employmentVerification,
  332. companyVerification: this.companyProofUrls.join(',')
  333. };
  334. uni.showLoading({ title: '提交中...' });
  335. try {
  336. const res = await this.$Request.postJson("/app/company/updateCompany", data);
  337. uni.hideLoading();
  338. if (res.code === 0) {
  339. uni.showToast({ title: '提交成功', icon: 'success' });
  340. // uni.navigateTo({ url: "/package/jobIntention/completeMsg" });
  341. uni.navigateTo({ url: "/package/jobIntention/underReview" });
  342. } else {
  343. uni.showToast({ title: res.msg || '提交失败', icon: 'none' });
  344. }
  345. } catch (e) {
  346. uni.hideLoading();
  347. console.error('提交失败', e);
  348. uni.showToast({ title: '网络异常,请重试', icon: 'none' });
  349. }
  350. },
  351. // 选择注册时间
  352. handleChangeDate(e) {
  353. this.companyCreateTime = e.result
  354. },
  355. // 稍后认证
  356. handleAfterVerify() {
  357. uni.navigateTo({ url: "/package/jobIntention/completeMsg" });
  358. }
  359. }
  360. };
  361. </script>
  362. <canvas canvas-id="myCanvas" style="width:1px;height:1px;position:absolute;top:-1000rpx"></canvas>
  363. <style scoped lang="scss">
  364. .company {
  365. position: absolute;
  366. left: 0;
  367. right: 0;
  368. top: 0;
  369. bottom: 0;
  370. display: flex;
  371. flex-direction: column;
  372. font-family: DM Sans;
  373. .company-content {
  374. flex: 1;
  375. padding: 40rpx;
  376. box-sizing: border-box;
  377. overflow-y: auto;
  378. .company-title {
  379. color: #333;
  380. font-size: 48rpx;
  381. font-weight: 700;
  382. line-height: 60rpx;
  383. margin-bottom: 20rpx;
  384. }
  385. .company-desc {
  386. color: #666;
  387. font-size: 24rpx;
  388. line-height: 32rpx;
  389. margin-bottom: 20rpx;
  390. }
  391. .form-item {
  392. margin-bottom: 20rpx;
  393. .form-label {
  394. font-size: 28rpx;
  395. font-weight: 500;
  396. line-height: 44rpx;
  397. color: #1F2C37;
  398. margin-bottom: 20rpx;
  399. .required {
  400. color: #FF0000;
  401. }
  402. }
  403. .form-content {
  404. box-sizing: border-box;
  405. border: 1px solid rgba(227, 231, 236, 1);
  406. border-radius: 48rpx;
  407. background: rgba(255, 255, 255, 1);
  408. padding: 15rpx 32rpx;
  409. text,
  410. .placeholder {
  411. color: rgba(153, 153, 153, 1);
  412. }
  413. input {
  414. font-size: 28rpx;
  415. font-weight: 400;
  416. line-height: 40rpx;
  417. }
  418. }
  419. }
  420. .upload-img {
  421. width: 142rpx;
  422. height: 142rpx;
  423. display: flex;
  424. justify-content: center;
  425. align-items: center;
  426. position: relative;
  427. }
  428. .upload-group {
  429. display: flex;
  430. flex-wrap: wrap;
  431. gap: 20rpx;
  432. margin-top: 20rpx;
  433. }
  434. .text-item {
  435. width: 142rpx;
  436. height: 142rpx;
  437. color: #666;
  438. font-size: 16rpx;
  439. display: flex;
  440. justify-content: center;
  441. align-items: center;
  442. flex-direction: column;
  443. background: #eee;
  444. border-radius: 12rpx;
  445. }
  446. .delete-btn {
  447. position: absolute;
  448. top: 0;
  449. right: 0;
  450. width: 36rpx;
  451. height: 36rpx;
  452. line-height: 36rpx;
  453. text-align: center;
  454. background: rgba(0, 0, 0, 0.5);
  455. color: #fff;
  456. border-radius: 50%;
  457. font-size: 28rpx;
  458. z-index: 10;
  459. }
  460. .warning-title {
  461. color: #666;
  462. font-size: 24rpx;
  463. margin-top: 20rpx;
  464. font-weight: 500;
  465. }
  466. .warning-desc {
  467. color: #666;
  468. font-size: 24rpx;
  469. margin-top: 8rpx;
  470. }
  471. }
  472. .button-section {
  473. padding: 28rpx 40rpx;
  474. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  475. }
  476. .submit-btn {
  477. flex-shrink: 0;
  478. border-radius: 999px;
  479. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  480. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  481. color: rgba(255, 255, 255, 1);
  482. font-family: DM Sans;
  483. font-size: 32rpx;
  484. font-weight: 400;
  485. line-height: 48rpx;
  486. display: flex;
  487. justify-content: center;
  488. align-items: center;
  489. padding: 16rpx 32rpx;
  490. box-sizing: border-box;
  491. }
  492. .link-btn {
  493. text-align: center;
  494. color: rgba(1, 107, 246, 1);
  495. font-size: 16px;
  496. font-weight: 400;
  497. line-height: 16px;
  498. margin-bottom: 32rpx;
  499. }
  500. }
  501. </style>