This commit is contained in:
2025-03-09 23:40:39 +08:00
parent ed1188098f
commit 7e801fed23
4 changed files with 218 additions and 148 deletions

View File

@@ -14,7 +14,13 @@ Page({
}, },
onShow() { onShow() {
this.getOrderList() // 重置页码并重新获取数据
this.setData({
pageNum: 1,
news: []
}, () => {
this.getOrderList()
})
}, },
// =============== 页面跳转相关 =============== // =============== 页面跳转相关 ===============
@@ -123,14 +129,22 @@ Page({
// 处理资讯列表响应 // 处理资讯列表响应
handleOrderListResponse(res) { handleOrderListResponse(res) {
if (res.data.erro !== 0) return if (res.data.erro !== 0) {
wx.showToast({
title: '获取数据失败',
icon: 'none'
})
return
}
const { lists, currentPage } = res.data const { lists, currentPage } = res.data
this.setData({ if (lists && lists.length > 0) {
news: currentPage === 1 ? lists : this.data.news.concat(lists), this.setData({
pageNum: currentPage + 1 news: currentPage === 1 ? lists : this.data.news.concat(lists),
}) pageNum: currentPage + 1
})
}
}, },
// 资讯项点击 // 资讯项点击
@@ -172,14 +186,21 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { onPullDownRefresh() {
// 下拉刷新时重置页码并重新获取数据
this.setData({
pageNum: 1,
news: []
}, () => {
this.getOrderList()
})
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() { onReachBottom() {
// 上拉加载更多数据
this.getOrderList()
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享

View File

@@ -1,3 +1,5 @@
{ {
"usingComponents": {} "usingComponents": {},
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
} }

View File

@@ -1,166 +1,135 @@
// pages/tool/tool.js // pages/tool/tool.js
const app = getApp() const app = getApp()
Page({ Page({
data: { data: {
heightone: '', // 表单数据
name: '诺言', formData: {
age: '6', name: '',
height: '120', age: '',
boneAge: '6', height: '',
fatherHeight: '32', boneAge: '',
motherHeight: '28', fatherHeight: '',
igf: '334', motherHeight: '',
lh: '0.6', igf: '',
thickness: '11', lh: '',
thickness: ''
},
// 计算结果
result: '', result: '',
show: false, // 结果弹窗显示状态
show: false
}, },
inputName: function (e) {
// =============== 表单输入处理 ===============
// 统一的输入处理函数
handleInput(e) {
const { field } = e.currentTarget.dataset
this.setData({ this.setData({
name: e.detail.value [`formData.${field}`]: e.detail.value
}) })
}, },
inputAge: function (e) {
this.setData({ // =============== 登录检查 ===============
age: e.detail.value
}) checkLogin() {
}, if (!wx.getStorageSync('phone')) {
inputHeight: function (e) { wx.setStorageSync('uidFlag', false)
this.setData({ this.showLoginModal()
height: e.detail.value return false
})
},
inputBoneAge: function (e) {
this.setData({
boneAge: e.detail.value
})
},
inputFatherHeight: function (e) {
this.setData({
fatherHeight: e.detail.value
})
},
inputMotherHeight: function (e) {
this.setData({
motherHeight: e.detail.value
})
},
inputIGF: function (e) {
this.setData({
igf: e.detail.value
})
},
inputLH: function (e) {
this.setData({
lh: e.detail.value
})
},
inputThickness: function (e) {
this.setData({
thickness: e.detail.value
})
},
pintuan() {
this.setData({
show: true
});
},
tiaoguo() {
this.setData({
show: false
});
},
calculate: function () {
const data = this.data;
const result = {
};
console.log(result);
if (wx.getStorageSync('phone') == '') {
wx.setStorageSync('uidFlag', false);
console.log('请登录')
this.isdenglu()
} else {
this.setData({
show: true
});
this.payment()
} }
return true
}, },
//是否登录
isdenglu() { showLoginModal() {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: '请先登录', content: '请先登录',
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定')
wx.switchTab({ wx.switchTab({
url: '/pages/my/my' url: '/pages/my/my'
}) })
} else if (res.cancel) {
console.log('用户点击取消')
} }
} }
}) })
}, },
payment() {
if (this.data.name == '') { // =============== 计算相关 ===============
// 开始计算
calculate() {
if (!this.checkLogin()) return
if (!this.validateForm()) return
this.setData({ show: true })
this.submitCalculation()
},
// 表单验证
validateForm() {
const { name } = this.data.formData
if (!name.trim()) {
wx.showToast({ wx.showToast({
title: '请输入姓名', title: '请输入姓名',
icon: 'none' icon: 'none'
}); })
return return false
} }
var that = this; return true
},
// 提交计算请求
submitCalculation() {
const { formData } = this.data
wx.request({ wx.request({
url: app.globalData.url + 'app/Ruilaiwechat/calculate', url: app.globalData.url + 'app/Ruilaiwechat/calculate',
data: {
uid: wx.getStorageSync('uid'), //人员id
name: this.data.name, //姓名
age: this.data.age, //年龄
height: this.data.height, //身高
bone_age: this.data.boneAge, //骨龄
father_height: this.data.fatherHeight, //父亲身高
mother_height: this.data.motherHeight, //母亲身高
IGF: this.data.igf, //IGF-1值
LH: this.data.lh, //LH基础值
uterus_thickness: this.data.thickness, //子宫厚度
},
method: 'POST', method: 'POST',
header: { header: {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
}, },
success(res) { data: {
if (res.data.erro == 0) { uid: wx.getStorageSync('uid'),
that.setData({ name: formData.name,
result: res.data.calculate_resutlt, age: formData.age,
}) height: formData.height,
} else { bone_age: formData.boneAge,
wx.showToast({ father_height: formData.fatherHeight,
title: res.data.msg, mother_height: formData.motherHeight,
icon: 'error', IGF: formData.igf,
duration: 2000 LH: formData.lh,
}) uterus_thickness: formData.thickness
} },
} success: this.handleCalculationResponse.bind(this)
}) })
}, },
onLoad: function (options) { // 处理计算响应
}, handleCalculationResponse(res) {
if (res.data.erro === 0) {
go_history(){
wx.navigateTo({
url: '/pages/order/order',
})
},
reset() {
if (wx.getStorageSync('phone') == '') {
wx.setStorageSync('uidFlag', false);
console.log('请登录')
this.isdenglu()
} else {
this.setData({ this.setData({
result: res.data.calculate_resutlt
})
} else {
wx.showToast({
title: res.data.msg,
icon: 'error',
duration: 2000
})
}
},
// =============== 其他功能 ===============
// 重置表单
reset() {
if (!this.checkLogin()) return
this.setData({
formData: {
name: '', name: '',
age: '', age: '',
height: '', height: '',
@@ -169,9 +138,24 @@ Page({
motherHeight: '', motherHeight: '',
igf: '', igf: '',
lh: '', lh: '',
thickness: '', thickness: ''
}); }
console.log('order_id==') })
} },
// 查看历史记录
go_history() {
wx.navigateTo({
url: '/pages/order/order'
})
},
// 弹窗控制
pintuan() {
this.setData({ show: true })
},
tiaoguo() {
this.setData({ show: false })
} }
}) })

