统一 wx.showToast 提示,新增表单必填校验(标题/描述为空时禁止提交)

lyt
JUNNE_TOPIC1 1 month ago
parent 9a95e9c062
commit ffadd85a20

@ -2,7 +2,7 @@
<!-- 用户信息区域 --> <!-- 用户信息区域 -->
<view class="user-info"> <view class="user-info">
<view class="user-info-bg"></view> <view class="user-info-bg"></view>
<view class="user-info-content"> <view class="user-info-content" style="height: 250rpx; display: flex; box-sizing: border-box; left: 0rpx; top: 0rpx">
<image class="avatar" src="{{userInfo.avatarUrl || '/images/default_avatar.png'}}"></image> <image class="avatar" src="{{userInfo.avatarUrl || '/images/default_avatar.png'}}"></image>
<view class="user-details" wx:if="{{hasUserInfo}}"> <view class="user-details" wx:if="{{hasUserInfo}}">
<text class="nickname">{{userInfo.nickName}}</text> <text class="nickname">{{userInfo.nickName}}</text>

@ -1,4 +1,5 @@
// pages/profile/orders.js // pages/profile/orders.js
const toast = require('../../utils/toast.js')
Page({ Page({
data: { data: {
currentTab: 'all', currentTab: 'all',
@ -134,12 +135,21 @@ Page({
}, 1000); }, 1000);
}, },
// 加载更多 // 加载更多
loadMore: function () { loadMore: function () {
if (!this.data.isLoading && this.data.hasMoreOrders) { if (!this.data.isLoading && this.data.hasMoreOrders) {
this.loadOrders(); this.loadOrders();
} }
}, },
//雷雨田2025.8.30添加
confirmOrder() {
if (!this.data.address) {
wx.showToast({ title: '请选择地址', icon: 'none' })
return
}
wx.showToast({ title: '下单成功', icon: 'success' })
},
// 下拉刷新 // 下拉刷新
onPullDownRefresh: function () { onPullDownRefresh: function () {

@ -2,7 +2,8 @@
<!-- 顶部搜索栏 --> <!-- 顶部搜索栏 -->
<view class="search-container"> <view class="search-container">
<view class="search-box"> <view class="search-box">
<image class="search-icon" src="/images/search.png"></image> <!-- 雷雨田2025.8.30添加 -->
<image class="search-icon" src="/images/new_search.png" style="width: 62rpx; display: block; box-sizing: border-box; height: 60rpx"></image>
<input class="search-input" placeholder="搜索二手商品" confirm-type="search" bindconfirm="searchGoods" /> <input class="search-input" placeholder="搜索二手商品" confirm-type="search" bindconfirm="searchGoods" />
</view> </view>
</view> </view>
@ -57,5 +58,5 @@
</scroll-view> </scroll-view>
<!-- 发布按钮 --> <!-- 发布按钮 -->
<view class="publish-btn" bindtap="navigateToPublish">+</view> <view class="publish-btn" bindtap="navigateToPublish" style="height: 118rpx; display: flex; box-sizing: border-box; left: 604rpx; top: 1047rpx; width: 118rpx; position: fixed">+</view>
</view> </view>

@ -1,4 +1,5 @@
// pages/secondhand/publish.js // pages/secondhand/publish.js
const toast = require('../../utils/toast.js')
Page({ Page({
data: { data: {
images: [], images: [],
@ -98,6 +99,19 @@ Page({
contact: e.detail.value contact: e.detail.value
}); });
}, },
//雷雨田2025.8.30添加
handleSubmit() {
if (!this.data.title) {
wx.showToast({ title: '标题不能为空', icon: 'none' })
return
}
if (!this.data.desc) {
wx.showToast({ title: '描述不能为空', icon: 'none' })
return
}
// 校验通过 -> 调用 showSuccess
wx.showToast({ title: '发布成功', icon: 'success' })
},
// 校验表单 // 校验表单
validateForm: function () { validateForm: function () {

@ -47,7 +47,7 @@
"ignore": [], "ignore": [],
"include": [] "include": []
}, },
"appid": "wx5c58a3560c248707", "appid": "wx6fb98f37027a7f79",
"cloudfunctionTemplateRoot": "cloudfunctionTemplate/", "cloudfunctionTemplateRoot": "cloudfunctionTemplate/",
"cloudfunctionRoot": "cloudfunctions/" "cloudfunctionRoot": "cloudfunctions/"
} }
Loading…
Cancel
Save