beautyPlanList.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import {
  2. get,
  3. post
  4. } from '../../utils/http';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. current: 0,
  11. list: [],
  12. total: 0,
  13. page: 1,
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. this.getPlanList()
  20. },
  21. /**
  22. * 生命周期函数--监听页面初次渲染完成
  23. */
  24. onReady: function () {
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面隐藏
  33. */
  34. onHide: function () {
  35. },
  36. /**
  37. * 生命周期函数--监听页面卸载
  38. */
  39. onUnload: function () {
  40. },
  41. /**
  42. * 页面相关事件处理函数--监听用户下拉动作
  43. */
  44. onPullDownRefresh: function () {
  45. },
  46. /**
  47. * 页面上拉触底事件的处理函数
  48. */
  49. onReachBottom: function () {
  50. if(this.data.page * 10 < this.data.total) {
  51. this.getPlanList(++this.data.page)
  52. }
  53. },
  54. /**
  55. * 用户点击右上角分享
  56. */
  57. onShareAppMessage: function () {
  58. },
  59. /**
  60. * 切换状态
  61. */
  62. onTabsChange(e) {
  63. let current = e.currentTarget.dataset.id
  64. if(current == this.data.current) {
  65. return;
  66. }
  67. this.setData({
  68. current,
  69. page: 1,
  70. },() => {
  71. this.getPlanList()
  72. })
  73. },
  74. /**
  75. * 获取美容计划列表
  76. * api/user/plan/list
  77. */
  78. getPlanList(_page) {
  79. let { list,current,page } = this.data;
  80. get('api/user/plan/list',{
  81. type: current,
  82. page: _page || page,
  83. limit: 10
  84. },(res) => {
  85. if(_page == 1 || page == 1) {
  86. list = []
  87. this.data.page = 1
  88. }
  89. list.push(...res.data.list)
  90. this.setData({ list,total:res.data.total })
  91. })
  92. },
  93. /**
  94. * 跳转到美容详情
  95. */
  96. goToBeautyPlan(e) {
  97. let item = e.currentTarget.dataset.item
  98. if(item.status == 0) {
  99. wx.navigateTo({
  100. url: `/pages/skinRecord/skinRecord?id=${item.id}&fromList=1`,
  101. })
  102. } else {
  103. wx.navigateTo({
  104. url: '/pages/beautyPlan/beautyPlan?analysis_id=' + item.id,
  105. })
  106. }
  107. }
  108. })