Skip to content

Commit

Permalink
微信地址接口的使用
Browse files Browse the repository at this point in the history
  • Loading branch information
316824590 committed Mar 20, 2018
1 parent 0bf92c5 commit ccccbf0
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 33 deletions.
1 change: 1 addition & 0 deletions pages/commodity-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Page({
});
}
})
console.log("e.commodityId:" + e.commodityId);
wx.request({
url: app.globalData.serverPath + '/wxapplet/commodity/' + e.commodityId,
success: function (res) {
Expand Down
12 changes: 10 additions & 2 deletions pages/member/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Page({
balance: 0,
freeze: 0,
score: 0,
score_sign_continuous: 0
score_sign_continuous: 0,
},
onLoad() {

Expand Down Expand Up @@ -183,7 +183,9 @@ Page({
url: "/pages/withdraw/index"
})
},
//查看收货地址
selectAddress:function(){
var that = this;
console.log("ddd")
wx.chooseAddress({
success: function (res) {
Expand All @@ -192,6 +194,12 @@ Page({
fail: function (res) { },
complete: function (res) { },
})
},
//查看优惠券
selectCoupons:function(){
console.log("优惠券");
wx.openCard({
cardList: [],
})
}

})
5 changes: 3 additions & 2 deletions pages/member/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
我的收货地址
<!-- <navigator url="/pages/address-select/index" hover-class="navigator-hover">我的收货地址</navigator> -->
</view>
<view class="my-item">
<navigator url="/pages/mycoupons/index" hover-class="navigator-hover">我的优惠券</navigator>
<view class="my-item" bindtap="selectCoupons">
我的优惠券
<!-- <navigator url="/pages/mycoupons/index" hover-class="navigator-hover">我的优惠券</navigator> -->
</view>
<view wx:if="{{!userMobile}}" class="my-item" style="border:none;padding-right:150rpx;width:auto;">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">绑定手机号码</button>
Expand Down
123 changes: 99 additions & 24 deletions pages/pay-order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Page({
goodsJsonStr: "",
orderType: "", //订单类型,购物车下单或立即支付下单,默认是购物车,

curAddressData:{},

hasNoCoupons: true,
coupons: [],
youhuijine: 0, //优惠券金额
Expand Down Expand Up @@ -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
}
Expand All @@ -53,8 +55,7 @@ Page({
return entity.active;
});
}
}
console.log(shopList);
};
that.setData({
goodsList: shopList,
});
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pages/pay-order/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<view class="title" bindtap="addAddress">新增收货地址</view>
</view>
<view class="show-address" hidden="{{!curAddressData}}" bindtap="selectAddress">
<view class="name-tel">{{curAddressData.consignee}} {{curAddressData.mobile}}</view>
<view class="addr-text">{{curAddressData.region}} {{curAddressData.site}}</view>
<view class="name-tel">{{curAddressData.nickname}} {{curAddressData.mobile}}</view>
<view class="addr-text">{{curAddressData.provinceName}} {{curAddressData.cityName}} {{curAddressData.diatrictName}} {{curAddressData.site}}</view>
</view>
</view>
<view class="goods-list">
Expand Down
9 changes: 6 additions & 3 deletions pages/shop-cart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ccccbf0

Please sign in to comment.