companyImg.vue 9.8 KB

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