order.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. let app = getApp();
  2. let host = app.globalData.servsers; // 请求的url
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. goodsList:[],
  9. host: app.globalData.servsers,
  10. amount:''
  11. },
  12. /**
  13. * 生命周期函数--监听页面显示
  14. */
  15. onShow: function () {
  16. let goodsList=[],that=this;
  17. goodsList = [...wx.getStorageSync('goodsList')];
  18. that.setData({
  19. goodsList: goodsList,
  20. amount: wx.getStorageSync('amount')
  21. })
  22. },
  23. /**
  24. * 生命周期函数--监听页面隐藏
  25. */
  26. onHide: function () {
  27. },
  28. /**
  29. * 生命周期函数--监听页面卸载
  30. */
  31. onUnload: function () {
  32. },
  33. /**
  34. * 页面相关事件处理函数--监听用户下拉动作
  35. */
  36. onPullDownRefresh: function () {
  37. },
  38. /**
  39. * 页面上拉触底事件的处理函数
  40. */
  41. onReachBottom: function () {
  42. },
  43. /**
  44. * 用户点击右上角分享
  45. */
  46. onShareAppMessage: function () {
  47. },
  48. submitOrder(){
  49. let that = this, goodsList = that.data.goodsList;
  50. //生成订单
  51. goodsList.forEach(res=>{
  52. res['userId'] = app.globalData.user_id, //'oovpNwjlsY6xx8ceCebFa1dOLd9E',
  53. res['adress'] = '虹漕路88号',
  54. res['area'] = '闵行区',
  55. res['city'] = '上海市',
  56. res['province'] = '上海市',
  57. res['consignee'] = '阿哥子',
  58. res['phone'] = '18888888888'
  59. });
  60. // let params = {
  61. // userId: 'oovpNwjlsY6xx8ceCebFa1dOLd9E', //app.globalData.user_id,
  62. // adress: '',// string 街道
  63. // area: '闵行区',// string 区
  64. // city: '上海市',// string 市
  65. // province: '上海市',// string 省
  66. // consignee: '王勇',// string 收件人
  67. // phone: '15055166539',// string 收件人电话
  68. // shopCarList: [...that.data.goodsList]
  69. // }
  70. wx.request({
  71. url: host + '/createNewOrderCustomer',
  72. method:'post',
  73. // header: {
  74. // 'content-type': 'application/x-www-form-urlencoded'
  75. // },
  76. data: {
  77. shopCarList:goodsList
  78. },
  79. success(res){
  80. console.log(res)
  81. }
  82. })
  83. }
  84. })