123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- var app = getApp();
- Page({
- data:{
- checkedGoodsList: [],
- checkedAddress: {},
- checkedCoupon: [],
- couponList: [],
- goodsTotalPrice: 0.00,
- freightPrice: 0.00,
- couponPrice: 0.00,
- orderTotalPrice: 0.00,
- actualPrice: 0.00,
- addressId: 0,
- couponId: 0
- },
- onLoad:function(options){
-
- try {
- var addressId = wx.getStorageSync('addressId');
- if (addressId) {
- this.setData({
- 'addressId': addressId
- });
- }
- var couponId = wx.getStorageSync('couponId');
- if (couponId) {
- this.setData({
- 'couponId': couponId
- });
- }
- } catch (e) {
-
- }
-
- },
- getCheckoutInfo: function () {
- let that = this;
- util.request(api.CartCheckout, { addressId: that.data.addressId, couponId: that.data.couponId}).then(function (res) {
- if (res.errno === 0) {
- console.log(res.data);
- that.setData({
- checkedGoodsList: res.data.checkedGoodsList,
- checkedAddress: res.data.checkedAddress,
- actualPrice: res.data.actualPrice,
- checkedCoupon: res.data.checkedCoupon,
- couponList: res.data.couponList,
- couponPrice: res.data.couponPrice,
- freightPrice: res.data.freightPrice,
- goodsTotalPrice: res.data.goodsTotalPrice,
- orderTotalPrice: res.data.orderTotalPrice
- });
- }
- wx.hideLoading();
- });
- },
- selectAddress(){
- wx.navigateTo({
- url: '/pages/shopping/address/address',
- })
- },
- addAddress() {
- wx.navigateTo({
- url: '/pages/shopping/addressAdd/addressAdd',
- })
- },
- onReady:function(){
-
-
- },
- onShow:function(){
-
- wx.showLoading({
- title: '加载中...',
- })
- this.getCheckoutInfo();
-
- },
- onHide:function(){
-
-
- },
- onUnload:function(){
-
-
- },
- submitOrder: function(){
- if (this.data.addressId <=0) {
- util.showErrorToast('请选择收货地址');
- return false;
- }
- let that = this;
- util.request(api.OrderSubmit, { addressId: that.data.addressId, couponId: that.data.couponId }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.navigateTo({
- url: '/pages/pay/pay'
- })
-
- } else {
- util.showErrorToast(res.data.errmsg);
- }
- });
-
- }
- })
|