var util = require('../../utils/util.js') const app = getApp(); Page({ data: { customerId:"", rules: { contactName: [{ required: true, message: '联系人必填', trigger: 'blur' }], telephone: [{ required: true, message: '联系人电话必填', trigger: 'blur' }], }, // 新增/编辑 create: { dialogStatus: '', temp: { contactName: '', telephone: '', address: '', remark: '', customerId:"", created: util.getToday(), }, } }, onLoad: function (options) { // 表单初始化 wx.lin.initValidateForm(this) var id = options.id; //获取编辑内容 util.getDataByName({ name:'getContactsById', parammaps: {"id":id} }, this.getShowList) }, getShowList:function(res){ console.log('展示数据======>', res.data.list) var customerId = res.data.list[0].customerId this.setData({ ['create.temp']: res.data.list[0], "customerId":res.data.list[0].customerId }) }, //保存 submit:function(e){ var detail_value = e.detail.values var detail_errors = e.detail.errors var detail_errors = e.detail.errors console.log("detail_value",detail_value) console.log("create.temp",this.data.create.temp) const submit_data = Object.assign({}, this.data.create.temp, detail_value) console.log("保存发送:",submit_data) var send_data = { "name": "updateContacts" , "parammaps": submit_data } util.postDataByName(send_data, this.getListSuccess) }, getListSuccess: function (res) { console.log('table数据======>', res) var that = this var id = this.data.customerId if (res.msg !== 'fail') { wx.showToast({ title: '保存成功', icon: 'success', duration: 2000, success: function(){ wx.redirectTo({ url:"../contact/contact?id=" + id}) } }) } else { wx.showToast({ title: '保存失败'+res.data, icon: 'error', duration: 2000, }) } }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, onShareAppMessage: function () { } })