plan.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // pages/skinRecord/components/plan/plan.js
  2. import {
  3. post,
  4. } from '../../../../utils/http';
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. options: {
  10. addGlobalClass: true
  11. },
  12. properties: {
  13. analysis: {
  14. type: Object,
  15. value: null,
  16. },
  17. plan: {
  18. type: Object,
  19. value: null,
  20. observer(newVal) {
  21. if(newVal && this.data.fromList == "1") {
  22. this.setData({
  23. toView: "btm-btn"
  24. })
  25. }
  26. }
  27. },
  28. analysis_id: {
  29. type: String,
  30. value: ''
  31. },
  32. fromList: {
  33. type: String,
  34. value: '',
  35. }
  36. },
  37. pageLifetimes: {
  38. show: function() {
  39. // 页面被展示
  40. },
  41. hide: function() {
  42. // 页面被隐藏
  43. this.setData({
  44. visible: false
  45. })
  46. },
  47. },
  48. /**
  49. * 组件的初始数据
  50. */
  51. data: {
  52. visible: false,
  53. toView: ""
  54. },
  55. /**
  56. * 组件的方法列表
  57. */
  58. methods: {
  59. onAddPlan() {
  60. let that = this;
  61. let plan = this.data.plan
  62. if(plan.is_has_plan == 1) {
  63. this.setData({
  64. visible: true
  65. })
  66. } else {
  67. that.addPlanApi()
  68. }
  69. },
  70. goToBeautyPlan() {
  71. wx.navigateTo({
  72. url: '/pages/beautyPlan/beautyPlan?analysis_id=' + this.data.analysis_id,
  73. })
  74. },
  75. addPlanApi() {
  76. post('api/user/plan/add',{
  77. analysis_id: this.data.analysis_id
  78. },(res) => {
  79. wx.showToast({
  80. title: res.msg,
  81. icon: 'none'
  82. })
  83. this.setData({
  84. ['plan.is_add_plan']: 1
  85. })
  86. setTimeout(() => {
  87. wx.navigateTo({
  88. url: '/pages/beautyPlan/beautyPlan?analysis_id=' + this.data.analysis_id,
  89. })
  90. }, 1000);
  91. })
  92. },
  93. onCancelUse() {
  94. this.setData({ visible: false })
  95. },
  96. }
  97. })