| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 | 
							- // pages/submit-order/submit-order.js
 
- var http = require("../../../utils/http.js");
 
- Page({
 
-   /**
 
-    * 页面的初始数据
 
-    */
 
-   data: {
 
-     popupShow: false,
 
-     couponSts: 1,
 
-     couponList: [],
 
-     // 订单入口 0购物车 1立即购买
 
-     orderEntry: "0",
 
-     userAddr: null,
 
-     orderItems: [],
 
-     shopCartOrders: [], //所有店铺的数据
 
-     productItemDto: [], //商品信息
 
-     coupons: {
 
-       totalLength: 0,
 
-       canUseCoupons: [],
 
-       noCanUseCoupons: []
 
-     },
 
-     actualTotal: 0,
 
-     total: 0,
 
-     totalCount: 0,
 
-     transfee: 0,
 
-     reduceAmount: 0,
 
-     couponIds: [],
 
-     orderReduce: 0,
 
-     platformCoupons: [], //整个订单可以使用的优惠券列表
 
-     scorePrice: 0,
 
-     remarks: '', //留言
 
-     isPurePoints: false, // 是否纯积分商品
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面加载
 
-    */
 
-   onLoad: function(options) {
 
-     this.setData({
 
-       orderEntry: options.orderEntry,
 
-     });
 
-     this.loadOrderData()
 
-   },
 
-   //加载订单数据
 
-   loadOrderData: function() {
 
-     var addrId = 0;
 
-     if (this.data.userAddr != null) {
 
-       addrId = this.data.userAddr.addrId;
 
-     }
 
-     wx.showLoading({
 
-       mask: true
 
-     });
 
-     console.log(JSON.parse(wx.getStorageSync("orderItem")))
 
-     // console.log(JSON.parse(wx.getStorageSync("basketIds")))
 
-     var params = {
 
-       url: "/p/score/confirm",
 
-       method: "POST",
 
-       data: {
 
-         addrId: addrId,
 
-         orderItem: this.data.orderEntry === "1" ? JSON.parse(wx.getStorageSync("orderItem")) : undefined,
 
-         basketIds: this.data.orderEntry === "0" ? JSON.parse(wx.getStorageSync("basketIds")) : undefined,
 
-         couponIds: this.data.couponIds,
 
-         userChangeCoupon: 1
 
-       },
 
-       callBack: res => {
 
-         wx.hideLoading();
 
-         var shopCartOrders = res.shopCartOrders;
 
-         this.setData({
 
-           // shopCartOrders: shopCartOrders, //每个店铺的购物车信息
 
-           productItemDto: res.productItemDto, //商品信息
 
-           actualTotal: res.actualTotal, //实际总值
 
-           total: res.total, //商品总值
 
-           totalCount: res.totalCount, //商品总数  
 
-           userAddr: res.userAddr, //地址Dto
 
-           // transfee: res.totalTransfee, //总运费
 
-           // orderReduce: res.orderReduce, //订单优惠金额(所有店铺优惠金额和使用积分抵现相加)
 
-           scorePrice: res.productItemDto.scorePrice, //商品所需积分
 
-           // remarks: res.remarks,  //留言
 
-         });
 
-       },
 
-       errCallBack: res => {
 
-         wx.hideLoading();
 
-         this.chooseCouponErrHandle(res)
 
-       }
 
-     };
 
-     http.request(params);
 
-   },
 
-   /**
 
-    * 优惠券选择出错处理方法
 
-    */
 
-   // chooseCouponErrHandle(res) {
 
-   //   // 优惠券不能共用处理方法
 
-   //   if (res.statusCode == 601) {
 
-   //     wx.showToast({
 
-   //       title: res.data,
 
-   //       icon: "none",
 
-   //       duration: 3000,
 
-   //       success: res => {
 
-   //         this.setData({
 
-   //           couponIds: []
 
-   //         })
 
-   //       }
 
-   //     })
 
-   //     setTimeout(() => {
 
-   //       this.loadOrderData();
 
-   //     }, 2500)
 
-   //   }
 
-   // },
 
-   /**
 
-    * 提交订单
 
-    */
 
-   toPay: function() {
 
-     if (!this.data.userAddr) {
 
-       wx.showToast({
 
-         title: '请选择地址',
 
-         icon: "none"
 
-       })
 
-       return;
 
-     }
 
-     this.submitOrder();
 
-   },
 
-   // 提交订单
 
-   submitOrder: function() {
 
-     wx.showLoading({
 
-       mask: true
 
-     });
 
-     // var shopCartOrders = this.data.shopCartOrders;
 
-     // var orderShopParam = [];
 
-     // shopCartOrders.forEach(shopCart => {
 
-     // orderShopParam.push({
 
-     //   remarks: shopCart.remarks,
 
-     //   shopId: shopCart.shopId
 
-     // });
 
-     // })
 
-     var params = {
 
-       url: "/p/score/submit",
 
-       method: "POST",
 
-       data: {
 
-         // orderShopParam: orderShopParam
 
-         remarks: this.data.remarks
 
-       },
 
-       callBack: res => {
 
-         wx.hideLoading();
 
-         if(res.nextPay){
 
-           this.calWeixinPay(res.orderNumbers);
 
-         }else{
 
-           wx.redirectTo({
 
-             url: `/pages/pay-result/pay-result?sts=1&orderNumbers=${res.orderNumbers}&orderType=${this.data.orderType}`,
 
-           })
 
-         }
 
-       }
 
-     };
 
-     http.request(params);
 
-   },
 
-   /**
 
-    * 唤起微信支付
 
-    */
 
-   calWeixinPay: function(orderNumbers) {
 
-     if (this.data.actualTotal == 0) {
 
-       this.setData({
 
-         isPurePoints: true
 
-       })
 
-     }
 
-     wx.showLoading({
 
-       mask: true
 
-     });
 
-     var params = {
 
-       url: "/p/order/pay",
 
-       method: "POST",
 
-       data: {
 
-         payType: 1,
 
-         orderNumbers: orderNumbers
 
-       },
 
-       callBack: res => {
 
-         wx.hideLoading();
 
-         if (this.data.isPurePoints) {
 
-           wx.navigateTo({
 
-             url: '/pages/pay-result/pay-result?sts=1&orderNumbers=' + orderNumbers + "&orderType=" + this.data.orderType,
 
-           })
 
-         } else {
 
-           wx.requestPayment({
 
-             timeStamp: res.timeStamp,
 
-             nonceStr: res.nonceStr,
 
-             package: res.package,
 
-             signType: res.signType,
 
-             paySign: res.paySign,
 
-             success: e => {
 
-               console.log('积分+钱')
 
-               wx.navigateTo({
 
-                 url: '/pages/pay-result/pay-result?sts=1&orderNumbers=' + orderNumbers + "&orderType=" + this.data.orderType,
 
-               })
 
-             },
 
-             fail: err => {
 
-               console.log('积分+钱')
 
-               wx.navigateTo({
 
-                 url: '/pages/pay-result/pay-result?sts=0&orderNumbers=' + orderNumbers + "&orderType=" + this.data.orderType,
 
-               })
 
-             }
 
-           })
 
-         }
 
-       }
 
-     };
 
-     http.request(params);
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面初次渲染完成
 
-    */
 
-   onReady: function() {
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面显示
 
-    */
 
-   onShow: function() {
 
-     var pages = getCurrentPages();
 
-     var currPage = pages[pages.length - 1];
 
-     if (currPage.data.selAddress == "yes") {
 
-       this.setData({ //将携带的参数赋值
 
-         userAddr: currPage.data.item
 
-       });
 
-     }
 
-     //获取订单数据
 
-     this.loadOrderData();
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面隐藏
 
-    */
 
-   onHide: function() {
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面卸载
 
-    */
 
-   onUnload: function() {
 
-   },
 
-   /**
 
-    * 页面相关事件处理函数--监听用户下拉动作
 
-    */
 
-   onPullDownRefresh: function() {
 
-   },
 
-   /**
 
-    * 页面上拉触底事件的处理函数
 
-    */
 
-   onReachBottom: function() {
 
-   },
 
-   /**
 
-    * 用户点击右上角分享
 
-    */
 
-   onShareAppMessage: function() {
 
-   },
 
-   changeCouponSts: function(e) {
 
-     this.setData({
 
-       couponSts: e.currentTarget.dataset.sts
 
-     });
 
-   },
 
-   // 店铺优惠券弹框
 
-   showCouponPopup: function(e) {
 
-     var index = e.currentTarget.dataset.index;
 
-     var shopCartOrders = this.data.shopCartOrders;
 
-     this.setData({
 
-       coupons: shopCartOrders[index].showCoupons,
 
-       popupShow: true
 
-     });
 
-   },
 
-   closePopup: function() {
 
-     this.setData({
 
-       popupShow: false
 
-     });
 
-   },
 
-   /**
 
-    * 去地址页面
 
-    */
 
-   toAddrListPage: function() {
 
-     wx.navigateTo({
 
-       url: '/pages/delivery-address/delivery-address?order=0',
 
-     })
 
-   },
 
-   /**
 
-    * 确定选择好的优惠券
 
-    */
 
-   choosedCoupon: function() {
 
-     this.loadOrderData();
 
-     this.setData({
 
-       popupShow: false
 
-     });
 
-   },
 
-   /**- 
 
-    * 优惠券子组件发过来
 
-    */
 
-   checkCoupon: function(e) {
 
-     var ths = this;
 
-     let index = ths.data.couponIds.indexOf(e.detail.couponId);
 
-     if (index === -1) {
 
-       ths.data.couponIds.push(e.detail.couponId)
 
-     } else {
 
-       ths.data.couponIds.splice(index, 1)
 
-     }
 
-   },
 
-   /**
 
-    * 输入备注
 
-    */
 
-   onRemarkIpt: function(e) {
 
-     // var index = e.currentTarget.dataset.index;
 
-     // var shopCartOrders = this.data.shopCartOrders;
 
-     this.setData({
 
-       remarks: e.detail.value
 
-     })
 
-     // this.setData({
 
-     //   shopCartOrders: shopCartOrders
 
-     // });
 
-     console.log(this.data.remarks)
 
-   }
 
- })
 
 
  |