小程序选择商品页面

2023-12-03  本文已影响0人  糖醋里脊120625
//存放右侧分类的高度累加数组
import { requestMarketInfo, basicBusinessInfo, goodsNoTokenGroup } from '../../http/goodsApi'
import { centToYuan } from '../../unit/priceUtil'
import { getLocalUserInfo } from '../../unit/userInfo'
var dayjs = require('dayjs')
const app = getApp()

function FindPrice(item){
  // centToYuan(each.latestSaleUnitPrice),
  if(item.agreementUnitPrice){
    return  centToYuan(item.agreementUnitPrice);
  }else if(item.customerUnitPrice){
    return  centToYuan(item.customerUnitPrice);
  }else{
    return  centToYuan(item.latestSaleUnitPrice);
  }

}
// https://www.bookstack.cn/read/vant-3.4.7-zh/8bd11acebe45f23c.md


Page({

  /**
   * 页面的初始数据
   */
  data: {
    goodsList: [],
    curIndex: 0,
    pageData: 1,
    hasLoadData: true,
    itemCateData: {},
    mainActiveIndex: 0,


    basicInfo: {},
    SeledGoods: [],
    GoodsNum: "",
    showPopup: false,


    heightArr: [],
    distance: 0,
    active: 0,
    selectId: "item0",
    MerchantInfo: {},
    postBusiness: {},
    SendTimeVal: dayjs(new Date().getTime()).format('YYYY-MM-DD'),
    ProductList: [],
    HasSelectedList: [],

    pageTotal: 0,
    pageSize: 10,
    pageIndex: 1,
    TotalDataList: [],
    detailID: "adc8f0fe062e49daa9957deec14d4eb5",
    editChoose: false,


    statusBarHeight: 0,
    navInfo: {},
    heightScroll: 0,
    showMarket: true,
    MarketID: "",

    hasLogin:"",
    hidePhone:"",

    leftClassifyList:[],
    SearchValue:"",


  },

  getArea(){
    
    wx.navigateTo({ url: `/pages/companyLocation/companyLocation?str=`+this.data.postBusiness.eiAddress});
  },
  setScrollHeight() {
    var that = this;
    let WHeight = "";
    let NHeight = "";
    wx.getSystemInfo({//微信api,可以获取页面的信息
      success: (result) => {
        WHeight = result.windowHeight
      },
      fail: (res) => { },
      complete: (res) => { },
    })
    // 166?
    wx.createSelectorQuery().select('#nameID').boundingClientRect(function (rect) {
      let setHeight = WHeight - rect.height - 210;
     

      that.setData({
        heightScroll: setHeight,
      })
      
    }).exec()


  },
  backFun() {
    wx.navigateBack({ delta: 1 });
  },

  callPhone() {
    if(this.data.hasLogin){
      wx.makePhoneCall({
        phoneNumber: this.data.postBusiness.eiAdminMobile
      })
    }else{
      wx.navigateTo({ url: `/pages/login/login`});
    }
  },

  // 选择左侧标签锚点定位
  activeNav(e) {
    var index = e.currentTarget.dataset.index
    this.setData({
      active: index,
      selectId: "item" + index
    })
  },

  //计算右侧每个锚点的高度
  selectHeight() {

    var list = []
    var height = 0;
    const query = wx.createSelectorQuery();
    query.selectAll('.subtitle').boundingClientRect()
    query.exec((res) => {
      res[0].forEach((item) => {
        height += item.height;
        list.push(height)
      })

      this.data.heightArr = list
    })
  },

  //监听scroll-view的滚动事件
  watchScroll(e) {

    let scrollTop = e.detail.scrollTop; //获取距离顶部的距离
    let active = this.data.active;
    if (scrollTop >= this.data.distance) {
      if (active + 1 < this.data.heightArr.length && scrollTop >= this.data.heightArr[active]) {
        this.setData({
          active: active + 1
        })
      }
    } else {
      if (active - 1 >= 0 && scrollTop < this.data.heightArr[active - 1]) {
        this.setData({
          active: active - 1
        })
      }
    }
    this.data.distance = scrollTop;
  },

  getNavigationInfo() {
    var that = this;
    wx.getSystemInfo({
      success(res) {
        const menuButton = wx.getMenuButtonBoundingClientRect();
        that.setData({
          navInfo: {
            top: menuButton.top,
            right: res.windowWidth - menuButton.right,
            width: menuButton.width + 18,
            height: menuButton.height,
            bottom: menuButton.top - res.statusBarHeight
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */

  // aaa
  onLoad: function (options) {
    const that =this;
   

    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#FE6526',
      animation: {
        duration: 400,
        timingFunc: 'easeIn'
      }
    })


    this.getNavigationInfo()
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          statusBarHeight: res.statusBarHeight,
        })
      },
    })



    if (JSON.stringify(options) == "{}") {
      return

    } else {
      let optionData = JSON.parse(decodeURIComponent(options.detInfo));
      console.log(optionData)
      if (optionData.editChose) {
        console.log("编辑")
        this.setData({
          editChoose: true,
          SendTimeVal: optionData.basicInfo.SendTimeVal,
          MerchantInfo: optionData,
          basicInfo: optionData.basicInfo,
          HasSelectedList: optionData.SeledGoods.map((item) => {
            return {
              piImageUrl: item.productImage,
              piId: item.productId,
              piProductName: item.productName,
              ProductDes: item.ProductDes,
              SelNum: item.productNum,
              showAddOrSub: true
            };
          }),
          detailID: optionData.basicInfo.ordSupplierId
        })

      } else {
        console.log("新增")
        this.setData({
          MerchantInfo: optionData,
          detailID: optionData.eiId,
        })


        this.getMarketData(optionData.eiId)
      }

      this.getGoodsLoginStatusData(this.data.detailID)
      this.getBusinessBasicInfo(this.data.detailID)
    }

    wx.setNavigationBarTitle({
      title: '商品下单',
    })

    this.selectHeight();
  },
  // mmmmmm
  getMarketData(eiId) {
    requestMarketInfo(eiId).then((res) => {
      if (res.data.length > 0) {
        this.setData({
          showMarket: true,
          MarketID: res.data[0].id
        })
      }
      if (res.data.length == 0) {
        this.setData({
          showMarket: false
        })
      }
    })
  },
  goMarket() {
    getApp().globalData.storeMarketID = this.data.MarketID,
    wx.reLaunch({
      url:'../market/market?MarketID='+this.data.MarketID
    })
  },
  getBusinessBasicInfo(eiId) {

    basicBusinessInfo(eiId).then((res) => {
      console.log("公司的整个主体信息")
      let resuleData = res.data;

      let buildData = {
        eiId: resuleData.eiId,
        eiName: resuleData.eiName,

        eiContact: resuleData.eiContact,
        eiAdminMobile: resuleData.eiAdminMobile,

        eiProvinceName: resuleData.eiProvinceName,
        eiCityName: resuleData.eiCityName,
        eiAreaName: resuleData.eiAreaName,
        eiAddress: resuleData.eiAddress,
        eiLicenseNo: resuleData.eiLicenseNo,
      }

      let hideNum = resuleData.eiAdminMobile.toString().slice(0, 3)+ '****'+ resuleData.eiAdminMobile.toString().slice(-4);

      this.setData({
        postBusiness: buildData,
        hidePhone:hideNum
      })
      

    })
  },

  goLogin(){
    wx.navigateTo({ url: `/pages/login/login`});
  },
  onShareAppMessage: function (res) {
    
    const shareData = {
      eiId: this.data.detailID,
    }
    const BuildData = JSON.stringify(shareData);
    
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res);
    }
    
    return {
      title: this.data.postBusiness.eiName,
      path: '/pages/ChoseGoods/ChoseGoods?detInfo=' + encodeURIComponent(BuildData),
    }
  },
  // sssss
  switchCategory(e) {
    var that = this;
    console.log(e.currentTarget.dataset)
    let rowData = e.currentTarget.dataset;
    var index = rowData.index;
    const floorRowData = this.data.goodsList.find(item => {
      return item.ptId === rowData.bean.ptId
    })
    console.log(floorRowData)
    // return
    // var that = this;
    // var index = rowData.index;
    var childData = floorRowData.products;

    function FindItem(itemID, moreList) {
      let findData = moreList.find(x => x.piId == itemID.piId);
      return findData
    }
    var changeGoods = childData.map((each) => {
      if (FindItem(each, that.data.HasSelectedList)) {
        return {
          ...each,
          SelNum: FindItem(each, that.data.HasSelectedList).SelNum,
          showAddOrSub: true
        }
      } else {
        return {
          ...each
        }
      }

    })


    this.setData({
      ProductList: [],
      pageSize: 10,
      pageIndex: 1,
    })

    let list = changeGoods
    let qielist = list.slice(that.pageIndex - 1, that.data.pageSize)
    this.setData({
      TotalDataList: list,
      ProductList: qielist,
      curIndex: e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0,
      toView: 'order' + e.currentTarget.dataset.bean.productTypeId,
      active: index,
      selectId: "item" + index,

    })
  },


  Reachbottom() {
    console.log("是个啥")
    // wx.showLoading({
    //   title: '加载中',
    // })
    let shu = this.data.pageIndex
    this.setData({
      pageIndex: shu + 1
    })
    let num = (this.data.pageIndex - 1) * this.data.pageSize
    let num2 = num + this.data.pageSize
    let arr = this.data.TotalDataList
    let qielist = arr.slice(num, num2)
    let slist = this.data.ProductList
    let newarr = slist.concat(qielist)
    this.setData({
      ProductList: newarr
    })

    setTimeout(function () {
      wx.hideLoading()
    }, 300)
  },




  TotalAllSelecteFun() {
    this.countClassifySelectedNum()
    this.setData({
      GoodsNum: this.data.HasSelectedList.length
    })

  },
  onCancelCategory() {
    this.setData({
      showPopup: false
    })
  },
  onClickIcon() {
    this.setData({
      showPopup: !this.data.showPopup
    })
  },
  ClickShop() {
    wx.navigateTo({ url: `/pages/poster/poster` });
  },
  SubmitFun() {
    if (this.data.HasSelectedList.length == 0) {
      wx.showToast({
        icon: 'none',
        title: "请选择商品",
      })
      return
    }

    const newData = JSON.stringify(
      {
        FromChoseGoods: this.data.HasSelectedList,
        basicInfo: this.data.postBusiness
      }
    );
    wx.navigateTo({ url: `/pages/addOrder/addOrder?detInfo=` + encodeURIComponent(newData) });
  },
  EditSubmit() {
    if (this.data.HasSelectedList.length == 0) {
      wx.showToast({
        icon: 'none',
        title: "请选择商品",
      })
      return
    }
    var pages = getCurrentPages(); // 获取页面栈
    var prevPage = pages[pages.length - 2]; // 上一个页面


    if (prevPage.__route__ == 'pages/addOrder/addOrder') {
      prevPage.changeGoods(this.data.HasSelectedList);
      wx.navigateBack({
        delta: 1
      })
    }

  },
  getGoodsLoginStatusData(infoID) {
    let that = this;
    let postData = {
      enterpriseId: infoID,
    }
    goodsNoTokenGroup(postData).then((res) => {
      var that =this;
      function FindItem(itemID, moreList) {
        let findData = moreList.find(x => x.piId == itemID.piId);
        return findData
      }

      function FindPrice(item) {
        if (item.agreementUnitPrice) {
          return centToYuan(item.agreementUnitPrice);
        } else if (item.customerUnitPrice) {
          return centToYuan(item.customerUnitPrice);
        } else {
          return centToYuan(item.latestSaleUnitPrice);
        }

      }

      var ClassifyData =[]
      let newdata = res.data.map((item) => {
        if (item.products) {
          ClassifyData.push({
            ...item,
            products:null,
            tipsSelected:0,

          })
          var childFloor = []
          item.products.map((each) => {
            if (each.piIsValid === 1) {
              childFloor.push({
                ...each,
                ProductDes: that.changeDes(each),
                // ProductDes: each.piSpec + '、' + each.piNetContent + each.piNetContentUnit + '/' + each.piSpec,
                standardPrice: FindPrice(each),
                showAddOrSub: FindItem(each, that.data.SeledGoods) == undefined ? false : true,
                SelNum: FindItem(each, that.data.SeledGoods) == undefined ? 0 : FindItem(each, this.data.SeledGoods).SelNum,

              })
            }

          })
        } else {
          childFloor = []
        }

        return {
          ...item,
          text: item.ptItemName,
          products: childFloor,
        };
      });
      
      console.log("原始数据")
      // console.log(newdata)
      console.log(ClassifyData)
      if (newdata.length == 0) {
        this.setData({
          goodsList: [],
          ProductList: [],

        })
        return
      }

      var oneChild = newdata[0].products.map((each) => {
        if (FindItem(each, that.data.HasSelectedList)) {
          return {
            ...each,
            SelNum: FindItem(each, that.data.HasSelectedList).SelNum,
            showAddOrSub: true
          }
        } else {
          return {
            ...each
          }
        }

      })
      // xxxxx
      this.setData({
        pageTotal: Math.ceil(oneChild.length / 10) //根据后台返回的总数量,判断有多少页
      })
      let list = oneChild
      let qielist = list.slice(that.pageIndex - 1, that.data.pageSize)

      this.setData({
        leftClassifyList:ClassifyData,
        goodsList: newdata,     //所有数据
        TotalDataList: list,    //单个分类所有数据
        ProductList: qielist,   //视图显示数据
        curIndex: 0

      })
      console.log("左侧数据")
      console.log(this.data.leftClassifyList)
      this.TotalAllSelecteFun()

      this.setScrollHeight()

    })
  },

  DynamicCacheArray(itemData) {
    let that = this;
    var findData = this.data.HasSelectedList.find(x => x.piId == itemData.piId);
    if (findData) {
      this.data.HasSelectedList = this.data.HasSelectedList.map((item) => {
        if (item.piId == itemData.piId) {
          return {
            ...item,
            SelNum: itemData.SelNum
          }
        } else {
          return {
            ...item,
          }
        }

      });
    } else {
      this.data.HasSelectedList.push(itemData)

    }
    if (itemData.SelNum == 0) {
      var indexNum = this.data.HasSelectedList.findIndex((tableData) => tableData.piId == itemData.piId);
      this.data.HasSelectedList.splice(indexNum, 1);
      console.log("删除")
    }


    that.setData({
      HasSelectedList: that.data.HasSelectedList,
      ProductList: this.data.ProductList
    });
    // 最后算
    this.TotalAllSelecteFun()
  },

  JudgeDecimal(num) {
    var x = String(num).indexOf('.') + 1;   //小数点的位置
    var y = String(num).length - x;  //小数的位数
    return y
  },
  addCart(event) {
    let childIndex = event.currentTarget.dataset.itemIndex;
    this.data.ProductList[childIndex].showAddOrSub = true;
    this.data.ProductList[childIndex].SelNum = 1;
    this.setData({
      ProductList: this.data.ProductList
    });
    this.DynamicCacheArray(this.data.ProductList[childIndex])
  },

  BlurItemNum(event) {
    var that = this;
    let indexNum = event.currentTarget.dataset.itemIndex;
    that.data.ProductList[indexNum].SelNum = event.detail.value;
    that.ChangeItemNum(indexNum, that.data.ProductList[indexNum])
  },
  MinusItemNum(event) {
    var that = this;
    let indexNum = event.currentTarget.dataset.itemIndex;
    that.data.ProductList[indexNum].SelNum--;
    if (that.data.ProductList[indexNum].SelNum < 0) {
      console.log(that.data.ProductList[indexNum].SelNum)
      that.data.ProductList[indexNum].SelNum = 0
    }
    that.ChangeItemNum(indexNum, that.data.ProductList[indexNum])
  },
  PlusItemNum(event) {
    let indexNum = event.currentTarget.dataset.itemIndex;
    var that = this;
    that.data.ProductList[indexNum].SelNum++;
    that.ChangeItemNum(indexNum, that.data.ProductList[indexNum])
  },
  
  // aaa
  ChangeItemNum(indexNum, itemData) {
    itemData.SelNum = this.JudgeDecimal(itemData.SelNum) > 2 ? itemData.SelNum.toFixed(2) : itemData.SelNum;
    var that = this;
    if (itemData.SelNum == 0) {
      that.data.ProductList[indexNum].showAddOrSub = false;
    }
    that.DynamicCacheArray(that.data.ProductList[indexNum])

  },
  // ccccccc

   // ccccccc
  countClassifySelectedNum(){
    var that =this;
    function contentNum(itemData,list){
      var sumCount = 0;
      for (var i in list) {
          if(list[i].productTypeId===itemData.ptId )
          sumCount += 1
      }
      return sumCount
    }

    let ClassifyData = this.data.leftClassifyList;   
    let changedClassify = ClassifyData.map((item) => {
      return {
        ...item,
        tipsSelected: contentNum(item, this.data.HasSelectedList)
      }
    });
    that.setData({
      leftClassifyList: changedClassify,
    });

  },


  BlurSelectedItemNum(event) {
    var that = this;
    let indexNum = event.currentTarget.dataset.itemIndex;
    that.data.HasSelectedList[indexNum].SelNum = event.detail.value;
    that.changedSelected(indexNum, that.data.HasSelectedList[indexNum])
  },
  MinusSelectedItemNum(event) {
    var that = this;
    let indexNum = event.currentTarget.dataset.itemIndex;
    that.data.HasSelectedList[indexNum].SelNum--;
    if (that.data.HasSelectedList[indexNum].SelNum < 0) {
      console.log(that.data.HasSelectedList[indexNum].SelNum)
      that.data.HasSelectedList[indexNum].SelNum = 0
    }
    that.changedSelected(indexNum, that.data.HasSelectedList[indexNum])
  },
  PlusSelectedItemNum(event) {
    console.log(event)
    let indexNum = event.currentTarget.dataset.itemIndex
    var that = this;
    that.data.HasSelectedList[indexNum].SelNum++;
    that.changedSelected(indexNum, that.data.HasSelectedList[indexNum])
  },


  // cccc
  changedSelected(indexNum, itemData) {
    itemData.SelNum = this.JudgeDecimal(itemData.SelNum) > 2 ? itemData.SelNum.toFixed(2) : itemData.SelNum;
    console.log(this.JudgeDecimal(itemData.SelNum))
    let that = this;
    this.data.ProductList = this.data.ProductList.map((item, index) => {
      if (item.piId == itemData.piId) {
        if (itemData.SelNum == 0) {
          return {
            ...item,
            showAddOrSub: false,
            SelNum: 0
          }
        } else {
          return {
            ...item,
            SelNum: itemData.SelNum
          }
        }

      } else {
        return {
          ...item,
        }
      }

    });

    if (itemData.SelNum == 0) {
      this.data.HasSelectedList.splice(indexNum, 1);
    }
    // 需要注意
    that.setData({
      HasSelectedList: this.data.HasSelectedList,
      ProductList: this.data.ProductList
    });
    
    this.TotalAllSelecteFun()
  },

  onSearch(){
       
    if(this.data.SearchValue==""){
        wx.showToast({
            icon: 'none',
            title: "输入框不可为空",
        })
        return false
    }
    this.getSearchData(this.data.goodsList,this.data.SearchValue)
    
  },
  getSearchData(list, keyWord) { //本地模糊搜索
    console.log(keyWord)
      
      //将list数据转换一下
    var newData=[]
    list.map((item) => {
        item.products.map((each)=>{
            newData.push(each)
        })
    });
    
      let arrVal = [];
      arrVal = keyWord.trim().split(' ').filter(item => {
        return item && !arrVal.includes(item);
      })
      let newArr = [];
              // 判断input框是否为空
      if (arrVal.length < 1) {
        return;
      }
      for (let i = 0; i < newData.length; i++) {
        let result = arrVal.some(item => {
          return newData[i].piProductName.includes(item);
        })
        if (result) {//都包含则向newArr添加
          let str = newData[i];
          newArr.push(str);
        }
      }

      console.log(newArr)
      
      if(newArr.length==0){
          wx.showToast({
              icon: 'none',
              title: "没有此商品",
          })

          return
      }
      let that =this;
      console.log(this.data.HasSelectedList)
      console.log(newArr)
      function FindItem(itemID,moreList){
        let findData = moreList.find(x => x.piId == itemID.piId);
        return findData
      }
      var changeGoods = newArr.map((each)=>{
          return {
              ...each,   
              standardPrice:FindPrice(each),
              // ProductDes:each.piSpec+'、'+each.piNetContent+each.piNetContentUnit+'/'+each.piSpec,
              ProductDes: that.changeDes(each),
              showAddOrSub:FindItem(each,that.data.HasSelectedList)==undefined?false:true,
              SelNum:FindItem(each,that.data.HasSelectedList)==undefined?0:FindItem(each,this.data.HasSelectedList).SelNum,
            
          }
      })

      this.TotalAllSelecteFun()
      this.setData({
        ProductList:changeGoods,
      })
},

