diff --git a/app.json b/app.json index fc5d089..7fd2619 100644 --- a/app.json +++ b/app.json @@ -13,7 +13,9 @@ "pages/user/index", "pages/add/index", "pages/community/add", - "pages/badge/index" + "pages/badge/index", + "pages/user/about", + "pages/community/info" ], "window": { "navigationBarTextStyle": "black", @@ -62,6 +64,14 @@ } ] }, + "permission": { + "scope.userFuzzyLocation": { + "desc": "您的位置信息将用于智能规划养护任务" + } + }, + "requiredPrivateInfos": [ + "getFuzzyLocation" + ], "componentFramework": "glass-easel", "sitemapLocation": "sitemap.json", "lazyCodeLoading": "requiredComponents", diff --git a/pages/community/add.wxml b/pages/community/add.wxml index 71e6742..dabd0a8 100644 --- a/pages/community/add.wxml +++ b/pages/community/add.wxml @@ -25,7 +25,7 @@ - + diff --git a/pages/community/index.js b/pages/community/index.js index bff3ae9..0ce05ba 100644 --- a/pages/community/index.js +++ b/pages/community/index.js @@ -21,7 +21,15 @@ Page({ }, - handleClick(){ + goAdd(){ + const tmp = wx.getStorageSync('user') + // todo + // if (tmp.phone.length === 0){ + // wx.navigateTo({ + // url: '../login/index', + // }) + // return + // } wx.navigateTo({ url: '../community/add', }) @@ -34,6 +42,15 @@ Page({ }, + + + goInfo(e){ + const id = e.currentTarget.dataset.id + wx.navigateTo({ + url: '../community/info?id=' +id, + }) + }, + /** * 生命周期函数--监听页面显示 */ diff --git a/pages/community/index.wxml b/pages/community/index.wxml index 3e6658c..3e2add1 100644 --- a/pages/community/index.wxml +++ b/pages/community/index.wxml @@ -7,7 +7,7 @@ - + @@ -45,5 +45,5 @@ - + \ No newline at end of file diff --git a/pages/community/index.wxss b/pages/community/index.wxss index e818c73..1a191e1 100644 --- a/pages/community/index.wxss +++ b/pages/community/index.wxss @@ -8,7 +8,7 @@ .grid { display: grid; - grid-template-columns: 30% 30% 30%; + grid-template-columns: 32% 32% 32%; grid-row-gap: 8px; grid-column-gap: 8px; } diff --git a/pages/community/info.js b/pages/community/info.js new file mode 100644 index 0000000..5485774 --- /dev/null +++ b/pages/community/info.js @@ -0,0 +1,99 @@ +const { api } = require("../../utils/api") + +// pages/community/info.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + id : '', + info:null, + content:'', + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + const id = options.id + this.data.id = id + this.fetchInfo() + }, + + fetchInfo(){ + api('/post/detail','GET',{id: this.data.id}).then(res => { + if (res.code== 200){ + const tmp = res.data + this.setData({info:tmp}) + } + }) + }, + + input(e){ + const value = e.detail.value + console.log(value); + this.data.content = value + }, + add(){ + const data = {content: this.data.content, postId: this.data.id,parentId: this.data.id,rootId:this.data.id} + console.log(data); + api('/comment/add','POST',data,'json').then(res => { + if (res.code === 200){ + this.fetchInfo() + } + }) + }, + + + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/community/info.json b/pages/community/info.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/community/info.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/community/info.wxml b/pages/community/info.wxml new file mode 100644 index 0000000..f3832a3 --- /dev/null +++ b/pages/community/info.wxml @@ -0,0 +1,70 @@ + + + + + + + + 第五季 + 23 小时前 + + + + {{info.content}} + + + + + + + + + + + + + + + + + + + {{info.likeCount}} + + + + {{info.commentCount}} + + + + + + + + + + + {{item.user.name}} + + + {{item.createdAt}} + + + + {{item.content}} + + + + + + + + + + + + + + + + diff --git a/pages/community/info.wxss b/pages/community/info.wxss new file mode 100644 index 0000000..efcf935 --- /dev/null +++ b/pages/community/info.wxss @@ -0,0 +1,29 @@ +/* pages/community/info.wxss */ +.avatar { + height: 80rpx; + width: 80rpx; + border: white 2rpx solid; + border-radius: 60rpx; +} + +.grid { + display: grid; + grid-template-columns: 32% 32% 32%; + grid-row-gap: 8px; + grid-column-gap: 8px; +} + +.item { + background-color: #f1f1f1; + width: 100%; +} + +.bottom { + position: fixed; + bottom: 0; + background-color: #F6F6F6; + left: 0; + right: 0; + padding:32rpx; + z-index: 2; +} \ No newline at end of file diff --git a/pages/garden/index.wxml b/pages/garden/index.wxml index ec9abcf..c243e7a 100644 --- a/pages/garden/index.wxml +++ b/pages/garden/index.wxml @@ -37,15 +37,15 @@ - {{item.name}} + {{item.plant.name}} 立即完成 已完成 跳过 已逾期{{item.todayCare.expireDays}}天 - - + + 上次养护:{{item.plant.lastPeriod}} diff --git a/pages/index/index.js b/pages/index/index.js index 47af646..a1d76df 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -38,6 +38,22 @@ Page({ */ onShow() { this.fetchList() + this.fethcLocation() + }, + + fethcLocation(){ + wx.getFuzzyLocation({ + type: 'wgs84', + success (res) { + console.log(res); + const latitude = res.latitude + const longitude = res.longitude + console.log(latitude,longitude); + }, + fail(err){ + console.log(err); + } + }) }, fetchList() { api('/plant/page', 'POST', { @@ -124,6 +140,13 @@ Page({ goAdd() { + const tmp = wx.getStorageSync('user') + if (tmp.phone.length === 0){ + wx.navigateTo({ + url: '../login/index', + }) + return + } wx.navigateTo({ url: '../add/index', }) diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 7ea2a45..d0655c0 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -32,19 +32,19 @@ - + 今日需养护 - - - + + + 今日无需养护 - 上次养护:{{item.lastPeriod ? itme.lastPeriod:'-' }} 天前 + 上次养护:{{item.lastPeriod ? item.lastPeriod:'-' }} @@ -76,7 +76,7 @@ 今日无需养护 - 上次养护:{{item.lastPeriod ? itme.lastPeriod:'-' }} 天前 + 上次养护:{{item.lastPeriod ? item.lastPeriod:'-' }} diff --git a/pages/login/index.js b/pages/login/index.js index 9603279..c3c87a8 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -29,10 +29,14 @@ Page({ this.setData({openData:tmp}) }, + goPrivate(){ + wx.openPrivacyContract() + }, + read(){ if (this.data.checked === false){ wx.showModal({ - content: '请先勾选我已经阅读并同意《植趣用户协议》和《植趣隐私政策》', + content: '请先勾选我已经阅读并同意《植趣用户协议》', }) } }, @@ -60,7 +64,7 @@ Page({ }) }, change(e){ - const tmp = this.data.checked === false + const tmp = this.data.checked === false console.log(tmp); this.setData({checked:tmp}) } diff --git a/pages/login/index.json b/pages/login/index.json index 10a8d6c..9f82ca1 100644 --- a/pages/login/index.json +++ b/pages/login/index.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "账号登录", "usingComponents": { - "t-radio": "tdesign-miniprogram/radio/radio" + } } \ No newline at end of file diff --git a/pages/login/index.wxml b/pages/login/index.wxml index 975d9e2..513b27f 100644 --- a/pages/login/index.wxml +++ b/pages/login/index.wxml @@ -9,11 +9,11 @@ - - - 我已经阅读并同意

《植趣用户协议》

《植趣隐私政策》

+ + + + 我已经阅读并同意

《植趣用户协议》

-
- +
\ No newline at end of file diff --git a/pages/user/about.js b/pages/user/about.js new file mode 100644 index 0000000..07ed452 --- /dev/null +++ b/pages/user/about.js @@ -0,0 +1,66 @@ +// pages/user/about.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/user/about.json b/pages/user/about.json new file mode 100644 index 0000000..84db5d8 --- /dev/null +++ b/pages/user/about.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "植趣微信群", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/user/about.wxml b/pages/user/about.wxml new file mode 100644 index 0000000..9da2a60 --- /dev/null +++ b/pages/user/about.wxml @@ -0,0 +1,8 @@ + + + + + 长按二维码,加入群聊, + 一起交流种植小技巧 + + \ No newline at end of file diff --git a/pages/user/about.wxss b/pages/user/about.wxss new file mode 100644 index 0000000..aefc434 --- /dev/null +++ b/pages/user/about.wxss @@ -0,0 +1 @@ +/* pages/user/about.wxss */ \ No newline at end of file diff --git a/pages/user/index.js b/pages/user/index.js index f311850..9fe53e9 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -1,5 +1,5 @@ const { api } = require("../../utils/api") - +const config = require("../../config/config") // pages/user/index.js Page({ @@ -16,7 +16,7 @@ Page({ */ onLoad(options) { const tmp = wx.getStorageSync('user') - if ( tmp){ + if (tmp){ this.setData({user:tmp}) } }, @@ -37,11 +37,57 @@ Page({ fetchInfo(){ api('/personal/personal','GET').then(res => { if (res.code === 200){ + const tmps = res.data this.setData({info:res.data}) } }) }, + 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 + _this.setData({ + user:tmps + }) + _this.update() + } + } + }) + }, + + update(){ + api('/user/update','POST',this.data.user,"json").then(res => { + if (res.code === 200){ + + } + }) + }, + + goAbout(){ + wx.navigateTo({ + url: '../user/about', + }) + }, + + goPrivate(){ + wx.openPrivacyContract() + }, + + /** * 生命周期函数--监听页面隐藏 */ diff --git a/pages/user/index.wxml b/pages/user/index.wxml index c68e042..2f42b1f 100644 --- a/pages/user/index.wxml +++ b/pages/user/index.wxml @@ -2,10 +2,14 @@ - - - - + + + + + + {{user.name}} @@ -14,7 +18,7 @@ - 我的徽章 已解锁 23 个 + 我的徽章 已解锁 23 个 🎖️🎖️🎖️🎖️🎖️🎖️🎖️ @@ -76,10 +80,10 @@ - - - - + + + + diff --git a/pages/user/index.wxss b/pages/user/index.wxss index 75945a1..d8bf62c 100644 --- a/pages/user/index.wxss +++ b/pages/user/index.wxss @@ -2,6 +2,7 @@ .bg { background-color: #4FAB5F; padding: 32rpx; + } .avatar { @@ -11,6 +12,33 @@ border-radius: 60rpx; } + + +button::after { + border: none; +} + +.avatar-wrapper { + padding: 0; + + background-color: rebeccapurple !important; + width: 280rpx; +} + +.avatar-example { + width: 120rpx; + height: 120rpx; + border-radius: 100%; + border: white solid 1px; + object-fit: contain; + margin-top: 32rpx; +} +.avatar-wrapper { + padding: 0; + background-color: transparent !important; + width: 280rpx; +} + .camera{ background-color: #4fab5e3d; width: 100rpx; diff --git a/project.private.config.json b/project.private.config.json index 0c9a4af..33c1c33 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -20,5 +20,17 @@ "bigPackageSizeSupport": false }, "libVersion": "3.10.1", - "condition": {} + "condition": { + "miniprogram": { + "list": [ + { + "name": "pages/community/info", + "pathName": "pages/community/info", + "query": "id=d7082150-c68d-11f0-b4a9-bc2411e64a23", + "scene": null, + "launchMode": "default" + } + ] + } + } } \ No newline at end of file