View File

@@ -22,39 +22,102 @@
<view class="form-group"> <view class="form-group">
<text class="label">姓名:</text> <text class="label">姓名:</text>
<input class="input" type="text" placeholder="请输入姓名" bindinput="inputName" value="{{name}}" /> <input
class="input"
type="text"
placeholder="请输入姓名"
data-field="name"
bindinput="handleInput"
value="{{formData.name}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">年龄:</text> <text class="label">年龄:</text>
<input class="input" type="digit" placeholder="请输入年龄" bindinput="inputAge" value="{{age}}" /> <input
class="input"
type="digit"
placeholder="请输入年龄"
data-field="age"
bindinput="handleInput"
value="{{formData.age}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">身高(cm)</text> <text class="label">身高(cm)</text>
<input class="input" type="digit" placeholder="请输入身高" bindinput="inputHeight" value="{{height}}" /> <input
class="input"
type="digit"
placeholder="请输入身高"
data-field="height"
bindinput="handleInput"
value="{{formData.height}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">骨龄:</text> <text class="label">骨龄:</text>
<input class="input" type="digit" placeholder="请输入骨龄" bindinput="inputBoneAge" value="{{boneAge}}" /> <input
class="input"
type="digit"
placeholder="请输入骨龄"
data-field="boneAge"
bindinput="handleInput"
value="{{formData.boneAge}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">父亲身高(cm)</text> <text class="label">父亲身高(cm)</text>
<input class="input" type="digit" placeholder="请输入父亲身高" bindinput="inputFatherHeight" value="{{fatherHeight}}" /> <input
class="input"
type="digit"
placeholder="请输入父亲身高"
data-field="fatherHeight"
bindinput="handleInput"
value="{{formData.fatherHeight}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">母亲身高(cm)</text> <text class="label">母亲身高(cm)</text>
<input class="input" type="digit" placeholder="请输入母亲身高" bindinput="inputMotherHeight" value="{{motherHeight}}" /> <input
class="input"
type="digit"
placeholder="请输入母亲身高"
data-field="motherHeight"
bindinput="handleInput"
value="{{formData.motherHeight}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">IGF-1:(ng/ml)</text> <text class="label">IGF-1:(ng/ml)</text>
<input class="input" type="digit" placeholder="请输入IGF基础值" bindinput="inputIGF" value="{{igf}}" /> <input
class="input"
type="digit"
placeholder="请输入IGF基础值"
data-field="igf"
bindinput="handleInput"
value="{{formData.igf}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">LH基础(mIU/ml):</text> <text class="label">LH基础(mIU/ml):</text>
<input class="input" type="digit" placeholder="请输入LH基础值" bindinput="inputLH" value="{{lh}}" /> <input
class="input"
type="digit"
placeholder="请输入LH基础值"
data-field="lh"
bindinput="handleInput"
value="{{formData.lh}}"
/>
</view> </view>
<view class="form-group"> <view class="form-group">
<text class="label">子宫厚度(mm):</text> <text class="label">子宫厚度(mm):</text>
<input class="input" type="digit" placeholder="请输入厚度" bindinput="inputThickness" value="{{thickness}}" /> <input
class="input"
type="digit"
placeholder="请输入厚度"
data-field="thickness"
bindinput="handleInput"
value="{{formData.thickness}}"
/>
</view> </view>
<view class="addperson"> <view class="addperson">