lrf 1 年之前
父節點
當前提交
d100a86d2f
共有 3 個文件被更改,包括 13 次插入7 次删除
  1. 1 1
      app/controller/user/config/.user.js
  2. 5 1
      app/controller/view/config/.goods.js
  3. 7 5
      app/service/user/user.js

+ 1 - 1
app/controller/user/config/.user.js

@@ -50,7 +50,7 @@ module.exports = {
     requestBody: ['!phone', '!password'],
   },
   wxLogin: {
-    requestBody: ['!openid'],
+    requestBody: ['!openid', '!shop'],
   },
   toBindEmail: {
     requestBody: ['!id', '!email'],

+ 5 - 1
app/controller/view/config/.goods.js

@@ -23,6 +23,10 @@ module.exports = {
   },
   iatg: {
     service: 'indexActTagsGoods',
-    shop: 'shop',
+    parameters: {
+      query: {
+        shop: 'shop',
+      },
+    },
   },
 };

+ 7 - 5
app/service/user/user.js

@@ -23,13 +23,14 @@ class UserService extends CrudService {
   async beforeCreate(data) {
     const openid = _.get(data, 'openid');
     const phone = _.get(data, 'phone');
+    const shop = _.get(data, 'shop');
     if (!openid && phone) {
       const num = await this.model.count({ phone });
       if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '该手机号已注册');
-    } else if (openid) {
-      const num = await this.model.count({ openid });
+    } else if (openid && shop) {
+      const num = await this.model.count({ openid, shop });
       if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '该微信号已注册');
-    }
+    } else throw new BusinessError(ErrorCode.BADPARAM, '参数不正确');
     return data;
   }
 
@@ -67,10 +68,11 @@ class UserService extends CrudService {
    * 微信登录
    * @param {Object} body 登陆参数
    * @param body.openid 微信小程序的openid
+   * @param body.shop 店铺id
    */
-  async wxLogin({ openid }) {
+  async wxLogin({ openid, shop }) {
     const { populate } = this.getRefMods();
-    const user = await this.model.findOne({ openid }).populate(populate);
+    const user = await this.model.findOne({ openid, shop }).populate(populate);
     if (!user) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
     const { status } = user;
     if (status !== '0') throw new BusinessError(ErrorCode.USER_NOT_BIND, '该账号处于禁止使用状态');