companyImg.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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="upload-img">
  9. <image v-if="filePath" :src="filePath" mode="aspectFit"
  10. style="height:100%; width:100%; border-radius:8rpx"></image>
  11. <view v-else class="text-item" @click="chooseImage">
  12. <u-icon name="plus" color="#999" size="40" style="margin-bottom: 8rpx;"></u-icon>
  13. 上传营业执照
  14. </view>
  15. <view v-if="filePath" class="delete-btn" @click="deleteImage">×</view>
  16. </view>
  17. <view class="warning-title">注意事项</view>
  18. <view class="warning-desc">1.请上传所填公司一致的营业执照</view>
  19. <view class="warning-desc">2.营业执照信息和公章清晰可辨</view>
  20. <!-- 在职证明上传 -->
  21. <view class="upload-img">
  22. <view v-if="pdfFilePath" class="text-item">
  23. <template v-if="isImageFile(pdfFilePath)">
  24. <image
  25. :src="pdfFilePath"
  26. mode="aspectFill"
  27. class="preview-img"
  28. ></image>
  29. <view class="delete-btn" @click="deletePDF">×</view>
  30. </template>
  31. <template v-else>
  32. <u-icon name="file-text" color="#016bf6" size="40"></u-icon>
  33. <text style="margin-top: 8rpx;">已选择 PDF</text>
  34. <view class="delete-btn" @click="deletePDF">×</view>
  35. </template>
  36. </view>
  37. <fileSelector v-else :isShowStyle="false" title="上传在职证明" allowType=".pdf,image/*" @fileSelected="choosePDF" />
  38. </view>
  39. <!-- 模板下载部分 -->
  40. <view class="warning-title" style="margin-top: 20rpx;">
  41. <text style="color: #016bf6; margin-left: 8rpx;" @click="downloadTemplate">点击下载模板</text>
  42. </view>
  43. <view class="warning-title">注意事项</view>
  44. <view class="warning-desc">1.请上传加盖公章的在职证明(仅限 PDF 文件 或者 图片)</view>
  45. <!-- 公司证明上传 -->
  46. <view class="upload-group">
  47. <view v-for="(img, index) in companyProofList" :key="index" class="upload-img">
  48. <image :src="img" mode="aspectFill" style="width:100%;height:100%;border-radius:8rpx;"></image>
  49. <view class="delete-btn" @click="deleteCompanyProof(index)">×</view>
  50. </view>
  51. <view v-if="companyProofList.length < 4" class="upload-img text-item" @click="chooseCompanyProof">
  52. <u-icon name="plus" color="#999" size="40" style="margin-bottom: 8rpx;"></u-icon>
  53. 上传公司证明
  54. </view>
  55. </view>
  56. <view class="warning-title">注意事项</view>
  57. <view class="warning-desc">1.请上传公司前台LOGO照1-2张</view>
  58. <view class="warning-desc">2.请上传公司办公区照片1-2张</view>
  59. </view>
  60. <view class="bottom-btn" @click="goUnderReview">确认并提交</view>
  61. </view>
  62. </template>
  63. <script>
  64. import navBar from "@/components/nav-bar/index.vue";
  65. import configdata from '../../common/config.js';
  66. // 引入组件
  67. import fileSelector from '@/uni_modules/zhouquan-fileSelector/components/zhouquan-fileSelector/file-selector.vue';
  68. export default {
  69. data() {
  70. return {
  71. companyName: "",
  72. companyId: "",
  73. filePath: "", // 营业执照本地路径
  74. licenseUrl: "", // 营业执照上传后URL
  75. pdfFilePath: "", // 在职证明本地路径
  76. employmentVerification: "", // PDF 上传后URL
  77. companyProofList: [], // 公司证明本地预览图
  78. companyProofUrls: [], // 上传后URL列表
  79. action: configdata.APIHOST1 + '/alioss/upload'
  80. };
  81. },
  82. components: { navBar,fileSelector},
  83. onLoad(options) {
  84. if (options.companyName) this.companyName = decodeURIComponent(options.companyName);
  85. if (options.companyId) this.companyId = options.companyId;
  86. },
  87. methods: {
  88. // 判断是否为图片
  89. isImageFile(path) {
  90. return /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(path) || path.startsWith('data:image/')
  91. },
  92. // 下载模板
  93. downloadTemplate() {
  94. const url = 'https://h5.bosszan.com/员工在职证明-亿职赞模板.docx';
  95. uni.showLoading({ title: '正在下载模板...' });
  96. uni.downloadFile({
  97. url,
  98. success: (res) => {
  99. if (res.statusCode === 200) {
  100. uni.openDocument({
  101. filePath: res.tempFilePath,
  102. showMenu: true,
  103. success: () => {
  104. uni.hideLoading();
  105. },
  106. fail: () => {
  107. uni.hideLoading();
  108. uni.showToast({ title: '打开失败', icon: 'none' });
  109. }
  110. });
  111. } else {
  112. uni.hideLoading();
  113. uni.showToast({ title: '下载失败', icon: 'none' });
  114. }
  115. },
  116. fail: () => {
  117. uni.hideLoading();
  118. uni.showToast({ title: '网络异常', icon: 'none' });
  119. }
  120. });
  121. },
  122. // 通用上传
  123. async uploadSingleFile(path) {
  124. return new Promise((resolve, reject) => {
  125. uni.uploadFile({
  126. url: this.action,
  127. filePath: path,
  128. name: 'file',
  129. success: (res) => {
  130. const data = JSON.parse(res.data);
  131. if (data.code === 0 && data.data) resolve(data.data);
  132. else reject(data.msg || '上传失败');
  133. },
  134. fail: (err) => reject(err)
  135. });
  136. });
  137. },
  138. // ======= 营业执照上传 =======
  139. async chooseImage() {
  140. uni.chooseImage({
  141. count: 1,
  142. success: async (res) => {
  143. let tempFilePath = res.tempFilePaths[0];
  144. // HEIC 转换
  145. if (tempFilePath.toLowerCase().endsWith('.heic')) {
  146. try {
  147. tempFilePath = await this.convertHeicToJpg(tempFilePath);
  148. } catch (e) {
  149. return uni.showToast({ title: 'HEIC 转换失败,请使用 JPG/PNG', icon: 'none' });
  150. }
  151. }
  152. this.filePath = tempFilePath;
  153. // 自动上传
  154. uni.showLoading({ title: '上传营业执照中...' });
  155. try {
  156. this.licenseUrl = await this.uploadSingleFile(tempFilePath);
  157. uni.showToast({ title: '上传成功', icon: 'success' });
  158. } catch (e) {
  159. uni.showToast({ title: '上传失败', icon: 'none' });
  160. } finally {
  161. uni.hideLoading();
  162. }
  163. }
  164. });
  165. },
  166. deleteImage() {
  167. this.filePath = "";
  168. this.licenseUrl = "";
  169. },
  170. // ======= 在职证明上传 (PDF) =======
  171. async choosePDF(e) {
  172. var that = this
  173. const validExtensions = ['pdf', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
  174. const ext = e.name.split('.').pop().toLowerCase();
  175. if (!validExtensions.includes(ext)) {
  176. this.$queue.showToast('仅支持PDF或图片格式');
  177. return;
  178. }
  179. uni.getFileInfo({
  180. filePath: e.path,
  181. success: (info) => {
  182. let attachment_size = (info.size / 1024).toFixed(1)
  183. that.$queue.uploadFile(e.path, function (path) {
  184. if (path){
  185. that.pdfFilePath = path;
  186. that.employmentVerification = path;
  187. }else
  188. that.$queue.showToast('文件上传失败')
  189. })
  190. },
  191. fail: (err) => {
  192. console.error('获取失败', err);
  193. }
  194. });
  195. },
  196. deletePDF() {
  197. this.pdfFilePath = "";
  198. this.employmentVerification = "";
  199. },
  200. // ======= 公司证明上传(多图) =======
  201. async chooseCompanyProof() {
  202. if (this.companyProofList.length >= 4) {
  203. return uni.showToast({ title: '最多上传4张图片', icon: 'none' });
  204. }
  205. uni.chooseImage({
  206. count: 4 - this.companyProofList.length,
  207. success: async (res) => {
  208. const imgs = res.tempFilePaths;
  209. for (let img of imgs) {
  210. this.companyProofList.push(img);
  211. uni.showLoading({ title: '上传中...' });
  212. try {
  213. const url = await this.uploadSingleFile(img);
  214. this.companyProofUrls.push(url);
  215. } catch (e) {
  216. uni.showToast({ title: '部分图片上传失败', icon: 'none' });
  217. } finally {
  218. uni.hideLoading();
  219. }
  220. }
  221. }
  222. });
  223. },
  224. deleteCompanyProof(index) {
  225. this.companyProofList.splice(index, 1);
  226. this.companyProofUrls.splice(index, 1);
  227. },
  228. // ======= HEIC 转 JPG =======
  229. convertHeicToJpg(path) {
  230. return new Promise((resolve, reject) => {
  231. uni.getImageInfo({
  232. src: path,
  233. success: (img) => {
  234. const ctx = uni.createCanvasContext('myCanvas', this);
  235. ctx.drawImage(path, 0, 0, img.width, img.height);
  236. ctx.draw(false, () => {
  237. uni.canvasToTempFilePath({
  238. canvasId: 'myCanvas',
  239. fileType: 'jpg',
  240. quality: 0.9,
  241. success: (res) => resolve(res.tempFilePath),
  242. fail: (err) => reject(err)
  243. }, this);
  244. });
  245. },
  246. fail: (err) => reject(err)
  247. });
  248. });
  249. },
  250. // ======= 提交 =======
  251. async goUnderReview() {
  252. if (!this.licenseUrl) return uni.showToast({ title: '请上传营业执照', icon: 'none' });
  253. if (!this.employmentVerification) return uni.showToast({ title: '请上传在职证明PDF或者图片', icon: 'none' });
  254. if (this.companyProofUrls.length === 0) return uni.showToast({ title: '请上传公司证明图片', icon: 'none' });
  255. const data = {
  256. companyId: this.companyId,
  257. companyCertification: this.licenseUrl,
  258. employmentVerification: this.employmentVerification,
  259. companyVerification: this.companyProofUrls.join(',')
  260. };
  261. uni.showLoading({ title: '提交中...' });
  262. try {
  263. const res = await this.$Request.postJson("/app/company/updateCompany", data);
  264. uni.hideLoading();
  265. if (res.code === 0) {
  266. uni.showToast({ title: '提交成功', icon: 'success' });
  267. uni.navigateTo({ url: "/package/jobIntention/completeMsg" });
  268. } else {
  269. uni.showToast({ title: res.msg || '提交失败', icon: 'none' });
  270. }
  271. } catch (e) {
  272. uni.hideLoading();
  273. console.error('提交失败', e);
  274. uni.showToast({ title: '网络异常,请重试', icon: 'none' });
  275. }
  276. }
  277. }
  278. };
  279. </script>
  280. <canvas canvas-id="myCanvas" style="width:1px;height:1px;position:absolute;top:-1000rpx"></canvas>
  281. <style scoped lang="scss">
  282. .company {
  283. position: absolute;
  284. left: 0;
  285. right: 0;
  286. top: 0;
  287. bottom: 0;
  288. display: flex;
  289. flex-direction: column;
  290. font-family: DM Sans;
  291. .company-content {
  292. flex: 1;
  293. padding: 40rpx;
  294. box-sizing: border-box;
  295. overflow-y: auto;
  296. .company-title {
  297. color: #333;
  298. font-size: 40rpx;
  299. font-weight: 600;
  300. margin-bottom: 20rpx;
  301. }
  302. .company-desc {
  303. color: #666;
  304. font-size: 24rpx;
  305. line-height: 32rpx;
  306. }
  307. .upload-img {
  308. width: 142rpx;
  309. height: 142rpx;
  310. display: flex;
  311. justify-content: center;
  312. align-items: center;
  313. margin-top: 20rpx;
  314. position: relative;
  315. }
  316. .upload-group {
  317. display: flex;
  318. flex-wrap: wrap;
  319. gap: 20rpx;
  320. margin-top: 20rpx;
  321. }
  322. .text-item {
  323. width: 142rpx;
  324. height: 142rpx;
  325. color: #666;
  326. font-size: 16rpx;
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. flex-direction: column;
  331. background: #eee;
  332. border-radius: 12rpx;
  333. }
  334. .delete-btn {
  335. position: absolute;
  336. top: 0;
  337. right: 0;
  338. width: 36rpx;
  339. height: 36rpx;
  340. line-height: 36rpx;
  341. text-align: center;
  342. background: rgba(0, 0, 0, 0.5);
  343. color: #fff;
  344. border-radius: 50%;
  345. font-size: 28rpx;
  346. z-index: 10;
  347. }
  348. .warning-title {
  349. color: #666;
  350. font-size: 24rpx;
  351. margin-top: 20rpx;
  352. font-weight: 500;
  353. }
  354. .warning-desc {
  355. color: #666;
  356. font-size: 24rpx;
  357. margin-top: 8rpx;
  358. }
  359. }
  360. .bottom-btn {
  361. border-radius: 999px;
  362. background: #016bf6;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. color: #fff;
  367. font-size: 32rpx;
  368. padding: 16rpx 32rpx;
  369. margin: 20rpx;
  370. margin-bottom: 110rpx;
  371. }
  372. }
  373. </style>