代码如下,请大佬帮我瞅瞅。数据传入的都没问题,不知道为什么就是存不进去。找了很久了也没个头绪。
formSubmit: function (e) { var time = util.formatDate( new Date()); //文件送达的时间 var formObject = e.detail.value; var documentType= '工程函件' //文件类别 var isCheck=formObject.isCheck; //是否为原件 var drafter=formObject.drafter; //起草人 var theme = formObject.theme; //文件主题 var pages = formObject.pages; //文件页数 var remark = formObject.remark; //备注 var state = '1' ; //文件的状态(1.未确认 2.已确认) var confirmTime = '' ; //文件的确认时间,新增时候默认空。剩余属性为送检人和联系电话通过查询user_idc来获得 if (theme == null || theme == '' || theme.length == 0) { wx.showToast({ title: '函件主题不能为空' , icon: 'none' }) } else if (drafter == null || drafter == '' || drafter.length == 0) { wx.showToast({ title: '起草人不能为空' , icon: 'none' }) } else if (pages == null || pages == '' || pages.length == 0) { wx.showToast({ title: '文件页数不能为空' , icon: 'none' }) } else { console.log( "存储数据" ) wx.getUserInfo({ success: function (data) { var nickName = data.userInfo.nickName; console.log(nickName) const db = wx.cloud.database(); const appointment = db.collection( 'user_idc' ); db.collection( 'user_idc' ).where({ nickName: nickName }).get({ success: function (res) { var name = res.data[0].name; var tel = res.data[0].tel; var dep = res.data[0].persondepartment console.log(name, tel, dep, documentType, dep, isCheck, theme, drafter, pages, remark, confirmTime, time) const appointment = db.collection( 'projectDocument' ); db.collection( 'projectDocument' ).add({ data: { documentType: documentType, department: dep, isCheck: isCheck, theme: theme, drafter: drafter, pages: pages, remark: remark, confirmTime: confirmTime, state: '1' , name: name, tel: tel, sendTime: time }, success: function (res) { wx.showToast({ title: '递交成功' , icon: 'success' }); wx.reLaunch({ url: '/pages/index/index' , }) }, fail:console.log(err) }) } }) } }) } }, |
const appointment = db.collection(
'projectDocument'
);
db.collection(
'projectDocument'
).add({
这两句是不是上一句没用了,要是你下边这样写。。还有你的db 在哪定义了?我没看到