- 为什么我的开发工具 云开发点了没有反应?
之前没有任何问题,这几天这个云开发按钮 点了一点反应都没有,不知道出了什么问题。
2天前 - 物流组件真的可以用吗?为什么调用的时候总是出现 "invalid url"?
这个云函数调用的时候一直报错: 云函数返回结果: {errMsg: "cloud.callFunction:ok", result: {…}, requestID: "7cd07d46-2454-4024-934f-6a37a34b364b"}errMsg: "cloud.callFunction:ok"requestID: "7cd07d46-2454-4024-934f-6a37a34b364b"result: {success: false, error: "invalid url rid: 67f8b07c-55bea4f6-516feb3b", errorCode: 40066}__proto__: Object index.js? [sm]:755 获取 waybillToken 失败: {success: false, error: "invalid url rid: 67f8b07c-55bea4f6-516feb3b", errorCode: 40066}(env: Windows,mp,1.06.2503281; lib: 3.7.12) (anonymous) @ index.js? [sm]:755 Promise.then (async) getWaybillToken @ index.js? [sm]:728 (anonymous) @ index.js? [sm]:613 Promise.then (async) checkLogistics @ index.js? [sm]:564 index.js? [sm]:761 错误信息: invalid url rid: 67f8b07c-55bea4f6-516feb3b(env: Windows,mp,1.06.2503281; lib: 3.7.12) 下面是云函数代码: // 云函数 getwaybilltoken/index.js const cloud = require('wx-server-sdk'); cloud.init({ env: 'xxxxxxxxxxxxxxxx' }); // 引入请求库 const rp = require('request-promise'); exports.main = async (event, context) => { console.log('接收到的参数:', event); try { // 获取access_token const tokenRes = await cloud.callFunction({ name: 'getaccesstoken' }); const accessToken = tokenRes.result.accessToken; console.log('获取到的accessToken:', accessToken); if (!accessToken) { console.log('未获取到有效的accessToken'); return { success: false, error: 'Failed to get access_token' }; } // 获取当前用户的openid const openid = event.openid || cloud.getWXContext().OPENID; console.log('使用的openid:', openid); // 处理商品信息,确保图片URL有效 let detailList = []; const goods = event.goods; const defaultImgUrl = "https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg"; // 微信官方示例图片 // 准备商品数据 if (goods && Array.isArray(goods) && goods.length > 0) { // 临时存储需要转换的云文件ID const cloudFileIDs = []; const goodsItemsMap = {}; // 用于关联云文件ID和商品项 goods.forEach((item, index) => { const imgUrl = item.image_url || item.image || ''; // 检查是否是云存储路径 if (imgUrl && imgUrl.startsWith('cloud://')) { cloudFileIDs.push(imgUrl); goodsItemsMap[imgUrl] = index; } }); // 如果有云存储路径,先转换为临时URL if (cloudFileIDs.length > 0) { try { console.log('开始转换云文件URL,文件数:', cloudFileIDs.length); const tempFileResult = await cloud.getTempFileURL({ fileList: cloudFileIDs }); console.log('获取临时文件URL结果:', tempFileResult); // 处理临时URL结果 if (tempFileResult && tempFileResult.fileList) { tempFileResult.fileList.forEach(fileItem => { if (fileItem.tempFileURL && goodsItemsMap[fileItem.fileID] !== undefined) { const index = goodsItemsMap[fileItem.fileID]; goods[index].convertedImageUrl = fileItem.tempFileURL; } }); } } catch (fileErr) { console.error('获取临时文件URL失败:', fileErr); } } // 构建最终的商品详情列表 detailList = goods.map(item => { // 优先使用转换后的URL,然后是原始URL,最后是默认URL let finalImgUrl = item.convertedImageUrl || item.image_url || item.image || ''; // 如果URL仍然不是http/https开头,使用默认URL if (!finalImgUrl || !finalImgUrl.startsWith('http')) { finalImgUrl = defaultImgUrl; } return { goods_name: item.name || '商品', goods_img_url: finalImgUrl }; }); } // 如果没有有效的商品信息,使用默认 if (detailList.length === 0) { detailList = [{ goods_name: item.name || '商品', goods_img_url: finalImgUrl }]; } // 构建请求参数 const waybillId = event.waybillId; const deliveryId = event.deliveryId; const receiverPhone = event.receiverPhone || ''; const transId = event.transId || ''; console.log('构建请求参数:', { waybillId, deliveryId, receiverPhone, transId, detailList: detailList }); // 构建请求体 const requestData = { waybill_id: waybillId, delivery_id: deliveryId, openid: openid, version: 1, goods_info: detailList, receiver_phone: receiverPhone || '', trans_id: transId || '' }; console.log('完整请求数据:', JSON.stringify(requestData)); // 调用微信物流API const result = await rp({ method: 'POST', url: `https://api.weixin.qq.com/cgi-bin/express/business/logistics/getpath?access_token=${accessToken}`, body: requestData, json: true }); console.log('物流API返回结果:', result); // 处理API响应 if (result.errcode === 0) { return { success: true, waybillToken: result.waybill_token }; } else { console.error('物流API返回错误:', result); return { success: false, error: result.errmsg || '获取物流路径失败', errorCode: result.errcode }; } } catch (error) { console.error('云函数执行异常:', error); return { success: false, error: error.message || '云函数执行异常' }; }};
04-11 - 物流查询组件里的商品图片必须是HTTP url?
物流API报"invalid url"错误:因为您的代码中使用了微信云开发的云存储路径(以"cloud://"开头),而物流API需要标准的HTTP/HTTPS URL。
04-11 - 查询物流组件的调用 怎么卡住了?
// 显示加载中 wx.showLoading({ title: '加载物流信息...', mask: true }); // 查询订单信息,获取物流信息 const db = wx.cloud.database(); db.collection('orders').doc(orderId).get().then(res => { const orderData = res.data; // 确保有物流信息 if (!orderData.productLogistics || orderData.productLogistics.length === 0) { if (orderData.logistics && orderData.logistics.waybill_id) { // 使用旧版本物流信息 this.getWaybillToken(orderData.logistics.waybill_id, orderData.logistics.delivery_id || 'SF', orderData._openid, orderData.address.phone, orderData); } else { wx.hideLoading(); wx.showToast({ title: '暂无物流信息', icon: 'none' }); this.setData({ isButtonClick: false }); } return; } [图片] 查看物流 是调用的查询物流组件,不知道为什么卡在这里了
04-11 - 如何获取支付单号trans_Id?
在物流查询组件中,查询运单接口trace_waybill需要trans_id 微信支付单号) https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html 请问这个微信支付单号如何获取?
04-10 - 物流接口 怎么将物流轨迹发到收件人微信上?
[图片]这里没有讲到如何发物流轨迹到微信前端啊;也没有说如何生成电子面单打印
04-07 - 小程序发布版支付功能失效 说我违反平台规则?
我在调试的时候,微信支付是没有问题的,为什么发布版本里说我违法平台规则? [图片]
04-01 - 使用云开发模板一真机调试就报错,怎么回事?
[图片]
03-15 - 为什么我的prepay_id= 是个空值,如何获取
我在开发小程序的微信支付,在云函数getpayparams里通过调用await cloud.cloudPay.unifiedOrder({}) return { payment: { timeStamp: res.payment.timeStamp, nonceStr: res.payment.nonceStr, package: res.payment.package, signType: 'MD5', paySign: res.payment.paySign }, 显示结果是 nonceStr: "HMNaIB4cyvSRyL09" package: "prepay_id=" paySign: "0D5C123F73E78DBB0F053E0AFB305987" signType: "MD5" timeStamp: "1700107100", 这个prepay_id是个空值,然后手机扫码支付显示错 JASPI params Invalid: total_fee, total_fee 设置为100分。请问如何获得这个prepya_id。 或者正确的做法是什么
03-03