import { $wuxSelect } from '../../dist/index'; let app = getApp() Page({ /** * 页面的初始数据 */ data: { goodsList:[], isNeedLogistics: 1, curAddressData:false, yunPrice: 0, allGoodsAndYunPrice:0, name:'', tel:'', zw:'', remark:'', isPickerRender: false, isPickerShow: false, startTime: "2020-07-25 08:00", endTime: "2020-07-25 08:00", pickerConfig: { endDate: true, column: "second", dateLimit: true, initStartTime: "2020-07-25 08:00", initEndTime: "2022-12-01 12:00", limitStartTime: "2015-05-06 12:00", limitEndTime: "2055-05-06 12:00" } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.processInfo(); this.setData({ name:app.globalData.name, tel:app.globalData.tel }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that = this wx.getStorage({ key:'shopCarInfo', success: function(res){ //console.log(res.data) let goodsList = res.data.shoplist let ActiveGoods = goodsList.filter(function(item){ return item.active == true }) that.setData({ goodsList: ActiveGoods }) console.log(" 444 "); } }) }, createOrder(e){ let uid = app.globalData.openid; if (uid == '') { wx.redirectTo({ url: '../../pages/login/login' }) return; } let that = this let tprice = that.data.allGoodsAndYunPrice //console.log(loginToken) let remark = e.detail.value.remark let name = e.detail.value.name let tel = e.detail.value.tel let zuowei = app.globalData.zw; if (name == "") { wx.showModal({ title: '提示', content: '请填写联系人', showCancel: false }) return } if (tel == "") { wx.showModal({ title: '提示', content: '请填写电话', showCancel: false }) return } let openid = app.globalData.openid; let pastData = { openid: openid, goodsJsonStr: that.data.goodsJsonStr, remark: remark, name:name, tel:tel, tprice: tprice } wx.request({ url: app.data.resturl + '/submitorder.action', method:'post', header:{ 'content-type': 'application/x-www-form-urlencoded' }, data: pastData, success:function(res){ //清除订单 wx.getStorage({ key: 'shopCarInfo', success: function(res) { let newShopCar = {} let newList = [] let list = res.data.shoplist let num = 0 for (let i = 0; i < list.length;i++){ if (!list[i].active){ newList.push(list[i]) num++ } } newShopCar.shoplist = newList newShopCar.shopNum = num wx.setStorage({ key: 'shopCarInfo', data:newShopCar }) // console.log(newShopCar) }, }) let code = res.data; if(code=='yes'){ wx.reLaunch({ url: "/pages/order-list/index" }) }else{ wx.showModal({ title: '提示', content: '剩余不足', showCancel: false }) } } }) }, processInfo(){ let that = this var scar = wx.getStorageSync('shopCarInfo'); let goodList = scar.shoplist; console.log(" ==== "); let isNeedLogistics = 0 let allGoodsPrice =0 let goodsJsonStr = '[' for (let i = 0; i < goodList.length;i++) { let carShopBean = goodList[i] if (carShopBean.logistics){ isNeedLogistics = 1 } allGoodsPrice += carShopBean.price * carShopBean.number let goodsJsonStrTmp = '' if(i>0){ goodsJsonStrTmp =',' } goodsJsonStrTmp += `{"goodsId":${carShopBean.goodsId},"goodsQuantity":${carShopBean.number}}` goodsJsonStr += goodsJsonStrTmp } goodsJsonStr+=']' console.log(allGoodsPrice) that.setData({ allGoodsAndYunPrice: allGoodsPrice, goodsJsonStr: goodsJsonStr, name:app.globalData.uinfo.name, tel: app.globalData.uinfo.tel }) console.log(goodsJsonStr) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, pickerShow: function() { this.setData({ isPickerShow: true, isPickerRender: true, chartHide: true }); }, pickerHide: function() { this.setData({ isPickerShow: false, chartHide: false }); }, bindPickerChange: function(e) { console.log("picker发送选择改变,携带值为", e.detail.value); console.log(this.data.sensorList); this.getData(this.data.sensorList[e.detail.value].id); // let startDate = util.formatTime(new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 7)); // let endDate = util.formatTime(new Date()); this.setData({ index: e.detail.value, sensorId: this.data.sensorList[e.detail.value].id // startDate, // endDate }); }, setPickerTime: function(val) { console.log(val); let data = val.detail; let index=data.startTime.indexOf(":"); let start=data.startTime.substring(index-13,index+3); let id=data.startTime.substring(index-2,index); var hh=''; hh=parseInt(id); hh++; var h=hh.toString(); h=h.concat(':00'); this.setData({ startTime: start, endTime: h }); } })