changeDes(each){
  if(each.piNetContent){
    return  each.piSpec+'、'+each.piNetContent+each.piNetContentUnit+'/'+each.piSpec
  }else{
    return  each.piSpec
  }

},
onCancel(){
var that =this;
  this.setData({
      SearchList:[],
      SearchValue:"",
  })
  setTimeout(function () {
    that.getGoodsLoginStatusData(that.data.detailID)
  }, 10);
},
  searchClick() {
    var that = this;
    var selData = []
    this.data.goodsList.map((item) => {
      item.products.map((each) => {
        if (each.SelNum > 0) {
          selData.push(each)
        }

      })

    });

    const newData = JSON.stringify(
      {
        allData: this.data.goodsList,
        hasIncludedData: that.data.HasSelectedList
      }
    );
    wx.navigateTo({ url: `/pages/GoodsSearch/GoodsSearch?detInfo=` + encodeURIComponent(newData) });
  },
  haveSearchGoods(usefulData) {
    var that = this;
    console.log(usefulData)
    console.log(this.data.HasSelectedList)

    var selData = []
    this.data.HasSelectedList.map((each) => {
      if (each.SelNum > 0) {
        selData.push(each)
      }



    });
    let OldGoods = selData;
    let NewGoods = usefulData;

    NewGoods.forEach((item) => {
      let index = OldGoods.findIndex(e =>
        e.piId == item.piId
      )
      if (index > -1) {
        OldGoods[index] = item
      } else {
        OldGoods.push(item)
      }
    })

    this.setData({
      HasSelectedList: OldGoods,
    });
    setTimeout(function () {
      that.getGoodsLoginStatusData(that.data.detailID)
    }, 10);
    return
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const that =this;
    that.setData({
      hasLogin:getLocalUserInfo().tokenValue? true:false,
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },


  /**
   * 用户点击右上角分享
   */

})
    <!-- 自定义的导航栏开始 -->
    <view class="custom flex_center" style="padding-top:{{statusBarHeight}}px">

        <view class="title-left">
            <view class="back" bind:tap="backFun">
                <van-icon color="white" name="arrow-left" size="25px" />
            </view>
            <!-- <view class="avatar-title">选择商品</view> -->
        </view>
        <view class="search-icon" style="margin-right:{{navInfo.width}}px">
            
        </view>
    </view>


