Initial Commit
This commit is contained in:
182
pages/my/my_feedback/my_feedback.js
Normal file
182
pages/my/my_feedback/my_feedback.js
Normal file
@ -0,0 +1,182 @@
|
||||
const app = getApp();
|
||||
const IP = app.globalData.ip;
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
ipUrl: app.globalData.ipUrl,
|
||||
num: 0,
|
||||
photo: [],
|
||||
textarea: "",
|
||||
phone: "",
|
||||
customerId: "",
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
wx.getStorage({
|
||||
key: 'user',
|
||||
success: res => {
|
||||
this.setData({
|
||||
customerId: res.data.id
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
//提交
|
||||
submitBut: function () {
|
||||
var photos = this.data.photo.join(",")
|
||||
if (this.data.phone.length == 11) {
|
||||
if (this.data.textarea != "" && this.data.phone != "") {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确认提交反馈?',
|
||||
success: ress => {
|
||||
if (ress.confirm) {
|
||||
wx.showLoading({
|
||||
title: '提交中',
|
||||
})
|
||||
wx.request({
|
||||
url: IP + '/wisdommining/api/user/addFeedBack',
|
||||
method: 'POST',
|
||||
data: {
|
||||
userId: app.globalData.userId,
|
||||
feedbackContent: this.data.textarea,
|
||||
feedbackPhone: this.data.phone,
|
||||
feedbackImage: photos,
|
||||
},
|
||||
success: res => {
|
||||
console.log(res)
|
||||
wx.hideLoading()
|
||||
if (res.data.code == 1) {
|
||||
wx.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success',
|
||||
success() {
|
||||
setTimeout(() => {
|
||||
wx.navigateBack()
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '获取数据失败!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '请完善信息',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '手机号码有误',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
//选择图片
|
||||
revise_img: function (e) {
|
||||
if (this.data.photo.length < 4) {
|
||||
var a = 4 - this.data.photo.length
|
||||
console.log(a)
|
||||
wx.chooseImage({
|
||||
count: a,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: res => {
|
||||
console.log(res)
|
||||
for (var i = 0; i < res.tempFilePaths.length; i++) {
|
||||
wx.uploadFile({
|
||||
url: IP + '/wisdommining/api/user/img',
|
||||
filePath: res.tempFilePaths[i],
|
||||
name: 'file',
|
||||
success: ress => {
|
||||
console.log(ress)
|
||||
var photo = this.data.photo;
|
||||
var data = JSON.parse(ress.data);
|
||||
photo.push(data.src);
|
||||
this.setData({
|
||||
photo: photo
|
||||
})
|
||||
console.log(this.data.photo)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '超过上传上限',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
//字数改变,获取输入内容-问题
|
||||
num: function (e) {
|
||||
this.setData({
|
||||
num: e.detail.cursor,
|
||||
textarea: e.detail.value,
|
||||
})
|
||||
},
|
||||
//获取输入内容-电话
|
||||
phone: function (e) {
|
||||
this.setData({
|
||||
phone: e.detail.value,
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user