This commit is contained in:
wt 2025-09-28 15:17:20 +08:00
parent 558f54e721
commit cf6c88b7a3
7 changed files with 82 additions and 8 deletions

View File

@ -1,18 +1,50 @@
// pages/add/edit.js
const config = require("../../config/config")
const { api } = require("../../utils/api")
Page({
/**
* 页面的初始数据
*/
data: {
fileList:[],
form:{
name:'',
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.fetchList()
},
fetchList(){
api('/farmTemplate/list','POST').then(res => {
console.log(res);
})
},
upload(file){
const fileList = file.detail.files
this.setData({fileList:fileList})
wx.uploadFile({
header:{
'Authorization': 'Bearer ' + wx.getStorageSync('token'),
},
name:"file",
filePath: fileList[0].url,
url: config.baseUrl + '/oss/upload',
success: res => {
if(res.errMsg.indexOf("uploadFile:ok") > -1){
const data = JSON.parse(res.data)
const id = data.data.file.id
console.log(id);
}
}
})
},
/**

View File

@ -2,6 +2,8 @@
"usingComponents": {
"t-textarea": "tdesign-miniprogram/textarea/textarea",
"t-upload": "tdesign-miniprogram/upload/upload"
"t-upload": "tdesign-miniprogram/upload/upload",
"t-radio": "tdesign-miniprogram/radio/radio",
"t-radio-group": "tdesign-miniprogram/radio-group/radio-group"
}
}

View File

@ -1,15 +1,43 @@
<!--pages/add/edit.wxml-->
<view>
<view>
<t-input placeholder="请输入花盆名称" borderless t-class="t-input" />
<t-textarea t-class="external-class" placeholder="请输入备注" disableDefaultPadding="{{true}}" />
<t-input placeholder="请输入植物名称" borderless t-class="t-input" />
<view class="mt-16 ml-32 ">
<view class="font-12 grey">上传一张花盆的照片(可选)</view>
<view class="font-12 grey">什么时候施肥(可选)</view>
<view class="mt-16">
<t-upload disabled mediaType="{{['image']}}" max="{{1}}" files="{{fileList}}" bind:add="handleAdd" bind:remove="handleRemove">
<t-radio-group default-value="0" borderless t-class="box">
<t-radio class="padding" block="{{false}}" label="每30天" value="0" />
<t-radio class="padding" block="{{false}}" label="每40天" value="1" />
<t-radio class="padding" block="{{false}}" label="每50天" value="2" />
<t-radio class="padding" block="{{false}}" label="每60天" value="3" />
</t-radio-group>
</view>
</view>
<view class="mt-16 ml-32 ">
<view class="font-12 grey">何时进行修建(可选)</view>
<view class="mt-16">
<t-radio-group default-value="0" borderless t-class="box">
<t-radio class="padding" block="{{false}}" label="每30天" value="0" />
<t-radio class="padding" block="{{false}}" label="每40天" value="1" />
<t-radio class="padding" block="{{false}}" label="每50天" value="2" />
<t-radio class="padding" block="{{false}}" label="每60天" value="3" />
</t-radio-group>
</view>
</view>
<view class="mt-16 ml-32 ">
<view class="font-12 grey">上传花的照片(必填)</view>
<view class="mt-16">
<t-upload mediaType="{{['image']}}" max="{{9}}" files="{{fileList}}" bind:add="upload" bind:remove="handleRemove">
</t-upload>
</view>
</view>
</view>
<view class="flex flex-center" style="margin-top: 64rpx;">
<t-button theme="primary" shape="round" style="width: 80%;">确定并保存</t-button>
</view>
</view>

View File

@ -14,4 +14,13 @@
height: 256rpx;
background-color: wheat;
}
}
.box {
display: flex;
margin: 32rpx;
justify-content: space-around;
flex-wrap: wrap;
background-color: var(--td-bg-color-container, #fff);
}

View File

@ -1,4 +1,5 @@
// pages/add/index.js
Page({
/**

View File

@ -1,6 +1,6 @@
<!--pages/add/index.wxml-->
<view class="flex flex-center flex-col">
<view class="card mt-32 flex flex-center flex-col" bind:tap="goEdit">
<!-- <view class="card mt-32 flex flex-center flex-col" bind:tap="goEdit">
<view class="flex flex-center flex-col">
<view class="bg flex flex-center">
<t-icon name="add"></t-icon>
@ -8,7 +8,7 @@
<view class="font-16 bold mt-16">花盆</view>
<view class="font-12 grey mt-16">添加新的花盆</view>
</view>
</view>
</view> -->
<view class="card mt-32 flex flex-center flex-col" style="background-color: #FCFAFF; border: #E9D0FC 1rpx solid;" bind:tap="goEdit">
<view class="flex flex-center flex-col">

View File

@ -9,4 +9,6 @@
<view class="font-12 grey mt-16">您还没有添加任何花盆</view>
</view>
</view>
</view>