fix 任务工单
This commit is contained in:
parent
777bfd2f57
commit
3fa72b2b3d
@ -1 +1,7 @@
|
|||||||
/* components/picker/index.wxss */
|
/* components/picker/index.wxss */
|
||||||
|
.camera{
|
||||||
|
background-color: #4fab5e3d;
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
border-radius: 50rpx;
|
||||||
|
}
|
||||||
104
components/profile/index.js
Normal file
104
components/profile/index.js
Normal file
@ -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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
7
components/profile/index.json
Normal file
7
components/profile/index.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"styleIsolation": "apply-shared",
|
||||||
|
"usingComponents": {
|
||||||
|
"t-popup": "tdesign-miniprogram/popup/popup"
|
||||||
|
}
|
||||||
|
}
|
||||||
37
components/profile/index.wxml
Normal file
37
components/profile/index.wxml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<!--components/profile/index.wxml-->
|
||||||
|
<view>
|
||||||
|
<t-popup visible="{{visible}}" bind:visible-change="change" placement="bottom">
|
||||||
|
<view class="padding">
|
||||||
|
<view class="font-16 bold">获取您的头像、昵称</view>
|
||||||
|
<view class="font-14 mt-5 font-sub">
|
||||||
|
获取用户头像、昵称完善个人资料,主要用于向用户提供具有辨识度的个性展示
|
||||||
|
</view>
|
||||||
|
<view class="mt-32">
|
||||||
|
<view class="flex flex-center flex-justify-between">
|
||||||
|
<view class="flex flex-center flex-justify-start">
|
||||||
|
<view class="font-sub">头像</view>
|
||||||
|
<view style="width: 560rpx;" class="ml-32">
|
||||||
|
<button class="avatar-wrapper flex flex-center flex-justify-start" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
||||||
|
<image class="avatar-example" src="{{avatar ? avatar : 'https://res.catter.cn/pub/2025/09/30/20250930143142508.png'}}" />
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<t-divider />
|
||||||
|
<view class="flex flex-center flex-justify-start">
|
||||||
|
<view class="font-sub">昵称</view>
|
||||||
|
<view class="ml-32">
|
||||||
|
<input type="nickname" bindinput="input"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="mt-32 mb-32">
|
||||||
|
<t-divider />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="flex flex-center mt-32 mb-32" style="margin-top: 80rpx;">
|
||||||
|
<t-button style="width: 80%;" shape="round" theme="primary" bind:tap="update">确认更新</t-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</t-popup>
|
||||||
|
</view>
|
||||||
23
components/profile/index.wxss
Normal file
23
components/profile/index.wxss
Normal file
@ -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;
|
||||||
|
}
|
||||||
@ -124,7 +124,6 @@ Page({
|
|||||||
},
|
},
|
||||||
url: config.baseUrl + '/oss/upload',
|
url: config.baseUrl + '/oss/upload',
|
||||||
success: res => {
|
success: res => {
|
||||||
wx.hideLoading()
|
|
||||||
var data = JSON.parse(res.data);
|
var data = JSON.parse(res.data);
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
const ossIds =[data.data.file.id]
|
const ossIds =[data.data.file.id]
|
||||||
@ -139,8 +138,8 @@ Page({
|
|||||||
|
|
||||||
fetchCheck(id){
|
fetchCheck(id){
|
||||||
api("/ocr/url",'GET',{id:id}).then(res => {
|
api("/ocr/url",'GET',{id:id}).then(res => {
|
||||||
|
wx.hideLoading()
|
||||||
if (res.code == 200){
|
if (res.code == 200){
|
||||||
|
|
||||||
const tmp = res.data.result[0]
|
const tmp = res.data.result[0]
|
||||||
if ( tmp.score > 0.5){
|
if ( tmp.score > 0.5){
|
||||||
const tmps = this.data.form
|
const tmps = this.data.form
|
||||||
|
|||||||
@ -38,7 +38,6 @@
|
|||||||
<view class="mt-32">
|
<view class="mt-32">
|
||||||
<view>
|
<view>
|
||||||
<count-picker item="{{item}}" wx:for="{{form.carePlans}}" bind:ok="update"></count-picker>
|
<count-picker item="{{item}}" wx:for="{{form.carePlans}}" bind:ok="update"></count-picker>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -20,6 +20,12 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view wx:else>
|
||||||
|
<view class="flex flex-center flex-col" style="margin-top: 56rpx;">
|
||||||
|
<image src="https://res.catter.cn/pub/2025/12/30/20251230113009120.png" style="width: 300rpx;" mode="widthFix"></image>
|
||||||
|
<view class="mt-32 font-12 font-sub">暂无徽章</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,8 @@ Page({
|
|||||||
data: {
|
data: {
|
||||||
content: '',
|
content: '',
|
||||||
ossIds: [],
|
ossIds: [],
|
||||||
fileList: []
|
fileList: [],
|
||||||
|
show:false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +47,19 @@ Page({
|
|||||||
content: value
|
content: value
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
update(e) {
|
||||||
|
const tmps = e.detail.value
|
||||||
|
this.setData({user:tmps})
|
||||||
|
},
|
||||||
submit() {
|
submit() {
|
||||||
|
const tmp = wx.getStorageSync('user')
|
||||||
|
if (tmp) {
|
||||||
|
// 完善信息
|
||||||
|
if(tmp.avatarId.length === 0){
|
||||||
|
this.setData({show:true})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this.data.content.length === 0) {
|
if (this.data.content.length === 0) {
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
content: '请输入这一刻的想法',
|
content: '请输入这一刻的想法',
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"navigationBarTitleText": "发布帖子",
|
"navigationBarTitleText": "发布帖子",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||||
"t-upload": "tdesign-miniprogram/upload/upload"
|
"t-upload": "tdesign-miniprogram/upload/upload",
|
||||||
|
"profile":"/components/profile/index"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,4 +40,6 @@
|
|||||||
<t-button theme="primary" style="width: 80%;" shape="round" bind:tap="submit">发布</t-button>
|
<t-button theme="primary" style="width: 80%;" shape="round" bind:tap="submit">发布</t-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<profile visible="{{show}}" bind:ok="update"/>
|
||||||
</view>
|
</view>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
<view class="padding">
|
<view class="padding">
|
||||||
<view wx:for="{{list}}" class="padding row mb-32" data-id="{{item.id}}" bind:tap="goInfo">
|
<view wx:for="{{list}}" class="padding row mb-32" data-id="{{item.id}}" bind:tap="goInfo">
|
||||||
<view class="flex flex-center flex-justify-start">
|
<view class="flex flex-center flex-justify-start">
|
||||||
<image src="{{item.user.avatar.url}}" class="avatar"></image>
|
<image src="{{item.user.avatar.url ? item.user.avatar.url :'https://res.catter.cn/pub/2025/09/30/20250930143142508.png'}}" class="avatar"></image>
|
||||||
<view class="ml-16">
|
<view class="ml-16">
|
||||||
<view class="bold">{{item.user.name}}</view>
|
<view class="bold">{{item.user.name}}</view>
|
||||||
<view class="font-12 grey">{{item.createdAtStr}}</view>
|
<view class="font-12 grey">{{item.createdAtStr}}</view>
|
||||||
|
|||||||
@ -26,9 +26,8 @@ Page({
|
|||||||
api('/plant/detail','GET',{id: this.data.id}).then(res => {
|
api('/plant/detail','GET',{id: this.data.id}).then(res => {
|
||||||
if (res.code === 200){
|
if (res.code === 200){
|
||||||
const tmp = res.data
|
const tmp = res.data
|
||||||
tmp.farms.suitableFertilizer = tmp.pestsDiseases.split(',')
|
if (tmp.imgList.length >0 ){
|
||||||
if (tmp.ossList.length >0 ){
|
tmp.pic = tmp.imgList[0].url
|
||||||
tmp.pic = tmp.ossList[0].url
|
|
||||||
}
|
}
|
||||||
this.setData({info:res.data})
|
this.setData({info:res.data})
|
||||||
}
|
}
|
||||||
@ -45,18 +44,7 @@ Page({
|
|||||||
this.setData({newName:value})
|
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(){
|
upload(){
|
||||||
const _this = this
|
const _this = this
|
||||||
@ -80,7 +68,7 @@ Page({
|
|||||||
success: res => {
|
success: res => {
|
||||||
var data = JSON.parse(res.data);
|
var data = JSON.parse(res.data);
|
||||||
if (data.code === 200) {
|
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 => {
|
api('/plant/uploadImg','POST',params,'json').then(res => {
|
||||||
if (res.code === 200){
|
if (res.code === 200){
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
@ -103,11 +91,22 @@ Page({
|
|||||||
|
|
||||||
update(){
|
update(){
|
||||||
const data = {id: this.data.id}
|
const data = {id: this.data.id}
|
||||||
if (this.data.newName != ''){
|
if(this.data.newName != this.data.info.name){
|
||||||
data.name = this.data.newName
|
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){
|
if (res.code === 200){
|
||||||
this.fetchInfo()
|
this.fetchInfo()
|
||||||
} else {
|
} else {
|
||||||
@ -115,7 +114,6 @@ Page({
|
|||||||
content: res.msg
|
content: res.msg
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.setData({showDialog:false})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -127,6 +125,9 @@ Page({
|
|||||||
const data = {ids: [this.data.id]}
|
const data = {ids: [this.data.id]}
|
||||||
api('/plant/delete','POST',data,'json').then(res => {
|
api('/plant/delete','POST',data,'json').then(res => {
|
||||||
if (res.code === 200){
|
if (res.code === 200){
|
||||||
|
wx.showToast({
|
||||||
|
title: '删除成果',
|
||||||
|
})
|
||||||
wx.navigateBack()
|
wx.navigateBack()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||||
"picker": "/components/count-picker/index"
|
"picker": "/components/count-picker/index",
|
||||||
|
"count-picker":"/components/count-picker/index"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,8 +31,8 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="white-bg mt-32 " style="border-radius: 16rpx;">
|
<view class="white-bg mt-32 " style="border-radius: 16rpx;">
|
||||||
<view style=" padding-top: 16rpx; padding-bottom: 16rpx;">
|
<view class="padding">
|
||||||
<picker wx:for="{{info.farms}}" title="{{item.name}}" value="{{item.cycleDays}}" prop="{{item.id}}" bind:ok="updateFarms"></picker>
|
<count-picker item="{{item}}" wx:for="{{info.carePlans}}" bind:ok="updateCarePlan"></count-picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,9 @@ const { api } = require("../../utils/api")
|
|||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
list:[],
|
list:[],
|
||||||
dash:null
|
dash:null,
|
||||||
|
badge:null,
|
||||||
|
show:false
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
|
||||||
@ -58,15 +60,24 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
changeStatus(data){
|
changeStatus(data){
|
||||||
api('/plant/makeCare','POST',data,'json').then(res => {
|
api('/plant/makeCare','POST',data,'json').then(res => {
|
||||||
if (res.code === 200){
|
if (res.code === 200){
|
||||||
wx.requestSubscribeMessage({
|
if (res.data != null){
|
||||||
tmplIds: ['iG5GYMPQAgKxIE9zZNOgKUghR6hP2WKKwws1RfLABuE'],
|
const tmps = res.data
|
||||||
success (res) {
|
if (tmps.length >0){
|
||||||
|
this.setData({
|
||||||
|
show:true,
|
||||||
|
badge: tmps[0]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
} else {
|
||||||
|
wx.requestSubscribeMessage({
|
||||||
|
tmplIds: ['inVOG9qy5NylOivO4Xb9H1db6PQlfv5doNNVhh_3iFE'],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -76,6 +87,10 @@ Page({
|
|||||||
url: '../community/index',
|
url: '../community/index',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
change(){
|
||||||
|
const show = !this.data.show
|
||||||
|
this.setData({show:show})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 用户点击右上角分享
|
* 用户点击右上角分享
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"navigationBarTitleText": "今日任务",
|
"navigationBarTitleText": "今日任务",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-progress": "tdesign-miniprogram/progress/progress"
|
"t-progress": "tdesign-miniprogram/progress/progress",
|
||||||
|
"badge":"/components/badge/index"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,10 +58,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
<badge visible="{{show}}" info="{{badge}}" bind:ok="change"></badge>
|
||||||
</view>
|
</view>
|
||||||
@ -43,7 +43,13 @@ Page({
|
|||||||
tmp.picList = tmp.imgList.map(sub => sub.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})
|
this.setData({info:res.data})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -99,7 +105,7 @@ Page({
|
|||||||
|
|
||||||
goEdit(){
|
goEdit(){
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../index/edit?id=' + this.data.id,
|
url: '../garden/edit?id=' + this.data.id,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view class="grid">
|
<view class="grid">
|
||||||
<view wx:for="{{info.todayCares}}" class="full-width" data-item="{{item}}" bind:tap="make">
|
<view wx:for="{{info.carePlans}}" class="full-width" data-item="{{item}}" bind:tap="make">
|
||||||
<view style="background-color: #FAFAFA; border-radius: 16rpx; width: 100%; border: {{item.color}}3C 1px solid;">
|
<view style="background-color: #FAFAFA; border-radius: 16rpx; width: 100%; border: {{item.color}}3C 1px solid;">
|
||||||
<view class="flex flex-center flex-col padding">
|
<view class="flex flex-center flex-col padding">
|
||||||
<view class="camera flex flex-center" style="background-color:{{item.color ? item.color+'3C':'red'}};">
|
<view class="camera flex flex-center" style="background-color:{{item.color ? item.color+'3C':'red'}};">
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
<view class="flex flex-center flex-justify-start flex-aligin-center mt-16">
|
<view class="flex flex-center flex-justify-start flex-aligin-center mt-16">
|
||||||
<t-icon wx:if="{{info.weather === '雾'}}" name="fog" size="34"></t-icon>
|
<t-icon wx:if="{{info.weather === '雾'}}" name="fog" size="34"></t-icon>
|
||||||
<t-icon wx:if="{{info.weather === '多云'}}" name="cloud" size="34"></t-icon>
|
<t-icon wx:if="{{info.weather === '多云'}}" name="cloud" size="34"></t-icon>
|
||||||
|
<t-icon wx:if="{{info.weather === '晴'}}" name="sunny" size="34"></t-icon>
|
||||||
<view class="bold ml-16" style="font-size: 40px;" >{{info.temperature}} ℃</view>
|
<view class="bold ml-16" style="font-size: 40px;" >{{info.temperature}} ℃</view>
|
||||||
</view>
|
</view>
|
||||||
<view wx:if="{{leftList.length > 0}}" bind:tap="goTask" class="flex flex-center flex-justify-start">
|
<view wx:if="{{leftList.length > 0}}" bind:tap="goTask" class="flex flex-center flex-justify-start">
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
const { api } = require("../../utils/api")
|
const {
|
||||||
|
api
|
||||||
|
} = require("../../utils/api")
|
||||||
|
|
||||||
// pages/knowlage/index.js
|
// pages/knowlage/index.js
|
||||||
Page({
|
Page({
|
||||||
@ -7,17 +9,51 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
tags:['懒人必养','吸甲醛','猫咪友好','阳台党','办公搭子'],
|
tags: [],
|
||||||
list:[]
|
list: [],
|
||||||
|
page: {
|
||||||
|
current: 1,
|
||||||
|
pageSize: 999,
|
||||||
|
classId:''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
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()
|
this.fetchList()
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchList(){
|
fetchList() {
|
||||||
api('/library/page','POST',{current:1,pageSize:10,name:"",classId:"",isHot:1},'json').then(res => {
|
const data = {
|
||||||
if (res.code === 200){
|
name: "",
|
||||||
|
...this.data.page
|
||||||
|
}
|
||||||
|
api('/library/page', 'POST', data, 'json').then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
const tmps = res.data.list.map(e => {
|
const tmps = res.data.list.map(e => {
|
||||||
e.pic = e.imgList[0].url
|
e.pic = e.imgList[0].url
|
||||||
return e
|
return e
|
||||||
})
|
})
|
||||||
this.setData({list:tmps})
|
this.setData({
|
||||||
|
list: tmps
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
goInfo(e){
|
goInfo(e) {
|
||||||
const id = e.currentTarget.dataset.id
|
const id = e.currentTarget.dataset.id
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../knowlage/info?id=' + id,
|
url: '../knowlage/info?id=' + id,
|
||||||
|
|||||||
@ -4,8 +4,8 @@
|
|||||||
<view class="white-bg padding">
|
<view class="white-bg padding">
|
||||||
<t-search placeholder="搜索植物" shape="round" />
|
<t-search placeholder="搜索植物" shape="round" />
|
||||||
<view class="flex flex-center flex-justify-start mt-32">
|
<view class="flex flex-center flex-justify-start mt-32">
|
||||||
<view wx:for="{{tags}}" class="mr-16">
|
<view wx:for="{{tags}}" class="mr-16" data-index="{{index}}" bind:tap="checked">
|
||||||
<t-tag shape="round">{{item}}</t-tag>
|
<t-tag shape="round" theme="{{item.checked ? 'primary':''}}" >{{item.name}}</t-tag>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -18,10 +18,10 @@
|
|||||||
<view class="white-bg" style="border-radius: 16rpx;">
|
<view class="white-bg" style="border-radius: 16rpx;">
|
||||||
<view style="position: relative;">
|
<view style="position: relative;">
|
||||||
<image src="{{item.pic}}" style="width: 100%; border-top-left-radius: 16rpx; border-top-right-radius: 16rpx;" mode="aspectFill"></image>
|
<image src="{{item.pic}}" style="width: 100%; border-top-left-radius: 16rpx; border-top-right-radius: 16rpx;" mode="aspectFill"></image>
|
||||||
<view style="position: absolute ; bottom: 0; right: 0; margin-bottom: 8rpx;" class="{{index === 0 ? 'price-tag-badge':'price-tag-badge2'}}" >
|
<!-- <view style="position: absolute ; bottom: 0; right: 0; margin-bottom: 8rpx;" class="{{index === 0 ? 'price-tag-badge':'price-tag-badge2'}}" >
|
||||||
<view wx:if="{{index === 0}}">已拥有</view>
|
<view wx:if="{{index === 0}}">已拥有</view>
|
||||||
<view wx:else >可兑换</view>
|
<view wx:else >可兑换</view>
|
||||||
</view>
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
<view style="padding: 32rpx 10rpx ; ">
|
<view style="padding: 32rpx 10rpx ; ">
|
||||||
<view class="bold ">{{item.name}}</view>
|
<view class="bold ">{{item.name}}</view>
|
||||||
|
|||||||
@ -52,7 +52,7 @@ Page({
|
|||||||
api("/auth/getPhone", 'GET', data).then(res => {
|
api("/auth/getPhone", 'GET', data).then(res => {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
wx.navigateBack()
|
this.fetchInfo(res.data.id)
|
||||||
} else {
|
} else {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: 'error',
|
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){
|
change(e){
|
||||||
const tmp = this.data.checked === false
|
const tmp = this.data.checked === false
|
||||||
|
|||||||
@ -12,7 +12,8 @@ Page({
|
|||||||
user: null,
|
user: null,
|
||||||
info: null,
|
info: null,
|
||||||
inviteCode: '',
|
inviteCode: '',
|
||||||
badgeList:[]
|
badgeList:[],
|
||||||
|
show:false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +25,11 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
user: tmp
|
user: tmp
|
||||||
})
|
})
|
||||||
|
// 完善信息
|
||||||
|
if(tmp.avatarId.length === 0){
|
||||||
|
this.setData({show:true})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
const inviteCode = wx.getStorageSync('inviteCode')
|
const inviteCode = wx.getStorageSync('inviteCode')
|
||||||
this.setData({
|
this.setData({
|
||||||
@ -42,6 +48,13 @@ Page({
|
|||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow() {
|
onShow() {
|
||||||
|
const tmp = wx.getStorageSync('user')
|
||||||
|
if (tmp) {
|
||||||
|
console.log("333");
|
||||||
|
this.setData({
|
||||||
|
user: tmp
|
||||||
|
})
|
||||||
|
}
|
||||||
this.fetchInfo()
|
this.fetchInfo()
|
||||||
},
|
},
|
||||||
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() {
|
update(e) {
|
||||||
api('/user/update', 'POST', this.data.user, "json").then(res => {
|
const tmps = e.detail.value
|
||||||
if (res.code === 200) {
|
this.setData({user:tmps})
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
goStore() {
|
goStore() {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-avatar": "tdesign-miniprogram/avatar/avatar",
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<view wx:if="{{info}}">
|
<view wx:if="{{info}}">
|
||||||
<view class="flex flex-center flex-justify-start" style="margin-top:128rpx;">
|
<view class="flex flex-center flex-justify-start" style="margin-top:128rpx;">
|
||||||
<view style="width: 140rpx;height:140rpx;" class="flex flex-center flex-justify-start full-width ">
|
<view style="width: 140rpx;height:140rpx;" class="flex flex-center flex-justify-start full-width ">
|
||||||
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar" style="background-color: red;">
|
<button class="avatar-wrapper" style="background-color: red;">
|
||||||
<image class="avatar-example" src="{{user.avatar ? user.avatar.url : 'https://res.catter.cn/pub/2025/09/30/20250930143142508.png'}}" />
|
<image class="avatar-example" src="{{user.avatar ? user.avatar.url : 'https://res.catter.cn/pub/2025/09/30/20250930143142508.png'}}" />
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
@ -96,4 +96,6 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="padding"></view>
|
<view class="padding"></view>
|
||||||
|
|
||||||
|
<profile visible="{{show}}" bind:ok="update"/>
|
||||||
</view>
|
</view>
|
||||||
Loading…
Reference in New Issue
Block a user