// pages/mall/dxkOrder/dxkOrder.js var app = getApp(); var WxParse = require('../../../lib/wxParse/wxParse.js'); var util = require('../../../utils/util.js'); var mall = require('../../../api/mall.js'); var user = require('../../../utils/user.js'); Page({ /** * 页面的初始数据 */ data: { skuText:"39元语音版:2500分钟语音+40GB通用流量+30GB定向流量", region: ['上海市', '上海市', '浦东新区'], customItem: '全部', showModal: false, phoneList:['13873344047','13873344048','13873344049','13873344168','13873344169','13873344100','13873344120','13873344121','13873344122','13873344123'], tempPhone:"", phone:"", isSelectedIndex:'', isPhone:false, currentSkuId:'', workerInfo:{}, isChecked:false, installedAddress:"", contactMobile:"", goodId:"", isSelect:true }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options) this.setData({ currentSkuId: options.currentSkuId, goodId: options.goodId }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getDetailInfo() }, getDetailInfo(){ let that=this; wx.showLoading({ title: '加载中', }); util.request(mall.getDetailInfo, { skuId: that.data.currentSkuId }).then(function (res) { wx.hideLoading(); if (res.errno == 0) { that.setData({ skuText: res.data.wmsSkuProperty.propertyValue, workerInfo: res.data.workerSupplier, }); } else if (res.errno == 501) { wx.redirectTo({ url: "/pages/auth/login/login" }); } else { wx.showToast({ title: res.errmsg, duration: 5000 }) } }); }, selectNumber:function(e){ let that=this; let params={ skuId:that.data.currentSkuId } wx.showLoading({ title: '加载中', }); util.request(mall.selectNumber,params,'post').then(function (res) { wx.hideLoading(); if (res.errno == 0) { that.setData({ phoneList: res.data }); } else if (res.errno == 501) { wx.redirectTo({ url: "/pages/auth/login/login" }); } else { wx.showToast({ title: res.errmsg, duration: 5000 }) } }); this.setData({ showModal:true }) }, bindRegionChange: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ region: e.detail.value }) }, hideModal:function(){ this.setData({ showModal:false }) }, selectdNumber(e){ let index=e.currentTarget.dataset.index this.setData({ isSelectedIndex:e.currentTarget.dataset.index, tempPhone: e.currentTarget.dataset.num }) }, selectedPhone(e){ this.setData({ phone: this.data.tempPhone, showModal: false, isPhone: true }) }, checkChange(e){ console.log(e) this.setData({ isChecked: e.detail, }); }, checkboxChange(e) { if(e.detail.value=="true"){ this.setData({ isChecked : true, isSelect:false }) }else{ this.setData({ isChecked : false, isSelect:true }) } }, checkProBtn() { wx.navigateTo({ url: '/pages/mall/dxkOrderXy/dxkOrderXy' }) }, inputAddress(e){ this.setData({ installedAddress : e.detail.value }) }, inputPhone(e){ this.setData({ contactMobile : e.detail.value }) }, saveOrder(){ if(this.data.phone==""){ util.showErrorToast('请选择手机号!'); return false; } if(this.data.region[0]=="全部" || this.data.region[1]=="全部" || this.data.region[2]=="全部"){ util.showErrorToast('请选择正确的省市区!'); return false; } if(this.data.installedAddress==""){ util.showErrorToast('请输入详细地址!'); return false; } if(this.data.contactMobile==""){ util.showErrorToast('请输入联系手机号!'); return false; } if(!this.data.isChecked){ util.showErrorToast('请阅读并同意入网协议!'); return false; } let that=this; wx.showLoading({ title: '加载中', }); let params={ name: that.data.workerInfo.workerName, idCard: that.data.workerInfo.workerIdcard, workerNo: that.data.workerInfo.workerNo, contactMobile: that.data.contactMobile, province: that.data.region[0], city: that.data.region[1], county: that.data.region[2], installedAddress: that.data.installedAddress, number:that.data.phone.replaceAll("-",""), skuId: that.data.currentSkuId, goodId: that.data.goodId } util.request(mall.saveOrder,params,'post').then(function (res) { wx.hideLoading(); if (res.errno == 0) { wx.showToast({ title: "领取成功", duration: 2000 }) wx.redirectTo({ url: "/pages/mall/order/order" }); } else if (res.errno == 501) { wx.redirectTo({ url: "/pages/auth/login/login" }); } else { wx.showToast({ title: res.errmsg, duration: 5000 }) } }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })