{ "info": {}, "msg": [], "user": [], "survey": [] }
user:{ id:20221001 ubirth:'2020-08-01', udesc:'hi,there.', ulike:[], uage:18, ugender:'女', uname:'glpla', }
submit(e){ wx.request({ url: 'http://127.0.0.1:3000/user', method:'POST', data:this.data.user, success:(res)=>{ console.log(res); }, fail:err=>{ console.log(err); } }) }
submitSurvey(e) { wx.request({ url: 'http://127.0.0.1:3000/survey', method:'POST', data: e.detail.value, success:res=>{ console.log(res); }, fail:err=>{ console.log(err); }, complete:()=>{ console.log('log done'); } }) }
const express = require('express') const fs = require('fs'); // 创建Web服务器 const app = express(); const port = 3000; // 静态资源;系统中间件-靠前引用;路由中间件 app .use(express.static('./public')) .use(express.json()) app.post('/userInfo', (req, res) => { console.log(req.body); fs.writeFile('./public/data/userInfo.json', JSON.stringify(req.body), (error) => { if (error) { console.log('保存文件失败了') } }); res.json(req.body) }) app.listen(port, () => { console.log('server is on at: http://127.0.0.1:3000'); });
. wx.showLoading()
. wx.hideLoading()
. wx.showToast()