123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- 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
- });
- }
- })
|