最近搜索

小程序 组件 可以向外传递多个方法 。

浏览:384
管理员 2022-10-29 15:55


<!-- 精选栏目  margin_class="nav_margin_top" -->
<w-image-scroll bind:scan_scan="scan_scan"  bind:scan_operation_sales="scan_operation_sales" wx:if="{{nav_head.state==1}}" image_list="{{nav_list}}" head="{{nav_head}}"  style="display: block; margin-top: 20rpx;"   >
</w-image-scroll>
<!-- 精选栏目 -->


 scan_scan() {
    var _this = this;
    //判断用户是否登录
    var that = this;
    if (app.globalData.is_login == 0) {
      wx.showToast({
        title: "请登录后操作",
        icon: 'none',
        duration: 2000
      })
      return;
    } else {
      // 允许从相机和相册扫码
      wx.scanCode({
        success: (res) => {
          var result = res.result;
          console.log(result);
          _this.setData({
            scan_scan_result: result,
          })
          var arr = result.split('_');
          console.log(arr[1]);
          var str0 = arr[0];
          if (str0 == 'h') {
            wx.redirectTo({
              url: "/pages/draw_operation/draw_operation?drawid=" + parseInt(arr[1])
            })
          } else {
            wx.showToast({
              title: "请扫图纸上面的二维码",
              icon: 'none',
              duration: 2000
            })
          }
        }
      })
    }
  },
  scan_operation_sales() {
    //扫一扫操作 订单发货
    var _this = this;
    //判断用户是否登录
    var that = this;
    if (app.globalData.is_login == 0) {
      wx.showToast({
        title: "请登录后操作",
        icon: 'none',
        duration: 2000
      })
      return;
    } else {
      // 允许从相机和相册扫码
      wx.scanCode({
        success: (res) => {
          var result = res.result;
          console.log("扫码内容是:"+result);
          var arr = result.split('_');
          var str0 = arr[0];
          if (str0 == 's') {
            wx.redirectTo({
              url: "/pages/sales_operation/sales_operation?salesid=" + parseInt(arr[1])
            })
          } else {
            wx.showToast({
              title: "请扫流程卡上面的二维码",
              icon: 'none',
              duration: 2000
            })
          }
        }
      })
    }


  }





组件内的js代码


image.png





联系站长

站长微信:xiaomao0055

站长QQ:14496453