diff --git a/packageD/pages/AI-test-skin/index/aiskin.js b/packageD/pages/AI-test-skin/index/aiskin.js index 49bb8e8..e1fc829 100644 --- a/packageD/pages/AI-test-skin/index/aiskin.js +++ b/packageD/pages/AI-test-skin/index/aiskin.js @@ -111,27 +111,7 @@ Page({ }, - check_num: function (func) { - //判断右没有开AI测肤 - getApp().promiseGet("/api/weshop/wx/weappSkin/get/" + setting.stoid, {}).then(rs => { - if (rs.data.code != 0 || !rs.data.data) { - wx.showToast({ - title: "未开通测肤功能,请联系商家", - icon: 'none', - duration: 3000 - }) - } else if (!rs.data.data.skin_num || rs.data.data.skin_num <= 0) { - wx.showToast({ - title: "测肤功能的使用次数已经达到上限,请联系商家", - icon: 'none', - duration: 3000 - }) - } else { - func(); - } - }) - }, - + async getHistoryData() { if (!getApp().globalData.user_id) return false; if (this.data.show_his) return false; @@ -151,7 +131,65 @@ Page({ if (res.code == 0 && res.data.pageData.length > 0) { this.setData({ show_his: 1 }) } - } + }, + + check_num:function (func) { + //判断右没有开AI测肤 + getApp().promiseGet("/api/weshop/wx/weappSkin/get/"+setting.stoid,{}).then(rs=>{ + if(rs.data.code!=0 || !rs.data.data){ + wx.showToast({ + title: "未开通测肤功能,请联系商家", + icon: 'none', + duration: 3000 + }) + }else if(!rs.data.data.skin_num || rs.data.data.skin_num<=0){ + wx.showToast({ + title: "测肤功能的使用次数已经达到上限,请联系商家", + icon: 'none', + duration: 3000 + }) + }else{ + var rdata={ + store_id:setting.stoid, + user_id:getApp().globalData.user_id + } + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{ + if(res.data.code==0){ + func(); + }else{ + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 3000 + }) + } + }) + } + }) + }, + + /** + * @param {Object} url //url地址 + * @param {Object} data //data入参 + * @param {Object} succ //成功的回调 + * @param {Object} fail //失败的回调 + */ + 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; + var str = JSON.stringify(data); + wx.request({ + url: url, + data: str, + method: Mathod, + header: { + 'content-type': 'application/json' + },// 设置请求的 header + success: function (res) { succ(res); }, + fail: function (res) { fail(res); } + }) + }, }) \ No newline at end of file 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 995d321..28fb089 100644 --- a/packageD/pages/AI-test-skin/select_photo/select_photo.js +++ b/packageD/pages/AI-test-skin/select_photo/select_photo.js @@ -197,8 +197,46 @@ Page({ duration: 3000 }) }else{ - func(); + var rdata={ + store_id:setting.stoid, + user_id:getApp().globalData.user_id + } + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{ + if(res.data.code==0){ + func(); + }else{ + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 3000 + }) + } + }) } }) - } + }, + + + /** + * @param {Object} url //url地址 + * @param {Object} data //data入参 + * @param {Object} succ //成功的回调 + * @param {Object} fail //失败的回调 + */ + 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; + var str = JSON.stringify(data); + wx.request({ + url: url, + data: str, + method: Mathod, + header: { + 'content-type': 'application/json' + },// 设置请求的 header + success: function (res) { succ(res); }, + fail: function (res) { fail(res); } + }) + }, }) \ No newline at end of file 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 c9e03d2..498e18f 100644 --- a/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js +++ b/packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js @@ -99,32 +99,37 @@ Page({ //选择图片 takePhoto() { + var that = this; - getApp().globalData.no_clear=1; - that.setData({selecting:1}); - 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); //获取图片后压缩 + this.check_num(function () { + getApp().globalData.no_clear=1; + that.setData({selecting:1}); + 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) { - that.setData({selecting:0}) - console.log(err); - } + }, + fail(err) { + that.setData({selecting:0}) + console.log(err); + } + }) }) + + }, //图片转码64 base64(url, type) { @@ -231,4 +236,62 @@ Page({ }, }) }, + + check_num:function (func) { + //判断右没有开AI测肤 + getApp().promiseGet("/api/weshop/wx/weappSkin/get/"+setting.stoid,{}).then(rs=>{ + if(rs.data.code!=0 || !rs.data.data){ + wx.showToast({ + title: "未开通测肤功能,请联系商家", + icon: 'none', + duration: 3000 + }) + }else if(!rs.data.data.skin_num || rs.data.data.skin_num<=0){ + wx.showToast({ + title: "测肤功能的使用次数已经达到上限,请联系商家", + icon: 'none', + duration: 3000 + }) + }else{ + var rdata={ + store_id:setting.stoid, + user_id:getApp().globalData.user_id + } + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{ + if(res.data.code==0){ + func(); + }else{ + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 3000 + }) + } + }) + } + }) + }, + + /** + * @param {Object} url //url地址 + * @param {Object} data //data入参 + * @param {Object} succ //成功的回调 + * @param {Object} fail //失败的回调 + */ + 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; + var str = JSON.stringify(data); + wx.request({ + url: url, + data: str, + method: Mathod, + header: { + 'content-type': 'application/json' + },// 设置请求的 header + success: function (res) { succ(res); }, + fail: function (res) { fail(res); } + }) + }, }) \ No newline at end of file