We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
封装了一个co发送一条模板消息的方法,然后co 调用并发,但是却不能接受到所有的模板消息,微信用户接受模板消息有限制吗? 1:封装方法
function* cosendfc(prepareid){ let API = require('wechat-api'); let api = new API(defaultAppid, defaultsecrut, function (callback) { // 传入一个获取全局token的方法 client.hget(hash_currTickets,defaultAppid, function(err, ret){ if(err){ return callback('[90]hget error. err=' + err); } // return callback(null,JSON.parse(ret)); var currACTicket = JSON.parse(ret); if (currACTicket !== undefined && currACTicket !== null && currACTicket !== '') { return callback(null,currACTicket); }else{ return callback(null,{ access_token: '', expire_time: 0 }); } }); }, function (token, callback) { // 请将token存储到全局,跨进程、跨机器级别的全局,比如写到数据库、redis等 client.hset(hash_currTickets, defaultAppid, JSON.stringify(token), function(err, ret){ if(err){ return callback('[109]hset error. err=' + err); } return callback(null); }); }); var sendinfo = ''; let statu = Promise.resolve(new Promise( (resolve,reject) => client.hget(store_prepare,prepareid,(err, res) => err ? reject(err) : resolve(res)) )); let length = Promise.resolve(new Promise( (resolve,reject) => client.llen(prepareid,(err, res) => err ? reject(err) : resolve(res)) )); let lpopcontent = Promise.resolve(new Promise( (resolve,reject) => client.lpop(prepareid,(err, res) => err ? reject(err) : resolve(res)) )); sendinfo = JSON.parse(lpopcontent); console.log(sendinfo); let openid = sendinfo.openid; let templateId = sendinfo.templateId; let data = sendinfo.data; let url = sendinfo.url; let uid = sendinfo.uid; data.first.value = Math.floor(Math.random() * 10000 + 1);//测试的代码,上线需注释 data.keyword1.value = Math.floor(Math.random() * 10000 + 1);//测试的代码,上线需注释 let sendtesult = Promise.resolve(new Promise( (resolve,reject) => api.sendTemplate(openid,templateId,url,data,(err, res) => err ? resolve(err) : resolve(res)) )); return sendtesult; }
2:co并发处理
co(function* () { var rs = yield [ cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), //10 cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), cosendfc(prepareid), //20 ]; return rs; }).then(function (value) { console.log(value); return callback(null,value); });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
封装了一个co发送一条模板消息的方法,然后co 调用并发,但是却不能接受到所有的模板消息,微信用户接受模板消息有限制吗?
1:封装方法
2:co并发处理
The text was updated successfully, but these errors were encountered: