yuliang 5 éve
szülő
commit
0eba1beaf8

+ 86 - 0
admin-ui/app/whepi/ceshi.js

@@ -0,0 +1,86 @@
+define(function (require) {
+  return function (context) {
+
+    var $form, $form1;
+
+    //检查查询
+    function queryGrid1() {
+      var obj = $form.formGet();
+      if (obj.we == "") {
+        $.yvan.msg('请选择电话号码');
+        return false;
+      }
+      return true;
+    }
+
+    //检查查询
+    function queryGrid2() {
+      var obj = $form1.formGet();
+      if (obj.uptownId == "") {
+        $.yvan.msg('请选择小区');
+        return false;
+      }
+      if (obj.date == "") {
+        $.yvan.msg('请选择导出时间');
+        return false;
+      }
+      return true;
+    }
+
+    return {
+      center: {
+        border: false,
+        title: '数据处理',
+        items: [
+          {
+            onRender: function () {
+              $form = $(this);
+            },
+            xtype: 'formgroup',
+            title: '',
+            items: [
+              [
+                {
+                  xtype: 'textbox',
+                  label: '电话号码',
+                  name: 'we',
+                  prompt: '请输入要添加的电话号码',
+                  labelWidth: 'auto',
+                  id: 'we',
+                },
+              ]
+            ]
+          },
+          {
+            xtype: 'group',
+            title: '具体操作',
+            items: [
+              [{xtype: 'offset'},
+                {
+                  xtype: 'button', text: '授权测试', class: 'button-blue', onClick: function () {
+                    if (!queryGrid1()) {
+                      return;
+                    }
+                    var a = $form.formGet()
+
+                    $.yvan.ajax({
+                      method: 'post',
+                      url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa3991865de920847&redirect_uri=http://yuliang.ng.yvanui.com/userOpen/loginTest&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect',
+                      data: $form.formGet(),
+                      success: function (data) {
+                        $.yvan.msg('操作成功');
+                        return;
+                      }
+                    });
+
+
+                  }
+                },
+              ],
+            ]
+          }
+        ]
+      },
+    };
+  };
+});

+ 25 - 0
whepi-web/src/main/java/com/bofeng/controller/WxUserOpenController.java

@@ -8,10 +8,15 @@ import com.bofeng.entity.UserRole;
 import com.bofeng.service.HomeService;
 import com.bofeng.service.WxUserOpenService;
 import com.yvan.Model;
+import com.yvan.ModelOps;
 import com.yvan.platform.JsonWapper;
 import com.yvan.platform.StringUtils;
+import com.yvan.springmvc.HttpParameterParser;
+import com.yvan.springmvc.HttpUtils;
 import io.swagger.annotations.ApiOperation;
+import lombok.val;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -30,6 +35,26 @@ public class WxUserOpenController {
     @Autowired
     private WxUserOpenService wxUserOpenService;
 
+    @GetMapping("/userOpen/loginTest")
+    public Model<UserOpen> loginTest() {
+        val parser = HttpParameterParser.newInstance(HttpUtils.currentRequest());
+        String openId = parser.getString("openId");
+        String code = parser.getString("code");
+        if (StringUtils.isNullOrEmpty(code)) {
+            return Model.newFail("code为空");
+        }
+        UserOpen userOpen = homeService.getUserOpenByCode(code);
+        if (userOpen == null) {
+            return Model.newFail("微信登录失败");
+        }
+        //成功返回用户Id
+        try {
+            return Model.newSuccess(userOpen);
+        } catch (Exception e) {
+            return Model.newFail(e.getMessage());
+        }
+    }
+
     @ApiOperation("用户注册页面点登录")
     @PostMapping("/userOpen/login")
     public Model<UserOpen> login(JsonWapper jsonWapper) {