companyImg.vue 11 KB

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