123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- import {
- get,
- post
- } from "../../../utils/http"
- var WxParse = require('../../../components/local/wxParse/wxParse.js');
- // subPackagesD/pages/testSkin/testSkin.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- store_id: '', //店铺ID
- skin_type: ['干性肌肤', '中性肌肤', '油性肌肤', '混合型肌肤', '敏感肌肤', '痤疮肌肤'], //肤质:1-干性肌肤 2-中性肌肤 3-油性肌肤 4-混合型肌肤,5敏感肌肤,6 痤疮肌肤
- skinInfo: [], //测肤详情
- ageChange: 0, //比实际年龄
- ageStatus: "", //比实际年龄的变化(0:比实际年龄小,1比实际年龄大,2跟实际年龄相符)
- skinLevel: '', //皮肤问题(严重程度:0无问题,1轻度,2中度,3重度)
- skinLevelList: ['健康', '轻度', '中度', '重度'], //皮肤问题
- isRadio: true, //查看护理方案是否加载(第一次加载时跳转)
- scheme_id:'',//推荐方案ID
- analysis_id:' ',//检测ID
- isHistory:true,//从历史记录跳转的是否显示历史记录
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log(options,'options');
- let isRadio = false
- let isHistory = true
- if (options.isRadio=='true') {
- isRadio = true
- }
- if(options.isHistory){
- isHistory=false
- }
- this.setData({
- store_id: wx.getStorageSync('store_id'), //店铺ID
- isRadio,
- analysis_id:options.analysis_id,
- isHistory
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- // 获取检测记录详情
- this.getSkinInfo()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- // 获取检测记录详情
- getSkinInfo() {
- get('v2/api/analysis/info', {
- analysis_id:this.data.analysis_id?this.data.analysis_id:'', //检测id,不填写则获取最新的检测信息
- store_id: this.data.store_id || wx.getStorageSync('store_id'), //店铺ID
- }, (res) => {
- if(res.data==null){
- wx.redirectTo({
- url: '/pages/plan/plan',
- })
- }
- if (res.code == 200) {
- let age = res.data.age
- let skin_age = res.data.skin_age
- // 判断肤龄状态
- if (age > skin_age) {
- this.setData({
- ageStatus: 0,
- ageChange: Number(age) - Number(skin_age)
- })
- } else if (skin_age > age) {
- this.setData({
- ageStatus: 1,
- ageChange: Number(skin_age) - Number(age)
- })
- } else {
- this.setData({
- ageStatus: 2,
- })
- }
- let that = this
- let length = res.data.suggest_list.length
- res.data.suggest_list.forEach((item,index)=>{
- WxParse.wxParse('article' + index, 'html', item.content[0], that, 5);
- if (index === length - 1) {
- WxParse.wxParseTemArray("askItemsArr", 'article', length, that)
- }
- })
- that.setData({
- skinInfo: res.data,
- skinLevel: res.data.degree.level
- })
- }
- })
- },
- // 查看您的专属方案
- goPlan() {
- // 是否已创建方案,1是,0否
- if(this.data.skinInfo.has_scheme==0){
- this.createPlan()
- }else{
- wx.navigateTo({
- url: '/subPackagesD/pages/skinPlan/skinPlan?isTestSkin=true',
- })
- }
- },
- // 创建推荐方案
- createPlan() {
- post('v2/api/scheme/add', {
- analysis_id: this.data.skinInfo.id
- }, (res) => {
- if(res.code==200){
- this.setData({
- scheme_id:res.data.scheme_id //推荐方案ID
- })
- wx.navigateTo({
- url: '/subPackagesD/pages/skinLoading/skinLoading',
- })
- }
- })
- },
- // 去历史报告
- goHistory() {
- wx.navigateTo({
- url: '/subPackagesD/pages/skinHistory/skinHistory',
- })
- },
- // 去商品详情
- goGoodsDetail(e) {
- let id = e.currentTarget.dataset.id
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=goods&id=${id}&store_id=${this.data.store_id}`,
- })
- }
- })
|