From ccccbf04b55691306e1ebf54f8a31f6117ed850a Mon Sep 17 00:00:00 2001 From: jixiaohui <316824590@qq.com> Date: Tue, 20 Mar 2018 17:24:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9C=B0=E5=9D=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/commodity-info/index.js | 1 + pages/member/index.js | 12 +++- pages/member/index.wxml | 5 +- pages/pay-order/index.js | 123 +++++++++++++++++++++++++++------- pages/pay-order/index.wxml | 4 +- pages/shop-cart/index.js | 9 ++- 6 files changed, 121 insertions(+), 33 deletions(-) diff --git a/pages/commodity-info/index.js b/pages/commodity-info/index.js index 0daf19f..68d67e2 100644 --- a/pages/commodity-info/index.js +++ b/pages/commodity-info/index.js @@ -46,6 +46,7 @@ Page({ }); } }) + console.log("e.commodityId:" + e.commodityId); wx.request({ url: app.globalData.serverPath + '/wxapplet/commodity/' + e.commodityId, success: function (res) { diff --git a/pages/member/index.js b/pages/member/index.js index bb16863..5ddb49e 100644 --- a/pages/member/index.js +++ b/pages/member/index.js @@ -5,7 +5,7 @@ Page({ balance: 0, freeze: 0, score: 0, - score_sign_continuous: 0 + score_sign_continuous: 0, }, onLoad() { @@ -183,7 +183,9 @@ Page({ url: "/pages/withdraw/index" }) }, + //查看收货地址 selectAddress:function(){ + var that = this; console.log("ddd") wx.chooseAddress({ success: function (res) { @@ -192,6 +194,12 @@ Page({ fail: function (res) { }, complete: function (res) { }, }) + }, + //查看优惠券 + selectCoupons:function(){ + console.log("优惠券"); + wx.openCard({ + cardList: [], + }) } - }) \ No newline at end of file diff --git a/pages/member/index.wxml b/pages/member/index.wxml index f1b332e..1f15cff 100644 --- a/pages/member/index.wxml +++ b/pages/member/index.wxml @@ -26,8 +26,9 @@ 我的收货地址 - - 我的优惠券 + + 我的优惠券 + diff --git a/pages/pay-order/index.js b/pages/pay-order/index.js index deb49ae..25d4c72 100644 --- a/pages/pay-order/index.js +++ b/pages/pay-order/index.js @@ -14,6 +14,8 @@ Page({ goodsJsonStr: "", orderType: "", //订单类型,购物车下单或立即支付下单,默认是购物车, + curAddressData:{}, + hasNoCoupons: true, coupons: [], youhuijine: 0, //优惠券金额 @@ -41,7 +43,7 @@ Page({ //立即购买下单 if ("buyNow" == that.data.orderType) { var buyNowInfoMem = wx.getStorageSync('buyNowInfo'); - console.log("buyNowInfoMem:" + buyNowInfoMem.shopList); + if (buyNowInfoMem && buyNowInfoMem.shopList) { shopList = buyNowInfoMem.shopList } @@ -53,8 +55,7 @@ Page({ return entity.active; }); } - } - console.log(shopList); + }; that.setData({ goodsList: shopList, }); @@ -95,26 +96,16 @@ Page({ }) return; } - postData.provinceId = that.data.curAddressData.provinceId; - postData.cityId = that.data.curAddressData.cityId; - if (that.data.curAddressData.districtId) { - postData.districtId = that.data.curAddressData.districtId; - } - postData.address = that.data.curAddressData.address; - postData.linkMan = that.data.curAddressData.linkMan; - postData.mobile = that.data.curAddressData.mobile; - postData.code = that.data.curAddressData.code; + postData.addressId = that.data.curAddressData.id; } if (that.data.curCoupon) { postData.couponId = that.data.curCoupon.id; } if (!e) { postData.calculate = "true"; - } - - + }; wx.request({ - url: 'https://api.it120.cc/' + app.globalData.subDomain + '/order/create', + url: app.globalData.serverPath + '/order', method: 'POST', header: { 'content-type': 'application/x-www-form-urlencoded' @@ -173,12 +164,12 @@ Page({ initShippingAddress: function () { var that = this; wx.request({ - url: app.globalData.serverPath + '/wxapplet/address/5', + url: app.globalData.serverPath + '/wxapplet/address/2', data: { token: app.globalData.token }, success: (res) => { - console.log(res.data); + if (res.data[0]) { that.setData({ curAddressData: res.data[0] @@ -213,14 +204,98 @@ Page({ }, addAddress: function () { - wx.navigateTo({ - url: "/pages/address-add/index" - }) + var that = this; + console.log("選擇地址") + wx.chooseAddress({ + success: function (res) { + var provinceName = res.provinceName; + var cityName = res.cityName; + var diatrictName = res.countyName; + var address = res.detailInfo; + var mobile = res.telNumber; + var nickname = res.userName; + console.log("res:" + res); + wx.request({ + url: app.globalData.serverPath + '/wxapplet/address', + method: "POST", + header: { + 'content-type': 'application/x-www-form-urlencoded' + }, + data: { + provinceName: provinceName, + cityName: cityName, + diatrictName: diatrictName, + address: address, + mobile: mobile, + nickname: nickname, + }, + dataType: "json", + success: function (res) { + if(res.data.success){ + wx.showModal({ + title: '提示', + content: res.data.msg, + }) + }else{ + wx.showModal({ + title: '提示', + content: res.data.msg, + }) + } + } + }) + } + }) }, selectAddress: function () { - wx.navigateTo({ - url: "/pages/select-address/index" - }) + // wx.navigateTo({ + // url: "/pages/select-address/index" + // }) + var that = this; + console.log("選擇地址") + wx.chooseAddress({ + success: function (res) { + var provinceName = res.provinceName; + var cityName = res.cityName; + var diatrictName = res.countyName; + var address = res.detailInfo; + var mobile = res.telNumber; + var nickname = res.userName; + wx.request({ + url: app.globalData.serverPath + '/wxapplet/address', + method:"POST", + header: { + 'content-type': 'application/x-www-form-urlencoded' + }, + data:{ + provinceName: provinceName, + cityName: cityName, + diatrictName: diatrictName, + address: address, + mobile: mobile, + nickname: nickname, + }, + dataType:"json", + success:function(res){ + console.log("res:" + res.data.success); + + if (res.data.success) { + console.log("res:" + res.data.msg); + wx.showModal({ + title: '提示', + content: res.data.msg, + }) + } else { + wx.showModal({ + title: '提示', + content: res.data.msg, + }) + } + } + }) + } + }) + }, getCoupons: function () { var that = this; diff --git a/pages/pay-order/index.wxml b/pages/pay-order/index.wxml index 8d82c4f..1594ca4 100644 --- a/pages/pay-order/index.wxml +++ b/pages/pay-order/index.wxml @@ -6,8 +6,8 @@ 新增收货地址 diff --git a/pages/shop-cart/index.js b/pages/shop-cart/index.js index 5af4906..b4486a2 100644 --- a/pages/shop-cart/index.js +++ b/pages/shop-cart/index.js @@ -56,9 +56,12 @@ Page({ this.setGoodsList(this.getSaveHide(), this.totalPrice(), this.allSelect(), this.noSelect(), shopList); }, toIndexPage: function () { - wx.switchTab({ - url: "/pages/index/index" - }); + wx.navigateTo({ + url: '/pages/commodity-info/index?commodityId=39', + }) + // wx.switchTab({ + // url: "/pages/commodity-info/index?commodityId=5" + // }); }, touchS: function (e) {