|
|
|
var app = getApp();
|
|
|
|
var WXAPI = require('../../utils/server.js');
|
|
|
|
var t = 0;
|
|
|
|
var show = false;
|
|
|
|
var moveY = 200;
|
|
|
|
var index = [0, 0, 0];
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
region: ['请选择','',''],
|
|
|
|
value: [0, 0, 0],
|
|
|
|
address: '',
|
|
|
|
check: false,
|
|
|
|
},
|
|
|
|
// 设置默认地址
|
|
|
|
switchChange: function (e) {
|
|
|
|
var that = this;
|
|
|
|
that.setData({
|
|
|
|
check: e.detail.value
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 下拉刷新
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
|
|
|
|
|
|
this.AddressManagement();
|
|
|
|
wx.hideNavigationBarLoading() //完成停止加载
|
|
|
|
wx.stopPullDownRefresh() //停止下拉刷新
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
console.log(options)
|
|
|
|
// wx.setNavigationBarColor({
|
|
|
|
// frontColor: app.d.frontColor,
|
|
|
|
// backgroundColor: app.d.bgcolor, //页面标题为路由参数
|
|
|
|
// animation: {
|
|
|
|
// duration: 400,
|
|
|
|
// timingFunc: 'easeIn'
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
var region = []
|
|
|
|
region.push(options.sheng)
|
|
|
|
region.push(options.city)
|
|
|
|
region.push(options.quyu)
|
|
|
|
this.setData({
|
|
|
|
address: options,
|
|
|
|
region: region,
|
|
|
|
check: options.is_default==0?false:true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 修改地址
|
|
|
|
*/
|
|
|
|
// 点击保存
|
|
|
|
SaveAddress: function (e) {
|
|
|
|
var region = this.data.region
|
|
|
|
var that = this;
|
|
|
|
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] == '请选择') {
|
|
|
|
wx.showToast({
|
|
|
|
title: '城市不得为空!',
|
|
|
|
icon: 'loading',
|
|
|
|
duration: 1500
|
|
|
|
})
|
|
|
|
wx.hideToast()
|
|
|
|
} else {
|
|
|
|
var that = this;
|
|
|
|
WXAPI.addressUpAdds({
|
|
|
|
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: that.data.check==true?1:0,
|
|
|
|
address: e.detail.value.address,
|
|
|
|
addr_id: that.data.address.addr_id,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.code == 200) {
|
|
|
|
wx.navigateBack()
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.message,
|
|
|
|
icon: 'loading',
|
|
|
|
duration: 1500
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
//动画事件
|
|
|
|
function animationEvents(that, moveY, show) {
|
|
|
|
that.animation = wx.createAnimation({
|
|
|
|
transformOrigin: "50% 50%",
|
|
|
|
duration: 400,
|
|
|
|
timingFunction: "ease",
|
|
|
|
delay: 0
|
|
|
|
})
|
|
|
|
that.animation.translateY(moveY + 'vh').step()
|
|
|
|
that.setData({
|
|
|
|
animation: that.animation.export(),
|
|
|
|
show: show
|
|
|
|
})
|
|
|
|
}
|