/* * @Author: abson * @Date: 2022-02-16 15:36:47 * @LastEditTime: 2022-02-21 16:07:09 * @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 */ // packageB/pages/AI-test-skin/success_result/success_result.js const app = getApp(); const request = app.request; const os = app.globalData; const setting = os.setting; const ut = require('../../../../utils/util'); //毛孔 const acne = require('acne/acne'); const blackhead = require('blackhead/blackhead'); const dark = require('dark/dark'); const pore = require('pore/pore'); const speckle = require('speckle/speckle'); const wrinkle = require('wrinkle/wrinkle'); Page({ /** * 页面的初始数据 */ data: { 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: 'ming_gan_ji', name: '敏感度' }], currentIndex: 0, tab_id: 'zong_he', iurl: setting.imghost, showDialog: false, yanjing: true, img_scale: true, //问题标注放大图片 img_scale_icon:true, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var th=this; //初始化一下,获取商品的价格 this.init(); //var face_result=getApp().globalData.face_result; //var face_data=face_result.face_list[0]; this.data.id=options.id; this.get_data(function (json,img) { //-- 数据先存着 -- var face_data=th.data.face_data=json.face_list[0]; //痤疮数 var acne_num=face_data.acnespotmole.acne_num; //色斑数 var speckle_num=face_data.acnespotmole.speckle_num; //皱纹数 var wrinkle_num=face_data.wrinkle.wrinkle_num; //黑头数 var blackhead_num=face_data.blackheadpore.blackhead_num; //毛孔数 var pore_num=face_data.blackheadpore.pore_num; //黑眼圈的严重程度 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; if(dark_type1>dark_type){ dark_type=dark_type1; } var skin_sensitive_check=face_data.skinquality.skin_sensitive_check[0]; var skin_dryoil_check=face_data.skinquality.skin_dryoil_check; th.setData({ acne_num:acne_num, speckle_num:speckle_num, wrinkle_num:wrinkle_num, blackhead_num:blackhead_num, pore_num:pore_num, dark_type:dark_type, skin_sensitive_check:skin_sensitive_check, skin_dryoil_check:skin_dryoil_check, face_img:img }) //-- 调用毛孔的推荐函数 -- if(pore_num>0) pore.get_goods(th,setting.stoid); //-- 调用黑头的推荐函数 -- if(blackhead_num>0) blackhead.get_goods(th,setting.stoid); //-- 调用色斑的推荐函数 -- if(speckle_num>0) speckle.get_goods(th,setting.stoid); //-- 调用皱纹的推荐函数 -- if(wrinkle_num>0) wrinkle.get_goods(th,setting.stoid); //-- 黑眼圈 -- if(dark_type>-1) dark.get_goods(th,setting.stoid); //-- 黑眼圈 -- if(acne_num>-0) acne.get_goods(th,setting.stoid); }) }, //-- 初始等级卡 -- init: function () { var th = this; if (!getApp().globalData.user_id) return false; getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { isShowLoading: false, success: function (e) { if (e.data.code == 0 && e.data && e.data.data) { getApp().globalData.userInfo = e.data.data; getApp().getConfig2(function (e) { var swithc_list = e.switch_list; var sw_arr = JSON.parse(swithc_list); //---如果后台有开等级卡的开关--- if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { th.setData({ rank_switch: true }); //---回调卡的列表--- th.getPlusCardType(function (ob) { th.setData({ card_list: ob.card_list }); var ti = setInterval(function () { var user = getApp().globalData.userInfo; if (!user) return false; clearInterval(ti); if (user.card_field && user['card_expiredate']) { var str = user['card_expiredate'].replace(/-/g, '/'); var end = new Date(str); end = Date.parse(end) / 1000; var now = ut.gettimestamp(); //--- 判断是等级会员,且在有效期范围内 --- if (user.card_field && now < end) { var card_name = ob.name_map.get(user.card_field); if (card_name.length > 4) card_name = card_name.substring(0, 8); th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list }); } } }, 500) }) } }) } } }) }, //-- 获取json数据 -- get_data:function (func) { var url="/api/weshop/face/storeSkinface/get/"+setting.stoid+"/"+this.data.id; getApp().request.promiseGet(url, {}).then(res=>{ if(res.data.code==0){ var json=JSON.parse(res.data.data.resultjson); func(json,res.data.data.img) }else{ getApp().showWarning("获取数据失败"); } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, clickTab(e) { let { index, tab_id } = e.currentTarget.dataset; this.setData({ currentIndex: index, tab_id, }) }, click_yanjing() { this.setData({ yanjing: !this.data.yanjing, }) }, click_fangda() { this.setData({ img_scale: !this.data.img_scale, img_scale_icon:!this.data.yanjing, }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, show_dailog() { this.setData({ showDialog: true, }) }, close_dialog() { this.setData({ showDialog: false, }) }, close_mask() { this.setData({ showDialog: false, img_scale: true, }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, //商品页面跳转 go_url:function (e) { var url=e.currentTarget.dataset.url; getApp().goto(url); }, //--- 获取卡类列表 --- getPlusCardType: function (func) { var storid = o.stoid; var th = this; getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { if (res.data.code != 0 || !res.data.data) { var ob = { "card_list": [], "name_map": "" }; func(ob); return false; } var plusCard = res.data.data; var arr = [1219, 2089, 3031]; var new_arr = new Array(); var card_name_map = new Map(); var user = getApp().globalData.userInfo; if (plusCard) { for (var i = 0; i < plusCard.length; i++) { if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { continue; } var name = "card" + plusCard[i].CorrPrice.toLowerCase(); card_name_map.set(name, plusCard[i].CardName); new_arr.push(plusCard[i]); } } var ob = { "card_list": new_arr, "name_map": card_name_map }; func(ob); }) }, })