康巴易测肤/伤疤uniapp小程序类
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

101 lines
2.4KB

  1. <template>
  2. <view class="detect-face-con">
  3. <!-- <u-navbar is-back="true" class="nav-bar" title-color="#333" title="皮肤拍照" :custom-back="onNavBack"></u-navbar> -->
  4. <div class="comp" :style="{'top': paddTopHeight + 'px'}">
  5. <face-bio-assay :isDev="false" :top="paddTopHeight" :isShowNavbar="false" ref="faceDetect" @detectFailed="detectFailed" @photoChange="photoChange">
  6. </face-bio-assay>
  7. </div>
  8. </view>
  9. </template>
  10. <script>
  11. import faceBioAssay from '@/components/face-bio-assay/face-bio-assay.vue'
  12. export default {
  13. components: {
  14. faceBioAssay,
  15. },
  16. data() {
  17. return {
  18. paddTopHeight: '',
  19. props: {}
  20. }
  21. },
  22. onLoad(props) { //一定要onLoad,onShow在进入相机授权页面退回时会再次触发
  23. this.$refs.faceDetect.initData();
  24. },
  25. methods: {
  26. onNavBack() {
  27. console.log("点击了返回", );
  28. this.$u.route({
  29. type: 'redirectTo',
  30. url: '/pages/index/index',
  31. })
  32. },
  33. detectFailed(e) {
  34. if(e) {
  35. uni.showToast({
  36. title: "您未授权摄像头权限",
  37. icon: 'none'
  38. })
  39. // setTimeout(() => {
  40. // this.$u.route({
  41. // type: 'switchTab',
  42. // url: '/pages/index/index',
  43. // })
  44. // }, 1000)
  45. } else {
  46. uni.showToast({
  47. title: "摄像头加载失败~,请重试~",
  48. icon: 'none'
  49. })
  50. }
  51. /* uni.navigateBack() */
  52. },
  53. async photoChange(path) {
  54. let image = await this.$api.upload(
  55. this.$util.tempUrlToUpload(path, `${this.$util.formateDate('yyyy-mm-dd-HH:MM:SS')}_sign.png`,)
  56. );
  57. let imgUrl = image.data.fileUrl;
  58. console.log("imgUrl", imgUrl);
  59. this.$store.commit('setPhotoPath', imgUrl);
  60. this.$store.commit('saveAll');
  61. if(image) {
  62. // 跳转页面
  63. uni.redirectTo({
  64. url: `/pages/skin-assessment/photoProcess`,
  65. })
  66. } else {
  67. uni.showToast({
  68. title: "请您重新拍照",
  69. icon: 'none'
  70. })
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .detect-face-con {
  78. height: 100vh;
  79. width: 100vw;
  80. // overflow: hidden;
  81. z-index: 950;
  82. .nav-bar{
  83. position: absolute;
  84. top: 0;
  85. left: 0;
  86. /* height: 80rpx !important; */
  87. font-weight: 500 !important;
  88. z-index: 9999;
  89. }
  90. .comp {
  91. position: relative;
  92. }
  93. }
  94. </style>