You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
2.7 KiB
146 lines
2.7 KiB
// 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 () {
|
|
|
|
}
|
|
})
|