// 保存表单
formSubmit: function(e) {
var self = this;
var formParams = e.detail.value;
if (!self.WxValidate.checkForm(formParams)) {
const error = self.WxValidate.errorList[0];
self.showModal(error);
return false;
} else {
wx.showLoading({
title: '正在保存',
mask: true,
})
console.log(formParams)
wx.cloud.callFunction({
name: self.data.cloudName,
data: {
openid: app.globalData.openid,
id: self.data.form.id,
userName: formParams.userName,
tel: formParams.tel,
pTIndex: formParams.pTIndex,
sexIndex: formParams.sexIndex,
birthday: formParams.birthday,
startWorkTime: formParams.startWorkTime,
city: formParams.city,
}
}).then(res => {
wx.hideLoading();
wx.navigateTo({
url: '../my/my',
})
}).catch(err => {
console.log(err)
})
}
},
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db=cloud.database()
const myResumeQ=db.collection("myResume")
// 云函数入口函数
exports.main = async (e, context) => {
try{
return await myResumeQ.doc({
_id:e.id,
}).update({
userName: e.userName,
tel: e.tel,
pTIndex: e.pTIndex,
sexIndex: e.sexIndex,
birthday: e.birthday,
startWorkTime: e.startWorkTime,
city: e.city,
});
}catch(err){
return err;
}
}
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-server-api/database/doc.update.html
云函数不太熟,看文档里面 要修改的字段 是放在update里面的data
看你代码 没写data
return await myResumeQ.doc({
_id:e.id,
}).update({
data:{
userName: e.userName,
tel: e.tel,
pTIndex: e.pTIndex,
sexIndex: e.sexIndex,
birthday: e.birthday,
startWorkTime: e.startWorkTime,
city: e.city,
}
});
我现在把云函数改了一下,也上传部署了,还是不行