Unverified Commit 6fec6b58 authored by beaver383's avatar beaver383 Committed by GitHub
Browse files

Merge pull request #1 from linlinjava/master

同步
parents c04bf486 5238b74e
......@@ -239,10 +239,12 @@ public class WxAuthController {
String password = JacksonUtil.parseString(body, "password");
String mobile = JacksonUtil.parseString(body, "mobile");
String code = JacksonUtil.parseString(body, "code");
// 如果是小程序注册,则必须非空
// 其他情况,可以为空
String wxCode = JacksonUtil.parseString(body, "wxCode");
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || StringUtils.isEmpty(mobile)
|| StringUtils.isEmpty(wxCode) || StringUtils.isEmpty(code)) {
|| StringUtils.isEmpty(code)) {
return ResponseUtil.badArgument();
}
......@@ -264,24 +266,28 @@ public class WxAuthController {
return ResponseUtil.fail(AUTH_CAPTCHA_UNMATCH, "验证码错误");
}
String openId = null;
try {
WxMaJscode2SessionResult result = this.wxService.getUserService().getSessionInfo(wxCode);
openId = result.getOpenid();
} catch (Exception e) {
e.printStackTrace();
return ResponseUtil.fail(AUTH_OPENID_UNACCESS, "openid 获取失败");
}
userList = userService.queryByOpenid(openId);
if (userList.size() > 1) {
return ResponseUtil.serious();
}
if (userList.size() == 1) {
LitemallUser checkUser = userList.get(0);
String checkUsername = checkUser.getUsername();
String checkPassword = checkUser.getPassword();
if (!checkUsername.equals(openId) || !checkPassword.equals(openId)) {
return ResponseUtil.fail(AUTH_OPENID_BINDED, "openid已绑定账号");
String openId = "";
// 非空,则是小程序注册
// 继续验证openid
if(!StringUtils.isEmpty(wxCode)) {
try {
WxMaJscode2SessionResult result = this.wxService.getUserService().getSessionInfo(wxCode);
openId = result.getOpenid();
} catch (Exception e) {
e.printStackTrace();
return ResponseUtil.fail(AUTH_OPENID_UNACCESS, "openid 获取失败");
}
userList = userService.queryByOpenid(openId);
if (userList.size() > 1) {
return ResponseUtil.serious();
}
if (userList.size() == 1) {
LitemallUser checkUser = userList.get(0);
String checkUsername = checkUser.getUsername();
String checkPassword = checkUser.getPassword();
if (!checkUsername.equals(openId) || !checkPassword.equals(openId)) {
return ResponseUtil.fail(AUTH_OPENID_BINDED, "openid已绑定账号");
}
}
}
......
......@@ -395,7 +395,7 @@ public class WxCartController {
LitemallAddress checkedAddress = null;
if (addressId == null || addressId.equals(0)) {
checkedAddress = addressService.findDefault(userId);
// 如果仍然没有地址,则是没有收地址
// 如果仍然没有地址,则是没有收地址
// 返回一个空的地址id=0,这样前端则会提醒添加地址
if (checkedAddress == null) {
checkedAddress = new LitemallAddress();
......
......@@ -30,6 +30,20 @@ public class WxCatalogController {
@Autowired
private LitemallCategoryService categoryService;
@GetMapping("/getfirstcategory")
public Object getFirstCategory() {
// 所有一级分类目录
List<LitemallCategory> l1CatList = categoryService.queryL1();
return ResponseUtil.ok(l1CatList);
}
@GetMapping("/getsecondcategory")
public Object getSecondCategory(@NotNull Integer id) {
// 所有二级分类目录
List<LitemallCategory> currentSubCategory = categoryService.queryByPid(id);
return ResponseUtil.ok(currentSubCategory);
}
/**
* 分类详情
*
......
......@@ -79,7 +79,7 @@ public class WxCouponController {
*/
@GetMapping("mylist")
public Object mylist(@LoginUser Integer userId,
@NotNull Short status,
Short status,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
......
......@@ -147,7 +147,7 @@
</view>
</view>
<view class="a-section a-topic" wx:if="topics.length > 0">
<view class="a-section a-topic" wx:if="topics.length > 0" hidden="{{topics.length <= 0}}">
<view class="h">
<view>
<navigator url="/pages/topic/topic">
......@@ -189,4 +189,4 @@
<view class="txt">{{'更多'+item.name+'好物 >'}}</view>
</navigator>
</view>
</view>
\ No newline at end of file
</view>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment