- 微信小程序PC端打开子页的问题?
[图片]
10-25 - 微信小程序电脑端打开子页会分屏?
[图片]
10-25 - 如何通过JS或jquery 上传 视频文件到云存储?
js代码调用云函数“uploadvideo”代码: [图片] 云函数代码: [图片]
2023-01-31 - 关于获取定位的问题?
获取定位(并同时转换为实际地址)功能只能在开发工具以及苹果机能实现,安卓机不行,为什么?怎么解决? 源码如下: let amapFile = require("../../../libs/amap-wx.130.js"); onShow() { let that = this; wx.getSetting({ success(res) { if (res.authSetting['scope.userLocation'] == false) { //如果没有授权地理位置 wx.openSetting({ success(res) { res.authSetting = { //打开授权位置页面,让用户自己开启 "scope.userLocation": true } } }) } else { //用户开启授权后可直接获取地理位置 wx.authorize({ scope: 'scope.userLocation', success() { //获取位置后相关操作 that.getLocation(); } }) } } }) }, getLocation: function () { var that = this; var myAmapFun = new amapFile.AMapWX({key:'xxxxxxxxxxxxxxxxxxx'}); //获取自己所在地址的定位 myAmapFun.getRegeo({ success: function(res){ //成功回调 console.log(res[0]) that.setData({ newAddress:res[0].name }) }, fail: function(info){ //失败回调 console.log(info) } }) },
2022-11-25 - 如何通过消息队列设置 定时发送多条订阅消息?
想实现通过消息队列设置定时发送多条订阅消息,但返回错误信息: 授权成功 {z0P4SZCU238iZNUU5NCN-UgAFHtQmDKPWC6H9ecxEow: "accept", errMsg: "requestSubscribeMessage:ok"} tuisong.js? [sm]:35 当前OPENID是 oZf6p4kGtehoZDs0Ox9lymWUFxBc 订阅成功 {errMsg: "cloud.callFunction:ok", result: Array(100), requestID: "7220f2f8-8c37-4270-9330-4a6ace8092fe"}errMsg: "cloud.callFunction:ok"requestID: "7220f2f8-8c37-4270-9330-4a6ace8092fe"result: Array(100)0: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4d85b2cf-27757ef5"}1: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-79184334-2c140a6d"}2: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-09f9d1b2-4650355b"}3: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-36621c48-6b007704"}4: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6ce884dd-4436ca79"}5: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-57ac3a78-7de03bd9"}6: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-5bd5f37f-2ab1c12f"}7: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-42e90b8c-4304e541"}8: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-14cbecb5-257d0b07"}9: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-147c90c3-12e5765d"}10: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-5ece7c8e-420e3e34"}11: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-69e84e5a-3368e776"}12: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-28273766-5b6c6997"}13: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-703737e1-4c025bc1"}14: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-65146bf4-6d7ca22b"}15: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7d24e67b-59c2eed4"}16: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7159acbe-0ef13807"}17: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-096a51b6-18a2913e"}18: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-3ba39540-33aeabb5"}19: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-0908f9d0-20cc778a"}20: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7372e644-59b78f5a"}21: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-2e002cdc-17761ced"}22: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-2b2a9d1e-31d025bf"}23: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6e60c076-5d9811ea"}24: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4f9cd948-4651cd22"}25: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-21d5c1bd-3c6475fb"}26: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-64b5027e-6cf5c69b"}27: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-189d4c12-619ef24b"}28: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7e1f082e-4ad948fe"}29: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4be029f9-0ce9f3b4"}30: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-06e08516-6546011d"}31: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-1296d570-6dcb34ad"}32: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-41387778-17f94062"}33: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-242a893c-4ef49843"}34: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4388464d-0bbd08a4"}35: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-56b948a6-4da98bf5"}36: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-1e94d732-4e7cc2dc"}37: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-537cd0da-7363f8f8"}38: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-0609f563-6a4b3a44"}39: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-378d7b83-6c0ffd52"}40: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-1b7474d1-36d3dd59"}41: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-399ded08-5c7292e2"}42: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4194469f-5e5bbb0b"}43: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-04ded8ac-7e0a09b1"}44: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-060f5c58-5586b5e3"}45: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-474e5729-74e0bc0d"}46: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6ee4c0a6-12a77b68"}47: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-457a00d7-145f6126"}48: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-3f50a666-47585a3e"}49: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-68f627e8-32db82d4"}50: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-791d56dc-77707d43"}51: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4f77ae26-71d14da8"}52: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6f412df3-1cb152d5"}53: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-0b73aea2-628a8438"}54: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-78495a94-6f26d3da"}55: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-1633de92-383d0445"}56: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-1e9a3dda-3ac73e8c"}57: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-137dc855-283ebc9f"}58: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-46008ad4-39ce8ce6"}59: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-5c23fd9b-3f64f7da"}60: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-68dfb0aa-7883568a"}61: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-70c2f5a0-485a5721"}62: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7c4480a4-707a3e49"}63: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-2603fde0-241b329a"}64: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-27f7ac6b-3d4a87d6"}65: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-22df3492-5ebbc0fe"}66: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-0b3d7ff8-303ba081"}67: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-58a2e702-6d1f5257"}68: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7c77165d-5f27b225"}69: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-223a4456-569b51a0"}70: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-33ebb1fb-4c7b99b7"}71: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-7eb15570-59b2492e"}72: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-768a6640-58cbe2d5"}73: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-60313189-1786831a"}74: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-3b02081a-375d8a9e"}75: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-231ad990-2db994c4"}76: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-0a90d12c-5996ef7c"}77: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-3c10fb91-31de9abe"}78: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-71d679b5-603d3365"}79: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-2d16b1fe-5b3c6b4a"}80: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-02cab5d4-5208696e"}81: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-11413067-7f4fdadd"}82: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-119a494f-71845148"}83: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-1454f612-4cd57cef"}84: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6f395741-6c3cd1ae"}85: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-2225b24a-53e994d4"}86: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-236733b1-711eeb69"}87: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6e5bf477-583a0e33"}88: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-0c3aeaa7-67f82996"}89: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-5e437355-76f3ec2e"}90: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4812b1bf-5b159420"}91: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6d648ac2-64ba7684"}92: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-35ca1d34-7e126545"}93: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6eb817cb-56e14124"}94: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-5355dac0-1b3c2da4"}95: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-02427aef-5418b28e"}96: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-4848e857-0d5b732b"}97: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-709a213d-71f8e93d"}98: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-6b4cd10a-2bd0d92c"}99: {errCode: 40003, errMsg: "openapi.subscribeMessage.send:fail invalid openid rid: 63589982-42a05f58-33574a28"}length: 100nv_length: (...)__proto__: Array(0)__proto__: Object 目前代码如下: 1.用一个按钮实现接受授权以及推送,代码如下: tuisong() { console.log(this.data.rec) var item = this.data.rec //要发送的记录集合 wx.requestSubscribeMessage({ tmplIds: ['z0P4SZCU238iZNUU5NCN-UgAFHtQmDKPWC6H9ecxEow'], //这里填入我们生成的模板id success: res => { if (res['z0P4SZCU238iZNUU5NCN-UgAFHtQmDKPWC6H9ecxEow'] === 'accept') { console.log('授权成功', res) wx.cloud.callFunction({ name: 'getopenid', }).then(res=>{ console.log('当前OPENID是',res.result.openid) this.setData({ openid:res.result.openid }) wx.cloud.callFunction({ name: 'timer', data: { data: item, openid: this.data.openid, templateId: 'z0P4SZCU238iZNUU5NCN-UgAFHtQmDKPWC6H9ecxEow', }}).then(res=>{ console.log('订阅成功', res) }) .catch(res=>{ console.log('订阅失败', res) }) }) } else if(res['z0P4SZCU238iZNUU5NCN-UgAFHtQmDKPWC6H9ecxEow'] === 'reject'){ console.log('拒绝订阅', res) } }, fail: res => { console.log('授权失败', res) } }) }, 2.相关定时触发器代码如下: const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境 // 云函数入口函数 exports.main = async (event, context) => { try { const messages = event.data.item const sendPromises = messages.data.map(async message => { try { await cloud.callFunction({ name: 'send', data: { data: message.data, templateId: event.templateId, touser: event.openid, } }); // 发送成功后将消息的状态改为已发送 } catch (e) { return e; } }); return Promise.all(sendPromises); } catch (err) { console.log(err); return err; } } 3.发送订阅消息云函数代码如下: const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) exports.main = async (event, context) => { cloud.openapi.subscribeMessage.send({ touser: event.openid, page: 'pages/query/index/index', data:{ "thing10":{ "value":event.data.line }, "thing11":{ "value":event.data.postion }, "thing12":{ "value":event.data.reporter }, "time13":{ "value":event.data.cdate }, "thing2":{ "value":event.data.status }, }, templateId: event.templateId, }) };
2022-10-26 - 订阅消息问题?
调用JS如下: tuisong() { console.log(this.data.rec) var item = { "time1": { "value": this.dateFormat(this.data.rec[1].cdate) }, "thing2": { "value": this.data.rec[1].line }, "thing3": { "value": this.data.rec[1].postion }, "thing4": { "value": this.data.rec[1].status } } wx.requestSubscribeMessage({ tmplIds: ['R88OQ7kzfTRYe0yFXbdtz_gtPQtlPGc-bt9V-TzQAZE'], //这里填入我们生成的模板id success: res => { if (res.errMsg === 'requestSubscribeMessage:ok') { console.log('授权成功', res) wx.cloud.callFunction({ name: 'getopenid', }).then(res=>{ console.log('当前OPENID是',res.result.openid) this.setData({ openid:res.result.openid }) wx.cloud.callFunction({ name: 'send', data: { data: item, openid: this.data.openid, templateId: 'R88OQ7kzfTRYe0yFXbdtz_gtPQtlPGc-bt9V-TzQAZE', }}).then(res=>{ console.log('订阅成功', res) }) .catch(res=>{ console.log('订阅失败', res) }) }) } }, fail: res => { console.log('授权失败', res) } }) }, 云函数如下: const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) exports.main = async (event, context) => { return cloud.openapi.subscribeMessage.send({ touser: event.openid, page: 'pages/query/index/index', data: event.data, templateId: event.templateId, }) }; 错误提示: 订阅失败 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 063184d2-56ce-474d-83f2-2349b16d26f2, cloud function service error code -504002, error message TypeError: Do not know how to serialize a BigInt at JSON.stringify (<anonymous>) at callback (:19586/var/runtime/node12/CallbackContext.js:31) at :19586/var/runtime/node12/CallbackContext.js:81 at :19586/var/runtime/node12/Runtime.engine.js:237 at processTicksAndRejections (:19586/appservice/internal/process/task_queues.js:97); at cloud.callFunction api; at new t (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:17) at u (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:17) at l (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:17) at Function.success (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:17) at f (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:2) at WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:2 at f (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:26) at Function.<anonymous> (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:26) at f (WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:2) at WASubContext.js?t=wechat&s=1666316963773&v=2.14.1:2
2022-10-21