zoukankan      html  css  js  c++  java
  • 微信小程序多表独立查询

    代码如下:

    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
          })
        }
      }
    
  • 相关阅读:
    Codeforces Beta Round #92 (Div. 2 Only) B. Permutations 模拟
    POJ 3281 Dining 最大流 Dinic算法
    POJ 2441 Arrange the BUlls 状压DP
    URAL 1152 Faise Mirrors 状压DP 简单题
    URAL 1039 Anniversary Party 树形DP 水题
    URAL 1018 Binary Apple Tree 树形DP 好题 经典
    pytorch中的forward前向传播机制
    .data()与.detach()的区别
    Argparse模块
    pytorch代码调试工具
  • 原文地址:https://www.cnblogs.com/LCXHY/p/13228072.html
Copyright © 2011-2022 走看看