<view class="name-all" id="nameID">
    <view class="business-top">
        <view class="business-left" >
            <view class="business-name">{{postBusiness.eiName}}</view>
            <view class="business-text" bind:tap="getArea"><van-icon name="location" color="white" /> {{postBusiness.eiAddress}}</view>
            

            <!-- <van-search
                clear-trigger="always"
                background="#fa550f"
                shape="round"
                model:value="{{ SearchValue }}" 
                placeholder="请输入商品名称"  
                bind:search="onSearch"  
                bind:clear="onCancel"
            /> -->
            <!-- <van-search 
                class="search-icon" 
                bind:click-input="searchClick" 
                value="{{ value }}" 
                disabled 
                placeholder="请输入搜索关键词" 
            /> -->
        </view>
    </view>
</view>
<van-search
                clear-trigger="always"
                shape="round"
                model:value="{{ SearchValue }}" 
                placeholder="请输入商品名称"  
                bind:search="onSearch"  
                bind:clear="onCancel"
            />
<view class="none-text" wx:if="{{ leftClassifyList.length==0 }}"> 
    
    <image  src="https://pic-shop.magcloud.net/miniapp_static/empty_order_icons.png" />
    <view >空空如也...</view>
</view>



<view class="main-cate" wx:if="{{ leftClassifyList.length>0 }}">
    <scroll-view class="menu-left" style="height:{{heightScroll}}px;box-sizing: border-box;" scroll-y scroll-with-animation="{{true}}">
        <view class="menu-main">
            <view
                class="cate-list"
                wx:for="{{leftClassifyList}}"
                wx:for-item="item"
                wx:for-index="index"
                wx:key="index"
                data-bean="{{item}}"
                data-index="{{index}}"
                bindtap="switchCategory"
            >
                <text class="cate-text {{curIndex==index?'on':''}}">{{item.ptItemName}}</text>
                <van-tag 
                    class="tips-num" 
                    color="#FE6526" 
                    round 
                    type="primary"  
                    wx:if="{{ item.tipsSelected>0 }}"
                >{{item.tipsSelected}}</van-tag>
            </view>

            
        </view>
        <view bind:tap="callPhone" class="phone-icon">
            <van-icon size="25px" name="phone"  color="white" />
            <view class="phone-text">电话询价</view>
        </view>
    </scroll-view>
    <view  class="menu-right" >
        <scroll-view style="height:{{heightScroll}}px;box-sizing: border-box;"  scroll-y="true" scroll-with-animation="true" bindscroll="watchScroll" scroll-into-view="{{toView}}" bindscrolltolower="Reachbottom">
            <block class="cate-product">
                <view  class="product-list" wx:for="{{ProductList}}"  wx:for-item="each" data-each="{{each}}" wx:key="key">                     <van-image   lazy-load src="{{each.piImageUrl}}"/>
                    <view class="product-left">
                        <view class="product-name">{{each.piProductName}}</view>
                        <view class="product-desc">{{each.ProductDes}}</view>
                        <view class="product-end">
                            <view class="product_price"></view>
                            <view class="add-cart"  wx:if="{{each.showAddOrSub==false}}">
                                <van-icon 
                                    name="shopping-cart"  
                                    color="#fa550f" 
                                    size="50rpx"  
                                    data-item-index="{{index}}" 
                                    data-parentIndex="{{parentIndex}}"
                                    bindtap="addCart"/>
                            </view>
                            <view class="count-part" wx:if="{{each.showAddOrSub==true}}">
                                <van-stepper
                                    data-item-index="{{index}}" 
                                    data-parentIndex="{{parentIndex}}"
                                    min="" 
                                    
                                    value="{{ each.SelNum }}" 
                                    bind:blur="BlurItemNum"
                                    bind:minus="MinusItemNum"
                                    bind:plus="PlusItemNum" 
                                    input-class="stepinput" 
                                    plus-class="stepplus" 
                                    minus-class="stepplus"
                                    input-width="60px" 
                                    button-size="25px"
                                />
                            </view>
                        </view>
                    </view>
                </view>
                <view class="none-text" wx:if="{{ProductList.length==0}}">
                    <image  src="https://pic-shop.magcloud.net/miniapp_static/empty_order_icons.png" />
                    <view >空空如也...</view>
                </view>
                
            </block>
        </scroll-view>
    </view>

    
