let app = getApp(); let host = app.globalData.servsers; // 请求的url Page({ /** * 页面的初始数据 */ data: { goodsList:[], host: app.globalData.servsers, amount:'' }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let goodsList=[],that=this; goodsList = [...wx.getStorageSync('goodsList')]; that.setData({ goodsList: goodsList, amount: wx.getStorageSync('amount') }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, submitOrder(){ let that = this, goodsList = that.data.goodsList; //生成订单 goodsList.forEach(res=>{ res['userId'] = app.globalData.user_id, //'oovpNwjlsY6xx8ceCebFa1dOLd9E', res['adress'] = '虹漕路88号', res['area'] = '闵行区', res['city'] = '上海市', res['province'] = '上海市', res['consignee'] = '阿哥子', res['phone'] = '18888888888' }); // let params = { // userId: 'oovpNwjlsY6xx8ceCebFa1dOLd9E', //app.globalData.user_id, // adress: '',// string 街道 // area: '闵行区',// string 区 // city: '上海市',// string 市 // province: '上海市',// string 省 // consignee: '王勇',// string 收件人 // phone: '15055166539',// string 收件人电话 // shopCarList: [...that.data.goodsList] // } wx.request({ url: host + '/createNewOrderCustomer', method:'post', // header: { // 'content-type': 'application/x-www-form-urlencoded' // }, data: { shopCarList:goodsList }, success(res){ console.log(res) } }) }, addressBtn(){ wx.navigateTo({ url: '/customized/pages/address/address', }) } })