收藏
回答

如何调用openid来进行订单过滤鸭?

// 云函数入口函数
exports.main = async (event, context) => {
  const { OPENID } = cloud.getWXContext();
  const res = await cloud.cloudPay.unifiedOrder({
    "openid": OPENID, // 微信用户的openid
    "body" : event.body, // 商品描述
    "outTradeNo" : event.outTradeNo, // 商户订单号
    "spbillCreateIp" : "127.0.0.1"// 终端 IP
    "subMchId" : "1659201615"// 商户号
    "totalFee" : event.totalFee, // 总金额
    "envId""cloud1-8gfd19nr926f700d"// 云函数环境名称
    "tradeType":"JSAPI",//交易类型
    "functionName""pay_cb" // 支付结果通知回调云函数名 
    //"functionName": "buy_pay_success" // 支付结果通知回调云函数名 
  })
  return res


//小程序代码
  noPay(){
    wx.cloud.callFunction({
      name: 'buy_pay',
    }).then(res => {
      _openid = res.result.openid // 获取返回的openid
    wx.cloud.database().collection('buy_orders').orderBy('time','desc').where({
      status:0,
      openid: this.data._openid,  // 过滤当前用户的订单
    }).get()
    .then(res=>{
      this.setData({
        ordersList:res.data
      });
    });
  });
  },
为什么这个id并不能拿过来,我应该怎么拿过来并且判断过滤?
回答关注问题邀请回答
收藏

3 个回答

  • 跨商通
    跨商通
    2023-11-16

    你这JS基础知识都属于刚入门,不过关,就开始写支付代码啊?

    2023-11-16
    有用
    回复
  • showms
    showms
    2023-11-14

    把this.data._openid打印出来, 有值吗

    2023-11-14
    有用
    回复
  • Kuaile.
    Kuaile.
    2023-11-14

    这个赋值在哪里

    2023-11-14
    有用
    回复 2
    • 神呢
      神呢
      2023-11-14
      不能直接拿来用的吗
      2023-11-14
      回复
    • Kuaile.
      Kuaile.
      2023-11-15回复神呢
      能你用吧
      2023-11-15
      回复
登录 后发表内容