1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // pages/suggestions/suggestions.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- username: '',
- phoneNumber: '',
- content: ''
- },
- bindInput(e) {
- const { key } = e.currentTarget.dataset;
- const { value } = e.detail;
- this.setData({
- [key]: value
- })
- },
- submit(e) {
- let errorMsg = '';
- if (!this.data.username) {
- errorMsg = '请输入您的姓名';
- } else if (!this.data.phoneNumber) {
- errorMsg = '请输入您的联系电话';
- } else if (!this.data.content) {
- errorMsg = '请输入您的建议';
- }
- if (errorMsg) {
- wx.showToast({
- title: errorMsg,
- icon: 'none',
- duration: 2000
- })
- return;
- }
- app.$http.post('/suggest/add', this.data).then(({ status, msg }) => {
- if (status === 0) {
- wx.showToast({
- title: msg,
- icon: 'none',
- duration: 2000
- })
- wx.navigateBack({
- delta: 1
- })
- }
- })
- },
- })
|