diff --git a/components/count-picker/index.wxss b/components/count-picker/index.wxss
index 033253e..8a44c4d 100644
--- a/components/count-picker/index.wxss
+++ b/components/count-picker/index.wxss
@@ -1 +1,7 @@
-/* components/picker/index.wxss */
\ No newline at end of file
+/* components/picker/index.wxss */
+.camera{
+ background-color: #4fab5e3d;
+ width: 100rpx;
+ height: 100rpx;
+ border-radius: 50rpx;
+}
\ No newline at end of file
diff --git a/components/profile/index.js b/components/profile/index.js
new file mode 100644
index 0000000..1b99538
--- /dev/null
+++ b/components/profile/index.js
@@ -0,0 +1,104 @@
+const {
+ api
+} = require("../../utils/api")
+const config = require("../../config/config")
+
+// components/profile/index.js
+Component({
+
+ /**
+ * 组件的属性列表
+ */
+ properties: {
+ visible: {
+ type: Boolean,
+ require: false
+ },
+ },
+
+ /**
+ * 组件的初始数据
+ */
+ data: {
+ avatar: '',
+ avatarId: '',
+ name: ''
+ },
+
+ /**
+ * 组件的方法列表
+ */
+ methods: {
+ change() {
+ const show = !this.data.visible
+ this.setData({
+ visible: show
+ })
+ },
+ onChooseAvatar(e) {
+ const avatarUrl = e.detail.avatarUrl
+ // 上传
+ const _this = this
+ wx.uploadFile({
+ filePath: avatarUrl,
+ name: 'file',
+ header: {
+ 'Authorization': 'Bearer ' + wx.getStorageSync('token'),
+ },
+ url: config.baseUrl + '/oss/upload',
+ success: res => {
+ var data = JSON.parse(res.data)
+ console.log(data);
+ _this.setData({
+ avatar: data.data.file.url,
+ avatarId: data.data.file.id
+ })
+ }
+ })
+ },
+ input(e) {
+ const value = e.detail.value
+ this.data.name = value
+ },
+ update() {
+ const user = wx.getStorageSync('user')
+ if (this.data.name.length === 0 || this.data.avatarId.length === 0) {
+ wx.showToast({
+ icon: 'error',
+ title: '请完善信息',
+ })
+ return
+ }
+
+ user.avatarId = this.data.avatarId
+ user.name = this.data.name
+ console.log(user);
+ wx.showLoading({
+ title: '请稍后...',
+ })
+ api('/user/update','POST',user,'json').then(res => {
+ if (res.code === 200){
+ this.fetchInfo(user.id)
+ } else {
+ wx.showToast({
+ icon:'none',
+ title: res.msg,
+ })
+ }
+ })
+ },
+ fetchInfo(id){
+ api('/user/detail','GET',{id:id}).then(res => {
+ console.log(res);
+ wx.hideLoading()
+ if (res.code === 200){
+ wx.setStorageSync('user', res.data)
+ this.change()
+ this.triggerEvent('ok', {
+ value: res.data
+ });
+ }
+ })
+ },
+ }
+})
\ No newline at end of file
diff --git a/components/profile/index.json b/components/profile/index.json
new file mode 100644
index 0000000..d14e99f
--- /dev/null
+++ b/components/profile/index.json
@@ -0,0 +1,7 @@
+{
+ "component": true,
+ "styleIsolation": "apply-shared",
+ "usingComponents": {
+ "t-popup": "tdesign-miniprogram/popup/popup"
+ }
+}
\ No newline at end of file
diff --git a/components/profile/index.wxml b/components/profile/index.wxml
new file mode 100644
index 0000000..ce2bdef
--- /dev/null
+++ b/components/profile/index.wxml
@@ -0,0 +1,37 @@
+
+
+
+
+ 获取您的头像、昵称
+
+ 获取用户头像、昵称完善个人资料,主要用于向用户提供具有辨识度的个性展示
+
+
+
+
+ 头像
+
+
+
+
+
+
+
+
+ 昵称
+
+
+
+
+
+
+
+
+
+ 确认更新
+
+
+
+
\ No newline at end of file
diff --git a/components/profile/index.wxss b/components/profile/index.wxss
new file mode 100644
index 0000000..086e049
--- /dev/null
+++ b/components/profile/index.wxss
@@ -0,0 +1,23 @@
+/* components/profile/index.wxss */
+button::after {
+ border: none;
+}
+
+.avatar-wrapper {
+ padding: 0rpx !important;
+ margin: 0rpx !important;
+ color: #000000E6 !important;
+ height: 80rpx !important;
+ background-color: transparent !important;
+ width: 100% !important;
+}
+
+.avatar-example {
+ width: 80rpx;
+ height: 80rpx;
+ padding: 0;
+ margin: 0;
+ border-radius: 100%;
+ border: white solid 1px;
+ object-fit: contain;
+}
diff --git a/pages/add/index.js b/pages/add/index.js
index 4b42c00..c6cc4cd 100644
--- a/pages/add/index.js
+++ b/pages/add/index.js
@@ -124,7 +124,6 @@ Page({
},
url: config.baseUrl + '/oss/upload',
success: res => {
- wx.hideLoading()
var data = JSON.parse(res.data);
if (data.code === 200) {
const ossIds =[data.data.file.id]
@@ -139,8 +138,8 @@ Page({
fetchCheck(id){
api("/ocr/url",'GET',{id:id}).then(res => {
+ wx.hideLoading()
if (res.code == 200){
-
const tmp = res.data.result[0]
if ( tmp.score > 0.5){
const tmps = this.data.form
diff --git a/pages/add/index.wxml b/pages/add/index.wxml
index 3f94822..9015a72 100644
--- a/pages/add/index.wxml
+++ b/pages/add/index.wxml
@@ -38,7 +38,6 @@
-
diff --git a/pages/badge/index.wxml b/pages/badge/index.wxml
index 1fae6ee..1c52ce9 100644
--- a/pages/badge/index.wxml
+++ b/pages/badge/index.wxml
@@ -20,6 +20,12 @@
+
+
+
+ 暂无徽章
+
+
diff --git a/pages/community/add.js b/pages/community/add.js
index ca01706..e0ffc07 100644
--- a/pages/community/add.js
+++ b/pages/community/add.js
@@ -9,7 +9,8 @@ Page({
data: {
content: '',
ossIds: [],
- fileList: []
+ fileList: [],
+ show:false
},
/**
@@ -46,7 +47,19 @@ Page({
content: value
})
},
+ update(e) {
+ const tmps = e.detail.value
+ this.setData({user:tmps})
+ },
submit() {
+ const tmp = wx.getStorageSync('user')
+ if (tmp) {
+ // 完善信息
+ if(tmp.avatarId.length === 0){
+ this.setData({show:true})
+ return
+ }
+ }
if (this.data.content.length === 0) {
wx.showModal({
content: '请输入这一刻的想法',
diff --git a/pages/community/add.json b/pages/community/add.json
index ca9404d..058c897 100644
--- a/pages/community/add.json
+++ b/pages/community/add.json
@@ -2,6 +2,7 @@
"navigationBarTitleText": "发布帖子",
"usingComponents": {
"t-textarea": "tdesign-miniprogram/textarea/textarea",
- "t-upload": "tdesign-miniprogram/upload/upload"
+ "t-upload": "tdesign-miniprogram/upload/upload",
+ "profile":"/components/profile/index"
}
}
\ No newline at end of file
diff --git a/pages/community/add.wxml b/pages/community/add.wxml
index dabd0a8..677f9cf 100644
--- a/pages/community/add.wxml
+++ b/pages/community/add.wxml
@@ -40,4 +40,6 @@
发布
+
+
\ No newline at end of file
diff --git a/pages/community/index.wxml b/pages/community/index.wxml
index 1d95ac8..ebf1eb7 100644
--- a/pages/community/index.wxml
+++ b/pages/community/index.wxml
@@ -9,7 +9,7 @@
-
+
{{item.user.name}}
{{item.createdAtStr}}
diff --git a/pages/garden/edit.js b/pages/garden/edit.js
index bfcdc6a..a2be4f8 100644
--- a/pages/garden/edit.js
+++ b/pages/garden/edit.js
@@ -26,9 +26,8 @@ Page({
api('/plant/detail','GET',{id: this.data.id}).then(res => {
if (res.code === 200){
const tmp = res.data
- tmp.farms.suitableFertilizer = tmp.pestsDiseases.split(',')
- if (tmp.ossList.length >0 ){
- tmp.pic = tmp.ossList[0].url
+ if (tmp.imgList.length >0 ){
+ tmp.pic = tmp.imgList[0].url
}
this.setData({info:res.data})
}
@@ -45,18 +44,7 @@ Page({
this.setData({newName:value})
},
- updateFarms(e){
- const value = e.detail.value
- var data = {id: value.prop,cycleDays: value.value}
- api('/plant/updateFarm','POST',data,'json').then(res => {
- if (res.code === 200){
- wx.showToast({
- icon:'success',
- title: res.msg,
- })
- }
- })
- },
+
upload(){
const _this = this
@@ -80,7 +68,7 @@ Page({
success: res => {
var data = JSON.parse(res.data);
if (data.code === 200) {
- const params = {ossIds:[data.data.file.id],plantId: _this.data.info.id}
+ const params = {ossIds:[data.data.file.id],id: _this.data.info.id}
api('/plant/uploadImg','POST',params,'json').then(res => {
if (res.code === 200){
wx.showToast({
@@ -103,11 +91,22 @@ Page({
update(){
const data = {id: this.data.id}
- if (this.data.newName != ''){
+ if(this.data.newName != this.data.info.name){
data.name = this.data.newName
}
- console.log(data);
- api('/plant/updatePlant','POST',data,'json').then(res => {
+
+ api('/plant/update','POST',data,'json').then(res => {
+ if (res.code === 200){
+ this.fetchInfo()
+ this.changeDialog()
+ }
+ })
+ },
+ updateCarePlan(e){
+
+ const item = e.detail.value
+ const data = {id: item.id,period:item.period}
+ api('/plant/updateCarePlan','POST',data,'json').then(res => {
if (res.code === 200){
this.fetchInfo()
} else {
@@ -115,7 +114,6 @@ Page({
content: res.msg
})
}
- this.setData({showDialog:false})
})
},
@@ -127,6 +125,9 @@ Page({
const data = {ids: [this.data.id]}
api('/plant/delete','POST',data,'json').then(res => {
if (res.code === 200){
+ wx.showToast({
+ title: '删除成果',
+ })
wx.navigateBack()
}
})
diff --git a/pages/garden/edit.json b/pages/garden/edit.json
index 7772833..0a39083 100644
--- a/pages/garden/edit.json
+++ b/pages/garden/edit.json
@@ -2,6 +2,7 @@
"usingComponents": {
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-cell": "tdesign-miniprogram/cell/cell",
- "picker": "/components/count-picker/index"
+ "picker": "/components/count-picker/index",
+ "count-picker":"/components/count-picker/index"
}
}
\ No newline at end of file
diff --git a/pages/garden/edit.wxml b/pages/garden/edit.wxml
index cbf3eb1..cf6d74b 100644
--- a/pages/garden/edit.wxml
+++ b/pages/garden/edit.wxml
@@ -31,8 +31,8 @@
-
-
+
+
diff --git a/pages/garden/index.js b/pages/garden/index.js
index 40716ec..42a5e84 100644
--- a/pages/garden/index.js
+++ b/pages/garden/index.js
@@ -4,7 +4,9 @@ const { api } = require("../../utils/api")
Page({
data: {
list:[],
- dash:null
+ dash:null,
+ badge:null,
+ show:false
},
onLoad(options) {
@@ -58,15 +60,24 @@ Page({
}
},
+
changeStatus(data){
api('/plant/makeCare','POST',data,'json').then(res => {
if (res.code === 200){
- wx.requestSubscribeMessage({
- tmplIds: ['iG5GYMPQAgKxIE9zZNOgKUghR6hP2WKKwws1RfLABuE'],
- success (res) {
-
+ if (res.data != null){
+ const tmps = res.data
+ if (tmps.length >0){
+ this.setData({
+ show:true,
+ badge: tmps[0]
+ })
}
- })
+ } else {
+ wx.requestSubscribeMessage({
+ tmplIds: ['inVOG9qy5NylOivO4Xb9H1db6PQlfv5doNNVhh_3iFE'],
+ })
+ }
+
this.fetchList()
}
})
@@ -76,6 +87,10 @@ Page({
url: '../community/index',
})
},
+ change(){
+ const show = !this.data.show
+ this.setData({show:show})
+ },
/**
* 用户点击右上角分享
*/
diff --git a/pages/garden/index.json b/pages/garden/index.json
index 9598de5..a7da7c8 100644
--- a/pages/garden/index.json
+++ b/pages/garden/index.json
@@ -1,6 +1,7 @@
{
"navigationBarTitleText": "今日任务",
"usingComponents": {
- "t-progress": "tdesign-miniprogram/progress/progress"
+ "t-progress": "tdesign-miniprogram/progress/progress",
+ "badge":"/components/badge/index"
}
}
\ No newline at end of file
diff --git a/pages/garden/index.wxml b/pages/garden/index.wxml
index 7e071b9..59034ee 100644
--- a/pages/garden/index.wxml
+++ b/pages/garden/index.wxml
@@ -58,10 +58,7 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/pages/garden/info.js b/pages/garden/info.js
index c0d4778..1ef48e9 100644
--- a/pages/garden/info.js
+++ b/pages/garden/info.js
@@ -42,8 +42,14 @@ Page({
tmp.pic = tmp.imgList[0].url
tmp.picList = tmp.imgList.map(sub => sub.url)
}
-
- tmp.todayCares.map(e => e.period = tmp.carePlans.find(sub => sub.name === e.name).period)
+
+ tmp.carePlans.map(e => {
+ console.log(e.id);
+ const item = tmp.todayCares.find(sub => sub.careId === e.id)
+ e.status = item? item.status:2
+ return e
+
+ })
this.setData({info:res.data})
}
})
@@ -99,7 +105,7 @@ Page({
goEdit(){
wx.navigateTo({
- url: '../index/edit?id=' + this.data.id,
+ url: '../garden/edit?id=' + this.data.id,
})
},
diff --git a/pages/garden/info.wxml b/pages/garden/info.wxml
index 15d3816..f7e7cd7 100644
--- a/pages/garden/info.wxml
+++ b/pages/garden/info.wxml
@@ -54,7 +54,7 @@
-
+
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 42b7f9f..bb8f7f4 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -8,6 +8,7 @@
+
{{info.temperature}} ℃
diff --git a/pages/knowlage/index.js b/pages/knowlage/index.js
index 3fb0ecd..26da3e5 100644
--- a/pages/knowlage/index.js
+++ b/pages/knowlage/index.js
@@ -1,4 +1,6 @@
-const { api } = require("../../utils/api")
+const {
+ api
+} = require("../../utils/api")
// pages/knowlage/index.js
Page({
@@ -7,17 +9,51 @@ Page({
* 页面的初始数据
*/
data: {
- tags:['懒人必养','吸甲醛','猫咪友好','阳台党','办公搭子'],
- list:[]
+ tags: [],
+ list: [],
+ page: {
+ current: 1,
+ pageSize: 999,
+ classId:''
+ }
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
-
+ this.fetchTag()
},
+
+ fetchTag() {
+ api('/class/list', 'POST', {current:1,pageSize:999},'json').then(res => {
+ if (res.code === 200){
+ const tags = res.data.list.map(e=>{
+ e.checked = false
+ return e
+ })
+ this.setData({tags:tags})
+ }
+ })
+ },
+ checked(e){
+ const index = e.currentTarget.dataset.index
+ const tmps = this.data.tags.map(e => {
+ e.checked = false
+ return e
+ })
+ tmps[index].checked = true
+ this.setData({
+ tags:tmps
+ })
+ if(tmps[index].checked === false){
+ this.data.page.classId = ""
+ } else {
+ this.data.page.classId = tmps[index].id
+ }
+ this.fetchList()
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
@@ -32,19 +68,25 @@ Page({
this.fetchList()
},
- fetchList(){
- api('/library/page','POST',{current:1,pageSize:10,name:"",classId:"",isHot:1},'json').then(res => {
- if (res.code === 200){
+ fetchList() {
+ const data = {
+ name: "",
+ ...this.data.page
+ }
+ api('/library/page', 'POST', data, 'json').then(res => {
+ if (res.code === 200) {
const tmps = res.data.list.map(e => {
e.pic = e.imgList[0].url
return e
})
- this.setData({list:tmps})
+ this.setData({
+ list: tmps
+ })
}
})
},
- goInfo(e){
+ goInfo(e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: '../knowlage/info?id=' + id,
diff --git a/pages/knowlage/index.wxml b/pages/knowlage/index.wxml
index d33d628..b369f15 100644
--- a/pages/knowlage/index.wxml
+++ b/pages/knowlage/index.wxml
@@ -4,8 +4,8 @@
-
- {{item}}
+
+ {{item.name}}
@@ -18,10 +18,10 @@
-
+
{{item.name}}
diff --git a/pages/login/index.js b/pages/login/index.js
index 36ac0b7..6c5607e 100644
--- a/pages/login/index.js
+++ b/pages/login/index.js
@@ -52,7 +52,7 @@ Page({
api("/auth/getPhone", 'GET', data).then(res => {
wx.hideLoading()
if (res.code === 200) {
- wx.navigateBack()
+ this.fetchInfo(res.data.id)
} else {
wx.showToast({
icon: 'error',
@@ -60,6 +60,14 @@ Page({
})
}
})
+ },
+ fetchInfo(id){
+ api('/user/detail','GET',{id:id}).then(res => {
+ if (res.code === 200){
+ wx.setStorageSync('user', res.data)
+ wx.navigateBack()
+ }
+ })
},
change(e){
const tmp = this.data.checked === false
diff --git a/pages/user/index.js b/pages/user/index.js
index a985f14..754c294 100644
--- a/pages/user/index.js
+++ b/pages/user/index.js
@@ -12,7 +12,8 @@ Page({
user: null,
info: null,
inviteCode: '',
- badgeList:[]
+ badgeList:[],
+ show:false
},
/**
@@ -24,6 +25,11 @@ Page({
this.setData({
user: tmp
})
+ // 完善信息
+ if(tmp.avatarId.length === 0){
+ this.setData({show:true})
+ }
+
}
const inviteCode = wx.getStorageSync('inviteCode')
this.setData({
@@ -42,6 +48,13 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
+ const tmp = wx.getStorageSync('user')
+ if (tmp) {
+ console.log("333");
+ this.setData({
+ user: tmp
+ })
+ }
this.fetchInfo()
},
fetchInfo() {
@@ -62,39 +75,11 @@ Page({
})
},
- onChooseAvatar(e) {
- const avatarUrl = e.detail.avatarUrl
- // 上传
- const _this = this
- wx.uploadFile({
- filePath: avatarUrl,
- name: 'file',
- header: {
- 'Authorization': 'Bearer ' + wx.getStorageSync('token'),
- },
- url: config.baseUrl + '/oss/upload',
- success: res => {
- var data = JSON.parse(res.data)
+
- if (data.code === 200) {
- const tmps = _this.data.user
- tmps.avatar = data.data.file
- tmps.avatarId = data.data.file.id
- _this.setData({
- user: tmps
- })
- _this.update()
- }
- }
- })
- },
-
- update() {
- api('/user/update', 'POST', this.data.user, "json").then(res => {
- if (res.code === 200) {
-
- }
- })
+ update(e) {
+ const tmps = e.detail.value
+ this.setData({user:tmps})
},
goStore() {
diff --git a/pages/user/index.json b/pages/user/index.json
index 0c86c88..75c3d48 100644
--- a/pages/user/index.json
+++ b/pages/user/index.json
@@ -2,6 +2,7 @@
"navigationStyle": "custom",
"usingComponents": {
"t-avatar": "tdesign-miniprogram/avatar/avatar",
- "t-avatar-group": "tdesign-miniprogram/avatar-group/avatar-group"
+ "t-avatar-group": "tdesign-miniprogram/avatar-group/avatar-group",
+ "profile":"/components/profile/index"
}
}
\ No newline at end of file
diff --git a/pages/user/index.wxml b/pages/user/index.wxml
index 3f4f1e5..1b5d2a1 100644
--- a/pages/user/index.wxml
+++ b/pages/user/index.wxml
@@ -5,7 +5,7 @@
-
@@ -96,4 +96,6 @@
+
+
\ No newline at end of file