• 微信小程序多表独立查询


    代码如下:

    wxml文件
    <view class="search">
      <view class="search_arr">
        <icon class="searchcion" size="20" type="search"></icon>
        <input placeholder="请输入搜索产品名称" bindconfirm="gosearch" type="text" confirm-type="search"></input>
      </view>
    </view>
    
    wxss文件
    .search{
      margin: 2% 0% 2% 1%;
       98%;
    }
    .search_arr{
      border: 1px solid #d0d0d0;
      border-radius: 10rpx;
    }
    .search_arr input{
      margin-left: 60rpx;
      height: 60rpx;
      border-radius: 5px;
    }
    .searchcion {
      margin: 10rpx 10rpx 10rpx -5rpx;
      position: absolute;
      left: 25rpx;
      z-index: 2;
       20px;
      height: 20px;
      text-align: center;
    }
    
    js文件
    我这里是从五个表里面查询
    gosearch: function(e){
        var that = this;
        var search = e.detail.value; 
        if (search){
          db.collection("panotherlist").where({
            text: search
          }).get().then(res => {
            if(res.data.length != 0){
              that.data.sresult = JSON.stringify(res.data);
            }
            db.collection("pcuttinglist").where({
              text: search
            }).get().then(res => {
              if (res.data.length != 0) {
                that.data.sresult = that.data.sresult + JSON.stringify(res.data);
              }
              db.collection("pdrilllist").where({
                text: search
              }).get().then(res => {
                if (res.data.length != 0) {
                  that.data.sresult = that.data.sresult + JSON.stringify(res.data);
                }
                db.collection("pgrindinglist").where({
                  text: search
                }).get().then(res => {
                  if (res.data.length != 0) {
                    that.data.sresult = that.data.sresult + JSON.stringify(res.data);
                  }
                  db.collection("ppollpicklist").where({
                    text: search
                  }).get().then(res => {
                    if (res.data.length != 0) {
                      that.data.sresult = that.data.sresult + JSON.stringify(res.data);
                    }
                    if ((JSON.parse(that.data.sresult)).length === 0) {
                      wx.showToast({
                        title: '暂时没有该产品您可以联系我们的客服添加相关产品',
                        icon: 'none',
                        duration: 2000
                      })
                    } else {
                      wx.navigateTo({
                        url: '../searchShow/searchShow?value=' + encodeURIComponent(that.data.sresult)
                      })
                    }
                  })
                })
              })
            })
            }).catch(err => {
              console.log(err)
            })
        }else{
          wx.showToast({
            title: '输入不能为空',
            icon: 'none',
            duration: 1500
          })
        }
      }
    
  • 相关阅读:
    WebDriver关闭窗口
    WebDriver切换窗口
    WebDriver处理截屏
    获取当前窗口的地址栏url地址
    WebDriver获取当前窗口的title
    复选框
    勾选框
    单选框
    VUE 中获取摄像头进行扫码
    js byte 与 进制 相互转换
  • 原文地址:https://www.cnblogs.com/LCXHY/p/13228072.html
Copyright © 2020-2023  润新知