Commit 0104f600435741ec48b39294a624a2c88c439dad
1 parent
71d8574e
超出限购次数的优化
Showing
3 changed files
with
186 additions
and
47 deletions
packageD/pages/AI-test-skin/index/aiskin.js
| ... | ... | @@ -111,27 +111,7 @@ Page({ |
| 111 | 111 | |
| 112 | 112 | }, |
| 113 | 113 | |
| 114 | - check_num: function (func) { | |
| 115 | - //判断右没有开AI测肤 | |
| 116 | - getApp().promiseGet("/api/weshop/wx/weappSkin/get/" + setting.stoid, {}).then(rs => { | |
| 117 | - if (rs.data.code != 0 || !rs.data.data) { | |
| 118 | - wx.showToast({ | |
| 119 | - title: "未开通测肤功能,请联系商家", | |
| 120 | - icon: 'none', | |
| 121 | - duration: 3000 | |
| 122 | - }) | |
| 123 | - } else if (!rs.data.data.skin_num || rs.data.data.skin_num <= 0) { | |
| 124 | - wx.showToast({ | |
| 125 | - title: "测肤功能的使用次数已经达到上限,请联系商家", | |
| 126 | - icon: 'none', | |
| 127 | - duration: 3000 | |
| 128 | - }) | |
| 129 | - } else { | |
| 130 | - func(); | |
| 131 | - } | |
| 132 | - }) | |
| 133 | - }, | |
| 134 | - | |
| 114 | + | |
| 135 | 115 | async getHistoryData() { |
| 136 | 116 | if (!getApp().globalData.user_id) return false; |
| 137 | 117 | if (this.data.show_his) return false; |
| ... | ... | @@ -151,7 +131,65 @@ Page({ |
| 151 | 131 | if (res.code == 0 && res.data.pageData.length > 0) { |
| 152 | 132 | this.setData({ show_his: 1 }) |
| 153 | 133 | } |
| 154 | - } | |
| 134 | + }, | |
| 135 | + | |
| 136 | + check_num:function (func) { | |
| 137 | + //判断右没有开AI测肤 | |
| 138 | + getApp().promiseGet("/api/weshop/wx/weappSkin/get/"+setting.stoid,{}).then(rs=>{ | |
| 139 | + if(rs.data.code!=0 || !rs.data.data){ | |
| 140 | + wx.showToast({ | |
| 141 | + title: "未开通测肤功能,请联系商家", | |
| 142 | + icon: 'none', | |
| 143 | + duration: 3000 | |
| 144 | + }) | |
| 145 | + }else if(!rs.data.data.skin_num || rs.data.data.skin_num<=0){ | |
| 146 | + wx.showToast({ | |
| 147 | + title: "测肤功能的使用次数已经达到上限,请联系商家", | |
| 148 | + icon: 'none', | |
| 149 | + duration: 3000 | |
| 150 | + }) | |
| 151 | + }else{ | |
| 152 | + var rdata={ | |
| 153 | + store_id:setting.stoid, | |
| 154 | + user_id:getApp().globalData.user_id | |
| 155 | + } | |
| 156 | + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{ | |
| 157 | + if(res.data.code==0){ | |
| 158 | + func(); | |
| 159 | + }else{ | |
| 160 | + wx.showToast({ | |
| 161 | + title: res.data.msg, | |
| 162 | + icon: 'none', | |
| 163 | + duration: 3000 | |
| 164 | + }) | |
| 165 | + } | |
| 166 | + }) | |
| 167 | + } | |
| 168 | + }) | |
| 169 | + }, | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * @param {Object} url //url地址 | |
| 173 | + * @param {Object} data //data入参 | |
| 174 | + * @param {Object} succ //成功的回调 | |
| 175 | + * @param {Object} fail //失败的回调 | |
| 176 | + */ | |
| 177 | + json_post: function (url, data, succ, fail, mathod) { | |
| 178 | + var Mathod = "POST"; | |
| 179 | + if (mathod) Mathod = mathod; | |
| 180 | + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url; | |
| 181 | + var str = JSON.stringify(data); | |
| 182 | + wx.request({ | |
| 183 | + url: url, | |
| 184 | + data: str, | |
| 185 | + method: Mathod, | |
| 186 | + header: { | |
| 187 | + 'content-type': 'application/json' | |
| 188 | + },// 设置请求的 header | |
| 189 | + success: function (res) { succ(res); }, | |
| 190 | + fail: function (res) { fail(res); } | |
| 191 | + }) | |
| 192 | + }, | |
| 155 | 193 | |
| 156 | 194 | |
| 157 | 195 | }) |
| 158 | 196 | \ No newline at end of file | ... | ... |
packageD/pages/AI-test-skin/select_photo/select_photo.js
| ... | ... | @@ -197,8 +197,46 @@ Page({ |
| 197 | 197 | duration: 3000 |
| 198 | 198 | }) |
| 199 | 199 | }else{ |
| 200 | - func(); | |
| 200 | + var rdata={ | |
| 201 | + store_id:setting.stoid, | |
| 202 | + user_id:getApp().globalData.user_id | |
| 203 | + } | |
| 204 | + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{ | |
| 205 | + if(res.data.code==0){ | |
| 206 | + func(); | |
| 207 | + }else{ | |
| 208 | + wx.showToast({ | |
| 209 | + title: res.data.msg, | |
| 210 | + icon: 'none', | |
| 211 | + duration: 3000 | |
| 212 | + }) | |
| 213 | + } | |
| 214 | + }) | |
| 201 | 215 | } |
| 202 | 216 | }) |
| 203 | - } | |
| 217 | + }, | |
| 218 | + | |
| 219 | + | |
| 220 | + /** | |
| 221 | + * @param {Object} url //url地址 | |
| 222 | + * @param {Object} data //data入参 | |
| 223 | + * @param {Object} succ //成功的回调 | |
| 224 | + * @param {Object} fail //失败的回调 | |
| 225 | + */ | |
| 226 | + json_post: function (url, data, succ, fail, mathod) { | |
| 227 | + var Mathod = "POST"; | |
| 228 | + if (mathod) Mathod = mathod; | |
| 229 | + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url; | |
| 230 | + var str = JSON.stringify(data); | |
| 231 | + wx.request({ | |
| 232 | + url: url, | |
| 233 | + data: str, | |
| 234 | + method: Mathod, | |
| 235 | + header: { | |
| 236 | + 'content-type': 'application/json' | |
| 237 | + },// 设置请求的 header | |
| 238 | + success: function (res) { succ(res); }, | |
| 239 | + fail: function (res) { fail(res); } | |
| 240 | + }) | |
| 241 | + }, | |
| 204 | 242 | }) |
| 205 | 243 | \ No newline at end of file | ... | ... |
packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js
| ... | ... | @@ -99,32 +99,37 @@ Page({ |
| 99 | 99 | |
| 100 | 100 | //选择图片 |
| 101 | 101 | takePhoto() { |
| 102 | + | |
| 102 | 103 | var that = this; |
| 103 | - getApp().globalData.no_clear=1; | |
| 104 | - that.setData({selecting:1}); | |
| 105 | - wx.chooseImage({ | |
| 106 | - count: 1, | |
| 107 | - sizeType: ['compressed'], | |
| 108 | - sourceType: ['album', 'camera'], | |
| 109 | - success(res) { | |
| 110 | - var tempFilePaths = res.tempFilePaths | |
| 111 | - console.log(tempFilePaths); | |
| 112 | - console.log(res.tempFiles[0].size / 1024 + 'kb'); | |
| 113 | - var size1 =res.tempFiles[0].size; | |
| 114 | - var size = res.tempFiles[0].size / 1024; //kb单位 | |
| 115 | - // tempFilePath可以作为img标签的src属性显示图片 | |
| 116 | - var img = tempFilePaths[0]; | |
| 117 | - that.setData({ | |
| 118 | - imagesrc: img, | |
| 119 | - }) | |
| 120 | - that.imgToMin(img, size,size1); //获取图片后压缩 | |
| 104 | + this.check_num(function () { | |
| 105 | + getApp().globalData.no_clear=1; | |
| 106 | + that.setData({selecting:1}); | |
| 107 | + wx.chooseImage({ | |
| 108 | + count: 1, | |
| 109 | + sizeType: ['compressed'], | |
| 110 | + sourceType: ['album', 'camera'], | |
| 111 | + success(res) { | |
| 112 | + var tempFilePaths = res.tempFilePaths | |
| 113 | + console.log(tempFilePaths); | |
| 114 | + console.log(res.tempFiles[0].size / 1024 + 'kb'); | |
| 115 | + var size1 =res.tempFiles[0].size; | |
| 116 | + var size = res.tempFiles[0].size / 1024; //kb单位 | |
| 117 | + // tempFilePath可以作为img标签的src属性显示图片 | |
| 118 | + var img = tempFilePaths[0]; | |
| 119 | + that.setData({ | |
| 120 | + imagesrc: img, | |
| 121 | + }) | |
| 122 | + that.imgToMin(img, size,size1); //获取图片后压缩 | |
| 121 | 123 | |
| 122 | - }, | |
| 123 | - fail(err) { | |
| 124 | - that.setData({selecting:0}) | |
| 125 | - console.log(err); | |
| 126 | - } | |
| 124 | + }, | |
| 125 | + fail(err) { | |
| 126 | + that.setData({selecting:0}) | |
| 127 | + console.log(err); | |
| 128 | + } | |
| 129 | + }) | |
| 127 | 130 | }) |
| 131 | + | |
| 132 | + | |
| 128 | 133 | }, |
| 129 | 134 | //图片转码64 |
| 130 | 135 | base64(url, type) { |
| ... | ... | @@ -231,4 +236,62 @@ Page({ |
| 231 | 236 | }, |
| 232 | 237 | }) |
| 233 | 238 | }, |
| 239 | + | |
| 240 | + check_num:function (func) { | |
| 241 | + //判断右没有开AI测肤 | |
| 242 | + getApp().promiseGet("/api/weshop/wx/weappSkin/get/"+setting.stoid,{}).then(rs=>{ | |
| 243 | + if(rs.data.code!=0 || !rs.data.data){ | |
| 244 | + wx.showToast({ | |
| 245 | + title: "未开通测肤功能,请联系商家", | |
| 246 | + icon: 'none', | |
| 247 | + duration: 3000 | |
| 248 | + }) | |
| 249 | + }else if(!rs.data.data.skin_num || rs.data.data.skin_num<=0){ | |
| 250 | + wx.showToast({ | |
| 251 | + title: "测肤功能的使用次数已经达到上限,请联系商家", | |
| 252 | + icon: 'none', | |
| 253 | + duration: 3000 | |
| 254 | + }) | |
| 255 | + }else{ | |
| 256 | + var rdata={ | |
| 257 | + store_id:setting.stoid, | |
| 258 | + user_id:getApp().globalData.user_id | |
| 259 | + } | |
| 260 | + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{ | |
| 261 | + if(res.data.code==0){ | |
| 262 | + func(); | |
| 263 | + }else{ | |
| 264 | + wx.showToast({ | |
| 265 | + title: res.data.msg, | |
| 266 | + icon: 'none', | |
| 267 | + duration: 3000 | |
| 268 | + }) | |
| 269 | + } | |
| 270 | + }) | |
| 271 | + } | |
| 272 | + }) | |
| 273 | + }, | |
| 274 | + | |
| 275 | + /** | |
| 276 | + * @param {Object} url //url地址 | |
| 277 | + * @param {Object} data //data入参 | |
| 278 | + * @param {Object} succ //成功的回调 | |
| 279 | + * @param {Object} fail //失败的回调 | |
| 280 | + */ | |
| 281 | + json_post: function (url, data, succ, fail, mathod) { | |
| 282 | + var Mathod = "POST"; | |
| 283 | + if (mathod) Mathod = mathod; | |
| 284 | + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url; | |
| 285 | + var str = JSON.stringify(data); | |
| 286 | + wx.request({ | |
| 287 | + url: url, | |
| 288 | + data: str, | |
| 289 | + method: Mathod, | |
| 290 | + header: { | |
| 291 | + 'content-type': 'application/json' | |
| 292 | + },// 设置请求的 header | |
| 293 | + success: function (res) { succ(res); }, | |
| 294 | + fail: function (res) { fail(res); } | |
| 295 | + }) | |
| 296 | + }, | |
| 234 | 297 | }) |
| 235 | 298 | \ No newline at end of file | ... | ... |