interview.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <template>
  2. <view class="container">
  3. <!-- <view class="header">
  4. <text class="title">手部照片采集</text>
  5. </view> -->
  6. <view class="photo-container">
  7. <view class="instruction">
  8. <text>{{ instructions[currentStep] }}</text>
  9. </view>
  10. <view class="preview-container">
  11. <image v-if="photos[currentStep]" :src="photos[currentStep]" mode="aspectFit" class="preview-image"></image>
  12. <view v-else class="empty-preview">
  13. <text>{{ previewTexts[currentStep] }}</text>
  14. </view>
  15. </view>
  16. <view class="thumbnails">
  17. <view v-for="(photo, index) in photos" :key="index"
  18. class="thumbnail-item"
  19. :class="{ active: currentStep === index, completed: photo }">
  20. <image v-if="photo" :src="photo" mode="aspectFill" class="thumbnail-image" @click="previewPhoto(index)"></image>
  21. <view v-else class="thumbnail-placeholder">{{ index + 1 }}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="controls">
  26. <button class="camera-btn" @click="takePhoto">{{ photos[currentStep] ? '重新拍摄' : '拍摄照片' }}</button>
  27. <view class="navigation-btns">
  28. <button class="nav-btn prev" :disabled="currentStep === 0" @click="prevStep">上一步</button>
  29. <button class="nav-btn next" :disabled="!canGoNext" @click="nextStep">
  30. {{ currentStep === 5 && photos[5] ? '完成' : '下一步' }}
  31. </button>
  32. </view>
  33. </view>
  34. <!-- 为小程序环境添加camera组件 -->
  35. <view v-if="!isH5 && showCamera" class="camera-container">
  36. <camera
  37. device-position="back"
  38. flash="auto"
  39. @error="handleCameraError"
  40. class="camera-component"
  41. :mode="cameraMode"
  42. frame-size="medium"
  43. ></camera>
  44. <!-- 添加手势引导蒙层 -->
  45. <cover-view class="gesture-overlay">
  46. <cover-image
  47. :src="gestureOverlays[currentStep]"
  48. class="gesture-image"
  49. ></cover-image>
  50. <cover-view class="gesture-hint">
  51. <cover-view class="gesture-hint-text">{{ gestureHints[currentStep] }}</cover-view>
  52. </cover-view>
  53. </cover-view>
  54. <cover-view class="camera-controls">
  55. <cover-view class="capture-btn" @tap="capturePhotoMP"></cover-view>
  56. <cover-view class="cancel-btn" @tap="cancelCamera">取消</cover-view>
  57. </cover-view>
  58. </view>
  59. <!-- 为浏览器环境添加视频元素 -->
  60. <view v-if="isH5" class="camera-container" v-show="showCamera">
  61. <video ref="videoElement" class="camera-video" autoplay></video>
  62. <canvas ref="canvasElement" class="camera-canvas" style="display: none;"></canvas>
  63. <!-- 添加H5环境的手势引导蒙层 -->
  64. <view class="gesture-overlay">
  65. <image
  66. :src="gestureOverlays[currentStep]"
  67. class="gesture-image"
  68. ></image>
  69. <view class="gesture-hint">
  70. <text class="gesture-hint-text">{{ gestureHints[currentStep] }}</text>
  71. </view>
  72. </view>
  73. <button class="capture-btn" @click="capturePhoto">拍照</button>
  74. <button class="cancel-btn" @click="cancelCamera">取消</button>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import { apiBaseUrl } from '@/common/config.js'; // Import the base URL from a config file
  80. export default {
  81. data() {
  82. return {
  83. currentStep: 0,
  84. photos: [null, null, null, null, null, null], // 存储6张照片:左手正面、左手反面、左手握拳、右手正面、右手反面、右手握拳
  85. instructions: [
  86. '请将左手掌正面朝上,保持手指自然伸展,确保整个手掌清晰可见',
  87. '请将左手掌反面朝上,保持手指自然伸展,确保整个手背清晰可见',
  88. '请握紧左手拳头,使拳面朝向相机,确保整个拳头清晰可见',
  89. '请将右手掌正面朝上,保持手指自然伸展,确保整个手掌清晰可见',
  90. '请将右手掌反面朝上,保持手指自然伸展,确保整个手背清晰可见',
  91. '请握紧右手拳头,使拳面朝向相机,确保整个拳头清晰可见'
  92. ],
  93. previewTexts: [
  94. '左手掌正面照片预览区',
  95. '左手掌反面照片预览区',
  96. '左手握拳照片预览区',
  97. '右手掌正面照片预览区',
  98. '右手掌反面照片预览区',
  99. '右手握拳照片预览区'
  100. ],
  101. photoTypes: ['left_palm', 'left_back', 'left_fist', 'right_palm', 'right_back', 'right_fist'], // 照片类型标识
  102. isH5: false,
  103. showCamera: false,
  104. mediaStream: null,
  105. cameraContext: null,
  106. cameraMode: 'normal', // 添加相机模式
  107. cameraInitRetries: 0, // 添加重试计数器
  108. gestureOverlays: [
  109. /* '/static/images/palm_overlay.png', // 手掌正面引导图
  110. '/static/images/back_overlay.png', // 手掌反面引导图
  111. '/static/images/fist_overlay.png' // 握拳引导图 */
  112. ],
  113. gestureHints: [
  114. '请将左手掌对准轮廓线',
  115. '请将左手背对准轮廓线',
  116. '请将左手拳头对准轮廓线',
  117. '请将右手掌对准轮廓线',
  118. '请将右手背对准轮廓线',
  119. '请将右手拳头对准轮廓线'
  120. ],
  121. photoLinks: [null, null, null, null, null, null], // 存储上传后的图片链接
  122. }
  123. },
  124. computed: {
  125. canGoNext() {
  126. // 只有当前步骤的照片已拍摄才能进入下一步
  127. return this.photos[this.currentStep] !== null;
  128. }
  129. },
  130. onLoad() {
  131. // 判断当前平台
  132. // #ifdef H5
  133. this.isH5 = true;
  134. // #endif
  135. // 检查相机权限
  136. // #ifdef MP-WEIXIN
  137. uni.authorize({
  138. scope: 'scope.camera',
  139. success: () => {
  140. console.log('相机权限已授权');
  141. },
  142. fail: () => {
  143. uni.showModal({
  144. title: '提示',
  145. content: '请授权相机权限以完成手部照片采集',
  146. success: (res) => {
  147. if (res.confirm) {
  148. uni.openSetting();
  149. }
  150. }
  151. });
  152. }
  153. });
  154. // #endif
  155. },
  156. beforeDestroy() {
  157. // 在组件销毁前停止摄像头流
  158. this.stopMediaStream();
  159. },
  160. methods: {
  161. takePhoto() {
  162. // 根据平台选择不同的拍照方法
  163. if (this.isH5) {
  164. this.startCamera();
  165. } else {
  166. // 小程序环境使用camera组件
  167. this.showCamera = true;
  168. this.cameraInitRetries = 0; // 重置重试计数器
  169. this.$nextTick(() => {
  170. // 创建相机上下文
  171. // #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-TOUTIAO
  172. try {
  173. this.cameraContext = uni.createCameraContext();
  174. console.log('相机上下文创建成功');
  175. } catch (err) {
  176. console.error('创建相机上下文失败:', err);
  177. this.handleCameraInitError();
  178. }
  179. // #endif
  180. });
  181. }
  182. },
  183. uploadPhoto(filePathOrData, type) {
  184. console.log(`准备上传${type}类型的手部照片`);
  185. uni.showLoading({
  186. title: '上传中...'
  187. });
  188. // 获取用户openid
  189. const userInfo = uni.getStorageSync('userInfo');
  190. const openid = userInfo ? JSON.parse(userInfo).openid || '' : '';
  191. const tenant_id = uni.getStorageSync('tenant_id') || '1';
  192. // 检查用户信息是否完整
  193. if (!tenant_id) {
  194. uni.hideLoading();
  195. uni.showToast({
  196. title: '用户信息不完整,请重新登录',
  197. icon: 'none'
  198. });
  199. return;
  200. }
  201. // 如果是H5环境且是base64数据
  202. if (this.isH5 && filePathOrData.startsWith('data:image')) {
  203. // 将base64转为blob对象
  204. const base64Data = filePathOrData.split(',')[1];
  205. const blob = this.base64ToBlob(base64Data, 'image/jpeg');
  206. const formData = new FormData();
  207. // 确保文件参数名称正确
  208. formData.append('photo_file', blob, `${type}.jpg`);
  209. formData.append('application_id', uni.getStorageSync('appId'));
  210. formData.append('tenant_id', tenant_id);
  211. formData.append('description', `手部照片-${type}`);
  212. console.log('H5上传参数:', {
  213. application_id: uni.getStorageSync('appId'),
  214. tenant_id: tenant_id,
  215. description: `手部照片-${type}`
  216. });
  217. // 使用fetch直接上传到 job/upload_posture_photo 接口
  218. fetch(`${apiBaseUrl}/job/upload_posture_photo`, {
  219. method: 'POST',
  220. body: formData
  221. })
  222. .then(response => response.json())
  223. .then(result => {
  224. console.log('照片上传成功:', result);
  225. // 保存图片链接到对应类型的索引位置
  226. const index = this.photoTypes.indexOf(type);
  227. if (index !== -1 && result.data && result.data.url) {
  228. this.$set(this.photoLinks, index, result.data.url);
  229. console.log(`已保存${type}类型照片链接:`, result.data.url);
  230. }
  231. uni.hideLoading();
  232. uni.showToast({
  233. title: '照片上传成功',
  234. icon: 'success'
  235. });
  236. })
  237. .catch(error => {
  238. console.error('照片上传失败:', error);
  239. uni.hideLoading();
  240. uni.showToast({
  241. title: '照片上传失败,请重试',
  242. icon: 'none'
  243. });
  244. });
  245. } else {
  246. // 小程序环境的上传逻辑
  247. console.log(`小程序环境上传文件路径:`, filePathOrData);
  248. console.log('小程序上传参数:', {
  249. application_id: uni.getStorageSync('appId'),
  250. tenant_id: tenant_id,
  251. description: `手部照片-${type}`
  252. });
  253. uni.uploadFile({
  254. url: `${apiBaseUrl}/job/upload_posture_photo`,
  255. filePath: filePathOrData,
  256. name: 'photo_file', // 确保文件参数名称正确
  257. formData: { // 使用formData替代data以确保参数正确传递
  258. 'application_id': uni.getStorageSync('appId'),
  259. 'tenant_id': tenant_id,
  260. 'description': `手部照片-${type}`
  261. },
  262. success: (uploadRes) => {
  263. console.log('照片上传成功:', uploadRes);
  264. // 解析返回的JSON字符串
  265. let result;
  266. try {
  267. if (typeof uploadRes.data === 'string') {
  268. result = JSON.parse(uploadRes.data);
  269. } else {
  270. result = uploadRes.data;
  271. }
  272. console.log('解析后的上传结果:', result);
  273. // 保存图片链接到对应类型的索引位置
  274. const index = this.photoTypes.indexOf(type);
  275. if (index !== -1 && result.data && result.data.url) {
  276. this.$set(this.photoLinks, index, result.data.url);
  277. console.log(`已保存${type}类型照片链接:`, result.data.url);
  278. }
  279. } catch (e) {
  280. console.error('解析上传结果失败:', e);
  281. }
  282. uni.hideLoading();
  283. uni.showToast({
  284. title: '照片上传成功',
  285. icon: 'success'
  286. });
  287. },
  288. fail: (err) => {
  289. console.error('照片上传失败:', err);
  290. uni.hideLoading();
  291. uni.showToast({
  292. title: '照片上传失败,请重试',
  293. icon: 'none'
  294. });
  295. },
  296. complete: () => {
  297. uni.hideLoading();
  298. }
  299. });
  300. }
  301. },
  302. prevStep() {
  303. if (this.currentStep > 0) {
  304. this.currentStep--;
  305. }
  306. },
  307. nextStep() {
  308. if (this.currentStep < 5) {
  309. this.currentStep++;
  310. } else if (this.currentStep === 5 && this.photos[5]) {
  311. // 所有照片都已拍摄完成,可以进行提交或跳转
  312. this.submitAllPhotos();
  313. }
  314. },
  315. previewPhoto(index) {
  316. // 如果照片存在,则预览
  317. if (this.photos[index]) {
  318. uni.previewImage({
  319. urls: [this.photos[index]],
  320. current: this.photos[index]
  321. });
  322. }
  323. },
  324. submitAllPhotos() {
  325. // 检查是否所有照片都已拍摄
  326. if (this.photos.every(photo => photo !== null)) {
  327. uni.showLoading({
  328. title: '处理中...'
  329. });
  330. // 所有照片已经单独上传,这里只需要处理跳转
  331. setTimeout(() => {
  332. uni.hideLoading();
  333. uni.showToast({
  334. title: '手部照片采集完成',
  335. icon: 'success',
  336. duration: 2000,
  337. success: () => {
  338. // 延迟跳转,让用户看到成功提示
  339. setTimeout(() => {
  340. // 返回首页
  341. uni.switchTab({
  342. url: '/pages/index/index'
  343. });
  344. }, 2000);
  345. }
  346. });
  347. }, 500);
  348. } else {
  349. uni.showToast({
  350. title: '请完成所有照片拍摄',
  351. icon: 'none'
  352. });
  353. }
  354. },
  355. // H5环境下启动摄像头
  356. startCamera() {
  357. this.showCamera = true;
  358. // 确保浏览器支持getUserMedia
  359. if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  360. navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })
  361. .then(stream => {
  362. this.mediaStream = stream;
  363. // 等待DOM更新后再设置视频源
  364. this.$nextTick(() => {
  365. const videoElement = this.$refs.videoElement;
  366. if (videoElement) {
  367. videoElement.srcObject = stream;
  368. }
  369. });
  370. })
  371. .catch(error => {
  372. console.error('获取摄像头失败:', error);
  373. uni.showToast({
  374. title: '无法访问摄像头,请检查权限设置',
  375. icon: 'none'
  376. });
  377. this.showCamera = false;
  378. });
  379. } else {
  380. uni.showToast({
  381. title: '您的浏览器不支持摄像头功能',
  382. icon: 'none'
  383. });
  384. this.showCamera = false;
  385. }
  386. },
  387. // H5环境下拍照
  388. capturePhoto() {
  389. const videoElement = this.$refs.videoElement;
  390. const canvasElement = this.$refs.canvasElement;
  391. if (videoElement && canvasElement) {
  392. const context = canvasElement.getContext('2d');
  393. // 设置canvas尺寸与视频一致
  394. canvasElement.width = videoElement.videoWidth;
  395. canvasElement.height = videoElement.videoHeight;
  396. // 在canvas上绘制当前视频帧
  397. context.drawImage(videoElement, 0, 0, canvasElement.width, canvasElement.height);
  398. // 将canvas内容转为base64图片
  399. const photoData = canvasElement.toDataURL('image/jpeg');
  400. // 更新照片数据
  401. this.$set(this.photos, this.currentStep, photoData);
  402. // 上传照片
  403. this.uploadPhoto(photoData, this.photoTypes[this.currentStep]);
  404. // 关闭摄像头
  405. this.stopMediaStream();
  406. this.showCamera = false;
  407. }
  408. },
  409. // 小程序环境下拍照
  410. capturePhotoMP() {
  411. if (!this.cameraContext) {
  412. console.error('相机上下文不存在');
  413. this.handleCameraInitError();
  414. return;
  415. }
  416. try {
  417. this.cameraContext.takePhoto({
  418. quality: 'high',
  419. success: (res) => {
  420. console.log('拍照成功:', res);
  421. // 更新当前步骤的照片
  422. this.$set(this.photos, this.currentStep, res.tempImagePath);
  423. // 上传照片
  424. this.uploadPhoto(res.tempImagePath, this.photoTypes[this.currentStep]);
  425. // 关闭相机
  426. this.showCamera = false;
  427. },
  428. fail: (err) => {
  429. console.error('拍照失败:', err);
  430. uni.showToast({
  431. title: '拍照失败,请重试',
  432. icon: 'none'
  433. });
  434. // 尝试使用替代方法
  435. this.fallbackToChooseImage();
  436. }
  437. });
  438. } catch (err) {
  439. console.error('takePhoto方法执行失败:', err);
  440. this.fallbackToChooseImage();
  441. }
  442. },
  443. // 添加相机初始化错误处理
  444. handleCameraInitError() {
  445. if (this.cameraInitRetries < 3) {
  446. this.cameraInitRetries++;
  447. uni.showToast({
  448. title: `相机初始化失败,正在重试(${this.cameraInitRetries}/3)`,
  449. icon: 'none'
  450. });
  451. setTimeout(() => {
  452. this.showCamera = false;
  453. setTimeout(() => {
  454. this.takePhoto();
  455. }, 500);
  456. }, 1000);
  457. } else {
  458. uni.showToast({
  459. title: '相机初始化失败,将使用系统相机',
  460. icon: 'none'
  461. });
  462. this.fallbackToChooseImage();
  463. }
  464. },
  465. // 添加备用的系统相机方法
  466. fallbackToChooseImage() {
  467. this.showCamera = false;
  468. // 使用系统相机作为备选方案
  469. uni.chooseImage({
  470. count: 1,
  471. sourceType: ['camera'],
  472. success: (res) => {
  473. // 更新当前步骤的照片
  474. this.$set(this.photos, this.currentStep, res.tempFilePaths[0]);
  475. // 上传照片
  476. this.uploadPhoto(res.tempFilePaths[0], this.photoTypes[this.currentStep]);
  477. },
  478. fail: (err) => {
  479. console.error('选择图片失败:', err);
  480. uni.showToast({
  481. title: '拍照失败,请重试',
  482. icon: 'none'
  483. });
  484. }
  485. });
  486. },
  487. // 修改相机错误处理方法
  488. handleCameraError(e) {
  489. console.error('相机错误:', e.detail);
  490. // 记录更详细的错误信息
  491. const errorInfo = JSON.stringify(e.detail);
  492. console.log('详细错误信息:', errorInfo);
  493. uni.showToast({
  494. title: '相机启动失败,将使用系统相机',
  495. icon: 'none'
  496. });
  497. // 使用备用方法
  498. this.fallbackToChooseImage();
  499. },
  500. // 取消拍照 - 更新为同时支持H5和小程序
  501. cancelCamera() {
  502. if (this.isH5) {
  503. this.stopMediaStream();
  504. }
  505. this.showCamera = false;
  506. },
  507. // 停止摄像头流
  508. stopMediaStream() {
  509. if (this.mediaStream) {
  510. this.mediaStream.getTracks().forEach(track => {
  511. track.stop();
  512. });
  513. this.mediaStream = null;
  514. }
  515. },
  516. // base64转blob工具方法
  517. base64ToBlob(base64, mimeType) {
  518. const byteCharacters = atob(base64);
  519. const byteArrays = [];
  520. for (let offset = 0; offset < byteCharacters.length; offset += 512) {
  521. const slice = byteCharacters.slice(offset, offset + 512);
  522. const byteNumbers = new Array(slice.length);
  523. for (let i = 0; i < slice.length; i++) {
  524. byteNumbers[i] = slice.charCodeAt(i);
  525. }
  526. const byteArray = new Uint8Array(byteNumbers);
  527. byteArrays.push(byteArray);
  528. }
  529. return new Blob(byteArrays, { type: mimeType });
  530. },
  531. retryCamera() {
  532. this.showCamera = false;
  533. setTimeout(() => {
  534. this.takePhoto();
  535. }, 500);
  536. },
  537. // 可以添加一个方法来切换蒙层显示
  538. toggleGestureOverlay() {
  539. // 实现蒙层显示/隐藏的逻辑
  540. // 如果需要的话
  541. }
  542. }
  543. }
  544. </script>
  545. <style>
  546. .container {
  547. display: flex;
  548. flex-direction: column;
  549. height: 94vh;
  550. background-color: #f5f5f5;
  551. }
  552. .header {
  553. padding: 20rpx;
  554. background-color: #007AFF;
  555. text-align: center;
  556. }
  557. .title {
  558. color: #ffffff;
  559. font-size: 36rpx;
  560. font-weight: bold;
  561. }
  562. .photo-container {
  563. flex: 1;
  564. padding: 20rpx;
  565. display: flex;
  566. flex-direction: column;
  567. }
  568. .instruction {
  569. padding: 20rpx;
  570. background-color: #E5E5EA;
  571. border-radius: 10rpx;
  572. margin-bottom: 20rpx;
  573. }
  574. .preview-container {
  575. flex: 1;
  576. display: flex;
  577. justify-content: center;
  578. align-items: center;
  579. background-color: #E5E5EA;
  580. border-radius: 10rpx;
  581. margin-bottom: 20rpx;
  582. overflow: hidden;
  583. }
  584. .preview-image {
  585. width: 100%;
  586. height: 100%;
  587. }
  588. .empty-preview {
  589. display: flex;
  590. justify-content: center;
  591. align-items: center;
  592. width: 100%;
  593. height: 100%;
  594. color: #999;
  595. }
  596. .thumbnails {
  597. display: flex;
  598. justify-content: space-around;
  599. margin-bottom: 20rpx;
  600. }
  601. .thumbnail-item {
  602. width: 150rpx;
  603. height: 150rpx;
  604. border-radius: 10rpx;
  605. overflow: hidden;
  606. background-color: #E5E5EA;
  607. display: flex;
  608. justify-content: center;
  609. align-items: center;
  610. border: 4rpx solid transparent;
  611. }
  612. .thumbnail-item.active {
  613. border-color: #007AFF;
  614. }
  615. .thumbnail-item.completed {
  616. background-color: #ffffff;
  617. }
  618. .thumbnail-image {
  619. width: 100%;
  620. height: 100%;
  621. }
  622. .thumbnail-placeholder {
  623. font-size: 40rpx;
  624. color: #999;
  625. }
  626. .controls {
  627. padding: 20rpx;
  628. background-color: #ffffff;
  629. border-top: 1px solid #6c5ce7;
  630. }
  631. .camera-btn {
  632. width: 100%;
  633. height: 80rpx;
  634. line-height: 80rpx;
  635. text-align: center;
  636. background-color: #6c5ce7;
  637. color: white;
  638. border-radius: 40rpx;
  639. margin-bottom: 20rpx;
  640. }
  641. .navigation-btns {
  642. display: flex;
  643. justify-content: space-between;
  644. }
  645. .nav-btn {
  646. width: 48%;
  647. height: 80rpx;
  648. line-height: 80rpx;
  649. text-align: center;
  650. border-radius: 40rpx;
  651. }
  652. .nav-btn.prev {
  653. background-color: #E5E5EA;
  654. color: #333;
  655. }
  656. .nav-btn.next {
  657. background-color: #34C759;
  658. color: white;
  659. }
  660. .nav-btn[disabled] {
  661. opacity: 0.5;
  662. }
  663. /* 浏览器摄像头相关样式 */
  664. .camera-container {
  665. position: fixed;
  666. top: 0;
  667. left: 0;
  668. width: 100%;
  669. height: 100%;
  670. background-color: #000;
  671. z-index: 999;
  672. display: flex;
  673. flex-direction: column;
  674. justify-content: center;
  675. align-items: center;
  676. }
  677. .camera-video {
  678. width: 100%;
  679. height: 70%;
  680. object-fit: cover;
  681. }
  682. .camera-canvas {
  683. display: none;
  684. }
  685. .capture-btn {
  686. width: 200rpx;
  687. height: 200rpx;
  688. border-radius: 50%;
  689. background-color: #ffffff;
  690. border: 10rpx solid #6c5ce7;
  691. margin: 30rpx 0;
  692. }
  693. .cancel-btn {
  694. width: 200rpx;
  695. height: 80rpx;
  696. line-height: 80rpx;
  697. background-color: rgba(255, 255, 255, 0.3);
  698. color: #ffffff;
  699. text-align: center;
  700. border-radius: 40rpx;
  701. }
  702. /* 小程序相机组件样式 */
  703. .camera-component {
  704. width: 100%;
  705. height: 80%;
  706. display: block;
  707. }
  708. .camera-controls {
  709. width: 100%;
  710. display: flex;
  711. flex-direction: column;
  712. align-items: center;
  713. position: absolute;
  714. bottom: 50rpx;
  715. }
  716. /* 添加手势引导蒙层样式 */
  717. .gesture-overlay {
  718. position: absolute;
  719. top: 0;
  720. left: 0;
  721. width: 100%;
  722. height: 80%;
  723. display: flex;
  724. flex-direction: column;
  725. justify-content: center;
  726. align-items: center;
  727. pointer-events: none; /* 允许点击穿透 */
  728. z-index: 10;
  729. }
  730. .gesture-image {
  731. width: 70%;
  732. height: 70%;
  733. opacity: 0.6;
  734. }
  735. .gesture-hint {
  736. background-color: rgba(0, 0, 0, 0.5);
  737. padding: 10rpx 20rpx;
  738. border-radius: 10rpx;
  739. margin-top: 20rpx;
  740. }
  741. .gesture-hint-text {
  742. color: white;
  743. font-size: 28rpx;
  744. text-align: center;
  745. }
  746. </style>