From 1f11c563cc67f8c35e36653fa0c9bf52d76492b7 Mon Sep 17 00:00:00 2001 From: abson Date: Wed, 2 Mar 2022 11:49:10 +0800 Subject: [PATCH] 测肤图片压缩 --- packageD/ai_config/config.js | 21 +++++++++++++++++++++ packageD/pages/AI-test-skin/analyse/analyse.js | 725 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- packageD/pages/AI-test-skin/fail_result/fail_result.js | 19 +++++++++++++++---- packageD/pages/AI-test-skin/fail_result/fail_result.wxml | 24 ++++++++++++++++++------ packageD/pages/AI-test-skin/select_photo/select_photo.js | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------- packageD/pages/AI-test-skin/select_photo/select_photo.wxml | 5 +++-- packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- packageD/pages/AI-test-skin/shoot_notice/shoot_notice.wxml | 5 ++++- packageD/pages/AI-test-skin/success_result/sensitive/sensitive.js | 1 - packageD/pages/AI-test-skin/success_result/success_result.js | 371 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 10 files changed, 988 insertions(+), 504 deletions(-) create mode 100644 packageD/ai_config/config.js diff --git a/packageD/ai_config/config.js b/packageD/ai_config/config.js new file mode 100644 index 0000000..ca88091 --- /dev/null +++ b/packageD/ai_config/config.js @@ -0,0 +1,21 @@ +/* + * @Author: your name + * @Date: 2022-02-26 09:44:36 + * @LastEditTime: 2022-02-26 09:48:10 + * @LastEditors: your name + * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + * @FilePath: \MShopWeApp\utils\ai_config\config.js + */ +let pluginGD = { + app_id: 'f1WwFd7W1lduYRQaUpDVdvi3w9infpUwe1o', + app_secret: 'ICYb2dw1QDCguPuArQKi4EegwKfyFzDbdh', + plugin_name: 'mtSkinSdk', + redirect_url: '/packageD/pages/AI-test-skin/index/aiskin', + share_qrcode: 'https://titan-h5.meitu.com/webar/eve/mini_skin_sdk/demo/mini_qrcode.jpg', + wx_api: { + getFileSystemManager: wx.getFileSystemManager, + }, +}; +export { + pluginGD, +}; diff --git a/packageD/pages/AI-test-skin/analyse/analyse.js b/packageD/pages/AI-test-skin/analyse/analyse.js index 1fe48f0..f3aac4c 100644 --- a/packageD/pages/AI-test-skin/analyse/analyse.js +++ b/packageD/pages/AI-test-skin/analyse/analyse.js @@ -4,6 +4,7 @@ const request = app.request; const os = app.globalData; const setting = os.setting; const ut = require('../../../../utils/util'); +import { pluginGD } from '../../../ai_config/config' Page({ /** @@ -11,171 +12,171 @@ Page({ */ data: { iurl: setting.imghost, - per:0, - timer:0, - img:null, - sourceimg:null, - err_map:null, + per: 0, + timer: 0, + img: null, + sourceimg: null, + err_map: null, + skin_type: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - var th=this; - //设置错误码分析 - this.set_err_map(); - //进度条加载 - this.timer(); - //接口开始分析 - setTimeout(function () { - //th.analysis_img(); - //先检验一下图片 - th.img_check(function () { - - }); - },800) + var plugin = requirePlugin('mtSkinSdk') + plugin.setConfig(pluginGD) + var th = this; + //设置错误码分析 + this.set_err_map(); + //进度条加载 + this.timer(); + //接口开始分析 + setTimeout(function () { + //先检验一下图片 + th.data.skin_type ? th.img_check_mt() : th.img_check_bd(); + }, 800) }, //定时器 - timer:function (func) { - var per=this.data.per+5; - var th=this; - if(per<96){ - th.setData({per:per}); - setTimeout(function () { - th.timer(); - },400) - } + timer: function (func) { + var per = this.data.per + 5; + var th = this; + if (per < 96) { + th.setData({ per: per }); + setTimeout(function () { + th.timer(); + }, 400) + } }, //错误码表 - set_err_map:function () { - var map={ - "2":"服务暂不可用", - "4":"集群超限额", - "6":"没有接口权限", - "17":"每天流量超限额", - "18":"QPS超限额", - "19":"请求总量超限额", - "100":"无效的access_token参数", - "110":"Access Token失效", - "111":" Access token过期", - "222001":"必要参数未传入", - "222002":"参数格式错误", - "222003":"参数格式错误", - "222004":"参数格式错误", - "222005":"参数格式错误", - "222006":"参数格式错误", - "222007":"参数格式错误", - "222008":"参数格式错误", - "222009":"参数格式错误", - "222010":"参数格式错误", - "222011":"参数格式错误", - "222012":"参数格式错误", - "222013":"参数格式错误", - "222014":"参数格式错误", - "222015":"参数格式错误", - "222016":"参数格式错误", - "222017":"参数格式错误", - "222018":"参数格式错误", - "222019":"参数格式错误", - "222020":"参数格式错误", - "222021":"参数格式错误", - "222022":"身份证号不符合要求,备注:中国大陆身份证号的每一位数字都有其生成规则,不可随意填写。", - "222023":"参数格式错误", - "222024":"参数格式错误", - "222025":"参数格式错误", - "222026":"参数格式错误", - "222027":"验证码长度错误(最小值大于最大值)", - "222028":"参数格式错误", - "222029":"参数格式错误", - "222030":"参数格式错误", - "222039":"参数格式错误", - "222200":"该接口需使用application/json的格式进行请求", - "222201":"服务端请求失败", - "222202":"图片中没有人脸", - "222203":"无法解析人脸", - "222204":"从图片的url下载图片失败", - "222205":"服务端请求失败", - "222206":"服务端请求失败", - "222207":"未找到匹配的用户", - "222208":"图片的数量错误", - "222209":"face token不存在", - "222210":"人脸库中用户下的人脸数目超过限制", - "222300":"人脸图片添加失败", - "222301":"获取人脸图片失败", - "222302":"服务端请求失败", - "222303":"获取人脸图片失败", - "222152":"人脸属性编辑,target参数错误", - "222514":"人脸属性编辑v2调用服务失败,请重试", - "223100":"操作的用户组不存在", - "223101":"该用户组已存在", - "223102":"找不到该用户", - "223103":"找不到该用户", - "223104":"group_list包含组数量过多", - "223105":"该人脸已存在", - "223106":"该人脸不存在", - "223107":"人脸库中人脸复制时源组与目标组的scene_type不同", - "223110":"uid_list包含数量过多", - "223111":"目标用户组不存在", - "223112":"quality_conf格式不正确", - "223113":"人脸有被遮挡", - "223114":"人脸模糊", - "223115":"人脸光照不好", - "223116":"人脸不完整", - "223117":"app_list包含app数量过多", - "223118":"质量控制项错误", - "223119":"活体控制项错误", - "223120":"活体检测未通过", - "223121":"质量检测未通过 左眼遮挡程度过高", - "223122":"质量检测未通过 右眼遮挡程度过高", - "223123":"质量检测未通过 左脸遮挡程度过高", - "223124":"质量检测未通过 右脸遮挡程度过高", - "223125":"质量检测未通过 下巴遮挡程度过高", - "223126":"质量检测未通过 鼻子遮挡程度过高", - "223127":"质量检测未通过 嘴巴遮挡程度过高", - "222901":"参数校验初始化失败", - "222902":"参数校验初始化失败", - "222903":"参数校验初始化失败", - "222904":"参数校验初始化失败", - "222905":"接口初始化失败", - "222906":"接口初始化失败", - "222907":"缓存处理失败", - "222908":"缓存处理失败", - "222909":"缓存处理失败", - "222910":"数据存储处理失败", - "222911":"数据存储处理失败", - "222912":"数据存储处理失败", - "222913":"接口初始化失败", - "222914":"接口初始化失败", - "222915":"后端服务连接失败", - "222916":"后端服务连接失败", - "222304":"图片尺寸太大", - "222305":"当前版本不支持图片存储", - "223128":"正在清理该用户组的数据", - "223136":"该组内存在关联图片,无法新建相同名称组", - "222361":"公安服务连接失败", - "222046":"参数格式错误", - "222101":"参数格式错误", - "222102":"参数格式错误", - "222307":"图片非法 鉴黄未通过", - "222308":"图片非法 含有政治敏感人物", - "222211":"人脸融合失败 模板图质量不合格", - "222212":"人脸融合失败", - "223129":"人脸未面向正前方(人脸的角度信息大于30度)", - "223130":"spoofing_control参数格式错误", - "223131":"合成图检测未通过", - "223201":"请求参数scene_type 格式错误", - "223202":"识别时请求的scene_type与group设置的scene_type不匹配", - } - this.setData({err_map:map}); + set_err_map: function () { + var map = { + "2": "服务暂不可用", + "4": "集群超限额", + "6": "没有接口权限", + "17": "每天流量超限额", + "18": "QPS超限额", + "19": "请求总量超限额", + "100": "无效的access_token参数", + "110": "Access Token失效", + "111": " Access token过期", + "222001": "必要参数未传入", + "222002": "参数格式错误", + "222003": "参数格式错误", + "222004": "参数格式错误", + "222005": "参数格式错误", + "222006": "参数格式错误", + "222007": "参数格式错误", + "222008": "参数格式错误", + "222009": "参数格式错误", + "222010": "参数格式错误", + "222011": "参数格式错误", + "222012": "参数格式错误", + "222013": "参数格式错误", + "222014": "参数格式错误", + "222015": "参数格式错误", + "222016": "参数格式错误", + "222017": "参数格式错误", + "222018": "参数格式错误", + "222019": "参数格式错误", + "222020": "参数格式错误", + "222021": "参数格式错误", + "222022": "身份证号不符合要求,备注:中国大陆身份证号的每一位数字都有其生成规则,不可随意填写。", + "222023": "参数格式错误", + "222024": "参数格式错误", + "222025": "参数格式错误", + "222026": "参数格式错误", + "222027": "验证码长度错误(最小值大于最大值)", + "222028": "参数格式错误", + "222029": "参数格式错误", + "222030": "参数格式错误", + "222039": "参数格式错误", + "222200": "该接口需使用application/json的格式进行请求", + "222201": "服务端请求失败", + "222202": "未识别到单个人脸",//未识别到单个人脸 + "222203": "无法解析人脸", + "222204": "从图片的url下载图片失败", + "222205": "服务端请求失败", + "222206": "服务端请求失败", + "222207": "未找到匹配的用户", + "222208": "图片的数量错误", + "222209": "face token不存在", + "222210": "人脸库中用户下的人脸数目超过限制", + "222300": "人脸图片添加失败", + "222301": "获取人脸图片失败", + "222302": "服务端请求失败", + "222303": "获取人脸图片失败", + "222152": "人脸属性编辑,target参数错误", + "222514": "人脸属性编辑v2调用服务失败,请重试", + "223100": "操作的用户组不存在", + "223101": "该用户组已存在", + "223102": "找不到该用户", + "223103": "找不到该用户", + "223104": "group_list包含组数量过多", + "223105": "该人脸已存在", + "223106": "该人脸不存在", + "223107": "人脸库中人脸复制时源组与目标组的scene_type不同", + "223110": "uid_list包含数量过多", + "223111": "目标用户组不存在", + "223112": "quality_conf格式不正确", + "223113": "人脸有被遮挡", + "223114": "人脸模糊", + "223115": "人脸光照不好", + "223116": "人脸不完整", + "223117": "app_list包含app数量过多", + "223118": "质量控制项错误", + "223119": "活体控制项错误", + "223120": "活体检测未通过", + "223121": "质量检测未通过 左眼遮挡程度过高", + "223122": "质量检测未通过 右眼遮挡程度过高", + "223123": "质量检测未通过 左脸遮挡程度过高", + "223124": "质量检测未通过 右脸遮挡程度过高", + "223125": "质量检测未通过 下巴遮挡程度过高", + "223126": "质量检测未通过 鼻子遮挡程度过高", + "223127": "质量检测未通过 嘴巴遮挡程度过高", + "222901": "参数校验初始化失败", + "222902": "参数校验初始化失败", + "222903": "参数校验初始化失败", + "222904": "参数校验初始化失败", + "222905": "接口初始化失败", + "222906": "接口初始化失败", + "222907": "缓存处理失败", + "222908": "缓存处理失败", + "222909": "缓存处理失败", + "222910": "数据存储处理失败", + "222911": "数据存储处理失败", + "222912": "数据存储处理失败", + "222913": "接口初始化失败", + "222914": "接口初始化失败", + "222915": "后端服务连接失败", + "222916": "后端服务连接失败", + "222304": "图片尺寸太大", + "222305": "当前版本不支持图片存储", + "223128": "正在清理该用户组的数据", + "223136": "该组内存在关联图片,无法新建相同名称组", + "222361": "公安服务连接失败", + "222046": "参数格式错误", + "222101": "参数格式错误", + "222102": "参数格式错误", + "222307": "图片非法 鉴黄未通过", + "222308": "图片非法 含有政治敏感人物", + "222211": "人脸融合失败 模板图质量不合格", + "222212": "人脸融合失败", + "223129": "人脸未面向正前方(人脸的角度信息大于30度)", + "223130": "spoofing_control参数格式错误", + "223131": "合成图检测未通过", + "223201": "请求参数scene_type 格式错误", + "223202": "识别时请求的scene_type与group设置的scene_type不匹配", + } + this.setData({ err_map: map }); }, /** * 生命周期函数--监听页面显示 */ - onShow: function (){ }, + onShow: function () { }, /** * 生命周期函数--监听页面隐藏 @@ -199,163 +200,359 @@ Page({ }, - //检查图片有没有OK - img_check:function (func) { - var th=this; - var data={ + //检查图片有没有OK 百度 + img_check_bd: function (func) { + var th = this; + var data = { "appid": "25521854", "image": getApp().globalData.face_SourceImg, "face_field": "age,expression,face_shape,gender,glasses,landmark,landmark150,quality,eye_status,emotion,face_type,mask,spoofing", "image_type": "URL" } - //开始调用接口,进行对图片进行判断是否符合标准 - this.json_post("/api/weshop/baidubce/face/skindetect",data,function (res) { - if(res.data.code==0){ + //开始调用百度接口,进行对图片进行判断是否符合标准 + this.json_post("/api/weshop/baidubce/face/skindetect", data, function (res) { + if (res.data.code == 0) { //检查的字段存储 - var check_data=th.data.check_data=res.data.data; - check_data=check_data.face_list[0]; + var check_data = th.data.check_data = res.data.data; + check_data = check_data.face_list[0]; + let fail_result = new Array(); console.log(check_data); //检查睁眼闭眼 - var eye_status=check_data.eye_status; - if(eye_status.left_eye>0.1 || eye_status.right_eye>0.1) { - var msg="未闭眼拍照"; - th.go_error(msg); - return false; + var eye_status = check_data.eye_status; + if (eye_status.left_eye > 0.1 || eye_status.right_eye > 0.1) { + // var msg = "未闭眼拍照"; + // th.go_error(msg); + // return false; + fail_result.push({ + type: 1, + reason: "未闭眼拍摄" + }) } //检查是不是有带眼镜 - if(check_data.glasses.type!='none'){ - var msg="有佩戴眼镜"; - th.go_error(msg); - return false; - } - //检查头部的角度 - var angle=check_data.angle; - if(Math.abs(angle.Pitch)>20) { - var msg="头部的俯仰角度过大"; - th.go_error(msg); - return false; + if (check_data.glasses.type != 'none') { + // var msg = "有佩戴眼镜"; + // th.go_error(msg); + // return false; + fail_result.push({ + type: 2, + reason: "未摘下眼镜拍摄" + }) } - if(Math.abs(angle.Roll)>20) { - var msg="头部的平面角度过大"; - th.go_error(msg); - return false; + var quality = check_data.quality; + //检查框里人脸情况 + if (quality.completeness = 0) { + // var msg = "人脸未显示完整"; + // th.go_error(msg); + // return false; + fail_result.push({ + type: 3, + reason: "未识别到单个人脸" + }) } - if(Math.abs(angle.Yaw)>20) { - var msg="头部的左右角度过大"; - th.go_error(msg); - return false; - } - var quality=check_data.quality; - if(quality.blur>0.7){ - var msg="图片模糊"; - th.go_error(msg); - return false; + //检查环境情况 + if (quality.blur > 0.7 || quality.illumination < 40) { + // var msg = "图片模糊"; + // th.go_error(msg); + // return false; + fail_result.push({ + type: 4, + reason: "图片质量不佳" + }) } + + // if (Math.abs(angle.Roll) > 20) { + // var msg = "头部的平面角度过大"; + // th.go_error(msg); + // return false; + // } + // if (Math.abs(angle.Yaw) > 20) { + // var msg = "头部的左右角度过大"; + // th.go_error(msg); + // return false; + // } + //开始检查遮挡 - var occlusion=check_data.quality.occlusion; - if(occlusion.left_eye >0.6){ - var msg="左眼被遮挡"; - th.go_error(msg); - return false; + var zhe_dnag = 0; + var occlusion = check_data.quality.occlusion; + if (occlusion.left_eye > 0.6) { + // var msg = "左眼被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(occlusion.right_eye>0.6){ - var msg="右眼被遮挡"; - th.go_error(msg); - return false; + if (occlusion.right_eye > 0.6) { + // var msg = "右眼被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(occlusion.nose>0.7){ - var msg="鼻子被遮挡"; - th.go_error(msg); - return false; + if (occlusion.nose > 0.7) { + // var msg = "鼻子被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(occlusion.mouth>0.7){ - var msg="嘴巴被遮挡"; - th.go_error(msg); - return false; + if (occlusion.mouth > 0.7) { + // var msg = "嘴巴被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(occlusion.left_cheek >0.8){ - var msg="左脸颊被遮挡"; - th.go_error(msg); - return false; + if (occlusion.left_cheek > 0.8) { + // var msg = "左脸颊被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(occlusion.right_cheek >0.8){ - var msg="右脸颊被遮挡"; - th.go_error(msg); - return false; + if (occlusion.right_cheek > 0.8) { + // var msg = "右脸颊被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(occlusion.chin_contour >0.6){ - var msg="下巴颊被遮挡"; - th.go_error(msg); - return false; + if (occlusion.chin_contour > 0.6) { + // var msg = "下巴颊被遮挡"; + // th.go_error(msg); + // return false; + zhe_dnag = 1; } - if(quality.illumination<40){ - var msg="图像光照不足"; - th.go_error(msg); - return false; + if (zhe_dnag) { + fail_result.push({ + type: 7, + reason: "脸部有遮挡物" + }) } - if(quality.completeness=0){ - var msg="人脸未显示完整"; - th.go_error(msg); + //检查头部的角度 + var angle = check_data.angle; + if (Math.abs(angle.Pitch) > 20 || Math.abs(angle.Roll) > 20 || Math.abs(angle.Yaw) > 20) { + // var msg = "头部的俯仰角度过大"; + // th.go_error(msg); + // return false; + fail_result.push({ + type: 8, + reason: "未保持正脸拍摄" + }) + } + // if (quality.illumination < 40) { + // var msg = "图像光照不足"; + // th.go_error(msg); + // return false; + // } + if (fail_result.length > 0) { + fail_result = JSON.stringify(fail_result); + th.go_error(fail_result); return false; } //-- 开始调用分析的接口 -- - var face_token=check_data.face_token; - var data={ + var face_token = check_data.face_token; + var data = { "image": face_token, "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore,skinface,skinquality", "image_type": "FACE_TOKEN" } - th.analysis_img(data); - }else{ - var msg=th.data.err_map[res.data.code+""]; - th.go_error(msg); + th.analyse_by_bd(data); + } else { + var msg = th.data.err_map[res.data.code + ""]; + th.go_error1(msg); } }) }, - - //跳转到错误页面 - go_error:function (msg) { - let url = "/packageD/pages/AI-test-skin/fail_result/fail_result?msg="+msg; //跳到分析页 - wx.redirectTo({ - url: url - }); - }, + //检查图片有没有OK 美图 + img_check_mt() { + let img_info = getApp().globalData.skin_img_info; + var plugin = requirePlugin('mtSkinSdk'); + console.log('plugin'); + let th = this; + plugin.facePoseCorrect({ + path: img_info['path'], + size: img_info['size'], + success(res) { + console.log('=========姿态校正 成功==========') + console.log('姿态校正结果', res) + let fail_result = new Array(); + let analyse_info = res.data; + //检查闭眼情况 + if (analyse_info.analyse_info) { + //检查睁眼闭眼 + let { left, right } = analyse_info.analyse_info; + if (left !== 2 && right !== 2) { + fail_result.push({ + type: 1, + reason: "未闭眼拍摄" + }) + } + } + //检查佩戴情况 + if (analyse_info.faceGlasses) { + let { none, normal, sunglasses } = analyse_info.faceGlasses; + if (normal > 0.8 || sunglasses > 0.8 || none < 0.1) { + fail_result.push({ + type: 2, + reason: "未摘下眼镜拍摄" + }) + } + } + //检查框里人脸情况 + if (analyse_info.faceOutDetect.outBound == 1) { + fail_result.push({ + type: 3, + reason: "未识别到单个人脸" + }) + } - analysis_img:function (data) { - var th=this; + //检查环境情况 + if (analyse_info.faceQuality) { + let { bright, blur } = analyse_info.faceQuality; + if (bright > 80 || bright < 20 || blur < 20) { + fail_result.push({ + type: 4, + reason: "质量检测未通过" + }) + } + } + //检查距离 + if (analyse_info.faceRatio < 0.2) { + fail_result.push({ + type: 5, + reason: "脸部与摄像头距离过远" + }) + } + if (analyse_info.faceRatio > 0.8) { + fail_result.push({ + type: 6, + reason: "脸部与摄像头距离过近" + }) + + } + //检查遮挡物 + if (analyse_info.faceVisibility) { + let fail = Object.keys(analyse_info.faceVisibility).filter(key => { + return analyse_info.faceVisibility[key] <= 80; + }) + console.log('fail', fail); + if (fail.length > 0) { + fail_result.push({ + type: 7, + reason: "脸部有遮挡物" + }) + } + } + if (analyse_info.facePoseEuler) { + let { pitch, roll, yaw } = analyse_info.facePoseEuler; + if (pitch > 20 || roll > 20 || yaw > 20) { + fail_result.push({ + type: 8, + reason: "未保持正脸拍摄" + }) + } + } + if (fail_result.length > 0) { + fail_result = JSON.stringify(fail_result); + th.go_error1(fail_result); + return false; + } + th.analyse_by_mt(img_info,analyse_info); + }, + fail(err) { + console.log(err); + th.go_error1('识别有误,请重试'); + return false; + } + }) + + }, + //美图测肤接口 + analyse_by_mt(img_info,analyse_info) { + let th = this; + var plugin = requirePlugin('mtSkinSdk') + plugin.detectImage({ + path: img_info['path'], + size: img_info['size'], + success(res) { + console.log('=========用户传图片链接获取检测结果 成功==========') + console.log('检测结果', res); + let analyse_data = res.data.face_attributes; + analyse_data['face_rectangle'] = res.data.face_rectangle; + let req_data = { + store_id: setting.stoid, + user_id: getApp().globalData.user_id, + img: getApp().globalData.face_img, + sourceimg: getApp().globalData.face_SourceImg, + addtime: ut.gettimestamp(), + resultjson: JSON.stringify(analyse_data), + detectjson: JSON.stringify(analyse_info), + skin_type: 1, + } + //要保存一下分析的结果 + th.json_post("/api/weshop/face/storeSkinface/save", req_data, function (res) { + if (res.data.code == 0) { + let url = "/packageD/pages/AI-test-skin/success_result/success_result?id=" + res.data.data.id; //跳到分析页 + wx.redirectTo({ + url: url + }) + } else { + getApp().showWarning("保存失败"); + } + }) + }, + fail(err) { + console.error('=========用户传图片链接获取检测结果 失败==========') + console.log('error', err) + getApp().showWarning(err); + } + }) + }, + //百度测肤接口 + analyse_by_bd: function (data) { + var th = this; //开始调用接口,进行分析 - this.json_post("/api/weshop/baidubce/face/skinAnalyze",data,function (res) { - if(res.data.code==0){ - getApp().globalData.face_result=res.data.data; - var req_data={ - store_id:setting.stoid, - user_id:getApp().globalData.user_id, - img:getApp().globalData.face_img, - sourceimg:getApp().globalData.face_SourceImg, - addtime:ut.gettimestamp(), - resultjson:JSON.stringify(res.data.data), - detectjson:JSON.stringify(th.data.check_data) + this.json_post("/api/weshop/baidubce/face/skinAnalyze", data, function (res) { + if (res.data.code == 0) { + getApp().globalData.face_result = res.data.data; + var req_data = { + store_id: setting.stoid, + user_id: getApp().globalData.user_id, + img: getApp().globalData.face_img, + sourceimg: getApp().globalData.face_SourceImg, + addtime: ut.gettimestamp(), + resultjson: JSON.stringify(res.data.data), + detectjson: JSON.stringify(th.data.check_data), + skin_type: 0, } //要保存一下分析的结果 - th.json_post("/api/weshop/face/storeSkinface/save",req_data,function (res) { - if(res.data.code==0){ - let url = "/packageD/pages/AI-test-skin/success_result/success_result?id="+res.data.data.id; //跳到分析页 + th.json_post("/api/weshop/face/storeSkinface/save", req_data, function (res) { + if (res.data.code == 0) { + let url = "/packageD/pages/AI-test-skin/success_result/success_result?id=" + res.data.data.id; //跳到分析页 wx.redirectTo({ url: url }) - }else{ + } else { getApp().showWarning("保存失败"); } }) - }else{ - var msg=th.data.err_map[res.data.code+""]; - let url = "/packageD/pages/AI-test-skin/fail_result/fail_result?msg="+msg; //跳到分析页 + } else { + var msg = th.data.err_map[res.data.code + ""]; + let url = "/packageD/pages/AI-test-skin/fail_result/fail_result?msg=" + msg; //跳到分析页 wx.redirectTo({ - url: url + url: url }) } }) }, + //跳转到错误页面 美图 + go_error: function (fail_result) { + let url = `/packageD/pages/AI-test-skin/fail_result/fail_result?fail_result=${fail_result}`; //跳到分析页 + wx.redirectTo({ + url: url + }); + }, + //跳转到错误页面 + go_error1: function (msg) { + let url = "/packageD/pages/AI-test-skin/fail_result/fail_result?msg=" + msg; //跳到分析页 + wx.redirectTo({ + url: url + }); + }, /** * @param {Object} url //url地址 @@ -363,10 +560,10 @@ Page({ * @param {Object} succ //成功的回调 * @param {Object} fail //失败的回调 */ - json_post:function(url,data,succ,fail,mathod){ - var Mathod="POST"; + json_post: function (url, data, succ, fail, mathod) { + var Mathod = "POST"; if (mathod) Mathod = mathod; - if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url; + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url; var str = JSON.stringify(data); wx.request({ url: url, @@ -375,10 +572,8 @@ Page({ header: { 'content-type': 'application/json' },// 设置请求的 header - success: function (res) {succ(res); }, - fail:function(res){fail(res);} + success: function (res) { succ(res); }, + fail: function (res) { fail(res); } }) }, - - }) \ No newline at end of file diff --git a/packageD/pages/AI-test-skin/fail_result/fail_result.js b/packageD/pages/AI-test-skin/fail_result/fail_result.js index 964fc99..dad8387 100644 --- a/packageD/pages/AI-test-skin/fail_result/fail_result.js +++ b/packageD/pages/AI-test-skin/fail_result/fail_result.js @@ -1,7 +1,7 @@ /* * @Author: your name * @Date: 2022-02-15 10:01:57 - * @LastEditTime: 2022-02-16 15:40:54 + * @LastEditTime: 2022-02-28 15:51:37 * @LastEditors: Please set LastEditors * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEet urkl * @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\shoot_notice\shoot_notice.js @@ -20,15 +20,26 @@ Page({ data: { iurl: setting.imghost, msg:null, + fail_result:new Array(), //失败原因 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - var msg=options.msg; - msg=decodeURIComponent(msg); - this.setData({msg:msg}); + if(options?.fail_result){ + var fail_result = JSON.parse(options.fail_result); + this.setData({ + fail_result, + }) + } + if(options?.msg){ + this.setData({ + msg:options.msg + }) + } + // msg=decodeURIComponent(msg); + // this.setData({msg:msg}); }, /** diff --git a/packageD/pages/AI-test-skin/fail_result/fail_result.wxml b/packageD/pages/AI-test-skin/fail_result/fail_result.wxml index 327bb60..6ccabff 100644 --- a/packageD/pages/AI-test-skin/fail_result/fail_result.wxml +++ b/packageD/pages/AI-test-skin/fail_result/fail_result.wxml @@ -6,17 +6,29 @@ - 上传图片符合要求 + 上传图片符合要求 请重新更换图片获取相关检测 - 失败原因: - - - {{msg}} - + 失败原因: + + + + + {{item.reason}} + + + + + + + + {{msg}} + + + diff --git a/packageD/pages/AI-test-skin/select_photo/select_photo.js b/packageD/pages/AI-test-skin/select_photo/select_photo.js index 7c84067..68e9f1d 100644 --- a/packageD/pages/AI-test-skin/select_photo/select_photo.js +++ b/packageD/pages/AI-test-skin/select_photo/select_photo.js @@ -1,11 +1,3 @@ -/* - * @Author: your name - * @Date: 2022-02-16 14:34:42 - * @LastEditTime: 2022-02-16 15:42:25 - * @LastEditors: Please set LastEditors - * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - * @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\select_photo\select_photo.js - */ // packageB/pages/AI-test-skin/select_photo/select_photo.js const app = getApp(); const request = app.request; @@ -20,20 +12,21 @@ Page({ data: { iurl: setting.imghost, gl_skin_img: null, + skin_type: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - var img=getApp().globalData.skin_img; - this.setData({gl_skin_img:img}) + var img = getApp().globalData.skin_img_info; + this.setData({ gl_skin_img: img }) }, /** * 生命周期函数--监听页面显示 */ - onShow: function () {}, + onShow: function () { }, /** * 生命周期函数--监听页面隐藏 @@ -56,19 +49,22 @@ Page({ }, //-- 完成选择 -- - ok_select:function () { - var th=this; - app.request.uploadFile("/api/weshop/baidubce/face/uploadImg?uploadPath=faceimg&storeId="+setting.stoid, { - filePath: th.data.gl_skin_img, + ok_select: function () { + const th = this; + let filePath = th.data.gl_skin_img['path']; + console.log('filePath', filePath); + // if (th.data.skin_type) { + // filePath = th.data.gl_skin_img['path']; + // } + app.request.uploadFile("/api/weshop/baidubce/face/uploadImg?uploadPath=faceimg&storeId=" + setting.stoid, { + filePath: th.data.gl_skin_img['path'], name: "file", success: function (e) { - if(e.data.code==0) { - getApp().globalData.face_img=e.data.data.img; - getApp().globalData.face_SourceImg=e.data.data.SourceImg; - + if (e.data.code == 0) { + getApp().globalData.face_img = e.data.data.img; + getApp().globalData.face_SourceImg = e.data.data.SourceImg; let url = "/packageD/pages/AI-test-skin/analyse/analyse"; //跳到分析页 app.goto(url); - } else { wx.showToast({ title: e.data.msg, @@ -79,25 +75,133 @@ Page({ } }); }, - //-- 重新从相册中选择图片 -- - show_pai_pop:function () { - var th=this; + show_pai_pop: function () { + var th = this; //选择和拍照一张图片 wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], - success (res) { + success(res) { let imgArr = res.tempFilePaths; - getApp().globalData.skin_img=imgArr[0]; - th.setData({gl_skin_img:imgArr[0]}) + if (th.data.skin_type) { + imgArr = res.tempFiles; + } + getApp().globalData.skin_img_info = imgArr[0]; + th.setData({ gl_skin_img: imgArr[0] }) } }) - }, - - - - + //选择图片 + takePhoto() { + var that = this; + wx.chooseImage({ + count: 1, + sizeType: ['compressed'], + sourceType: ['album', 'camera'], + success(res) { + var tempFilePaths = res.tempFilePaths + console.log(tempFilePaths); + console.log(res.tempFiles[0].size / 1024 + 'kb'); + var size1 = res.tempFiles[0].size; + var size = res.tempFiles[0].size / 1024; //kb单位 + // tempFilePath可以作为img标签的src属性显示图片 + var img = tempFilePaths[0]; + that.setData({ + imagesrc: img, + }) + that.imgToMin(img, size, size1); //获取图片后压缩 + + }, + fail(err) { + console.log(err); + } + }) + }, + //缩放图片 + imgToMin(img, size, size1) { + var that = this; + //size小于100kb 时 直接转码识别 + if (size < 1024) { + getApp().globalData.skin_img_info = { + path:img, + size, + } + let url = "/packageD/pages/AI-test-skin/select_photo/select_photo"; + app.goto(url); + // that.base64(img,"jpg"); + return; + } + + //先获取图片 然后根据长宽 缩小 之后获取图片 + wx.getImageInfo({ + src: img, + success(res) { + var ratio = Math.trunc(size / 1024); + size1 = size1 / ratio; + var canvasWidth = res.width //图片原始长宽 + var canvasHeight = res.height + //while (canvasWidth > 375 || canvasHeight > 520){// 保证宽高在400以内 + canvasWidth = Math.trunc(canvasWidth / ratio) + canvasHeight = Math.trunc(canvasHeight / ratio) + //ratio++; + //} + that.setData({ canvasWidth: canvasWidth, canvasHeight: canvasHeight }) + console.log(canvasWidth) + console.log(canvasHeight) + //绘制图片 + var ctx = wx.createCanvasContext('attendCanvasId') + ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight) + ctx.draw(false, setTimeout(function () { + wx.canvasToTempFilePath({ + canvasId: 'attendCanvasId', + width: canvasWidth, + height: canvasHeight, + destWidth: canvasWidth, + destHeight: canvasHeight, + fileType: 'jpg', + success: function (res) { + console.log(res.tempFilePath)//最终图片路径 + that.setData({ + canvasImgUrl: res.tempFilePath + }); + getApp().globalData.skin_img_info = { + path: res.tempFilePath, + size: size1 + }; + let url = "/packageD/pages/AI-test-skin/select_photo/select_photo"; + app.goto(url); + }, + fail: function (res) { + console.log("缩放图片失败"); + console.log(res.errMsg) + wx.hideLoading(); + wx.showToast({ + title: '识别图片失败', + image: '../../utils/img/wrong.png', + duration: 2000 + }) + that.setData({ + title: "识别失败", + }) + } + }, this) //要填写this对象,表示canvas这个对象 + }, 1000)) //留一定的时间绘制canvas 否则会报错fail canvas is empty + }, + fail: function (res) { + console.log("获取图片失败"); + console.log(res.errMsg) + wx.hideLoading(); + wx.showToast({ + title: '识别图片失败', + image: '../../utils/img/wrong.png', + duration: 2000 + }) + that.setData({ + title: "识别失败", + }) + }, + }) + }, }) \ No newline at end of file diff --git a/packageD/pages/AI-test-skin/select_photo/select_photo.wxml b/packageD/pages/AI-test-skin/select_photo/select_photo.wxml index e71d53b..3c33116 100644 --- a/packageD/pages/AI-test-skin/select_photo/select_photo.wxml +++ b/packageD/pages/AI-test-skin/select_photo/select_photo.wxml @@ -1,9 +1,10 @@ - + + - + 重拍 diff --git a/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js b/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js index ce7ce0e..6004d73 100644 --- a/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js +++ b/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js @@ -1,7 +1,7 @@ /* * @Author: abson * @Date: 2022-02-15 10:01:57 - * @LastEditTime: 2022-02-28 15:37:20 + * @LastEditTime: 2022-03-02 11:44:11 * @LastEditors: Please set LastEditors * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEet urkl * @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\shoot_notice\shoot_notice.js @@ -19,7 +19,10 @@ Page({ */ data: { iurl: setting.imghost, - notice_show:"", + notice_show: "", + skin_type: 0, + cWidth: 0, + cHeight: 0, }, /** @@ -33,11 +36,12 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - setTimeout(()=>{ - this.setData({ - notice_show:'none', + let th = this; + setTimeout(() => { + th.setData({ + notice_show: 'none', }) - },3000).bind(this) + }, 3000) }, /** @@ -70,13 +74,19 @@ Page({ //从相册中选择图片 show_pai_pop: function () { + let th = this; //选择和拍照一张图片 wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { - let imgArr = res.tempFiles; + let imgArr = res.tempFilePaths; + // + if (th.data.skin_type) { + imgArr = res.tempFiles; + } + console.log(imgArr); getApp().globalData.skin_img_info = imgArr[0]; let url = "/packageD/pages/AI-test-skin/select_photo/select_photo"; app.goto(url); @@ -85,7 +95,134 @@ Page({ }, + //选择图片 + takePhoto() { + var that = this; - - + wx.chooseImage({ + count: 1, + sizeType: ['compressed'], + sourceType: ['album', 'camera'], + success(res) { + var tempFilePaths = res.tempFilePaths + console.log(tempFilePaths); + console.log(res.tempFiles[0].size / 1024 + 'kb'); + var size1 =res.tempFiles[0].size; + var size = res.tempFiles[0].size / 1024; //kb单位 + // tempFilePath可以作为img标签的src属性显示图片 + var img = tempFilePaths[0]; + that.setData({ + imagesrc: img, + }) + that.imgToMin(img, size,size1); //获取图片后压缩 + + }, + fail(err) { + console.log(err); + } + }) + }, + //图片转码64 + base64(url, type) { + var that = this; + return new Promise((resolve, reject) => { + wx.getFileSystemManager().readFile({ + filePath: url, //选择图片返回的相对路径 + encoding: 'base64', //编码格式 + success: res => { + resolve('data:image/' + type.toLocaleLowerCase() + ';base64,' + res.data) + // console.log(res.data); + // that.doDiscernment(res.data);//提交后台 + }, + fail: res => reject(res.errMsg) + }) + }) + }, + //缩放图片 + imgToMin(img, size,size1) { + var that = this; + //size小于100kb 时 直接转码识别 + if (size < 1024) { + getApp().globalData.skin_img_info = { + path:img, + size, + } + let url = "/packageD/pages/AI-test-skin/select_photo/select_photo"; + app.goto(url); + // that.base64(img,"jpg"); + return; + } + + //先获取图片 然后根据长宽 缩小 之后获取图片 + wx.getImageInfo({ + src: img, + success(res) { + console.log(res.width) + console.log(res.height) + var ratio = size / 1024; + size1 = size1 / ratio; + var canvasWidth = res.width //图片原始长宽 + var canvasHeight = res.height + //while (canvasWidth > 375 || canvasHeight > 520){// 保证宽高在400以内 + canvasWidth = Math.trunc(canvasWidth / ratio) + canvasHeight = Math.trunc(canvasHeight / ratio) + //ratio++; + //} + that.setData({ canvasWidth: canvasWidth, canvasHeight: canvasHeight }) + console.log(canvasWidth) + console.log(canvasHeight) + //绘制图片 + var ctx = wx.createCanvasContext('attendCanvasId') + ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight) + ctx.draw(false, setTimeout(function () { + wx.canvasToTempFilePath({ + canvasId: 'attendCanvasId', + width: canvasWidth, + height: canvasHeight, + destWidth: canvasWidth, + destHeight: canvasHeight, + fileType: 'jpg', + success: function (res) { + console.log(res.tempFilePath)//最终图片路径 + that.setData({ + canvasImgUrl: res.tempFilePath + }); + getApp().globalData.skin_img_info = { + path:res.tempFilePath, + size:size1 + }; + let url = "/packageD/pages/AI-test-skin/select_photo/select_photo"; + app.goto(url); + }, + fail: function (res) { + console.log("缩放图片失败"); + console.log(res.errMsg) + wx.hideLoading(); + wx.showToast({ + title: '识别图片失败', + image: '../../utils/img/wrong.png', + duration: 2000 + }) + that.setData({ + title: "识别失败", + }) + } + }, this) //要填写this对象,表示canvas这个对象 + }, 1000)) //留一定的时间绘制canvas 否则会报错fail canvas is empty + }, + fail: function (res) { + console.log("获取图片失败"); + console.log(res.errMsg) + wx.hideLoading(); + wx.showToast({ + title: '识别图片失败', + image: '../../utils/img/wrong.png', + duration: 2000 + }) + that.setData({ + title: "识别失败", + }) + }, + }) + }, }) \ No newline at end of file diff --git a/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.wxml b/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.wxml index b99fc67..bf3b8e6 100644 --- a/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.wxml +++ b/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.wxml @@ -50,9 +50,12 @@ + + + - 准备闭眼拍摄 + 准备闭眼拍摄 如无闭眼,将导致图片分析失败 diff --git a/packageD/pages/AI-test-skin/success_result/sensitive/sensitive.js b/packageD/pages/AI-test-skin/success_result/sensitive/sensitive.js index 0aa0c90..5c00212 100644 --- a/packageD/pages/AI-test-skin/success_result/sensitive/sensitive.js +++ b/packageD/pages/AI-test-skin/success_result/sensitive/sensitive.js @@ -2,7 +2,6 @@ module.exports = { //把组合购的商品价格计算出来,同时每个会员都有购买组合商品的上限!ladder_b_num是已经购买了多少件 get_goods: function (th, stoid,sort) { th.setData({sensitive_sort:sort}); - var r_code = '12'; //获取毛孔的类型 var arr = th.data.face_data.skinquality.skin_sensitive_check; diff --git a/packageD/pages/AI-test-skin/success_result/success_result.js b/packageD/pages/AI-test-skin/success_result/success_result.js index d764c24..e606b81 100644 --- a/packageD/pages/AI-test-skin/success_result/success_result.js +++ b/packageD/pages/AI-test-skin/success_result/success_result.js @@ -1,7 +1,7 @@ /* * @Author: abson * @Date: 2022-02-16 15:36:47 - * @LastEditTime: 2022-02-28 10:44:27 + * @LastEditTime: 2022-02-28 16:01:07 * @LastEditors: Please set LastEditors * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\success_result\success_result.js @@ -19,6 +19,7 @@ const dark = require('dark/dark'); const pore = require('pore/pore'); const speckle = require('speckle/speckle'); const wrinkle = require('wrinkle/wrinkle'); +const sensitive = require('sensitive/sensitive') Page({ /** * 页面的初始数据 @@ -27,13 +28,13 @@ Page({ // tab: [{ id: 'zong_he', name: '综合肤质' }, { id: 'mao_kong', name: '毛孔' }, { id: 'hei_tou', name: '黑头' }, { id: 'se_ban', name: '色斑' }, { id: 'zhou_wen', name: '皱纹' }, { id: 'hei_yan_quan', name: '黑眼圈' }, { id: 'cuo_chuang', name: '痤疮' }, { id: 'min_gan_du', name: '敏感度' }], zhouwen_arr: [{ id: 1, name: '全部皱纹' }, { id: 2, name: '抬头纹' }, { id: 3, name: '川字纹' }, { id: 4, name: '眼周细纹' }, { id: 5, name: '鱼尾纹' }, { id: 6, name: '法令纹' }, { id: 7, name: '口周纹' }], cuochuang_arr: [{ id: 1, name: '全部痤疮' }, { id: 2, name: '粉刺 ' }, { id: 3, name: '痘印 ' }, { id: 4, name: '脓包' }, { id: 5, name: '结节' }], - zhouwen_arr1: [{ id: 1, name: '皱纹/细纹',des:'是指皮肤受到外界环境影响,形成游离自由基,自由基破坏正常细胞膜组织内的胶原蛋白、活性物质,氧化细胞,或缺水而形成的小细纹,继而严重形成皱纹',sign: 'zhou1',sign1: 'zhou2' }, { id: 2, name: '抬头皱纹/抬头细纹',des:'位于额头的皱纹、细纹。形成原因因人而异,后天因素是比较少的。-般多为横纹, 竖纹较少见。' ,sign: 'zhou3',sign1:'zhou4'}, { id: 3, name: '眼部皱纹/眼部细纹',des:'眼部皱纹、细纹一般位于下眼睑部位,多见于下脸内1/3处。',sign:'zhou5',sign1:'zhou6' }, { id: 4, name: '鱼尾纹',des:'眼部皱纹的一种,是在人两侧外眼角和登角之间出现的皱纹,其纹路与鱼尾巴上的纹路很相似,故被形象地称为鱼尾纹。',sign:'zhou7',sign1:'zhou8' }, { id: 5, name: '眉间纹',des:'又叫川字纹,皱眉纹,是面部的一种正常的表情纹,随着年龄的增长,面部的皱纹会逐渐加深,双眉之间逐渐形成了较深的皱折,会使人看起来总是愁眉不展。',sign:'zhou9',sign1:'zhou10'}, { id: 6, name: '泪沟',des:'泪沟是指由内眼角开始出现在下眼睑靠鼻侧的两条凹沟,是由于眼眶隔膜下缘的软组织萎缩、下垂而生成的。',sign:'zhou11',sign1:'zhou12' }, { id: 7, name: '法令纹',des:'法令纹是位于鼻翼边延伸而下的两道纹路,是典型的皮肤组织老化、造成肌肤表面凹陷的现象。',sign:'zhou15',sign1:'zhou16' }, { id: 8, name: '口角纹',des:'口角纹又称木偶纹、括号纹,位于嘴角延伸而下的两道纹路,是表情肌、重力和遗传基因等几方面因素综合形成的。',sign:'zhou13',sign1:'zhou14' }], - cuochuang_arr1: [{ id: 1, name: '痘印,痘坑',des:'痤疮消退后留下的痕迹,- 般包括黑色痘印,红色痘印,凹洞性痘坑,增生性凸疤。', sign: 'cuo1',sign1: 'cuo2'}, { id: 2, name: '粉刺',des:'粉刺也称为白头,是毛囊漏斗部被角质层细胞堆积、堵塞,角化物质和皮脂充塞其中,形成白色丘疹,表面有表皮覆盖,与外界不相通,成为封闭式粉刺。(痤疮I级)', sign: 'cuo3',sign1: 'cuo4' }, { id: 3, name: '丘疹',des:'丘疹性痤疮是由皮损导致炎性弓|起的小米至豌豆大的坚硬的小丘疹,呈淡红色至深红色。丘疹中央可有一个黑头粉刺或顶端未变黑的皮脂栓。(痤疮II级)', sign: 'cuo5',sign1: 'cuo6' }, { id: 4, name: '结节囊肿',des:'表现为蚕豆至指甲大的炎性结节或囊肿,为重度痤疮,严重者可继发化脓感染、破溃流出血脓,后形成窦道及瘢痕。触摸有波动感。若面部相邻长着多个囊肿,可能通过皮下的“窦道"“暗通,可能需要手术解决。(痤疮IV级)',sign:'cuo7',sign1:'cuo8' }], + zhouwen_arr1: [{ id: 1, name: '皱纹/细纹', des: '是指皮肤受到外界环境影响,形成游离自由基,自由基破坏正常细胞膜组织内的胶原蛋白、活性物质,氧化细胞,或缺水而形成的小细纹,继而严重形成皱纹', sign: 'zhou1', sign1: 'zhou2' }, { id: 2, name: '抬头皱纹/抬头细纹', des: '位于额头的皱纹、细纹。形成原因因人而异,后天因素是比较少的。-般多为横纹, 竖纹较少见。', sign: 'zhou3', sign1: 'zhou4' }, { id: 3, name: '眼部皱纹/眼部细纹', des: '眼部皱纹、细纹一般位于下眼睑部位,多见于下脸内1/3处。', sign: 'zhou5', sign1: 'zhou6' }, { id: 4, name: '鱼尾纹', des: '眼部皱纹的一种,是在人两侧外眼角和登角之间出现的皱纹,其纹路与鱼尾巴上的纹路很相似,故被形象地称为鱼尾纹。', sign: 'zhou7', sign1: 'zhou8' }, { id: 5, name: '眉间纹', des: '又叫川字纹,皱眉纹,是面部的一种正常的表情纹,随着年龄的增长,面部的皱纹会逐渐加深,双眉之间逐渐形成了较深的皱折,会使人看起来总是愁眉不展。', sign: 'zhou9', sign1: 'zhou10' }, { id: 6, name: '泪沟', des: '泪沟是指由内眼角开始出现在下眼睑靠鼻侧的两条凹沟,是由于眼眶隔膜下缘的软组织萎缩、下垂而生成的。', sign: 'zhou11', sign1: 'zhou12' }, { id: 7, name: '法令纹', des: '法令纹是位于鼻翼边延伸而下的两道纹路,是典型的皮肤组织老化、造成肌肤表面凹陷的现象。', sign: 'zhou15', sign1: 'zhou16' }, { id: 8, name: '口角纹', des: '口角纹又称木偶纹、括号纹,位于嘴角延伸而下的两道纹路,是表情肌、重力和遗传基因等几方面因素综合形成的。', sign: 'zhou13', sign1: 'zhou14' }], + cuochuang_arr1: [{ id: 1, name: '痘印,痘坑', des: '痤疮消退后留下的痕迹,- 般包括黑色痘印,红色痘印,凹洞性痘坑,增生性凸疤。', sign: 'cuo1', sign1: 'cuo2' }, { id: 2, name: '粉刺', des: '粉刺也称为白头,是毛囊漏斗部被角质层细胞堆积、堵塞,角化物质和皮脂充塞其中,形成白色丘疹,表面有表皮覆盖,与外界不相通,成为封闭式粉刺。(痤疮I级)', sign: 'cuo3', sign1: 'cuo4' }, { id: 3, name: '丘疹', des: '丘疹性痤疮是由皮损导致炎性弓|起的小米至豌豆大的坚硬的小丘疹,呈淡红色至深红色。丘疹中央可有一个黑头粉刺或顶端未变黑的皮脂栓。(痤疮II级)', sign: 'cuo5', sign1: 'cuo6' }, { id: 4, name: '结节囊肿', des: '表现为蚕豆至指甲大的炎性结节或囊肿,为重度痤疮,严重者可继发化脓感染、破溃流出血脓,后形成窦道及瘢痕。触摸有波动感。若面部相邻长着多个囊肿,可能通过皮下的“窦道"“暗通,可能需要手术解决。(痤疮IV级)', sign: 'cuo7', sign1: 'cuo8' }], heitanquan_arr: [{ id: 1, name: '综合情况' }, { id: 2, name: '左眼' }, { id: 3, name: '右眼' }], - heitanquan_arr1: [{ id: 1, name: '色素性黑眼圈', des: '呈茶褐色,是因眼裂向外眼角的延伸段有色素沉着或因先天或外来刺激导致眼周肤色黯沉。', sign: 'hei1',sign1: 'hei2' }, { id: 2, name: '血管性黑眼圈', des: '呈青紫色,由于眼周血液循环不良,下眼脸处皮肤与皮下脂肪变薄,皮下血管透出颜色形成的。', sign: 'hei3',sign1: 'hei4' }, { id: 3, name: '阴影型黑眼圈', des: '表现为眼袋膨出、泪沟凹陷。由于年龄的增长,眼周皮肤肌肉都会变得松弛,脂肪量变化而引起。', sign: 'hei5',sign1: 'hei6' }], + heitanquan_arr1: [{ id: 1, name: '色素性黑眼圈', des: '呈茶褐色,是因眼裂向外眼角的延伸段有色素沉着或因先天或外来刺激导致眼周肤色黯沉。', sign: 'hei1', sign1: 'hei2' }, { id: 2, name: '血管性黑眼圈', des: '呈青紫色,由于眼周血液循环不良,下眼脸处皮肤与皮下脂肪变薄,皮下血管透出颜色形成的。', sign: 'hei3', sign1: 'hei4' }, { id: 3, name: '阴影型黑眼圈', des: '表现为眼袋膨出、泪沟凹陷。由于年龄的增长,眼周皮肤肌肉都会变得松弛,脂肪量变化而引起。', sign: 'hei5', sign1: 'hei6' }], currentIndex: 0, scroll_index: 0, - yiwen_index:0, + yiwen_index: 0, sex: 'female', //female女 male男 tab_id: 'zong_he', iurl: setting.imghost, @@ -54,17 +55,17 @@ Page({ wrinkle_num4: 0, //鱼尾纹 wrinkle_num5: 0, //法令纹 wrinkle_num6: 0, //口周纹 - yiwen_type:0, //1皱纹 2黑眼圈 3痤疮 + yiwen_type: 0, //1皱纹 2黑眼圈 3痤疮 acne_num1: 0, //粉刺 acne_num2: 0, //痘印 acne_num3: 0, //脓包 acne_num4: 0, //结节 }, - onReady:function () { + onReady: function () { //用异步的获取比较准一点 wx.getSystemInfo({ - success (res) { + success(res) { console.log(111); console.log(res.windowWidth); console.log(res.windowHeight); @@ -86,7 +87,7 @@ Page({ //用异步的获取比较准一点 wx.getSystemInfo({ - success (res) { + success(res) { //计算图片要显示的大小 th.data.cWidth = res.windowWidth; th.data.cHeight = res.windowHeight; @@ -98,7 +99,7 @@ Page({ th.data.face_height = th.data.cHeight * 0.8 * 0.75; - var bi1= (th.data.cHeight * 0.8 * 0.8)/(th.data.cWidth*0.8); + var bi1 = (th.data.cHeight * 0.8 * 0.8) / (th.data.cWidth * 0.8); th.get_data(function (json, json1, img) { //-- 数据先存着 -- var face_data = th.data.face_data = json.face_list[0]; @@ -118,8 +119,8 @@ Page({ var dark_type = face_data.eyesattr.dark_circle_left_type.length > 0 ? face_data.eyesattr.dark_circle_left_type[0] : -1; var dark_type1 = face_data.eyesattr.dark_circle_right_type.length > 0 ? face_data.eyesattr.dark_circle_right_type[0] : -1; - var dk_type1=dark_type; - var dk_type2=dark_type1; + var dk_type1 = dark_type; + var dk_type2 = dark_type1; if (dark_type1 > dark_type) { dark_type = dark_type1; } @@ -127,103 +128,103 @@ Page({ var skin_dryoil_check = face_data.skinquality.skin_dryoil_check; var location = face_data.location; - var bili = th.data.face_height*0.76/location.height; + var bili = th.data.face_height * 0.76 / location.height; //获取眼睛的画图比例 - var eye_data1=face_data1.landmark150.eye_left_corner_right; - var eye_data2=face_data1.landmark150.eye_left_corner_left; - var eye_data3=face_data1.landmark150.eye_right_corner_right; - - var hei1=Math.abs(eye_data1.x-eye_data2.x); - var bili_eye = th.data.face_height*0.56/hei1; - var eye_top=eye_data1.y-hei1/2 - var eye_left1=eye_data1.x-hei1/6; - var eye_left2=eye_data3.x-hei1/6; - - var skin_dryoil_check_type=0;//干性 - var skin_dryoil_check_arr=[] - for(let i in skin_dryoil_check){ - let item=skin_dryoil_check[i]; - if(item!='1' && skin_dryoil_check_arr.indexOf(item)==-1){ + var eye_data1 = face_data1.landmark150.eye_left_corner_right; + var eye_data2 = face_data1.landmark150.eye_left_corner_left; + var eye_data3 = face_data1.landmark150.eye_right_corner_right; + + var hei1 = Math.abs(eye_data1.x - eye_data2.x); + var bili_eye = th.data.face_height * 0.56 / hei1; + var eye_top = eye_data1.y - hei1 / 2 + var eye_left1 = eye_data1.x - hei1 / 6; + var eye_left2 = eye_data3.x - hei1 / 6; + + var skin_dryoil_check_type = 0;//干性 + var skin_dryoil_check_arr = [] + for (let i in skin_dryoil_check) { + let item = skin_dryoil_check[i]; + if (item != '1' && skin_dryoil_check_arr.indexOf(item) == -1) { skin_dryoil_check_arr.push(item); } } //皮肤干油性的判断 - if(skin_dryoil_check_arr.length==0) skin_dryoil_check_type=1; - else if(skin_dryoil_check_arr.length==1) skin_dryoil_check_type=parseInt(skin_dryoil_check_arr[0]); - else skin_dryoil_check_type=3; + if (skin_dryoil_check_arr.length == 0) skin_dryoil_check_type = 1; + else if (skin_dryoil_check_arr.length == 1) skin_dryoil_check_type = parseInt(skin_dryoil_check_arr[0]); + else skin_dryoil_check_type = 3; - var wrinkle_types=face_data.wrinkle.wrinkle_types; - var w_arr=wrinkle_types.filter(function (e) { - return e==1; + var wrinkle_types = face_data.wrinkle.wrinkle_types; + var w_arr = wrinkle_types.filter(function (e) { + return e == 1; }) - th.data.wrinkle_num1=w_arr.length; + th.data.wrinkle_num1 = w_arr.length; //皱纹的数量的统计 - w_arr=wrinkle_types.filter(function (e) { - return e==2; + w_arr = wrinkle_types.filter(function (e) { + return e == 2; }) - th.data.wrinkle_num2=w_arr.length; - w_arr=wrinkle_types.filter(function (e) { - return e==3; + th.data.wrinkle_num2 = w_arr.length; + w_arr = wrinkle_types.filter(function (e) { + return e == 3; }) - th.data.wrinkle_num3=w_arr.length; - w_arr=wrinkle_types.filter(function (e) { - return e==4; + th.data.wrinkle_num3 = w_arr.length; + w_arr = wrinkle_types.filter(function (e) { + return e == 4; }) - th.data.wrinkle_num4=w_arr.length; - w_arr=wrinkle_types.filter(function (e) { - return e==5; + th.data.wrinkle_num4 = w_arr.length; + w_arr = wrinkle_types.filter(function (e) { + return e == 5; }) - th.data.wrinkle_num5=w_arr.length; - w_arr=wrinkle_types.filter(function (e) { - return e==6; + th.data.wrinkle_num5 = w_arr.length; + w_arr = wrinkle_types.filter(function (e) { + return e == 6; }) - th.data.wrinkle_num6=w_arr.length; + th.data.wrinkle_num6 = w_arr.length; //痘痘的不同的统计 var acne_list = face_data.acnespotmole.acne_list; - var a_arr=acne_list.filter(function (e) { - return e.type==0; + var a_arr = acne_list.filter(function (e) { + return e.type == 0; }) - th.data.acne_num1=a_arr.length; - a_arr=acne_list.filter(function (e) { - return e.type==1; + th.data.acne_num1 = a_arr.length; + a_arr = acne_list.filter(function (e) { + return e.type == 1; }) - th.data.acne_num2=a_arr.length; - a_arr=acne_list.filter(function (e) { - return e.type==2; + th.data.acne_num2 = a_arr.length; + a_arr = acne_list.filter(function (e) { + return e.type == 2; }) - th.data.acne_num3=a_arr.length; - a_arr=acne_list.filter(function (e) { - return e.type==3; + th.data.acne_num3 = a_arr.length; + a_arr = acne_list.filter(function (e) { + return e.type == 3; }) - th.data.acne_num4=a_arr.length; + th.data.acne_num4 = a_arr.length; let tab_arr = [{ id: 'zong_he', name: '综合肤质' }]; - if(pore_num) { + if (pore_num) { tab_arr.push({ id: 'mao_kong', name: '毛孔' }); } - if(blackhead_num){ + if (blackhead_num) { tab_arr.push({ id: 'hei_tou', name: '黑头' }); } - if(speckle_num){ + if (speckle_num) { tab_arr.push({ id: 'se_ban', name: '色斑' }); } - if(wrinkle_num){ + if (wrinkle_num) { tab_arr.push({ id: 'zhou_wen', name: '皱纹' }); } - if(dark_type > -1) { - tab_arr.push( { id: 'hei_yan_quan', name: '黑眼圈' }); + if (dark_type > -1) { + tab_arr.push({ id: 'hei_yan_quan', name: '黑眼圈' }); } - if(acne_num){ + if (acne_num) { tab_arr.push({ id: 'cuo_chuang', name: '痤疮' }); } - tab_arr.push( { id: 'min_gan_du', name: '敏感度' }); + tab_arr.push({ id: 'min_gan_du', name: '敏感度' }); th.setData({ acne_num: acne_num, speckle_num: speckle_num, wrinkle_num: wrinkle_num, - wrinkle_types:wrinkle_types, //皱纹类型 + wrinkle_types: wrinkle_types, //皱纹类型 blackhead_num: blackhead_num, pore_num: pore_num, dark_type: dark_type, @@ -231,30 +232,30 @@ Page({ dark_type2: dk_type2, skin_sensitive_check: skin_sensitive_check, skin_dryoil_check: skin_dryoil_check, - skin_dryoil_check_type:skin_dryoil_check_type, + skin_dryoil_check_type: skin_dryoil_check_type, face_img: img, - m_top: (location.top-location.height/3)* bili, - m_left:Math.abs(th.data.cWidth*0.8-(location.width+location.left*2)* bili)/2, + m_top: (location.top - location.height / 3) * bili, + m_left: Math.abs(th.data.cWidth * 0.8 - (location.width + location.left * 2) * bili) / 2, bili: bili, - bili_eye:bili_eye, - sex:sex, - tab:tab_arr, - skin_dryoil_check_type:skin_dryoil_check_type, - eye_top:eye_top* bili_eye, - eye_left1:eye_left1* bili_eye, - eye_left2:eye_left2* bili_eye, - - wrinkle_num1:th.data.wrinkle_num1, //抬头纹 - wrinkle_num2:th.data.wrinkle_num2, //川字纹 - wrinkle_num3:th.data.wrinkle_num3, //眼周细纹 - wrinkle_num4:th.data.wrinkle_num4, //鱼尾纹 - wrinkle_num5:th.data.wrinkle_num5, //法令纹 - wrinkle_num6:th.data.wrinkle_num6, //口周纹 - - acne_num1:th.data.acne_num1, //粉刺 - acne_num2:th.data.acne_num2, //痘印 - acne_num3:th.data.acne_num3, //脓包 - acne_num4:th.data.acne_num4, //结节 + bili_eye: bili_eye, + sex: sex, + tab: tab_arr, + skin_dryoil_check_type: skin_dryoil_check_type, + eye_top: eye_top * bili_eye, + eye_left1: eye_left1 * bili_eye, + eye_left2: eye_left2 * bili_eye, + + wrinkle_num1: th.data.wrinkle_num1, //抬头纹 + wrinkle_num2: th.data.wrinkle_num2, //川字纹 + wrinkle_num3: th.data.wrinkle_num3, //眼周细纹 + wrinkle_num4: th.data.wrinkle_num4, //鱼尾纹 + wrinkle_num5: th.data.wrinkle_num5, //法令纹 + wrinkle_num6: th.data.wrinkle_num6, //口周纹 + + acne_num1: th.data.acne_num1, //粉刺 + acne_num2: th.data.acne_num2, //痘印 + acne_num3: th.data.acne_num3, //脓包 + acne_num4: th.data.acne_num4, //结节 }) var sort = 1; //-- 调用毛孔的推荐函数 -- @@ -275,7 +276,7 @@ Page({ //-- 黑眼圈 -- if (acne_num > -0) acne.get_goods(th, setting.stoid, sort++); - + sensitive.get_goods(th, setting.stoid, sort++); //-- 获取一下分享要用的图片 -- th.set_share_img(); acne.get_goods(th, setting.stoid); @@ -319,7 +320,7 @@ Page({ } }) }, - + //-- 初始等级卡 -- init: function () { @@ -486,11 +487,11 @@ Page({ }) }, - close_yiwen(){ + close_yiwen() { this.setData({ - question_dialog:false, - yiwen_index:0, - yiwen_id:'yiwen1' + question_dialog: false, + yiwen_index: 0, + yiwen_id: 'yiwen1' }) }, @@ -754,92 +755,92 @@ Page({ src: path3, success: function (res) { - var b=1.1; - //获取到二维码的图片 - var vpath = res.path; - var context = wx.createCanvasContext('share'); - // 先画背景 - context.fillStyle = '#ebf6f8'; - // 灰色实心矩形 - // 1. 语法: x坐标, y坐标, 宽度, 高度 - context.fillRect(0,0,750 * rpx,1338 * rpx); - - context.setFontSize(20* rpx) - context.setFillStyle("#00d8e9") - context.fillText("官方检测认证", 28*b* rpx, 80*b* rpx); - - //两个底部颜色 - context.fillStyle = '#a7ecf5'; - context.fillRect(28 *b* rpx,136 *b* rpx,262 *b* rpx,18 *b* rpx); - context.fillRect(28 *b* rpx,194 *b* rpx,262 *b* rpx,18 *b* rpx); - - context.setFontSize(42*b*rpx) - context.setFillStyle("#070609") - context.fillText("我的肌底强韧", 30*b* rpx, 140*b* rpx); - context.fillText("肌肤鲜活润泽", 30*b* rpx, 196*b* rpx); - - //先画一个圆形 - th.circle(context,110*b*rpx, 280*b*rpx,140*b*rpx,"#e7f3f8"); - th.circle(context,130*b*rpx, 300*b*rpx,120*b*rpx,"#c8f2fa"); - //绘制人脸 - context.drawImage(th.data.share_head, 132*b*rpx, 310*b*rpx, 230*b* rpx, 230 *b* rpx); - - //左右俩个框并填充文字 - th.darwRoundRect(38 *b* rpx,340*b*rpx,140*b*rpx,40*b*rpx,20*b*rpx,context); - th.darwRoundRect(324 *b* rpx,340*b*rpx,140*b*rpx,40*b*rpx,20*b*rpx,context); - context.setFontSize(20*b*rpx) - context.setFillStyle("black") - context.fillText("黑眼圈 重度", 50*b* rpx, 368*b* rpx); - context.fillText("毛孔 "+th.data.pore_num, 336*b* rpx, 368*b* rpx); - - //左右俩个框并填充文字 - th.darwRoundRect(40 *b* rpx,412*b*rpx,116*b*rpx,40*b*rpx,20*b*rpx,context); - th.darwRoundRect(348 *b* rpx,412*b*rpx,116*b*rpx,40*b*rpx,20*b*rpx,context); - context.setFillStyle("black") - context.fillText("黑头 "+th.data.blackhead_num, 52*b* rpx, 440*b* rpx); - context.fillText("色斑 "+th.data.speckle_num, 354*b* rpx, 440*b* rpx); - - //左右俩个框并填充文字 - th.darwRoundRect(60 *b* rpx,484*b*rpx,116*b*rpx,40*b*rpx,20*b*rpx,context); - th.darwRoundRect(328 *b* rpx,484*b*rpx,116*b*rpx,40*b*rpx,20*b*rpx,context); - context.setFillStyle("black") - context.fillText("皱纹 "+th.data.wrinkle_num, 74*b* rpx, 510*b* rpx); - context.fillText("痤疮 "+th.data.acne_num, 344*b* rpx, 510*b* rpx); - - //底部的绘制 - th.darwRoundRect(38 *b* rpx,650*b*rpx,430*b*rpx,160*b*rpx,10*b*rpx,context); - //绘制二维码 - context.drawImage(vpath, 60*b*rpx, 672*b*rpx, 120 *b* rpx, 120 *b* rpx); - context.setFillStyle("black") - context.setFontSize(32*b*rpx) - context.fillText("美肤管家AI测肤", 200*b* rpx, 726*b* rpx); - context.setFontSize(22*b*rpx) - context.fillText("科学了解皮肤的真实状态", 200*b* rpx, 766*b* rpx); - - //把画板内容绘制成图片,并回调 画板图片路径 - context.draw(false, function () { - setTimeout(function () { - wx.canvasToTempFilePath({ - x: 0, - y: 0, - width: 750, - height: 1338, - destWidth: 1.4 * 750 * 750 / th.data.screenWidth, - destHeight: 1.4 * 750 * 750 / th.data.screenWidth, - canvasId: 'share', - success: function (res) { - that.setData({ - shareImgPath: res.tempFilePath, - canvasHidden: true, - share_show:1 - }) - /*-- - wx.previewImage({ - //将图片预览出来 - ur--*/ - - wx.hideLoading(); - } + var b = 1.1; + //获取到二维码的图片 + var vpath = res.path; + var context = wx.createCanvasContext('share'); + // 先画背景 + context.fillStyle = '#ebf6f8'; + // 灰色实心矩形 + // 1. 语法: x坐标, y坐标, 宽度, 高度 + context.fillRect(0, 0, 750 * rpx, 1338 * rpx); + + context.setFontSize(20 * rpx) + context.setFillStyle("#00d8e9") + context.fillText("官方检测认证", 28 * b * rpx, 80 * b * rpx); + + //两个底部颜色 + context.fillStyle = '#a7ecf5'; + context.fillRect(28 * b * rpx, 136 * b * rpx, 262 * b * rpx, 18 * b * rpx); + context.fillRect(28 * b * rpx, 194 * b * rpx, 262 * b * rpx, 18 * b * rpx); + + context.setFontSize(42 * b * rpx) + context.setFillStyle("#070609") + context.fillText("我的肌底强韧", 30 * b * rpx, 140 * b * rpx); + context.fillText("肌肤鲜活润泽", 30 * b * rpx, 196 * b * rpx); + + //先画一个圆形 + th.circle(context, 110 * b * rpx, 280 * b * rpx, 140 * b * rpx, "#e7f3f8"); + th.circle(context, 130 * b * rpx, 300 * b * rpx, 120 * b * rpx, "#c8f2fa"); + //绘制人脸 + context.drawImage(th.data.share_head, 132 * b * rpx, 310 * b * rpx, 230 * b * rpx, 230 * b * rpx); + + //左右俩个框并填充文字 + th.darwRoundRect(38 * b * rpx, 340 * b * rpx, 140 * b * rpx, 40 * b * rpx, 20 * b * rpx, context); + th.darwRoundRect(324 * b * rpx, 340 * b * rpx, 140 * b * rpx, 40 * b * rpx, 20 * b * rpx, context); + context.setFontSize(20 * b * rpx) + context.setFillStyle("black") + context.fillText("黑眼圈 重度", 50 * b * rpx, 368 * b * rpx); + context.fillText("毛孔 " + th.data.pore_num, 336 * b * rpx, 368 * b * rpx); + + //左右俩个框并填充文字 + th.darwRoundRect(40 * b * rpx, 412 * b * rpx, 116 * b * rpx, 40 * b * rpx, 20 * b * rpx, context); + th.darwRoundRect(348 * b * rpx, 412 * b * rpx, 116 * b * rpx, 40 * b * rpx, 20 * b * rpx, context); + context.setFillStyle("black") + context.fillText("黑头 " + th.data.blackhead_num, 52 * b * rpx, 440 * b * rpx); + context.fillText("色斑 " + th.data.speckle_num, 354 * b * rpx, 440 * b * rpx); + + //左右俩个框并填充文字 + th.darwRoundRect(60 * b * rpx, 484 * b * rpx, 116 * b * rpx, 40 * b * rpx, 20 * b * rpx, context); + th.darwRoundRect(328 * b * rpx, 484 * b * rpx, 116 * b * rpx, 40 * b * rpx, 20 * b * rpx, context); + context.setFillStyle("black") + context.fillText("皱纹 " + th.data.wrinkle_num, 74 * b * rpx, 510 * b * rpx); + context.fillText("痤疮 " + th.data.acne_num, 344 * b * rpx, 510 * b * rpx); + + //底部的绘制 + th.darwRoundRect(38 * b * rpx, 650 * b * rpx, 430 * b * rpx, 160 * b * rpx, 10 * b * rpx, context); + //绘制二维码 + context.drawImage(vpath, 60 * b * rpx, 672 * b * rpx, 120 * b * rpx, 120 * b * rpx); + context.setFillStyle("black") + context.setFontSize(32 * b * rpx) + context.fillText("美肤管家AI测肤", 200 * b * rpx, 726 * b * rpx); + context.setFontSize(22 * b * rpx) + context.fillText("科学了解皮肤的真实状态", 200 * b * rpx, 766 * b * rpx); + + //把画板内容绘制成图片,并回调 画板图片路径 + context.draw(false, function () { + setTimeout(function () { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: 750, + height: 1338, + destWidth: 1.4 * 750 * 750 / th.data.screenWidth, + destHeight: 1.4 * 750 * 750 / th.data.screenWidth, + canvasId: 'share', + success: function (res) { + that.setData({ + shareImgPath: res.tempFilePath, + canvasHidden: true, + share_show: 1 + }) + /*-- + wx.previewImage({ + //将图片预览出来 + ur--*/ + + wx.hideLoading(); + } }) }, 500) -- libgit2 0.21.4