康巴易测肤/伤疤uniapp小程序类
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

233 行
5.5KB

  1. <template>
  2. <view class="photo-process">
  3. <!-- <u-navbar is-back="true" class="nav-bar" :border-bottom ="false" title-color="#333" title="图片识别" :custom-back="onNavBack">
  4. </u-navbar> -->
  5. <image class="photo-process-img" :src="detectFaceImg" mode="widthFix" :show-menu-by-longpress="true"></image>
  6. <!-- <view class="canvas-con">
  7. <canvas canvas-id="myCanvas" id="myCanvas"></canvas>
  8. </view> -->
  9. <cover-view class="action">
  10. <cover-view shape="circle" hover-class="none" class="btn" @click="onPhotoReSet">重拍</cover-view>
  11. <cover-view shape="circle" hover-class="none" class="btn full" @click="onSubmit">确认</cover-view>
  12. </cover-view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. paddTopHeight: '',
  20. imgSize: null,
  21. props: {}
  22. }
  23. },
  24. computed: {
  25. detectFaceImg() {
  26. return this.$store.state
  27. .detectFaceImg || 'https://telpo-healthy.oss-cn-hangzhou.aliyuncs.com/healthy/knowledge/202410/d09e1e9b99cf496aab3422d9f1e766d5.png'
  28. }
  29. },
  30. methods: {
  31. onNavBack() {
  32. if(this.props && this.props.nuring) {
  33. let params = '';
  34. params = `?imei=${this.props.imei}&isDetectFace=true&nuring=${this.props.nuring}&logId=${this.props.logId || 0}&mode=${this.props.mode}`;
  35. uni.redirectTo({
  36. url: `/pages/subPack/detect-face/index${params}`,
  37. })
  38. } else {
  39. uni.redirectTo({
  40. url: `/pages/subPack/detect-face/index`,
  41. })
  42. }
  43. },
  44. onSubmit() {
  45. uni.redirectTo({
  46. url: `/pages/skin-assessment/croppedImage`,
  47. })
  48. return
  49. let that = this;
  50. if(this.imgSize && this.imgSize > 8) {
  51. return uni.showModal({
  52. content: '上传或者拍照的图像大小不能超过8MB',
  53. showCancel: false,
  54. success: (res) => {
  55. if (res.confirm) {
  56. console.log("确认");
  57. } else {
  58. console.log("取消");
  59. }
  60. }
  61. })
  62. }
  63. that.skinanalyze();
  64. },
  65. onPhotoReSet() {
  66. // 重拍,返回拍照页面
  67. this.onNavBack();
  68. },
  69. async skinanalyze() {
  70. let that = this;
  71. uni.showLoading({
  72. title: '图片上传中',
  73. mask: true,
  74. })
  75. console.log("识别参数", "Mode", this.props.mode || 0, "TaskId", this.props.logId || 0);
  76. let re = await this.$api.skinanalyze(
  77. this.$util.tempUrlToUpload(
  78. that.detectFaceImg,
  79. `${this.$util.formateDate('yyyy-mm-dd-HH:MM:SS')}_sign.png`,
  80. {
  81. Mode: this.props.mode || 0,
  82. TaskId: this.props.logId || 0
  83. }
  84. ));
  85. console.log("图片上传结果", re);
  86. if(re) {
  87. if(re.succeed) {
  88. if(re.data) {
  89. // 跳转详情页面
  90. setTimeout(() => {
  91. this.$u.toast('上传成功');
  92. let params = `?id=${re.data}&type=0&active=0&imei=${this.props.imei}&isDetectFace=true&logId=${this.props.logId}&nuring=${this.props.nuring}&mode=${this.props.mode}`;
  93. uni.redirectTo({
  94. url: `/pages/subPack/detect-face/archivesDetails${params}`,
  95. })
  96. /* this.$u.route({
  97. url: '/pages/subPack/detect-face/archivesDetails',
  98. params: {
  99. id: re.data,
  100. type: 0,
  101. active: 0
  102. },
  103. }) */
  104. /* this.$u.route({
  105. url: '/pages/subPack/detect-face/detect-face-details',
  106. params: {
  107. id: re.data,
  108. },
  109. }) */
  110. }, 1500)
  111. } else {
  112. uni.hideLoading();
  113. uni.showModal({
  114. title: '',
  115. content: `${re.message}`,
  116. showCancel: false,
  117. confirmText: '确认',
  118. })
  119. }
  120. } else {
  121. uni.hideLoading();
  122. uni.showModal({
  123. title: '',
  124. content: `${re.message}`,
  125. showCancel: false,
  126. confirmText: '确认',
  127. })
  128. }
  129. } else {
  130. this.$u.toast('上传失败,请重试')
  131. }
  132. },
  133. getImgSize() {
  134. let that = this;
  135. if(that.detectFaceImg) {
  136. const fileSystemManager = uni.getFileSystemManager();
  137. // 获取文件状态
  138. fileSystemManager.stat({
  139. path: that.detectFaceImg,
  140. success: function (statRes) {
  141. console.log('文件大小:', statRes.stats.size);
  142. const fileSizeInMB = (statRes.stats.size / (1024 * 1024)).toFixed(2); // 转换为MB
  143. that.imgSize = fileSizeInMB;
  144. console.log('文件大小:', fileSizeInMB, 'MB'); // 输出文件大小,单位是MB// 文件大小,单位是字节
  145. },
  146. fail: function (err) {
  147. console.error('获取文件状态失败:', err);
  148. }
  149. });
  150. }
  151. }
  152. },
  153. onLoad(props) {
  154. // this.paddTopHeight = this.$util.getPaddTopheight();
  155. this.getImgSize();
  156. if(props) {
  157. this.props = {...props};
  158. console.log("其他页面传递过来的参数", this.props);
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. .photo-process {
  165. height: 100vh;
  166. width: 100vw;
  167. overflow: hidden;
  168. .action {
  169. height: 120rpx;
  170. width: 100vw;
  171. position: fixed;
  172. bottom: 60rpx;
  173. left: 0;
  174. display: flex;
  175. justify-content: center;
  176. align-items: center;
  177. background: none;
  178. z-index: 9999;
  179. .btn {
  180. height: 89rpx;
  181. line-height: 89rpx;
  182. width: 266rpx;
  183. border: 4rpx solid #7F66E8;
  184. text-align: center;
  185. border-radius: 60rpx;
  186. font-family: OPPOSans;
  187. font-weight: bold;
  188. font-size: 36rpx;
  189. color: #7F66E8;
  190. &.full {
  191. background-color: #7F66E8;
  192. color: #FFFFFF;
  193. margin-left: 30rpx;
  194. font-weight: bold;
  195. }
  196. }
  197. }
  198. .nav-bar {
  199. }
  200. .photo-process-img {
  201. position: relative;
  202. height: 100vh;
  203. width: 100vw;
  204. }
  205. .canvas-con {
  206. position: relative;
  207. z-index: 999;
  208. #myCanvas {
  209. height: 100vh;
  210. width: 100vw;
  211. z-index: 999;
  212. }
  213. }
  214. }
  215. </style>