let app = getApp(); let host = app.globalData.servsers; // 请求的url Page({ /** * 页面的初始数据 */ data: { goodsList:[], host: app.globalData.servsers, amount:'', address:{},// 地址为空 }, onLoad(){ let that =this; wx.request({ url: host + '/adressapi/getdefaustAdress', method:'get', data:{ user_id: app.globalData.user_id }, header: { 'content-type': 'application/x-www-form-urlencoded' }, success(res){ console.log(res,"获取默认地址") that.setData({ address: res.data }) } }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let goodsList=[],that=this; let address = wx.getStorageSync('accountAddress'); console.log(address,"addressaddress") if (address){ that.setData({ address: address }) } 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, address = that.data.address; //生成订单 goodsList.forEach(res=>{ res['userId'] = app.globalData.user_id; //'oovpNwjlsY6xx8ceCebFa1dOLd9E', res['adress'] = address.adress; res['area'] = address.area; res['city'] = address.city; res['province'] = address.province; res['consignee'] = address.consignee; res['phone'] = address.phone; delete res.imgArray }); wx.request({ url: host + '/createNewOrderCustomer', method:'post', data: { shopCarList:JSON.stringify(goodsList) }, success(res){ console.log(res) } }) }, addressBtn(){ wx.navigateTo({ url: '/customized/pages/address/address', }) } })