标签:method sync javascrip use eject name content glob each
//结算提交 checkOut : function(){ var price = this.data.sum; var user = wx.getStorageSync(‘userInfo‘); if (!user){ wx.showModel({ title:‘提示‘, content:‘请登录‘, success : function(){ }, }) } let goods_id=0; var shop = this.data.shoppingCartInfo; wx.request({ url: `${app.globalData.API_URL}`+‘/order‘, data:{ goods_price : this.data.sum, user_id : user.mid }, method: ‘POST‘, header :{ ‘content-type‘:‘application/json‘ }, success : function(res){ var order_id = res.data; //引入异步 var promises = new promise(function(resolve,reject){ resolve(shop); }) promises.then(function(value){
//循环遍历 value.forEach(function(value){ console.log(value,‘foreach‘); wx.request({ url: `${app.globalData.API_URL}/ordergoods`, data: { order_id : order_id, goods_id : value.goodId, goods_name : value.goodName, goods_price : value.goodPrice, goods_num : value.goodSum, spec_key : value.goodImg }, method: ‘POST‘, success: function(res){ console.log(‘成功‘); }, fail: function(res) { }, }); }); }).catch(function(error){ console.error(error); }); } }) }
标签:method sync javascrip use eject name content glob each
原文地址:http://www.cnblogs.com/pangxiaox/p/7802856.html