java后台实现小程序登录功能
前言
开发准备
流通图
流程介绍 注意啦:开发者服务器于开发者业务服务器是一样的(相当于 controller 和 service)
小程序端
html
js
/用户登陆 function userLogin() { wx.checkSession({ success: function () { //存在登陆态 }, fail: function () { //不存在登陆态 //调用登录function 其实可以直接使用下面的 } }) }
cofing.js(小程序的配置文件)
const localhost = http://169.254.235.123; const config = { hostApi: `http://localhost:8200`, //你的域名 // hostApi: `${localhost}:9120`, //你的域名 hostFile: `${localhost}:8080/files/thumbnails/`, //文件 httpCode:{ success:000000000 }, navigationBar: { backgroundColor: "#0D88FF", textStyle: "white" }, checkFrequency: { // 2: 日、3: 周、4: 月、5: 季、6: 年 2: { field: dayCount,label:日}, 3: { field: weekCount, label:周}, 4: { field: monthCount, label:月}, 5: { field: quarterCount, label:季}, 6: { field: yearCount, label:年} } } module.exports = config
服务端
@PostMapping("/getWexInfo") @ApiOperation(value = "根据加密文件 获取UnionID等信息") @ApiImplicitParam(name = "wexDTO", value = "参数列表:" + "<br/>iv:iv 加密算法的初始向量 必填 " + "<br/>code:wx.login时获取,后期用于serssion_key 必填 " + "<br/>encryptedData:密文,被加密的数据 必填 " , dataType = "WexDTO", required = true) public ResultResponse getWexInfo(@Validated(WexDTO.ValidSave.class) @RequestBody WexDTO wexDTO, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return ResultResponse.wrap(bindingResult.getFieldError().getDefaultMessage()); } ResultResponseresultResponse = this.accountService.getWexInfo(wexDTO); if (resultResponse.getCode().equals(IfConstant.SERVER_SUCCESS.getCode())) { Account account = (Account) resultResponse.getData(); AccountDTO accountDTO = new AccountDTO(); accountDTO.setMobilephone(account.getMobilephone()); accountDTO.setPassword(account.getPassword()); return loginQyForApp(accountDTO, bindingResult); } return resultResponse; }
注意了:只是思路 这里缺少类:WexDTO,accountDTO,ResultResponse,
这里缺少更多了 算了:不弄着这个
> 注:如果看到这里有啥疑问,可以留言哦
上一篇:
uniapp开发微信小程序-2.页面制作
下一篇:
uni-app 实现微信授权登录