interview.vue 23 KB

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