// 保存表单
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;
}
}