13 changed files with 305 additions and 10 deletions
@ -0,0 +1,146 @@ |
|||||
|
// pages/user/address/add/index.js
|
||||
|
import util from "../../../utils/util.js" |
||||
|
import user from "../../../utils/https/user.js" |
||||
|
import commonApi from "../../../utils/https/common" |
||||
|
let app = getApp() |
||||
|
Page({ |
||||
|
|
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
|
||||
|
formData:{ |
||||
|
username: "", |
||||
|
mobile: null, |
||||
|
content:"" |
||||
|
}, |
||||
|
|
||||
|
safeBottom:app.globalData.safeBottom, |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面加载 |
||||
|
*/ |
||||
|
onLoad: function (options) { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
// 输入监听 不是双向绑定啊 绝望
|
||||
|
nameInput:function(e){ |
||||
|
var formData = this.data.formData; |
||||
|
formData.username = e.detail.value; |
||||
|
this.setData({ |
||||
|
formData: formData |
||||
|
}) |
||||
|
}, |
||||
|
telInput:function(e){ |
||||
|
var formData = this.data.formData; |
||||
|
formData.mobile = e.detail.value; |
||||
|
this.setData({ |
||||
|
formData: formData |
||||
|
}) |
||||
|
}, |
||||
|
contentInput:function(e){ |
||||
|
var formData = this.data.formData; |
||||
|
formData.content = e.detail.value; |
||||
|
this.setData({ |
||||
|
formData: formData |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
// 保存
|
||||
|
save:function(){ |
||||
|
if (!(this.data.formData.username||'').trim()){ |
||||
|
wx.showToast({ |
||||
|
title: '请输入姓名!', |
||||
|
icon:"none" |
||||
|
}) |
||||
|
return false; |
||||
|
} |
||||
|
if (!this.data.formData.mobile) { |
||||
|
wx.showToast({ |
||||
|
title: '请输入手机号码!', |
||||
|
icon: "none" |
||||
|
}) |
||||
|
return false; |
||||
|
} |
||||
|
if (!util.isTel(this.data.formData.mobile)) { |
||||
|
wx.showToast({ |
||||
|
title: '请输入正确的手机号码!', |
||||
|
icon: "none" |
||||
|
}) |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
if (!(this.data.formData.content||'').trim()) { |
||||
|
wx.showToast({ |
||||
|
title: '请输入反馈内容!', |
||||
|
icon: "none" |
||||
|
}) |
||||
|
return false; |
||||
|
} |
||||
|
let data = this.data.formData; |
||||
|
|
||||
|
commonApi.user_post("Suggest/add", data).then(res => { |
||||
|
if(res.code==1){ |
||||
|
|
||||
|
let data = { |
||||
|
username: "", |
||||
|
mobile: null, |
||||
|
content:"" |
||||
|
} |
||||
|
|
||||
|
this.setData({formData: data}) |
||||
|
|
||||
|
wx.showToast({ |
||||
|
title: '提交成功', |
||||
|
icon:"none", |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面初次渲染完成 |
||||
|
*/ |
||||
|
onReady: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面显示 |
||||
|
*/ |
||||
|
onShow: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面隐藏 |
||||
|
*/ |
||||
|
onHide: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面卸载 |
||||
|
*/ |
||||
|
onUnload: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 页面相关事件处理函数--监听用户下拉动作 |
||||
|
*/ |
||||
|
onPullDownRefresh: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 页面上拉触底事件的处理函数 |
||||
|
*/ |
||||
|
onReachBottom: function () { |
||||
|
|
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"title-header": "/pages/component/TitleHeader" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
<!--pages/user/address/add/index.wxml--> |
||||
|
<view class="container-view"> |
||||
|
<view> |
||||
|
<title-header title="投诉建议"></title-header> |
||||
|
<view class="input-box"> |
||||
|
<view class="input-item"> |
||||
|
<text class="input-label">姓名:</text> |
||||
|
<input bindinput="nameInput" value="{{formData.username}}" class="weui-input" auto-focus placeholder="请填写您的姓名" /> |
||||
|
</view> |
||||
|
<view class="input-item"> |
||||
|
<text class="input-label">手机号:</text> |
||||
|
<input bindinput="telInput" type="number" value="{{formData.mobile}}" class="weui-input" placeholder="请填写您的联系方式" /> |
||||
|
</view> |
||||
|
|
||||
|
<view class="input-item" style="border-bottom: none;"> |
||||
|
<text class="input-label">反馈内容:</text> |
||||
|
</view> |
||||
|
<view class="textarea-container"> |
||||
|
<textarea bindinput="contentInput" maxlength="500" value="{{formData.content}}" class="weui-input" placeholder="请填写具体的问题内容" ></textarea> |
||||
|
|
||||
|
<view class="textarea-tip">{{formData.content.length}}/500</view> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view> |
||||
|
<view class="btn" bindtap="save">提交</view> |
||||
|
<view style="height:{{safeBottom}}rpx"></view> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
@ -0,0 +1,85 @@ |
|||||
|
/* pages/user/address/add/index.wxss */ |
||||
|
page { |
||||
|
background: white; |
||||
|
height: 100%; |
||||
|
} |
||||
|
.input-box { |
||||
|
background: white; |
||||
|
padding: 0 20rpx; |
||||
|
font-size: 28rpx; |
||||
|
margin: 0; |
||||
|
} |
||||
|
.input-item { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
height: 106rpx; |
||||
|
justify-content: space-between; |
||||
|
border-bottom: 1rpx solid #EEE; |
||||
|
} |
||||
|
.input-label { |
||||
|
width: 140rpx; |
||||
|
} |
||||
|
.input-item .weui-input { |
||||
|
flex: 1; |
||||
|
} |
||||
|
.select-card { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
line-height: 90rpx; |
||||
|
} |
||||
|
.select-card .iconfont { |
||||
|
line-height: 90rpx; |
||||
|
} |
||||
|
.btn { |
||||
|
margin: 0 20rpx; |
||||
|
margin-top: 100rpx; |
||||
|
width: 700rpx; |
||||
|
margin-bottom: 30rpx; |
||||
|
line-height: 72rpx; |
||||
|
border-radius: 35rpx; |
||||
|
text-align: center; |
||||
|
color: white; |
||||
|
font-size: 36rpx; |
||||
|
background: #0B898E; |
||||
|
} |
||||
|
.icon-xia { |
||||
|
margin-left: 10rpx; |
||||
|
color: #999; |
||||
|
font-size: 28rpx; |
||||
|
} |
||||
|
.textarea-container{ |
||||
|
width: 100%; |
||||
|
height: 243rpx; |
||||
|
background: #F7F7F7; |
||||
|
border-radius: 13rpx 13rpx 13rpx 13rpx; |
||||
|
margin: 0 auto; |
||||
|
padding: 20rpx; |
||||
|
box-sizing: border-box; |
||||
|
position: relative; |
||||
|
padding-bottom: 50rpx; |
||||
|
} |
||||
|
.textarea-container textarea{ |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
overflow-y: auto; |
||||
|
} |
||||
|
|
||||
|
.container-view{ |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
flex-direction: column; |
||||
|
height: 100%; |
||||
|
} |
||||
|
.textarea-tip{ |
||||
|
position: absolute; |
||||
|
right: 22rpx; |
||||
|
bottom: 13rpx; |
||||
|
|
||||
|
font-family: PingFangSC, PingFang SC; |
||||
|
font-weight: 400; |
||||
|
font-size: 24rpx; |
||||
|
color: #999999; |
||||
|
|
||||
|
text-align: left; |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue