|
@@ -0,0 +1,1823 @@
|
|
|
+```
|
|
|
+<style lang="scss">
|
|
|
+
|
|
|
+/* 如果有其他引入,合并即可,该文件最好放第一行 */
|
|
|
+
|
|
|
+@import "@kip/ui-mobile/theme/theme.css";
|
|
|
+
|
|
|
+</style>
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+const livePlayer = requirePlugin("live-player-plugin");
|
|
|
+
|
|
|
+import {
|
|
|
+
|
|
|
+REG_SOURCE,
|
|
|
+
|
|
|
+CRM_APP_PATH,
|
|
|
+
|
|
|
+KIP_API_CODE,
|
|
|
+
|
|
|
+TEST_BRAND_ID,
|
|
|
+
|
|
|
+MODEL_LBS_MAP_GROUP,
|
|
|
+
|
|
|
+} from "@/constants.js";
|
|
|
+
|
|
|
+import {getLocationAndSetDefaultMarket} from "@/utils/location.js";
|
|
|
+
|
|
|
+import log from "@/utils/log.js";
|
|
|
+
|
|
|
+import KipCacheTool from "@/utils/kip-cache-tool.js";
|
|
|
+
|
|
|
+import store from "@/store/index.js";
|
|
|
+
|
|
|
+import {crmGetMiniCodeParam} from "@/utils/api-crm-member.js";
|
|
|
+
|
|
|
+import {
|
|
|
+
|
|
|
+kipCheckToken,
|
|
|
+
|
|
|
+kipGetNewAccessTokenByRefreshToken,
|
|
|
+
|
|
|
+kipAllCities,
|
|
|
+
|
|
|
+kipRoomShare,
|
|
|
+
|
|
|
+} from "@/utils/api-kip.js";
|
|
|
+
|
|
|
+import {setDefaultMarket} from "@/utils/location-util.js";
|
|
|
+
|
|
|
+import MemberCacheTool from "@/utils/member-cache-tool.js";
|
|
|
+
|
|
|
+import {
|
|
|
+
|
|
|
+isKOMiniApp,
|
|
|
+
|
|
|
+buildExtraData,
|
|
|
+
|
|
|
+kipCitiesToCrmMarket,
|
|
|
+
|
|
|
+} from "@/utils/utils.js";
|
|
|
+
|
|
|
+import CacheTool from "@/utils/cache-tool.js";
|
|
|
+
|
|
|
+// import sensors from 'sa-sdk-miniprogram'
|
|
|
+
|
|
|
+import sensors from "@/utils/Sensorsdata-UniPlugin-JS";
|
|
|
+
|
|
|
+import {trackingInit} from "@/utils/tracking.js";
|
|
|
+
|
|
|
+import Vue from "vue";
|
|
|
+
|
|
|
+import Monitor from "@/utils/monitor.js";
|
|
|
+
|
|
|
+import moment from "@/common/js/moment.min.js";
|
|
|
+
|
|
|
+import {checkLocationPermission} from "@/utils/location.js";
|
|
|
+
|
|
|
+import {getWxEasyPointsCommitStatus} from "@/utils/wx-points-commit-status.js";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+let isKipAllCitiesResolved = false;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export default Monitor.hookApp({
|
|
|
+
|
|
|
+onLaunch: function (options) {
|
|
|
+
|
|
|
+uni.removeStorageSync("miniCodeParamsSameTime");
|
|
|
+
|
|
|
+const getAppAuthorizeSetting = wx.getAppAuthorizeSetting();
|
|
|
+
|
|
|
+const getDeviceInfo = wx.getDeviceInfo();
|
|
|
+
|
|
|
+const getWindowInfo = wx.getWindowInfo();
|
|
|
+
|
|
|
+const getAppBaseInfo = wx.getAppBaseInfo();
|
|
|
+
|
|
|
+const systemSetting = wx.getSystemSetting();
|
|
|
+
|
|
|
+uni.setStorageSync("wx_getAppAuthorizeSetting", getAppAuthorizeSetting);
|
|
|
+
|
|
|
+uni.setStorageSync("wx_getDeviceInfo", getDeviceInfo);
|
|
|
+
|
|
|
+uni.setStorageSync("wx_getWindowInfo", getWindowInfo);
|
|
|
+
|
|
|
+uni.setStorageSync("wx_getAppBaseInfo", getAppBaseInfo);
|
|
|
+
|
|
|
+uni.setStorageSync("wx_systemSetting", systemSetting);
|
|
|
+
|
|
|
+uni.removeStorageSync("miniCodeParamsSameTime");
|
|
|
+
|
|
|
+uni.removeStorageSync("miniCodeParams");
|
|
|
+
|
|
|
+uni.removeStorageSync("queryScene");
|
|
|
+
|
|
|
+uni.removeStorageSync("querySaUtm");
|
|
|
+
|
|
|
+if (
|
|
|
+
|
|
|
+options &&
|
|
|
+
|
|
|
+options.path &&
|
|
|
+
|
|
|
+options.path.indexOf("pages/package-parkingFee/parkingFeeWebViewLogin") >
|
|
|
+
|
|
|
+-1
|
|
|
+
|
|
|
+) {
|
|
|
+
|
|
|
+uni.showLoading({
|
|
|
+
|
|
|
+title: "正在加载中~",
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const BEIJING_OUT_OF_KO = uni.getStorageSync("BEIJING_OUT_OF_KO");
|
|
|
+
|
|
|
+if (!BEIJING_OUT_OF_KO) {
|
|
|
+
|
|
|
+uni.setStorageSync("BEIJING_OUT_OF_KO", false);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+console.log(`===> App.vue onLaunch <===`, options);
|
|
|
+
|
|
|
+if (options.query?.mallid) {
|
|
|
+
|
|
|
+uni.setStorageSync("mallid", options.query.mallid);
|
|
|
+
|
|
|
+const stage = CacheTool.getEnv();
|
|
|
+
|
|
|
+let brandId = "";
|
|
|
+
|
|
|
+MODEL_LBS_MAP_GROUP[stage].forEach((elm) => {
|
|
|
+
|
|
|
+if (elm.lbsId === options.query.mallid) {
|
|
|
+
|
|
|
+brandId = elm.brandId;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+if (brandId) {
|
|
|
+
|
|
|
+uni.setStorageSync("groupId", brandId);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+setDefaultMarket(this, store, null, options.query.mallid, false, false);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+uni.removeStorageSync("alipayIntegralJump");
|
|
|
+
|
|
|
+if (options) {
|
|
|
+
|
|
|
+uni.setStorageSync("loginUser", options);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+async onShow(options) {
|
|
|
+
|
|
|
+uni.removeStorageSync("miniCodeParamsSameTime");
|
|
|
+
|
|
|
+if (options) {
|
|
|
+
|
|
|
+uni.setStorageSync("loginUser", options);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+this.globalData.isFirstEnter = true;
|
|
|
+
|
|
|
+try {
|
|
|
+
|
|
|
+if (uni.getStorageSync("openId")) {
|
|
|
+
|
|
|
+var myPluginInterface = requirePlugin("selfAutoPoints");
|
|
|
+
|
|
|
+myPluginInterface
|
|
|
+
|
|
|
+.getLocation(uni.getStorageSync("openId"))
|
|
|
+
|
|
|
+.then((res) => {
|
|
|
+
|
|
|
+console.log("selfServicePoints-=-=res", res);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.log("===>获取位置信息(getLocationAndSetDefaultMarket)-=-=001");
|
|
|
+
|
|
|
+getLocationAndSetDefaultMarket(this, store, setDefaultMarket);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} catch (err) {
|
|
|
+
|
|
|
+console.log("selfServicePoints-=-=err", err);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+CacheTool.setMiniAppOptions(options);
|
|
|
+
|
|
|
+let _this = this;
|
|
|
+
|
|
|
+Vue.prototype.$onLaunched = new Promise((resolve) => {
|
|
|
+
|
|
|
+Vue.prototype.$isResolve = resolve;
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+const outMallId =
|
|
|
+
|
|
|
+options?.query?.mallId ??
|
|
|
+
|
|
|
+options?.query?.mallid ??
|
|
|
+
|
|
|
+options?.query?.lbsId ??
|
|
|
+
|
|
|
+"";
|
|
|
+
|
|
|
+if (outMallId) {
|
|
|
+
|
|
|
+await setDefaultMarket(_this, store, null, outMallId, false, true);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const type = options?.query?.type ?? "";
|
|
|
+
|
|
|
+if (type === "ump") {
|
|
|
+
|
|
|
+_this.unifiedCount(options.query);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+log.info(`App.vue onShow`, options);
|
|
|
+
|
|
|
+console.log(`===> App.vue onShow <===`, options);
|
|
|
+
|
|
|
+let previousUrl = "";
|
|
|
+
|
|
|
+uni.setStorageSync("previousUrl", previousUrl);
|
|
|
+
|
|
|
+this.setGlobalDataByStorage();
|
|
|
+
|
|
|
+const member = uni.getStorageSync("member");
|
|
|
+
|
|
|
+const wxMember = uni.getStorageSync("wxMember");
|
|
|
+
|
|
|
+this.$nextTick(() => {
|
|
|
+
|
|
|
+if (member && wxMember) {
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+"==>缓存里有值options_query",
|
|
|
+
|
|
|
+uni.getStorageSync("options_query")
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+sensors.register({
|
|
|
+
|
|
|
+saglobal_open_id: _this.globalData?.openId || wxMember.openid || "",
|
|
|
+
|
|
|
+saglobal_union_id:
|
|
|
+
|
|
|
+_this.globalData?.member?.unionid || wxMember.unionid || "",
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+// 1、判断是哪个小程序
|
|
|
+
|
|
|
+// 2、判断是否带了mallid
|
|
|
+
|
|
|
+// 3、判断是否是杭州
|
|
|
+
|
|
|
+const extraData = options.referrerInfo?.extraData || {};
|
|
|
+
|
|
|
+console.info("options888=", options);
|
|
|
+
|
|
|
+if (extraData.fromMini == "CRM") {
|
|
|
+
|
|
|
+uni.setStorageSync("fromOtherMiniExtraData", extraData);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+uni.removeStorageSync("fromOtherMiniExtraData");
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+console.info("fromOtherMiniExtraData=", extraData);
|
|
|
+
|
|
|
+const lbsId = extraData.lbsId || "";
|
|
|
+
|
|
|
+const optionsMallid =
|
|
|
+
|
|
|
+options.query?.mallid || lbsId || options.query?.lbsId || "";
|
|
|
+
|
|
|
+console.log("optionsMallid=", optionsMallid);
|
|
|
+
|
|
|
+const accountInfo = uni.getAccountInfoSync();
|
|
|
+
|
|
|
+const {
|
|
|
+
|
|
|
+miniProgram: {envVersion},
|
|
|
+
|
|
|
+} = accountInfo;
|
|
|
+
|
|
|
+const storageMallid = uni.getStorageSync("mallid");
|
|
|
+
|
|
|
+let project = "crm";
|
|
|
+
|
|
|
+let lbsRemark = `${CacheTool.getCurEnvConst(
|
|
|
+
|
|
|
+"TRACKING_LBS_REMARK"
|
|
|
+
|
|
|
+)}_${storageMallid}`;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 嘉里ko小程序,北京、静安、浦东
|
|
|
+
|
|
|
+if (isKOMiniApp()) {
|
|
|
+
|
|
|
+// 埋点project
|
|
|
+
|
|
|
+project = "kerryon";
|
|
|
+
|
|
|
+// 带mallid进来
|
|
|
+
|
|
|
+if (optionsMallid) {
|
|
|
+
|
|
|
+lbsRemark = `${CacheTool.getCurEnvConst(
|
|
|
+
|
|
|
+"TRACKING_LBS_REMARK"
|
|
|
+
|
|
|
+)}_${optionsMallid}`;
|
|
|
+
|
|
|
+_this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+// 没带mallid
|
|
|
+
|
|
|
+// 有缓存
|
|
|
+
|
|
|
+if (storageMallid) {
|
|
|
+
|
|
|
+_this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+// 没缓存
|
|
|
+
|
|
|
+_this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+// 嘉里Links小程序,都有,暂时只展示杭州
|
|
|
+
|
|
|
+// 带mallid进来
|
|
|
+
|
|
|
+if (optionsMallid) {
|
|
|
+
|
|
|
+_this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+// 不带mallid时不论是是否有缓存,都走正常逻辑
|
|
|
+
|
|
|
+} else _this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+// #ifdef MP-WEIXIN
|
|
|
+
|
|
|
+const {HEJI_LBS_ID} = CacheTool.getCurEnvConst();
|
|
|
+
|
|
|
+const lbsId = uni.getStorageSync("mallid");
|
|
|
+
|
|
|
+const isLocationPermission = await checkLocationPermission();
|
|
|
+
|
|
|
+const pages = getCurrentPages();
|
|
|
+
|
|
|
+const curPage = pages[pages.length - 1];
|
|
|
+
|
|
|
+const curPageRoute = curPage?.route ?? null;
|
|
|
+
|
|
|
+if (
|
|
|
+
|
|
|
+lbsId == HEJI_LBS_ID &&
|
|
|
+
|
|
|
+isLocationPermission &&
|
|
|
+
|
|
|
+curPageRoute &&
|
|
|
+
|
|
|
+curPageRoute !== "pages/chooseProject/chooseProject"
|
|
|
+
|
|
|
+) {
|
|
|
+
|
|
|
+uni.navigateTo({
|
|
|
+
|
|
|
+url: "/pages/chooseProject/chooseProject",
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// #endif
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// const trackingUrl = `${CacheTool.getCurEnvConst("TRACKING_API_URL")}?project=${project}&remark=${lbsRemark}`
|
|
|
+
|
|
|
+console.log("全局的埋点初始化");
|
|
|
+
|
|
|
+trackingInit({
|
|
|
+
|
|
|
+lbsRemark,
|
|
|
+
|
|
|
+groupId: uni.getStorageSync("groupId"),
|
|
|
+
|
|
|
+mallId: uni.getStorageSync("mallid"),
|
|
|
+
|
|
|
+marketName: _this.globalData.marketName,
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+_this.changeEnv();
|
|
|
+
|
|
|
+_this.getTencentKey();
|
|
|
+
|
|
|
+uni.getSystemInfo({
|
|
|
+
|
|
|
+success: (res) => {
|
|
|
+
|
|
|
+_this.globalData.navHeight = res.statusBarHeight + 46; // 赋值导航高度
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+fail: (err) => {
|
|
|
+
|
|
|
+console.log(err);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 直播数据收集
|
|
|
+
|
|
|
+// 分享卡片/订阅消息/扫码二维码/广告/朋友圈等场景才能调用 getShareParams 接口获取以下参数
|
|
|
+
|
|
|
+const sceneList = [
|
|
|
+
|
|
|
+1007, 1008, 1014, 1044, 1045, 1046, 1047, 1048, 1049, 1073, 1154, 1155,
|
|
|
+
|
|
|
+];
|
|
|
+
|
|
|
+if (sceneList.includes(options.scene)) {
|
|
|
+
|
|
|
+livePlayer
|
|
|
+
|
|
|
+.getShareParams()
|
|
|
+
|
|
|
+.then((res) => {
|
|
|
+
|
|
|
+// 房间号
|
|
|
+
|
|
|
+console.log("get room id", res.room_id);
|
|
|
+
|
|
|
+// 用户openid
|
|
|
+
|
|
|
+console.log("get openid", res.openid);
|
|
|
+
|
|
|
+// 分享者openid,分享卡片进入场景才有
|
|
|
+
|
|
|
+console.log("get share openid", res.share_openid);
|
|
|
+
|
|
|
+// 开发者在跳转进入直播间页面时,页面路径上携带的自定义参数,这里传回给开发者
|
|
|
+
|
|
|
+console.log("get custom params", res.custom_params);
|
|
|
+
|
|
|
+const roomShareParams = {
|
|
|
+
|
|
|
+enterSource: options.scene,
|
|
|
+
|
|
|
+qrcodeSource: res.custom_params,
|
|
|
+
|
|
|
+roomId: res.room_id,
|
|
|
+
|
|
|
+openId: res.openid,
|
|
|
+
|
|
|
+sharedOpenId: res.share_openid,
|
|
|
+
|
|
|
+enteringTime: moment().format("YYYY-MM-DD HH:mm:ss"),
|
|
|
+
|
|
|
+subscribeTime: moment().format("YYYY-MM-DD HH:mm:ss"),
|
|
|
+
|
|
|
+// roomStatus: 0,
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+this.kipRoomShare(roomShareParams);
|
|
|
+
|
|
|
+})
|
|
|
+
|
|
|
+.catch((err) => {
|
|
|
+
|
|
|
+console.log("get share params", err);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+if (this.globalData.openId && uni.getStorageSync("kipMember")) {
|
|
|
+
|
|
|
+const easyPointsCommitStatus = await getWxEasyPointsCommitStatus();
|
|
|
+
|
|
|
+if (easyPointsCommitStatus) {
|
|
|
+
|
|
|
+setTimeout(() => {
|
|
|
+
|
|
|
+const pages = getCurrentPages();
|
|
|
+
|
|
|
+this.$store.commit("setPointsModalFlag", false);
|
|
|
+
|
|
|
+pages[pages.length - 1].$vm.$refs.wxPointsCommit.open("selfPoints");
|
|
|
+
|
|
|
+}, 1000);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+onHide: function () {
|
|
|
+
|
|
|
+uni.removeStorageSync("miniCodeParamsSameTime");
|
|
|
+
|
|
|
+this.globalData.isFirstEnter = false;
|
|
|
+
|
|
|
+console.log("===> App.vue Hide <===");
|
|
|
+
|
|
|
+uni.removeStorageSync("waterfallList");
|
|
|
+
|
|
|
+uni.removeStorageSync("isBack");
|
|
|
+
|
|
|
+if (uni.getStorageSync("isCollectLoginBack")) {
|
|
|
+
|
|
|
+uni.removeStorageSync("isCollectLoginBack");
|
|
|
+
|
|
|
+uni.removeStorageSync("isCollectLoginBackIndex");
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+onError(e) {
|
|
|
+
|
|
|
+log.error(e);
|
|
|
+
|
|
|
+console.error(e);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+globalData: {
|
|
|
+
|
|
|
+isFirstEnter: false, // 全局标记是否是首次进入
|
|
|
+
|
|
|
+//顾客手机号
|
|
|
+
|
|
|
+phone: "",
|
|
|
+
|
|
|
+appid: "",
|
|
|
+
|
|
|
+groupId: "", // Brand ID
|
|
|
+
|
|
|
+miniTitle: "嘉里集团",
|
|
|
+
|
|
|
+// 商品分享底图【需要本地】
|
|
|
+
|
|
|
+productShareImg: "/images/common.png",
|
|
|
+
|
|
|
+// 腾讯地图key qqmap-wx-jssdk
|
|
|
+
|
|
|
+// OTHER
|
|
|
+
|
|
|
+key: "3HWBZ-CESKG-E3UQV-IUVUO-U7TNZ-HTB26",
|
|
|
+
|
|
|
+// DEV
|
|
|
+
|
|
|
+// key: 'UC7BZ-6CRCX-I3H4O-TMC4B-IM6IZ-7XB3F',
|
|
|
+
|
|
|
+appKey: "60ae0228dd01c71b57c5b809",
|
|
|
+
|
|
|
+//微信存储的信息(昵称,头像等)
|
|
|
+
|
|
|
+userInfo: uni.getStorageSync("userInfo") || {},
|
|
|
+
|
|
|
+// userInfo:{},
|
|
|
+
|
|
|
+//保存的openID和sessionkey
|
|
|
+
|
|
|
+mallid: "",
|
|
|
+
|
|
|
+marketName: "", // 当前商场
|
|
|
+
|
|
|
+marketAddress: "", // 当前商场地址
|
|
|
+
|
|
|
+sos: {},
|
|
|
+
|
|
|
+location: "",
|
|
|
+
|
|
|
+marketList: [],
|
|
|
+
|
|
|
+curMarket: {},
|
|
|
+
|
|
|
+params: {},
|
|
|
+
|
|
|
+paramsCode: "", // 场景二维码唯一标识
|
|
|
+
|
|
|
+tpId: "",
|
|
|
+
|
|
|
+tpName: "",
|
|
|
+
|
|
|
+paramsScene: null, // 场景二维码返回参数
|
|
|
+
|
|
|
+sceneKey: null,
|
|
|
+
|
|
|
+isNewMember: "", // 是否拉新 1
|
|
|
+
|
|
|
+pullVipcode: "", // 拉新人的会员号
|
|
|
+
|
|
|
+navHeight: 0,
|
|
|
+
|
|
|
+defaultAddressJson: {}, //地址
|
|
|
+
|
|
|
+isRecordLoction: false,
|
|
|
+
|
|
|
+openId: uni.getStorageSync("openId"),
|
|
|
+
|
|
|
+member: uni.getStorageSync("member"),
|
|
|
+
|
|
|
+wxMember: uni.getStorageSync("wxMember"),
|
|
|
+
|
|
|
+fxvipcode: "", // 分销人会员
|
|
|
+
|
|
|
+selfAddress: {}, // 自提地址
|
|
|
+
|
|
|
+regSource: REG_SOURCE.MINI_APP,
|
|
|
+
|
|
|
+brandInfo: null,
|
|
|
+
|
|
|
+sponsorMobile: "", // 邀约手机号
|
|
|
+
|
|
|
+sponsorVipcode: "", // 邀约会员卡号
|
|
|
+
|
|
|
+parkingFeeIsGZH: false, // 记录扫码入场的参数是否做过解析了,临时停车,其他业务如果用这个字段,可能会有影响临停与当前业务
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+methods: {
|
|
|
+
|
|
|
+// 统计短链跳到小程序次数
|
|
|
+
|
|
|
+unifiedCount(options) {
|
|
|
+
|
|
|
+let params = {};
|
|
|
+
|
|
|
+const {external_id, sa_utm, task_id} = options;
|
|
|
+
|
|
|
+if (external_id) {
|
|
|
+
|
|
|
+params.external_id = external_id;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+if (sa_utm) {
|
|
|
+
|
|
|
+params.sa_utm = sa_utm;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+if (task_id) {
|
|
|
+
|
|
|
+params.task_id = task_id;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+try {
|
|
|
+
|
|
|
+uni.request({
|
|
|
+
|
|
|
+url:
|
|
|
+
|
|
|
+CacheTool.getCurEnvConst("KIP_API") +
|
|
|
+
|
|
|
+"/message-distribution/v1/unified/counter",
|
|
|
+
|
|
|
+data: params,
|
|
|
+
|
|
|
+method: "get",
|
|
|
+
|
|
|
+success: (res) => {
|
|
|
+
|
|
|
+console.log("统计UM次数成功", res);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+} catch (err) {
|
|
|
+
|
|
|
+console.log("统计UM次数失败", err);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+navTitle() {
|
|
|
+
|
|
|
+let navTitle = document.getElementsByTagName("uni-page-head");
|
|
|
+
|
|
|
+navTitle[0].style.display = "none";
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+watchs(method, key) {
|
|
|
+
|
|
|
+var obj = this.globalData;
|
|
|
+
|
|
|
+console.log(obj);
|
|
|
+
|
|
|
+Object.defineProperty(obj, key, {
|
|
|
+
|
|
|
+configurable: true,
|
|
|
+
|
|
|
+enumerable: true,
|
|
|
+
|
|
|
+get() {
|
|
|
+
|
|
|
+return this._userInfo;
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+set(value) {
|
|
|
+
|
|
|
+this._userInfo = value;
|
|
|
+
|
|
|
+method(value);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+cleanAll() {
|
|
|
+
|
|
|
+// 清除所有用户信息
|
|
|
+
|
|
|
+KipCacheTool.cleanKipCache();
|
|
|
+
|
|
|
+MemberCacheTool.cleanMemberCache(this);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+async checkTokenOrRefreshToken(token) {
|
|
|
+
|
|
|
+// 判断token是否过期,过期后刷新token
|
|
|
+
|
|
|
+if (token) {
|
|
|
+
|
|
|
+const _this = this;
|
|
|
+
|
|
|
+const resp = await kipCheckToken(token).catch((err) => {
|
|
|
+
|
|
|
+console.error(err);
|
|
|
+
|
|
|
+console.warn("===>清除所有缓存3");
|
|
|
+
|
|
|
+log.info(`refresh_token获取失败,清除所有缓存3`, err);
|
|
|
+
|
|
|
+_this.cleanAll();
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+if (resp && resp.statusCode == "401") {
|
|
|
+
|
|
|
+log.info(
|
|
|
+
|
|
|
+`access_token已过期,使用refresh_token刷新access_token,如果refresh_token过期则删除所有数据`
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+// token过期之后使用refresh_token刷新access_token,如果refresh_token过期则删除所有数据
|
|
|
+
|
|
|
+const kipRefreshToken = KipCacheTool.getKipRefreshToken();
|
|
|
+
|
|
|
+if (!kipRefreshToken) {
|
|
|
+
|
|
|
+_this.cleanAll();
|
|
|
+
|
|
|
+return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const respRefresh = await kipGetNewAccessTokenByRefreshToken(
|
|
|
+
|
|
|
+kipRefreshToken
|
|
|
+
|
|
|
+).catch((err) => {
|
|
|
+
|
|
|
+console.warn("===>清除所有缓存2");
|
|
|
+
|
|
|
+log.info(`清除所有缓存2`);
|
|
|
+
|
|
|
+_this.cleanAll();
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+const result = respRefresh.data;
|
|
|
+
|
|
|
+if (result && result.code === "000000" && result.data.access_token) {
|
|
|
+
|
|
|
+KipCacheTool.setKipToken(result.data.access_token);
|
|
|
+
|
|
|
+log.info(`refreshToken获取成功,这是新的token:`, result.data);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+if (result && result.code !== KIP_API_CODE.REFRESH_TOKEN_EXPIRED) {
|
|
|
+
|
|
|
+console.log("getRefreshToken-error-app.vue-=-=", result.message);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+console.warn("===>清除所有缓存1---=-=3");
|
|
|
+
|
|
|
+log.info(`清除所有缓存1---=-=4`);
|
|
|
+
|
|
|
+_this.cleanAll();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+async getAllMarket(options, callback) {
|
|
|
+
|
|
|
+if (
|
|
|
+
|
|
|
+(options.query?.mallid || options.query?.lbsId) &&
|
|
|
+
|
|
|
+(options.query?.groupId || options.query?.brandId)
|
|
|
+
|
|
|
+) {
|
|
|
+
|
|
|
+uni.setStorageSync(
|
|
|
+
|
|
|
+"groupId",
|
|
|
+
|
|
|
+options.query?.groupId || options.query?.brandId
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+uni.setStorageSync(
|
|
|
+
|
|
|
+"mallid",
|
|
|
+
|
|
|
+options.query?.mallid ?? options.query?.lbsId
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+this.globalData.groupId =
|
|
|
+
|
|
|
+options.query?.groupId || options.query?.brandId;
|
|
|
+
|
|
|
+this.globalData.mallid = options.query?.mallid ?? options.query?.lbsId;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 获取所有商场
|
|
|
+
|
|
|
+console.log("断北京是否剥离KO-=-=-00000");
|
|
|
+
|
|
|
+const _this = this;
|
|
|
+
|
|
|
+const resp = await kipAllCities().catch((err) => {
|
|
|
+
|
|
|
+console.error("===>kipAllCities() 获取商场错误: ", JSON.stringify(err));
|
|
|
+
|
|
|
+if (!isKipAllCitiesResolved && err && err.errType == "NETWORK") {
|
|
|
+
|
|
|
+// 如果是网络错误,停下来,显示网络错误页
|
|
|
+
|
|
|
+// 此时 resp 为 undefined,后面的 const result = resp.data; 会报错,整个 getAllMarket 都会停止执行
|
|
|
+
|
|
|
+uni.$once("networkErrorPageLeave", () => {
|
|
|
+
|
|
|
+this.getAllMarket(options, callback);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+uni.navigateTo({
|
|
|
+
|
|
|
+url: "/pages/automatic/network-error?fromPage=appLaunch",
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const marketList =
|
|
|
+
|
|
|
+_this.globalData.marketList || uni.getStorageSync("marketList");
|
|
|
+
|
|
|
+if (marketList && marketList.length && marketList.length > 0) {
|
|
|
+
|
|
|
+if (callback) {
|
|
|
+
|
|
|
+console.warn("===>获取商场错误,从缓存仲获取");
|
|
|
+
|
|
|
+log.warn("===>获取商场错误,从缓存仲获取");
|
|
|
+
|
|
|
+callback(options, marketList);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.error(err);
|
|
|
+
|
|
|
+log.error("===>获取商场错误");
|
|
|
+
|
|
|
+if (callback) {
|
|
|
+
|
|
|
+callback(options, []);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+const stage = CacheTool.getEnv();
|
|
|
+
|
|
|
+const result = resp.data;
|
|
|
+
|
|
|
+console.log("断北京是否剥离KO-=-=-00000111");
|
|
|
+
|
|
|
+if (result && result.code === "000000") {
|
|
|
+
|
|
|
+console.log("===> 请求所有商场");
|
|
|
+
|
|
|
+result.data = result.data
|
|
|
+
|
|
|
+.filter((item) => "lbs" in item)
|
|
|
+
|
|
|
+.map((city) => {
|
|
|
+
|
|
|
+city.lbs = city.lbs.filter((ct) => {
|
|
|
+
|
|
|
+const misTestBrand = ct.brand.id !== TEST_BRAND_ID;
|
|
|
+
|
|
|
+return stage == "prod" ? misTestBrand : true;
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+return city;
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+const marketList = kipCitiesToCrmMarket(result.data);
|
|
|
+
|
|
|
+CacheTool.setMarketList(marketList, this);
|
|
|
+
|
|
|
+if (callback) {
|
|
|
+
|
|
|
+callback(options, marketList);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+const marketList =
|
|
|
+
|
|
|
+_this.globalData.marketList || uni.getStorageSync("marketList");
|
|
|
+
|
|
|
+if (marketList && marketList.length && marketList.length > 0) {
|
|
|
+
|
|
|
+if (callback) {
|
|
|
+
|
|
|
+console.info("===>获取商场失败,从缓存仲获取");
|
|
|
+
|
|
|
+log.info("===>获取商场失败,从缓存仲获取");
|
|
|
+
|
|
|
+callback(options, marketList);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.log("===>获取商场失败,是否进入 LBS 选择页面");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if (callback) {
|
|
|
+
|
|
|
+callback(options, []);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+isKipAllCitiesResolved = true;
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+chenageLocation(options, marketList) {
|
|
|
+
|
|
|
+if (!marketList) {
|
|
|
+
|
|
|
+console.log("===>获取位置信息(getLocationAndSetDefaultMarket)-=-=002");
|
|
|
+
|
|
|
+getLocationAndSetDefaultMarket(_this, store, setDefaultMarket);
|
|
|
+
|
|
|
+console.warn("===>修改location没有opetions或marketList参数");
|
|
|
+
|
|
|
+return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+options = options || {};
|
|
|
+
|
|
|
+const query =
|
|
|
+
|
|
|
+JSON.stringify(options.query) != "{}" ? options.query : null;
|
|
|
+
|
|
|
+const referrerInfoExtraData = options.referrerInfo?.extraData;
|
|
|
+
|
|
|
+const navigate_time = uni.getStorageSync("navigate_time");
|
|
|
+
|
|
|
+let referrerInfoExtraDataFlag = false;
|
|
|
+
|
|
|
+if (referrerInfoExtraData && referrerInfoExtraData.navigate_time) {
|
|
|
+
|
|
|
+if (navigate_time != referrerInfoExtraData.navigate_time) {
|
|
|
+
|
|
|
+uni.setStorageSync(
|
|
|
+
|
|
|
+"navigate_time",
|
|
|
+
|
|
|
+referrerInfoExtraData.navigate_time
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+referrerInfoExtraDataFlag = true;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+if (
|
|
|
+
|
|
|
+Object.prototype.toString.call(referrerInfoExtraData) ===
|
|
|
+
|
|
|
+"[object Object]" &&
|
|
|
+
|
|
|
+Object.keys(referrerInfoExtraData).length > 0
|
|
|
+
|
|
|
+) {
|
|
|
+
|
|
|
+referrerInfoExtraDataFlag = true;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const _this = this;
|
|
|
+
|
|
|
+if (!referrerInfoExtraDataFlag && !query) {
|
|
|
+
|
|
|
+// 正常进入
|
|
|
+
|
|
|
+console.log("===> 正常进入");
|
|
|
+
|
|
|
+// 如果当前进入的页面是"切换位置",则有可能是打开定位权限再返回到小程序中,此时不需要自动授权定位
|
|
|
+
|
|
|
+const curMallid = uni.getStorageSync("mallid");
|
|
|
+
|
|
|
+const myProtocolModalFlag = uni.getStorageSync("myProtocolModalFlag");
|
|
|
+
|
|
|
+if (!curMallid) {
|
|
|
+
|
|
|
+setTimeout(() => {
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+"===>获取位置信息(getLocationAndSetDefaultMarket)-=-=003"
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+uni.$once("myProtocolModalFlag", (data) => {
|
|
|
+
|
|
|
+getLocationAndSetDefaultMarket(this, store, setDefaultMarket);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+}, 500);
|
|
|
+
|
|
|
+if (myProtocolModalFlag) {
|
|
|
+
|
|
|
+const pages = getCurrentPages();
|
|
|
+
|
|
|
+if (pages.length === 0) {
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+"===>获取位置信息(getLocationAndSetDefaultMarket)-=-=004"
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+getLocationAndSetDefaultMarket(_this, store, setDefaultMarket);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+const curPage = pages[pages.length - 1];
|
|
|
+
|
|
|
+const curPageRoute = curPage?.route ?? null;
|
|
|
+
|
|
|
+console.log("===>curPageRoute", curPageRoute);
|
|
|
+
|
|
|
+if (
|
|
|
+
|
|
|
+curPageRoute &&
|
|
|
+
|
|
|
+curPageRoute !== "pages/chooseProject/chooseProject"
|
|
|
+
|
|
|
+) {
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+"===>获取位置信息(getLocationAndSetDefaultMarket)-=-=005"
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+getLocationAndSetDefaultMarket(_this, store, setDefaultMarket);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+// 如果不是当前appid的缓存则不使用
|
|
|
+
|
|
|
+if (CacheTool.isCurrentAppMallid(curMallid)) {
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, curMallid, false, true);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, null, false, true);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else if (query && query.source && query.source === "tparkingH5") {
|
|
|
+
|
|
|
+// 如果是从其他site进入积分商城
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, query.mallId, false, true);
|
|
|
+
|
|
|
+} else if (referrerInfoExtraDataFlag) {
|
|
|
+
|
|
|
+// 跳转进入
|
|
|
+
|
|
|
+// getLocationAndSetDefaultMarketNotUseCache(_this, store, setDefaultMarket)
|
|
|
+
|
|
|
+let {lbsId, isLogin} = referrerInfoExtraData || {};
|
|
|
+
|
|
|
+console.log("===> 小程序跳转进入", lbsId, referrerInfoExtraData, query);
|
|
|
+
|
|
|
+CacheTool.setMiniAppOptionsQuery(referrerInfoExtraData);
|
|
|
+
|
|
|
+if (!lbsId) {
|
|
|
+
|
|
|
+lbsId = referrerInfoExtraData
|
|
|
+
|
|
|
+? referrerInfoExtraData.mallid || referrerInfoExtraData.mallId
|
|
|
+
|
|
|
+: null;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+console.info("===>从小程序跳转参数中获取到的lbsId: " + lbsId);
|
|
|
+
|
|
|
+log.info("===>从小程序跳转参数中获取到的lbsId: " + lbsId);
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, lbsId, false, true);
|
|
|
+
|
|
|
+} else if(`${query.q}`.indexOf('t-parking') > -1){
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+"===>临时停车的扫码跳转不做任何处理"
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+uni.removeStorageSync("pointsMallEventSource");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 扫码进入
|
|
|
+
|
|
|
+console.log("===> 其他方式进入");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 获取位置并设置默认离自己最近的商场(当出现无牌车扫码场景时)
|
|
|
+
|
|
|
+if (/unlicensedIn|unlicensedOut/.test(options.query.scene)) {
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+"===>获取位置信息(getLocationAndSetDefaultMarket)-=-=006"
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+getLocationAndSetDefaultMarket(_this, store, setDefaultMarket);
|
|
|
+
|
|
|
+return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 获取位置并设置默认离自己最近的商场
|
|
|
+
|
|
|
+// getLocationAndSetDefaultMarketNotUseCache(_this, store, setDefaultMarket, true)
|
|
|
+
|
|
|
+// TODO 处理其他参数
|
|
|
+
|
|
|
+const {scene, mallid, mallId, lbsId, channel_id, wechatapp_id} =
|
|
|
+
|
|
|
+query || {};
|
|
|
+
|
|
|
+// scene 是二维码唯一标识,此时会员是通过扫码进入的,在App.vue中在 options.query.scene 而具体页面中在 options.scene 中
|
|
|
+
|
|
|
+// 芝麻小客服会传入3个参数:channel_id,wechatapp_id,scene此时不请求解析场景二维码
|
|
|
+
|
|
|
+const oldMallid = uni.getStorageSync("mallid");
|
|
|
+
|
|
|
+const isSpecialOffer = options.path === "pages/webView/specialOfferH5"; //优惠买单扫码解析在specialOfferH5中
|
|
|
+
|
|
|
+// 保存小程序扫码进入参数
|
|
|
+
|
|
|
+console.log("小程序码参数==", query, options);
|
|
|
+
|
|
|
+if (!query.url) {
|
|
|
+
|
|
|
+query.url = options.path;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+uni.setStorageSync("miniCodeParams", query);
|
|
|
+
|
|
|
+if (
|
|
|
+
|
|
|
+scene &&
|
|
|
+
|
|
|
+!channel_id &&
|
|
|
+
|
|
|
+!wechatapp_id &&
|
|
|
+
|
|
|
+!/unlicensedIn|unlicensedOut/.test(scene) &&
|
|
|
+
|
|
|
+!isSpecialOffer &&
|
|
|
+
|
|
|
+scene.indexOf("questionnaireScene") == -1
|
|
|
+
|
|
|
+) {
|
|
|
+
|
|
|
+_this.globalData.sceneKey = scene;
|
|
|
+
|
|
|
+console.log("===>解析小程序码参数");
|
|
|
+
|
|
|
+const params = {
|
|
|
+
|
|
|
+scene: scene,
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+crmGetMiniCodeParam(_this.$baseURL, params)
|
|
|
+
|
|
|
+.then((resp) => {
|
|
|
+
|
|
|
+const result = resp.data;
|
|
|
+
|
|
|
+if (result && result.code == "0" && result.data) {
|
|
|
+
|
|
|
+console.log("result", result.data);
|
|
|
+
|
|
|
+_this.globalData.paramsScene = result.data;
|
|
|
+
|
|
|
+// 将扫码进来的参数放入KIP所有请求的headers中
|
|
|
+
|
|
|
+CacheTool.setMiniAppOptionsQuery(result.data);
|
|
|
+
|
|
|
+const {
|
|
|
+
|
|
|
+mallid,
|
|
|
+
|
|
|
+mallId,
|
|
|
+
|
|
|
+page,
|
|
|
+
|
|
|
+id,
|
|
|
+
|
|
|
+lbsId,
|
|
|
+
|
|
|
+paramsCode,
|
|
|
+
|
|
|
+tpName,
|
|
|
+
|
|
|
+tpId,
|
|
|
+
|
|
|
+sponsorMobile,
|
|
|
+
|
|
|
+sponsorVipcode,
|
|
|
+
|
|
|
+regSource,
|
|
|
+
|
|
|
+fromPage,
|
|
|
+
|
|
|
+format,
|
|
|
+
|
|
|
+groupId,
|
|
|
+
|
|
|
+scene,
|
|
|
+
|
|
|
+url,
|
|
|
+
|
|
|
+channelId,
|
|
|
+
|
|
|
+} = result.data || {};
|
|
|
+
|
|
|
+console.log("coupon param ******", result.data);
|
|
|
+
|
|
|
+result.data.url = result.data.url || result.data.page;
|
|
|
+
|
|
|
+uni.setStorageSync("miniCodeParams", result.data);
|
|
|
+
|
|
|
+if (fromPage == "QRCODE") {
|
|
|
+
|
|
|
+uni.setStorageSync("groupId", groupId);
|
|
|
+
|
|
|
+uni.setStorageSync("mallid", mallId);
|
|
|
+
|
|
|
+uni.setStorageSync("activityId", id);
|
|
|
+
|
|
|
+uni.setStorageSync("format", format);
|
|
|
+
|
|
|
+uni.setStorageSync("fromPage", fromPage);
|
|
|
+
|
|
|
+uni.setStorageSync("eventH5Url", url);
|
|
|
+
|
|
|
+uni.setStorageSync("lbsId", lbsId);
|
|
|
+
|
|
|
+uni.setStorageSync("couponId", id);
|
|
|
+
|
|
|
+uni.setStorageSync("couponH5Url", url);
|
|
|
+
|
|
|
+uni.setStorageSync("channelId", channelId);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+_this.globalData.paramsCode = paramsCode;
|
|
|
+
|
|
|
+_this.globalData.tpId = tpId;
|
|
|
+
|
|
|
+_this.globalData.tpName = tpName;
|
|
|
+
|
|
|
+_this.globalData.sponsorMobile = sponsorMobile;
|
|
|
+
|
|
|
+_this.globalData.sponsorVipcode = sponsorVipcode;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if (regSource && regSource.trim() != "") {
|
|
|
+
|
|
|
+_this.globalData.regSource = REG_SOURCE[regSource];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+console.log(`===> 获取到mallid: ${mallid}`);
|
|
|
+
|
|
|
+if (mallid || mallId || lbsId) {
|
|
|
+
|
|
|
+const id = mallid ?? mallId ?? lbsId;
|
|
|
+
|
|
|
+if (CacheTool.isCurrentAppMallid(id)) {
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, id, false, true);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+//场景二维码不处理mallid与appid不统一的问题
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+`1111===>场景二维码解析出来的mallid不是当前小程序的mallid: ${id}`
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+_this.goToMiniApp(options, id, fromPage, scene);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.error("===> 场景二维码没有获取到mallid");
|
|
|
+
|
|
|
+log.error("===> 场景二维码没有获取到mallid");
|
|
|
+
|
|
|
+if (CacheTool.isCurrentAppMallid(id)) {
|
|
|
+
|
|
|
+setDefaultMarket(
|
|
|
+
|
|
|
+_this,
|
|
|
+
|
|
|
+store,
|
|
|
+
|
|
|
+marketList,
|
|
|
+
|
|
|
+oldMallid,
|
|
|
+
|
|
|
+false,
|
|
|
+
|
|
|
+true
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+`22222===>场景二维码未解析出mallid,使用原有缓存mallid: ${oldMallid}`
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+_this.goToMiniApp(options, oldMallid, fromPage, scene);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.error("解析二维码失败");
|
|
|
+
|
|
|
+setDefaultMarket(
|
|
|
+
|
|
|
+_this,
|
|
|
+
|
|
|
+store,
|
|
|
+
|
|
|
+marketList,
|
|
|
+
|
|
|
+oldMallid,
|
|
|
+
|
|
|
+false,
|
|
|
+
|
|
|
+true
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+})
|
|
|
+
|
|
|
+.catch((err) => {
|
|
|
+
|
|
|
+console.error(err);
|
|
|
+
|
|
|
+uni.showToast({
|
|
|
+
|
|
|
+title: "解析商场失败",
|
|
|
+
|
|
|
+icon: "none",
|
|
|
+
|
|
|
+duration: 2300,
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+setDefaultMarket(
|
|
|
+
|
|
|
+_this,
|
|
|
+
|
|
|
+store,
|
|
|
+
|
|
|
+marketList,
|
|
|
+
|
|
|
+oldMallid,
|
|
|
+
|
|
|
+false,
|
|
|
+
|
|
|
+true
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+} else if (mallid || mallId || lbsId) {
|
|
|
+
|
|
|
+const id = mallid ?? mallId ?? lbsId;
|
|
|
+
|
|
|
+console.log("===> 通过传入mallid进入", id);
|
|
|
+
|
|
|
+if (CacheTool.isCurrentAppMallid(id)) {
|
|
|
+
|
|
|
+// 判断是否有sceneId
|
|
|
+
|
|
|
+if (query.paramsCode) {
|
|
|
+
|
|
|
+_this.globalData.paramsCode = query.paramsCode;
|
|
|
+
|
|
|
+uni.setStorageSync("paramsCode", query.paramsCode);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+if (query.tpId) {
|
|
|
+
|
|
|
+_this.globalData.tpId = query.tpId;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+if (query.tpName) {
|
|
|
+
|
|
|
+_this.globalData.tpName = query.tpName;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, id, false, true);
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+//场景二维码不处理mallid与appid不统一的问题
|
|
|
+
|
|
|
+console.log(
|
|
|
+
|
|
|
+`3333===>场景二维码未解析出mallid,使用原有缓存mallid: ${oldMallid}`
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+_this.goToMiniApp(options, mallid);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+} else {
|
|
|
+
|
|
|
+console.log("===> 使用已有的商场,商场不修改 ");
|
|
|
+
|
|
|
+setDefaultMarket(_this, store, marketList, oldMallid, false, true);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+changeEnv() {
|
|
|
+
|
|
|
+const curEnvConst = CacheTool.getCurEnvConst();
|
|
|
+
|
|
|
+console.log("===>当前环境变量", curEnvConst);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+goToMiniApp(options, mallid, fromPage, scene) {
|
|
|
+
|
|
|
+const token = KipCacheTool.getKipToken();
|
|
|
+
|
|
|
+const accountInfo = uni.getAccountInfoSync();
|
|
|
+
|
|
|
+const {
|
|
|
+
|
|
|
+miniProgram: {envVersion},
|
|
|
+
|
|
|
+} = accountInfo;
|
|
|
+
|
|
|
+const extraParams = {
|
|
|
+
|
|
|
+lbsId: mallid,
|
|
|
+
|
|
|
+path: CRM_APP_PATH,
|
|
|
+
|
|
|
+isLogin: token ? true : false,
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+const extraData = buildExtraData(extraParams);
|
|
|
+
|
|
|
+console.log("===> options.query.fromPage", options.query.fromPage);
|
|
|
+
|
|
|
+if (options.query.fromPage && options.query.fromPage == "SHARE") {
|
|
|
+
|
|
|
+uni.redirectTo({
|
|
|
+
|
|
|
+url: `/pages/webView/eventH5?fromPage=SHARE&groupId=${options.query?.groupId}&mallId=${options.query?.mallId}&id=${options.query.id}&format=${options.query.format}&url=${options.query.url}`,
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+console.log("fromPage==", fromPage);
|
|
|
+
|
|
|
+if (fromPage == "QRCODE") {
|
|
|
+
|
|
|
+uni.redirectTo({
|
|
|
+
|
|
|
+url: "/pages/webView/eventH5?fromPage=QRCODE",
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+let _this = this;
|
|
|
+
|
|
|
+console.log("****goon****");
|
|
|
+
|
|
|
+uni.navigateToMiniProgram({
|
|
|
+
|
|
|
+appId: this.globalData.appId,
|
|
|
+
|
|
|
+path: "pages/automatic/automaticIndex",
|
|
|
+
|
|
|
+extraData: extraData,
|
|
|
+
|
|
|
+envVersion: envVersion,
|
|
|
+
|
|
|
+success(res) {
|
|
|
+
|
|
|
+// 打开成功
|
|
|
+
|
|
|
+if (mallid == uni.getStorageSync("mallid")) uni.clearStorage();
|
|
|
+
|
|
|
+_this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+fail(res) {
|
|
|
+
|
|
|
+if (mallid == uni.getStorageSync("mallid")) uni.clearStorage();
|
|
|
+
|
|
|
+_this.getAllMarket(options, _this.chenageLocation);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+setGlobalDataByStorage() {
|
|
|
+
|
|
|
+const marketList = uni.getStorageSync("marketList");
|
|
|
+
|
|
|
+const curMarket = uni.getStorageSync("curMarket");
|
|
|
+
|
|
|
+if (curMarket) {
|
|
|
+
|
|
|
+this.globalData.curMarket = curMarket;
|
|
|
+
|
|
|
+this.globalData.groupId = curMarket.groupId;
|
|
|
+
|
|
|
+this.globalData.mallid = curMarket.mallid;
|
|
|
+
|
|
|
+this.globalData.marketName = curMarket.name;
|
|
|
+
|
|
|
+this.globalData.marketAddress = curMarket.address;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+// 获取腾讯key
|
|
|
+
|
|
|
+getTencentKey() {
|
|
|
+
|
|
|
+this.globalData.key = "3HWBZ-CESKG-E3UQV-IUVUO-U7TNZ-HTB26";
|
|
|
+
|
|
|
+console.info("===>设置腾讯地图key: ", this.globalData.key);
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+// 直播间数据收集
|
|
|
+
|
|
|
+kipRoomShare(params) {
|
|
|
+
|
|
|
+uni.showLoading({
|
|
|
+
|
|
|
+title: "加载中",
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+kipRoomShare(params)
|
|
|
+
|
|
|
+.then((res) => {
|
|
|
+
|
|
|
+uni.hideLoading();
|
|
|
+
|
|
|
+console.log("数据收集传参", params);
|
|
|
+
|
|
|
+console.log(res);
|
|
|
+
|
|
|
+})
|
|
|
+
|
|
|
+.catch((err) => {
|
|
|
+
|
|
|
+uni.hideLoading();
|
|
|
+
|
|
|
+console.log(err);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+<style>
|
|
|
+
|
|
|
+/* 解决头条小程序组件内引入字体不生效的问题 */
|
|
|
+
|
|
|
+/* #ifdef MP-TOUTIAO */
|
|
|
+
|
|
|
+@font-face {
|
|
|
+
|
|
|
+font-family: uniicons;
|
|
|
+
|
|
|
+src: url("https://cnsh-kerry-crm-le.oss-cn-shanghai.aliyuncs.com/images/uni.ttf");
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/* #endif */
|
|
|
+
|
|
|
+page {
|
|
|
+
|
|
|
+display: flex;
|
|
|
+
|
|
|
+flex-direction: column;
|
|
|
+
|
|
|
+height: 100%;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|
|
|
+```
|