// pages/evaluate/index.js var myRequest = require("../../utils/api.js"); Page({ /** * 页面的初始数据 */ data: { autosize:{ minHeight: 70 }, orderId:'', serviceAttitudeScore:'', technicalLevelScore:'', standardOperationScore:'', communicationSkillScore:'', desc:'' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options) let info = JSON.parse(options.item) console.log(info) this.setData({ orderId:info.orderId }) }, onChange(e){ console.log(e) let key = e.currentTarget.dataset.key this.setData({ [key]:e.detail }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, saveRating(){ let orderId = this.data.orderId let {communicationSkillScore,serviceAttitudeScore,standardOperationScore,technicalLevelScore,desc} = this.data if(this.check(desc)&&this.check(communicationSkillScore)&&this.check(serviceAttitudeScore)&&this.check(standardOperationScore)&&this.check(technicalLevelScore)){ let param={ communicationSkillScore,serviceAttitudeScore,standardOperationScore,technicalLevelScore,desc } myRequest.myRequest('deviceRepairOrder/customer/rating/'+this.data.orderId,param,'post').then(res=>{ wx.showToast({ title: '评价成功', icon:'none' }) setTimeout(()=>{ wx.navigateBack({ delta: 1, success: function (e) { var page = getCurrentPages().pop(); if (page == undefined || page == null) return; page.onLoad({orderId:orderId}); // 刷新数据 } }); },1000) }) } }, check(val){ if(val==''){ wx.showToast({ title: '请对本次服务进行评价', icon:'none' }) return false } return true }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })