赞
踩
1、先通过checkSession检测是否处于登录状态(小程序端)
- //保持登录状态
- keeplogin: function () {
- var that = this;
- //用户授权
- wx.login({
- success: function (res) {
- api.request('/getSessionKey', {
- code: res.code
- }).then(res => {
- if (res.status == 200) {
- that.setData({
- session_key: ress.data.data
- })
- }
- }).catch(err => {
- api.showToast("接口异常");
- });
- }
- })
- },

后端获取 session_key
- /**
- * 获取session_key
- * @param encryptedData
- * @param iv
- * @param code
- * @return
- */
- @ResponseBody
- @RequestMapping("/getSessionKey")
- public Map<String, Object> getSessionKey(String code) {
- Map<String, Object> map = new HashMap<>();
- try {
- // 登录凭证不能为空
- if (code == null || code.length() == 0) {
- map.put("status",
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。