闫增涛
2024-03-27 696a0561d73970efdef2136d111269f626369fc9
登录功能记录登录信息完善
3个文件已修改
62 ■■■■ 已修改文件
assets/js/login.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
assets/js/userAction.js 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/bindInfo/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
assets/js/login.js
@@ -49,7 +49,7 @@
                      // 获取用户信息
                      getUserInfo(app, callback, res.token)
                      // 记录登录统计
                      // setSessionGuid()
                      setSessionGuid()
                    } else {
                      console.log(res);
                      callback(false)
assets/js/userAction.js
@@ -2,34 +2,15 @@
import jobApi from "./middleGround/api/job";// newJobWithNewView // newSession,
export function setSessionGuid(type, id) {
  var cityCode = null;
  var SnIp = null;
  try {
    // eslint-disable-next-line
    // SnIp = window.returnCitySN;
  } catch (error) {
    SnIp = null;
    console.log(error);
  }
  if (SnIp != undefined && SnIp != null) {
    cityCode = SnIp;
  } else {
    cityCode = {
      cip: "0.0.0.0",
      cname: "未知",
    };
  }
  const _city = cityCode.cname.substring(3);
  const _province = cityCode.cname.substring(0, 3);
  const params = {
    appRefCode: config.appRefCode,
    hostName: config.requestCtx,
    ipAddress: cityCode.cip,
    browser: myBrowser(),
    os: navigator.platform,
    ipAddress: "0.0.0.0", // 后台获取,前台随便传
    browser: 'WeChatApp',
    os: 'WeChat',
    device: "pc",
    province: _province,
    city: _city ? _city : _province,
    province: "未知",// 后台获取,前台随便传
    city: "未知",// 后台获取,前台随便传
  };
  jobApi.newSession(params).then(res => {
@@ -80,35 +61,6 @@
    return val;
  },
};
function myBrowser() {
  const userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  const isOpera = userAgent.indexOf("Opera") > -1;
  if (isOpera) {
    //判断是否Opera浏览器
    return "Opera";
  }
  if (userAgent.indexOf("Firefox") > -1) {
    //判断是否Firefox浏览器
    return "Firefox";
  }
  if (userAgent.indexOf("Chrome") > -1) {
    return "Chrome";
  }
  if (userAgent.indexOf("Safari") > -1) {
    //判断是否Safari浏览器
    return "Safari";
  }
  if (
    userAgent.indexOf("compatible") > -1 &&
    userAgent.indexOf("MSIE") > -1 &&
    !isOpera
  ) {
    //判断是否IE浏览器
    return "IE";
  }
  return "";
}
export function setNewView(type, id) {
  if (!wx.getStorageSync("sessionGuid")) {
pages/bindInfo/index.js
@@ -59,7 +59,7 @@
                // 获取用户信息
                this.getUserInfo()
                // 记录登录统计
                // setSessionGuid()
                setSessionGuid()
              } else {
                wx.showToast({
                  icon: "error",