</view>

<view class="pop-button" >
    <van-goods-action custom-class="action-box">
        <van-goods-action-icon icon="shop-collect-o" text="市场"  wx:if="{{ showMarket }}" bind:click="goMarket"/>
        <van-goods-action-icon icon="share-o" text="分享"  open-type="share"/>
        <van-goods-action-icon icon="shop-o" text="我要开店"  bind:click="ClickShop"  />
        <van-goods-action-icon icon="cart-o" text="购物车" info="{{GoodsNum}}"   bind:click="onClickIcon"  />
        <van-goods-action-button wx:if="{{ editChoose==false }}" color="#fa550f" text="去下单" bind:click="SubmitFun" />
        <van-goods-action-button  wx:if="{{ editChoose }}" color="#fa550f" text="去下单" bind:click="EditSubmit" />
    </van-goods-action>
    <view class="support-text">技术支持:400-100-9083</view>
</view>




<van-popup  custom-style="height: 50%;" position="bottom" z-index="{{100}}" show="{{ showPopup }}"  bind:close="onCancelCategory">
    <view class="eject-product">
        <view class="eject-list">
            <view  class="ejectselected-list" wx:for="{{HasSelectedList}}"  wx:for-item="each" data-each="{{each}}" wx:key="key"  wx:if="{{ each.SelNum>0}}" >
                <van-image  lazy-load src="{{each.piImageUrl}}"/>
                <view class="ejectselected-left">
                    <view class="ejectselected-name">{{each.piProductName}}</view>
                    <view class="product-desc">{{each.ProductDes}}</view>
                    <view class="product-end">
                        <view class="product_price"></view>
                        <view class="ejectselected-part" wx:if="{{each.showAddOrSub==true}}">
                            <van-stepper
                                data-item-index="{{index}}" 
                                data-parentIndex="{{parentIndex}}"
                                min="" 
                                value="{{ each.SelNum }}"
                                bind:blur="BlurSelectedItemNum"
                                bind:minus="MinusSelectedItemNum"
                                bind:plus="PlusSelectedItemNum"   
                                input-class="stepinput" 
                                plus-class="stepplus" 
                                minus-class="stepplus"
                                input-width="60px" 
                                button-size="25px"
                            />
                        </view>
                    </view>
                </view>
            </view>
        </view>
        
    </view>
</van-popup>


上一篇 下一篇

猜你喜欢

热点阅读