You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.6 KiB

2 years ago
var app = getApp();
var WXAPI = require('../../utils/server.js');
2 years ago
var t = 0;
var moveY = 200;
var index = [0, 0, 0];
Page({
data: {
region: ['请选择','',''],
2 years ago
value: [0, 0, 0],
cartId: 0,
check: false,
2 years ago
},
bindRegionChange: function (e) {
2 years ago
this.setData({
region: e.detail.value
2 years ago
})
},
// 设置默认地址
switchChange: function (e) {
var that = this;
that.setData({
check: e.detail.value
});
},
2 years ago
/**
* 生命周期函数--监听页面加载
2 years ago
*/
onLoad: function (options) {
2 years ago
},
// 点击保存
SaveAddress: function (e) {
var region = this.data.region
console.log(e.detail.value)
2 years ago
if (e.detail.value.user_name.length == 0) {
wx.showToast({
title: '联系人不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else if (e.detail.value.mobile.length == 0) {
wx.showToast({
title: '电话不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else if (region[0] == '请选择') {
2 years ago
wx.showToast({
title: '城市不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else {
var cartId = this.data.cartId,
mobile = e.detail.value.mobile;
//预处理验证手机号码
if (mobile.match(/^\d{11}$/)) {
WXAPI.saveAddress({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
user_name: e.detail.value.user_name,
mobile: e.detail.value.mobile,
place: region[0]+'-'+region[1]+'-'+region[2],
is_default: this.data.check==true?1:0,
address: e.detail.value.address,
}).then(res => {
2 years ago
if (res.code == 200) {
var data = res.data;
app.d.islogin = true;
//成功后返回上一页面
wx.navigateBack({
delta: 1
2 years ago
});
} else {
wx.showToast({
title: res.message,
icon: 'loading',
duration: 1500
});
2 years ago
}
});
2 years ago
} else {
wx.showToast({
title: '手机号码格式错误,请重新输入!',
icon: 'none',
duration: 1000
});
}
}
}
})
//动画事件
function animationEvents(that, moveY, show) {
that.animation = wx.createAnimation({
transformOrigin: "50% 50%",
duration: 400,
timingFunction: "linear",
delay: 0
})
that.animation.translateY(moveY + 'vh').step()
that.setData({
animation: that.animation.export(),
show: show
})
}