Commit 22f7cc82 by 李嘉林

index-params解析

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