更新了两个mock的常量

This commit is contained in:
Xu Chang 2023-02-09 14:38:52 +08:00
parent 6ecf53dcf6
commit 17d2435475
4 changed files with 8 additions and 6 deletions

View File

@ -121,7 +121,7 @@ var WechatPublicInstance = /** @class */ (function () {
var result, nickname, sex, headimgurl;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.access("https://api.weixin.qq.com/sns/userinfo?access_token=".concat(accessToken, "&openid=").concat(openId, "&lang=zh_CN"), { nickname: '张三丰', sex: 1, headimgurl: 'hhttps://www.ertongzy.com/uploads/allimg/161005/2021233Y7-0.jpg' })];
case 0: return [4 /*yield*/, this.access("https://api.weixin.qq.com/sns/userinfo?access_token=".concat(accessToken, "&openid=").concat(openId, "&lang=zh_CN"), { nickname: '张三丰', sex: 1, headimgurl: 'https://www.ertongzy.com/uploads/allimg/161005/2021233Y7-0.jpg' })];
case 1:
result = _a.sent();
nickname = result.nickname, sex = result.sex, headimgurl = result.headimgurl;
@ -140,12 +140,13 @@ var WechatPublicInstance = /** @class */ (function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.access("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".concat(this.appId, "&secret=").concat(this.appSecret), { access_token: 'mockToken', expires_in: 3600 * 1000 })];
case 0: return [4 /*yield*/, this.access("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".concat(this.appId, "&secret=").concat(this.appSecret), { access_token: 'mockToken', expires_in: 600 })];
case 1:
result = _a.sent();
access_token = result.access_token, expires_in = result.expires_in;
this.accessToken = access_token;
// 生成下次刷新的定时器
console.log((expires_in - 10) * 1000);
this.refreshAccessTokenHandler = setTimeout(function () {
_this.refreshAccessToken();
}, (expires_in - 10) * 1000);

View File

@ -98,7 +98,7 @@ var WechatWebInstance = /** @class */ (function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.access("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".concat(this.appId, "&secret=").concat(this.appSecret), { access_token: 'mockToken', expires_in: 3600 * 1000 })];
case 0: return [4 /*yield*/, this.access("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".concat(this.appId, "&secret=").concat(this.appSecret), { access_token: 'mockToken', expires_in: 600 })];
case 1:
result = _a.sent();
access_token = result.access_token, expires_in = result.expires_in;

View File

@ -119,7 +119,7 @@ export class WechatPublicInstance {
async getUserInfo(accessToken: string, openId: string) {
const result = await this.access(
`https://api.weixin.qq.com/sns/userinfo?access_token=${accessToken}&openid=${openId}&lang=zh_CN`,
{ nickname: '张三丰', sex: 1, headimgurl: 'hhttps://www.ertongzy.com/uploads/allimg/161005/2021233Y7-0.jpg' }
{ nickname: '张三丰', sex: 1, headimgurl: 'https://www.ertongzy.com/uploads/allimg/161005/2021233Y7-0.jpg' }
);
const { nickname, sex, headimgurl } = result;
return {
@ -132,11 +132,12 @@ export class WechatPublicInstance {
private async refreshAccessToken() {
const result = await this.access(
`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${this.appId}&secret=${this.appSecret}`,
{ access_token: 'mockToken', expires_in: 3600 * 1000 }
{ access_token: 'mockToken', expires_in: 600 }
);
const { access_token, expires_in } = result;
this.accessToken = access_token;
// 生成下次刷新的定时器
console.log((expires_in - 10) * 1000);
this.refreshAccessTokenHandler = setTimeout(() => {
this.refreshAccessToken();
}, (expires_in - 10) * 1000);

View File

@ -83,7 +83,7 @@ export class WechatWebInstance {
private async refreshAccessToken() {
const result = await this.access(
`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${this.appId}&secret=${this.appSecret}`,
{ access_token: 'mockToken', expires_in: 3600 * 1000 }
{ access_token: 'mockToken', expires_in: 600 }
);
const { access_token, expires_in } = result;
this.accessToken = access_token;