提交法律援助和财税援助,调整我的页面

This commit is contained in:
2024-11-29 15:36:18 +08:00
parent 520f44a25f
commit 3ad21ea708
15 changed files with 219 additions and 50 deletions

View File

@@ -1,3 +1,9 @@
import { askAid } from "../../../service/system";
import dayjs from "../../../utils/dayjs";
import { alertInfo, alertSuccess, isValidPhoneNumber, loadingFunc } from "../../../utils/index";
import request from '../../../utils/request'
const { OK } = request
// pages/aid/consult/index.js
Page({
@@ -12,10 +18,54 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const { type } = options;
this.setData({ type });
const { id, type } = options;
this.setData({ type: Number(type), id });
},
onChange(e) {
const data = e.detail;
const { name } = e.currentTarget.dataset
const { form } = this.data;
form[name] = data;
this.setData({
form,
})
},
back() {
wx.navigateBack()
},
async submit() {
const { form } = this.data;
const { name, phone, detail } = form;
if (!name) {
alertInfo("请输入名字")
return;
}
if (!phone) {
alertInfo("请输入手机号")
return;
}
if (phone && !isValidPhoneNumber(phone)) {
alertInfo("手机号格式不正确")
return
}
if (!detail) {
alertInfo("请输入详情")
return
}
const that = this;
loadingFunc(async () => {
const { type, id } = that.data;
const { code, message } = await askAid({ ...form, type, createTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), connectId: id })
if (code !== OK) {
alertInfo(message)
return
}
alertSuccess("创建成功")
setTimeout(() => {
wx.navigateBack();
}, 500)
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@@ -12,7 +12,7 @@
required
/>
<van-field
value="{{form.name}}"
value="{{form.phone}}"
label="手机号"
bind:change="onChange"
data-name="phone"
@@ -25,7 +25,6 @@
label="邮箱"
bind:change="onChange"
data-name="email"
required
placeholder="请输入邮箱"
title-width="140rpx"
/>
@@ -33,7 +32,7 @@
value="{{form.detail}}"
label="咨询内容"
bind:change="onChange"
data-name="email"
data-name="detail"
required
type="textarea"
autosize="{{true}}"
@@ -45,7 +44,7 @@
</view>
</van-cell-group>
<view class="submit" wx:if="{{editType === 'edit'}}">
<van-button block class="cancelEdit" bind:click="cancelEdit">取消编辑</van-button>
<view class="submit">
<van-button block class="cancelEdit" bind:click="back">返回</van-button>
<van-button type="info" block class="save" bind:click="submit">保存</van-button>
</view>

View File

@@ -1,8 +1,17 @@
/* pages/aid/consult/index.wxss */
.submit {
margin: 32rpx;
margin-bottom: 50rpx;
display: flex;
align-items: center;
}
margin: 40rpx;
margin-bottom: 50rpx;
display: flex;
align-items: center;
}
.cancelEdit, .save {
flex: 1;
}
.cancelEdit {
margin-right: 40rpx;
}