var app = getApp(); var WXAPI = require('../../utils/server.js'); var t = 0; var moveY = 200; var index = [0, 0, 0]; Page({ data: { region: ['请选择','',''], value: [0, 0, 0], cartId: 0, }, bindRegionChange: function (e) { this.setData({ region: e.detail.value }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // wx.setNavigationBarColor({ // frontColor: app.d.frontColor, // backgroundColor: app.d.bgcolor, //页面标题为路由参数 // animation: { // duration: 400, // timingFunc: 'easeIn' // } // }) // this.setData({ // bgcolor: app.d.bgcolor, // cartId: options.cartId // }); }, // 点击保存 SaveAddress: function (e) { var region = this.data.region console.log(e.detail.value) 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 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: 0, address: e.detail.value.address, }).then(res => { if (res.code == 200) { var data = res.data; app.d.islogin = true; //成功后返回上一页面 wx.navigateBack({ delta: 1 }); } else { wx.showToast({ title: res.message, icon: 'loading', duration: 1500 }); } }); } 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 }) }