123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- // pages/skinRecord/components/plan/plan.js
- import {
- post,
- } from '../../../../utils/http';
- Component({
- /**
- * 组件的属性列表
- */
- options: {
- addGlobalClass: true
- },
- properties: {
- analysis: {
- type: Object,
- value: null,
- },
- plan: {
- type: Object,
- value: null,
- observer(newVal) {
- if(newVal && this.data.fromList == "1") {
- this.setData({
- toView: "btm-btn"
- })
- }
- }
- },
- analysis_id: {
- type: String,
- value: ''
- },
- fromList: {
- type: String,
- value: '',
- }
- },
- pageLifetimes: {
- show: function() {
- // 页面被展示
- },
- hide: function() {
- // 页面被隐藏
- this.setData({
- visible: false
- })
- },
- },
- /**
- * 组件的初始数据
- */
- data: {
- visible: false,
- toView: ""
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onAddPlan() {
- let that = this;
- let plan = this.data.plan
- if(plan.is_has_plan == 1) {
- this.setData({
- visible: true
- })
- } else {
- that.addPlanApi()
- }
- },
- goToBeautyPlan() {
- wx.navigateTo({
- url: '/pages/beautyPlan/beautyPlan?analysis_id=' + this.data.analysis_id,
- })
- },
- addPlanApi() {
- post('api/user/plan/add',{
- analysis_id: this.data.analysis_id
- },(res) => {
- wx.showToast({
- title: res.msg,
- icon: 'none'
- })
- this.setData({
- ['plan.is_add_plan']: 1
- })
- setTimeout(() => {
- wx.navigateTo({
- url: '/pages/beautyPlan/beautyPlan?analysis_id=' + this.data.analysis_id,
- })
- }, 1000);
- })
- },
- onCancelUse() {
- this.setData({ visible: false })
- },
- }
- })
|