|
@@ -66,7 +66,38 @@ class LoginService extends CrudService {
|
|
|
return token;
|
|
|
}
|
|
|
|
|
|
+ // 微信校验mq接口
|
|
|
+ async wxcheck(data) {
|
|
|
+ const { qrcode, openid } = data;
|
|
|
+ assert(qrcode, 'qrcode不能为空');
|
|
|
+ assert(openid, 'openid不能为空');
|
|
|
+ // TODO: 发布扫码成功消息
|
|
|
+ const { mq } = this.ctx;
|
|
|
+ const ex = 'qrcode.login';
|
|
|
+ const parm = {
|
|
|
+ durable: true,
|
|
|
+ headers: {
|
|
|
+ openid,
|
|
|
+ } };
|
|
|
+ if (mq) {
|
|
|
+ await mq.topic(ex, qrcode, 'scaned', parm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 微信登录接口
|
|
|
async wxlogin(data) {
|
|
|
+ const { qrcode, openid } = data;
|
|
|
+ assert(qrcode, 'qrcode不能为空');
|
|
|
+ assert(openid, 'openid不能为空');
|
|
|
+ const res = await this.uModel.findOne({ openid });
|
|
|
+ if (!res) {
|
|
|
+ throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+ const result = await this.createJwt(res);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ async userbind(data) {
|
|
|
const { qrcode, openid } = data;
|
|
|
assert(qrcode, 'qrcode不能为空');
|
|
|
assert(openid, 'openid不能为空');
|