50 lines
911 B
JavaScript
50 lines
911 B
JavaScript
const { api } = require("../../utils/api")
|
|
|
|
// index.js
|
|
Page({
|
|
data: {
|
|
list:[]
|
|
},
|
|
onLoad(options) {
|
|
wx.setNavigationBarTitle({
|
|
title: '我的花园',
|
|
})
|
|
},
|
|
onShow(){
|
|
this.fetchList()
|
|
},
|
|
goInfo(e){
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: '../index/info?id=' + id,
|
|
})
|
|
},
|
|
fetchList(){
|
|
const user = wx.getStorageSync('user')
|
|
const data = {userId: user.id,current:1,pageSize:20}
|
|
api('/plant/todayCare','GET',data,'json').then(res => {
|
|
if (res.code === 200){
|
|
const tmps = res.data.map(e => {
|
|
if (e.imgList.length >0){
|
|
e.pic = e.imgList[0].url
|
|
|
|
}
|
|
return e
|
|
})
|
|
this.setData({list:tmps})
|
|
}
|
|
})
|
|
},
|
|
goAdd(){
|
|
wx.navigateTo({
|
|
url: '../add/index',
|
|
})
|
|
},
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
})
|