import md5 from "_js-md5@0.7.3@js-md5";網絡
pay() {
console.log(md5);
console.log(md5("123"));
var timeStamp = (new Date()).getTime() + "";
var noncestr = "46kUt3rht6K5tY38";
var pak = "prepay_id=wx271305096966822a8e1bdd833696284909";
var str =
"appId=" +
"wx222e561f71d412f0" +
"&" +
"nonceStr=" +
noncestr +
"&" +
"package=" +
pak +
"&" +
"signType=MD5&timeStamp=" +
timeStamp +
"&" +
"key=" +
"YS2Y0234DASDxxxadCVBSDX678K17APY";
var ps = md5(str);
console.log(ps);
wx.requestPayment({
timeStamp: timeStamp,
nonceStr: noncestr,
package: pak,
signType: "MD5",
paySign: ps,
success(res) {
console.log("success");
},
fail(res) {
console.log("fail");
}
});
}
login() {
wx.login({
success: function(res) {
if (res.code) {
console.log(res.code)
//發起網絡請求
// wx.request({
// url: 'https://test.com/onLogin',
// data: {
// code: res.code
// }
// })
} else {
console.log('獲取用戶登陸態失敗!' + res.errMsg)
}
}
});
}
須要先引入js-md5
複製代碼