时间:2019-04-30 来源:小程序工厂
里面 safer-buffer 用到了 nodejs 的 buffer 模块导致,因为此处不会将 nodejs 的实现给打包进去,文档里有这个约束:
尝试多安装一个 buffer 包(https://github.com/feross/buffer )给 safer-buffer 使用试试?
这个js文件require了urlencode,然后被页面的index.js引用
const md5 = require('./md5.js');
const urlencode = require('urlencode');
const sortData = function (data) {
let keys = Object.keys(data).sort();
let result = {}
for (let i = 0; i < keys.length; i++) {
let value = data[keys[i]]
if (value instanceof Object) {
value = sortData(value)
}
result[keys[i]] = value
}
return result;
}
const makeUrl = function (method_tag, params) {
console.log('Call makeUrl:', method_tag, params)
let time = (new Date()).valueOf();
let token = 'test';
let tag = method_tag;
let params_str = JSON.stringify(sortData(params))
let sign_data = 'createTime=' + time + 'params=' + params_str+'tag='+tag+'token='+token;
let url = 'http://qae.qunar.com/api/router?';
let createTime = time;
let sign = md5.md5(sign_data).toLowerCase();
console.log(sign_data, sign.toLowerCase())
params_str = urlencode(params_str);
return url + 'token=' + token + '&tag' + method_tag + '&token' + token + '&createTime' + time + '¶ms' + params_str;
}
module.exports = {
makeUrl: makeUrl
}
麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题