绚火健康

This commit is contained in:
2023-08-15 17:18:15 +08:00
commit 32cc588ae7
200 changed files with 8924 additions and 0 deletions

179
pages/site/add/add.js Normal file
View File

@@ -0,0 +1,179 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
nameValue : '', // 姓名
mobile : '', // 电话
address : '', // 地址
isDefault : '', // 默认地址
// 省份选择
areasArr : [],
areaId : 0,
areaIndex : 0,
// 市级选择
cityArr : [],
cityId : 0,
cityIndex : 0,
// 区域选择
regiArr : [],
regiId : 0,
regiIndex : 0,
disabled : false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
experience: options.experience
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 获取省市区列表
this.createInfo();
},
/**
* 省市区列表
*/
createInfo() {
wx.$api.site.create().then(res => {
let areas = res.data,
areaIndex = this.data.areaIndex
this.setData({
areasArr : areas,
areaId : areas[areaIndex].id,
})
this.citylist(areas[areaIndex].id)
}).catch(err => {})
},
/**
* 所在省份-下拉
*/
areasChange(e) {
let area = this.data.areasArr,
index = e.detail.value,
atcode = area[index].id
if (index != this.data.areaIndex) {
this.setData({
areaIndex : index,
areaId : atcode
})
// 获取市级列表
this.citylist(atcode)
}
},
/**
* 市级列表
*/
citylist(cityId) {
wx.$api.site.create({
parent_id: cityId
}).then(res=>{
let cityArr = res.data
this.setData({
cityId : cityArr[0].id,
cityIndex : 0,
cityArr : cityArr
})
// 获取区级列表
this.regilist(cityArr[0].id)
})
},
/**
* 市级下拉筛选
*/
cityDrop(e) {
let city = this.data.cityArr,
index = e.detail.value,
citycode = city[index].id
if (index != this.data.cityIndex) {
this.setData({
cityIndex : index,
cityId : citycode
})
// 获取市级列表
this.regilist(citycode)
}
},
/**
* 区列表
*/
regilist(areaId) {
wx.$api.site.create({
parent_id: areaId
}).then(res=>{
this.setData({
regiArr : res.data,
regiId : res.data[0].id,
regiIndex : 0
})
})
},
/**
* 区下拉筛选
*/
regiDrop(e) {
let newIndex = e.detail.value
this.setData({
regiIndex : newIndex,
regiId : this.data.regiArr[newIndex].id
})
},
/*
姓名截取
*/
bindinput(e) {
this.setData({
nameValue: e.detail.value.substr(0,5)
})
},
// 提交表单
siteform(e) {
let value = e.detail.value
let data = {
name : this.data.nameValue,
mobile : value.mobile,
address : value.address,
province_id : this.data.areaId,
city_id : this.data.cityId,
district_id : this.data.regiId
}
this.setData({
disabled: true
})
wx.$api.site.siteAdd(data).then(res => {
wx.navigateBack()
}).catch(() =>{
this.setData({
disabled: false
})
})
}
})

4
pages/site/add/add.json Normal file
View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "新增地址"
}

44
pages/site/add/add.wxml Normal file
View File

@@ -0,0 +1,44 @@
<form bindsubmit="siteform" class="site-form">
<view class="site-input">
<label>收货人</label>
<input placeholder="请输入收货人姓名" name="name" type="text" value="{{nameValue}}" bindinput="bindinput"></input>
</view>
<view class="site-input">
<label>手机号码</label>
<input placeholder="请输入手机号码" maxlength="11" name="mobile" type="number"></input>
</view>
<view class="site-input">
<label>所在省份</label>
<picker bindchange="areasChange" value="{{areaIndex}}" range="{{areasArr}}" range-key="name">
<view class="picker">
{{ areasArr[areaIndex].name }}
</view>
<image src="/static/icons/orderArrow.png"></image>
</picker>
</view>
<view class="site-input">
<label>所在城市</label>
<picker bindchange="cityDrop" value="{{cityIndex}}" range="{{cityArr}}" range-key="name" class="conneColor">
<view class="picker">
{{ cityArr[cityIndex].name }}
</view>
<image src="/static/icons/orderArrow.png"></image>
</picker>
</view>
<view class="site-input">
<label>所在区域</label>
<picker bindchange="regiDrop" value="{{regiIndex}}" range="{{regiArr}}" range-key="name" class="conneColor">
<view class="picker">
{{ regiArr[regiIndex].name }}
</view>
<image src="/static/icons/orderArrow.png"></image>
</picker>
</view>
<view class="site-input">
<label>收货地址</label>
<input placeholder="请输入详细地址" name="address"></input>
</view>
<view class="site-btn">
<button form-type="submit" size="mini" disabled="{{disabled}}">保存</button>
</view>
</form>

79
pages/site/add/add.wxss Normal file
View File

@@ -0,0 +1,79 @@
.site-form {
background: white;
display: block;
}
.site-input {
padding: 0 30rpx 0 200rpx;
position: relative;
line-height: 110rpx;
min-height: 110rpx;
border-bottom: 2rpx solid #f3f3f3;
}
.site-input::before {
position: absolute;
bottom: 0;
left: 30rpx;
right: 0;
height: 1rpx;
content: "";
background: #e4e6f2;
}
.site-input:last-child::before {
display: none;
}
.site-input label {
position: absolute;
left: 30rpx;
top: 0;
}
.site-input input {
height: 110rpx;
}
.site-input image {
width: 44rpx;
height: 44rpx;
position: absolute;
right: 20rpx;
top: calc(50% - 22rpx);
}
.site-btn {
padding: 20rpx 30rpx;
margin-top: 100rpx;
}
.site-btn button[size="mini"] {
width: 100%;
background: #e92152;
height: 88rpx;
line-height: 88rpx;
font-size: 30rpx;
color: white;
padding: 0;
}
.site-btn button[disabled] {
background: #e92152 !important;
color: #fff !important;
}
.site-switch {
font-size: 32rpx;
margin: 30rpx;
display: flex;
line-height: 40rpx;
}
.site-switch text {
flex: 1;
}
.site-switch-active {
color: #797979;
}