From 55949f95a609733d1771d5b017d679cd7d1f005d Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 20 十二月 2024 17:33:17 +0800 Subject: [PATCH] 题库加入购物车优化 --- assets/js/userAction.js | 76 ++++++------------------------------- 1 files changed, 13 insertions(+), 63 deletions(-) diff --git a/assets/js/userAction.js b/assets/js/userAction.js index 8ecf23a..cdfd7e3 100644 --- a/assets/js/userAction.js +++ b/assets/js/userAction.js @@ -1,40 +1,20 @@ -import config from "@/assets/js/config.js"; - -import jobApi from "./middleGround/api/job"; // newJobWithNewView // newSession, +import config from "./config.js"; +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 => { - storage.set("sessionGuid", res, 30); + wx.setStorageSync("sessionGuid", res); setNewView(type, id); }); } @@ -82,43 +62,13 @@ }, }; -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 (!sessionStorage.getItem("sessionGuid")) { + if (!wx.getStorageSync("sessionGuid")) { setSessionGuid(type, id); } - - const sessionGuid = sessionStorage.getItem("sessionGuid"); - const fromPath = sessionStorage.getItem("fromPath"); - const toPath = sessionStorage.getItem("toPath"); + const sessionGuid = wx.getStorageSync("sessionGuid"); + const fromPath = wx.getStorageSync("fromPath"); + const toPath = wx.getStorageSync("toPath"); if (sessionGuid) { let params = { sessionGuid: sessionGuid, @@ -130,6 +80,6 @@ if (id) { params[type] = id; } - jobApi.newJobWithNewView(params).then(res => {}); + jobApi.newJobWithNewView(params).then(res => { }); } } \ No newline at end of file -- Gitblit v1.9.1