mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-09 05:25:57 +08:00
bug(custom): 分享
This commit is contained in:
@@ -6,7 +6,6 @@ import React, { useEffect } from 'react'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import dayjs from 'dayjs'
|
||||
import { SG_ROUTER_PARAMS, SG_GUIDE_PARAMS, SG_GUIDE_PARAMS_UPDATETIME } from '@/consts'
|
||||
import S from '@/spx'
|
||||
import qs from 'qs'
|
||||
import { entryLaunch, showToast } from '@/utils'
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import Taro, { getCurrentInstance } from '@tarojs/taro'
|
||||
import api from '@/api'
|
||||
import qs from 'qs'
|
||||
import S from '@/spx'
|
||||
import dayjs from 'dayjs'
|
||||
import { showToast, log, isArray, VERSION_STANDARD, resolveUrlParamsParse } from '@/utils'
|
||||
import configStore from '@/store'
|
||||
@@ -14,6 +13,15 @@ import { SG_ROUTER_PARAMS, SG_GUIDE_PARAMS } from '@/consts/localstorage'
|
||||
|
||||
import MapLoader from '@/utils/lbs'
|
||||
|
||||
// 惰性获取 spx,避免服务号冷启动时 S 未就绪(与 utils 中 getS 逻辑一致,不能从 utils 引入防循环依赖)
|
||||
function getS() {
|
||||
return (
|
||||
(typeof global !== 'undefined' && global.__SPX__) ||
|
||||
(typeof globalThis !== 'undefined' && globalThis.__SPX__) ||
|
||||
require('@/spx').default
|
||||
)
|
||||
}
|
||||
|
||||
const $instance = getCurrentInstance()
|
||||
const { store } = configStore()
|
||||
class EntryLaunch {
|
||||
@@ -194,7 +202,7 @@ class EntryLaunch {
|
||||
lng: res.longitude,
|
||||
lat: res.latitude
|
||||
})
|
||||
S.set('currentLocation', {
|
||||
getS().set('currentLocation', {
|
||||
lng: res.longitude,
|
||||
lat: res.latitude
|
||||
})
|
||||
@@ -422,7 +430,7 @@ class EntryLaunch {
|
||||
* 导购UV统计
|
||||
*/
|
||||
async postGuideUV() {
|
||||
if (!S.getAuthToken()) return
|
||||
if (!getS().getAuthToken()) return
|
||||
const { gu } = Taro.getStorageSync(SG_GUIDE_PARAMS) || {}
|
||||
if (gu) {
|
||||
const [work_userid] = gu.split('_')
|
||||
@@ -467,7 +475,7 @@ class EntryLaunch {
|
||||
// gu_user_id: 欢迎语上带过来的员工编号, 同work_user_id
|
||||
const { gu, subtask_id, item_id, dtid, smid, gu_user_id, id } =
|
||||
Taro.getStorageSync(SG_GUIDE_PARAMS) || {}
|
||||
if (gu && S.getAuthToken()) {
|
||||
if (gu && getS().getAuthToken()) {
|
||||
const [employee_number, shop_code] = gu.split('_')
|
||||
const _params = {
|
||||
employee_number,
|
||||
|
||||
@@ -7,7 +7,6 @@ import classNames from 'classnames'
|
||||
import qs from 'qs'
|
||||
import dayjs from 'dayjs'
|
||||
import copy from 'copy-to-clipboard'
|
||||
import S from '@/spx'
|
||||
import { STATUS_TYPES_MAP, SG_ROUTER_PARAMS } from '@/consts'
|
||||
import api from '@/api'
|
||||
import configStore from '@/store'
|
||||
@@ -30,6 +29,15 @@ import linkPage from './linkPage'
|
||||
|
||||
const { store } = configStore()
|
||||
|
||||
// 惰性获取 spx,避免服务号冷启动打开 custom-page 等页时 utils→spx 循环依赖导致 S 未就绪
|
||||
function getS() {
|
||||
return (
|
||||
(typeof global !== 'undefined' && global.__SPX__) ||
|
||||
(typeof globalThis !== 'undefined' && globalThis.__SPX__) ||
|
||||
require('@/spx').default
|
||||
)
|
||||
}
|
||||
|
||||
const isPrimitiveType = (val, type) => Object.prototype.toString.call(val) === type
|
||||
|
||||
export function isFunction(val) {
|
||||
@@ -284,7 +292,7 @@ export function copyText(text, msg = '内容已复制') {
|
||||
return
|
||||
}
|
||||
if (copy(text)) {
|
||||
S.toast(msg)
|
||||
getS().toast(msg)
|
||||
resolve(text)
|
||||
} else {
|
||||
reject()
|
||||
@@ -524,7 +532,7 @@ export async function buriedPoint(data) {
|
||||
}
|
||||
api.wx.taskReportData(newData)
|
||||
}
|
||||
if (data.event_type && S.getAuthToken() && employee_number) {
|
||||
if (data.event_type && getS().getAuthToken() && employee_number) {
|
||||
const { userId } = Taro.getStorageSync('userinfo')
|
||||
api.wx.interactiveReportData({
|
||||
event_id: employee_number,
|
||||
@@ -909,7 +917,7 @@ export function buildSharePath(from_scene, params = {}) {
|
||||
const getMobAppExtraData = () => {
|
||||
const store = configStore()
|
||||
|
||||
const token = S.getAuthToken()
|
||||
const token = getS().getAuthToken()
|
||||
const userInfo = token ? tokenParse(token) : {}
|
||||
const aioucd = userInfo?.user_card_code
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user