|
@@ -6,6 +6,12 @@ var app = getApp();
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
+ addressList:[],
|
|
|
+ address:{
|
|
|
+ detail:'',
|
|
|
+ name:'',
|
|
|
+ tel:''
|
|
|
+ },
|
|
|
shopAddress:'',//门店地址
|
|
|
buyNumber:'',
|
|
|
memberDiscount: '',
|
|
@@ -114,18 +120,20 @@ Page({
|
|
|
// userCouponId: that.data.userCouponId,
|
|
|
// grouponRulesId: that.data.grouponRulesId,
|
|
|
// shareId: that.data.shareId,
|
|
|
- },'POST').then(function (res) {
|
|
|
+ },'POST').then(res=> {
|
|
|
|
|
|
wx.hideLoading();
|
|
|
console.log(res);
|
|
|
- if (res.errno === 0) {
|
|
|
+ if (res.errno == 0) {
|
|
|
+
|
|
|
that.setData({
|
|
|
// isMember: res.data.isMember,
|
|
|
// memberDiscount: res.data.memberDiscount,
|
|
|
checkedGoodsList: res.data.skus,
|
|
|
shopAddress:res.data.address,
|
|
|
buyNumber:res.data.buyNumber,
|
|
|
- actualPrice: res.data.price,
|
|
|
+ actualPrice: res.data.price,
|
|
|
+ addressId:res.data.addressId
|
|
|
// checkedAddress: res.data.checkedAddress,
|
|
|
// availableCouponLength: res.data.availableCouponLength,
|
|
|
// couponPrice: res.data.couponPrice,
|
|
@@ -138,7 +146,10 @@ Page({
|
|
|
// userCouponId: res.data.userCouponId,
|
|
|
// grouponRulesId: res.data.grouponRulesId,
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
+ if (res.data.addressId) {
|
|
|
+ this.getAddressList();
|
|
|
+ }
|
|
|
|
|
|
// that.LimitCanAppointmentDate();
|
|
|
|
|
@@ -425,8 +436,31 @@ Page({
|
|
|
},
|
|
|
|
|
|
orderPay() {
|
|
|
+ if(this.data.addressId==null||this.data.addressId==''){
|
|
|
+ if(this.data.address.detail==''){
|
|
|
+ util.showErrorToast('请输入收货地址');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(this.data.address.name==''){
|
|
|
+ util.showErrorToast('请输入联系人');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(this.data.address.tel==''){
|
|
|
+ util.showErrorToast('请输入联系电话');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let reg=/^1\d{10}$/;
|
|
|
+ if(!reg.test(this.data.address.tel)){
|
|
|
+ util.showErrorToast('电话号码格式不正确');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
var orderInfo = {
|
|
|
- cartId: ['this.data.cartId'],
|
|
|
+ cartId: [this.data.cartId],
|
|
|
+ addressId:this.data.addressId,
|
|
|
+ receiverAddress:this.data.address.detail,
|
|
|
+ receiverName:this.data.address.name,
|
|
|
+ receiverPhone:this.data.address.tel
|
|
|
|
|
|
};
|
|
|
|
|
@@ -1152,7 +1186,36 @@ Page({
|
|
|
wx.navigateTo({
|
|
|
url: "/pages/member/buyMember/buyMember"
|
|
|
});
|
|
|
- },
|
|
|
+ },
|
|
|
+ addressConfirm(e) {
|
|
|
+ let address = e.currentTarget.dataset.address;
|
|
|
+ this.setData({
|
|
|
+ checkedAddress: address,
|
|
|
+ addressShow: false
|
|
|
+ });
|
|
|
+},
|
|
|
+getAddressList() {
|
|
|
+ util.request(mall.AddressList).then((res) => {
|
|
|
+ if (res.errno === 0) {
|
|
|
+ this.setData({
|
|
|
+ addressList: res.data.list
|
|
|
+ });
|
|
|
+ let current = this.data.addressList.filter((item) => {
|
|
|
+ return item.id == this.data.addressId;
|
|
|
+ });
|
|
|
+ if (current.length > 0) {
|
|
|
+ this.setData({
|
|
|
+ checkedAddress: current[0]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+},
|
|
|
+addressSelect() {
|
|
|
+ this.setData({
|
|
|
+ addressShow: true
|
|
|
+ });
|
|
|
+},
|
|
|
|
|
|
|
|
|
|