Commit 22f7cc82 by 李嘉林

index-params解析

parent ee63910b
...@@ -58,4 +58,8 @@ export default { ...@@ -58,4 +58,8 @@ export default {
queryProductInformation(productId) { queryProductInformation(productId) {
return requestGET(`${process.env.OLSHOP_URL}/product/queryProductInformation?productId=${productId}`) return requestGET(`${process.env.OLSHOP_URL}/product/queryProductInformation?productId=${productId}`)
}, },
// 记录分销员分享商品信息
saveSpokesmanShareGoodsLog(data) {
return requestGET(`${process.env.OLSHOP_URL}/product/saveSpokesmanShareGoodsLog`, data)
},
}; };
...@@ -9,10 +9,12 @@ let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default; ...@@ -9,10 +9,12 @@ let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
let getUrlKey = require("mayi-front-tools/getUrlKey").default; let getUrlKey = require("mayi-front-tools/getUrlKey").default;
import spokesman from "@/api/spokesman.js"; import spokesman from "@/api/spokesman.js";
import shop from "@/api/shop.js"; import shop from "@/api/shop.js";
import goods from "@/api/goods.js";
import indexApi from "@/api/index.js"; import indexApi from "@/api/index.js";
import { serialize, getQueryVariable, DFSImg, parseQueryString } from "@/utils/index"; import { serialize, getQueryVariable, DFSImg, parseQueryString } from "@/utils/index";
import login from "@/api/login"; import login from "@/api/login";
import { getStoreInfo, setStoreInfo } from "@/utils/mayi.js"; import { getStoreInfo, setStoreInfo } from "@/utils/mayi.js";
import tool from '@/utils/tool.js'
const app = getApp(); const app = getApp();
const { log } = app; const { log } = app;
export default { export default {
...@@ -152,11 +154,18 @@ export default { ...@@ -152,11 +154,18 @@ export default {
wx.setStorageSync(this.$store.state.mixid+'storeId','') wx.setStorageSync(this.$store.state.mixid+'storeId','')
wx.setStorageSync(this.$store.state.mixid+'sellerId','') wx.setStorageSync(this.$store.state.mixid+'sellerId','')
} }
Object.assign(this.$data, this.$options.data());
this.options = options; this.options = options;
log.info(this.options,'----------------index-----options') log.info(this.options,'----------------index-----options')
Object.assign(this.$data, this.$options.data()); let h5Params = {};
try { if (options.params) {
const h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : ""; if (tool.isObjectString(options.params)) {
h5Params = JSON.parse(decodeURIComponent(options.params));
} else {
h5Params = parseQueryString(decodeURIComponent(options.params));
}
}
console.log("onLoad-h5Params", h5Params);
if (h5Params && h5Params.offlineShopCode) { if (h5Params && h5Params.offlineShopCode) {
// 存储h5url门店信息 // 存储h5url门店信息
setStoreInfo({ setStoreInfo({
...@@ -164,7 +173,6 @@ export default { ...@@ -164,7 +173,6 @@ export default {
offlineShopName:h5Params.offlineShopName, offlineShopName:h5Params.offlineShopName,
}); });
} }
} catch (e) { console.log(e) }
if(wx.getStorageSync("workBox")){ if(wx.getStorageSync("workBox")){
this.params += `&workBox=${wx.getStorageSync("workBox")}` this.params += `&workBox=${wx.getStorageSync("workBox")}`
} }
...@@ -211,6 +219,7 @@ export default { ...@@ -211,6 +219,7 @@ export default {
this.link = decodeURIComponent(options.share); this.link = decodeURIComponent(options.share);
log.info('options.share-link',this.link) log.info('options.share-link',this.link)
console.log('options.share-link',this.link) console.log('options.share-link',this.link)
console.log('options.share-options',this.options)
this.spokesmanGroupId = this.spokesmanGroupId =
getQueryVariable(this.link, "spokesmanGroupId") || ""; getQueryVariable(this.link, "spokesmanGroupId") || "";
this.spokesmanShopId = this.spokesmanShopId =
...@@ -236,6 +245,8 @@ export default { ...@@ -236,6 +245,8 @@ export default {
} }
this.page = ""; this.page = "";
this.params = ""; this.params = "";
// 记录分销员分享商品信息
// this.saveSpokesmanShareGoodsLog();
} else if (options.from && options.from == "h5login") { } else if (options.from && options.from == "h5login") {
let params = JSON.parse(options.params); let params = JSON.parse(options.params);
log.info(params.sessionid,'--------------h5login--params') log.info(params.sessionid,'--------------h5login--params')
...@@ -642,6 +653,20 @@ export default { ...@@ -642,6 +653,20 @@ export default {
url = beforeUrl + nextUrl; url = beforeUrl + nextUrl;
return url; return url;
}, },
saveSpokesmanShareGoodsLog() {
let query = {
spokesmanGroupId: getQueryVariable(this.link, "spokesmanGroupId") || "",
spokesmanRelId: getQueryVariable(this.link, "spokesmanRelId") || "",
userId: getQueryVariable(this.link, "userId") || "",
productId: getQueryVariable(this.link, "productId") || "",
terminalProductId: getQueryVariable(this.link, "terminalProductId") || "",
mixid: getQueryVariable(this.link, "mixid") || "",
spokesmanShopId: getQueryVariable(this.link, "spokesmanShopId") || "",
timeStamp: getQueryVariable(this.link, "timeStamp") || "",
}
console.log("saveSpokesmanShareGoodsLog", query)
goods.saveSpokesmanShareGoodsLog(query);
}
}, },
onUnload() { onUnload() {
log.info("卸载----------------", this.options); log.info("卸载----------------", this.options);
......
...@@ -68,7 +68,7 @@ export function getQueryVariable(query, variable) { ...@@ -68,7 +68,7 @@ export function getQueryVariable(query, variable) {
// url完整链接把参数转成对象 // url完整链接把参数转成对象
export function parseQueryString(url) { export function parseQueryString(url) {
let str = url.split("?")[1], let str = url.split("?").length > 1 ? url.split("?")[1] : url,
items = str.split("&"); items = str.split("&");
let arr, name, value; let arr, name, value;
let obj={} let obj={}
......
...@@ -23,6 +23,12 @@ export async function requestGET(url, options) { ...@@ -23,6 +23,12 @@ export async function requestGET(url, options) {
resolve(res) resolve(res)
}, },
fail: function (res) { fail: function (res) {
if (res.data.message && res.data.message == "API rate limit exceeded") {
wx.showToast({
title: '您好,当前访问人数过多,请稍后再试试',
icon: 'none',
});
}
reject(res) reject(res)
} }
}) })
...@@ -48,6 +54,12 @@ export async function requestPOST(url, options) { ...@@ -48,6 +54,12 @@ export async function requestPOST(url, options) {
resolve(res) resolve(res)
}, },
fail: function (res) { fail: function (res) {
if (res.data.message && res.data.message == "API rate limit exceeded") {
wx.showToast({
title: '您好,当前访问人数过多,请稍后再试试',
icon: 'none',
});
}
reject(res) reject(res)
} }
}) })
......
...@@ -45,9 +45,23 @@ function debounce(fn, interval) { ...@@ -45,9 +45,23 @@ function debounce(fn, interval) {
}, gapTime); }, gapTime);
}; };
} }
/**
* 判断字符串对象
* @param {*} str 目标参数
* @returns
*/
function isObjectString(str) {
try {
JSON.parse(str);
return true;
} catch (e) {
return false;
}
}
export default { export default {
throttle, throttle,
debounce, debounce,
appArea appArea,
isObjectString
}; };
Markdown is supported
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