Commit 752d1602 by 张立顺

feat utils

1 parent 084c5681
......@@ -1150,12 +1150,6 @@ describe('report date helpers', async () => {
it('IT-DATE-001: isTodayReport matches today string', () => {
const today = timeUtil.getTodayDateStr()
assert.equal(timeUtil.isTodayReport(today), true)
assert.equal(timeUtil.isPastReport(today), false)
})
it('IT-DATE-002: isPastReport detects historical date', () => {
assert.equal(timeUtil.isPastReport('2000-01-01'), true)
assert.equal(timeUtil.isTodayReport('2000-01-01'), false)
})
})
......
......@@ -24,6 +24,5 @@ export { resolveAsyncMenuProviders, resolveCustomerClue } from './asyncProviders
export { createEquityMenuJumpHandler } from './jumpHandlers.js'
export {
clearMenuApiCache,
invalidateMenuAndApiCaches,
invalidateEquityMenuApiCaches
invalidateMenuAndApiCaches
} from './menuApiCache.js'
......@@ -4,7 +4,6 @@
export {
clearMenuApiCache,
invalidateMenuAndApiCaches,
invalidateEquityMenuApiCaches,
cachedHasPerformanceConfig,
cachedCheckMerchantDirect,
cachedGetStaffTargetTask
......
......@@ -46,7 +46,6 @@ import {
applyEquityMenuBadges,
onWorkReportPopupSelect,
getMenuFingerprint,
invalidateEquityMenuApiCaches,
invalidateMenuAndApiCaches as clearSharedMenuApiCaches
} from '../../menu/index.js'
import {
......
......@@ -15,10 +15,4 @@ describe('imageBase', () => {
const { ImgUrl } = require(path.join(rootDir, 'config.js'))
assert.equal(IMG_URL, `${ImgUrl}/`)
})
it('IT-IMG-BASE-002: rootImageUrl builds images/ path', () => {
setupWxMock(globalThis)
const { rootImageUrl } = require(path.join(rootDir, 'utils/imageBase.js'))
assert.match(rootImageUrl('search.png'), /\/images\/search\.png$/)
})
})
......@@ -10,7 +10,7 @@ import { setupWxMock } from './menuTestHelpers.mjs'
import {
cachedHasPerformanceConfig,
clearMenuApiCache,
invalidateEquityMenuApiCaches
invalidateMenuAndApiCaches
} from '../menu/menuApiCache.js'
import {
__setApiClientForTest,
......@@ -35,7 +35,7 @@ describe('equityStoreSwitch', async () => {
__setApiClientForTest(null)
})
it('IT-EQ-STORE-SWITCH-001: invalidateEquityMenuApiCaches clears menu API cache', async () => {
it('IT-EQ-STORE-SWITCH-001: invalidateMenuAndApiCaches clears menu API cache', async () => {
let perfCalls = 0
const commonApi = {
hasPerformanceConfig: async () => {
......@@ -47,13 +47,13 @@ describe('equityStoreSwitch', async () => {
await cachedHasPerformanceConfig(commonApi, 'store-a')
assert.equal(perfCalls, 1)
invalidateEquityMenuApiCaches()
invalidateMenuAndApiCaches()
await cachedHasPerformanceConfig(commonApi, 'store-a')
assert.equal(perfCalls, 2)
})
it('IT-EQ-STORE-SWITCH-001b: invalidateEquityMenuApiCaches clears daily report isNeed cache', async () => {
it('IT-EQ-STORE-SWITCH-001b: invalidateMenuAndApiCaches clears daily report isNeed cache', async () => {
let isNeedCalls = 0
__setApiClientForTest({
dailyReportNewVersionIsNeed: async () => {
......@@ -65,7 +65,7 @@ describe('equityStoreSwitch', async () => {
await fetchDailyReportNewVersionMenuVisible('store-a')
assert.equal(isNeedCalls, 1)
invalidateEquityMenuApiCaches()
invalidateMenuAndApiCaches()
await fetchDailyReportNewVersionMenuVisible('store-a')
assert.equal(isNeedCalls, 2)
......
// packageEquity/pages/employeeInspection/components/ItemSelectStore/itemSelectStore.js
import { array } from '~/utils/lib/md5';
import api from '../../api'
Component({
/**
......
/**
* @deprecated 请从 ~/utils/marketingFlag 引用(主包页不可直接引用分包模块)
*/
export {
buildMarketingFlagMap,
buildActivityIdMap,
buildMarketingMetaMaps,
resolveMarketingFlag,
resolveActivityId,
applyMarketingFlagToFlatGoods,
applyActivityIdToFlatGoods,
applyMarketingFlagToGoodsData,
applyActivityIdToGoodsData,
normalizeMarketingFlagOnItem,
normalizeActivityIdOnItem,
normalizeMarketingMetaOnItem,
resolvePackageMarketingFlag,
resolvePackageActivityId,
isMarketingActive,
applyMarketingFlagMapToSelectOrderItem,
applyMarketingFlagMapToSelectOrderList,
SELECT_ORDER_CATALOG_KEYS,
MARKETING_FLAG_ACTIVE
} from '~/utils/marketingFlag'
/**
* @file http 签名对 qs.stringify 的依赖契约(防误删 lib/qs.js)
* 运行:node --test tests/httpSign.qs.test.mjs
*/
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
const require = createRequire(import.meta.url)
const rootDir = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '..')
const qs = require(path.join(rootDir, 'utils/lib/qs.js'))
const sha1 = require(path.join(rootDir, 'utils/lib/sha1.js'))
/** 与 utils/request/http.js sign 保持一致,供单测与 qs 替换评估 */
function sign(params, secret, noSignAttr = []) {
delete params.sign
const objStr = qs.stringify(params, {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
const objVal = objStr.split('&')
const realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
const str = []
let obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
if (!noSignAttr.includes(e)) str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
describe('http sign qs dependency', () => {
it('IT-SIGN-QS-001: sign produces uppercase sha1 sign for flat params', () => {
const secret = 'test-secret'
const params = {
appKey: 'ak',
method: 'dj.api.test',
v: '1.0.0',
format: 'json',
locale: 'zh_CN',
source: 'dj-wechat',
foo: 'bar'
}
const signed = sign({ ...params }, secret, [])
assert.equal(typeof signed.sign, 'string')
assert.match(signed.sign, /^[0-9A-F]{40}$/)
assert.equal(signed.foo, 'bar')
})
it('IT-SIGN-QS-002: noSignAttr excludes keys from sign string', () => {
const secret = 'test-secret'
const base = {
appKey: 'ak',
method: 'dj.api.test',
v: '1.0.0',
format: 'json',
locale: 'zh_CN',
source: 'dj-wechat',
foo: 'bar'
}
const withExclude = sign({ ...base, skip: 'x' }, secret, ['skip'])
const withoutExclude = sign({ ...base, skip: 'x' }, secret, [])
assert.notEqual(withExclude.sign, withoutExclude.sign)
})
})
/**
* @file 省市区数据:从 CDN 拉取并本地缓存,替代 @vant/area-data 以减主包 npm 体积。
* 边界:仅提供数据加载,不调 setData;调用方在打开 van-area 前需 await loadAreaList。
*
* 主包预载:app.js 侧 effect require 本模块,满足 GLForm/GLCustForm 上传依赖链分析。
*/
const { ImgUrl } = require('../config.js')
......@@ -105,6 +107,5 @@ function loadAreaList() {
module.exports = {
AREA_LIST_CDN_URL,
isValidAreaList,
getAreaList,
loadAreaList
}
/**
* @file 菜单/页面点击埋点 API 薄封装;避免 util.js 依赖整包 api/api。
* 边界:仅 post burialPoint,不调 setData、不 getPageInstance。
*/
import requestApi from '~/utils/request/request.js'
/**
* 上报点击埋点(dj.api.smartcarlife.common.insertRecord)
* @param {{ userId: string, clickEventType: number }} data
* @returns {Promise<unknown>}
*/
export function burialPointRecord(data) {
return requestApi.get('dj.api.smartcarlife.common.insertRecord', data)
}
......@@ -38,16 +38,6 @@ export function getStorageSync(key) {
// JSON.parse(data)
}
/**设置标题栏 */
export function setNavigationBarTitleText(title) {
$Storage.set('app_title', title)
}
/**获取app标题 */
export function getNavigationBarTitleText() {
return $Storage.get('app_title')
}
/** 存储设备信息 */
export function setSystem_info() {
let info = $Storage.get('system_info')
......
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/'
// 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
......
/**
* @file 图片路径工具 — CDN(rootImageUrl/IMG_URL)与本地 components/images/ 分离;仅拼 URL,不 setData。
* @file 图片路径工具 — CDN(IMG_URL)与本地 components/images/ 分离;仅拼 URL,不 setData。
*/
import { ImgUrl } from '../config.js'
......@@ -7,13 +7,6 @@ import { ImgUrl } from '../config.js'
export const IMG_URL = `${ImgUrl}/`
/**
* 根目录 images/ 下静态图完整 URL(须已上传至 CDN images/ 目录)
* @param {string} name 文件名,如 search.png
* @returns {string}
*/
export const rootImageUrl = name => `${ImgUrl}/images/${name}`
/**
* components/images/ 下本地静态图(打进小程序包体,非 CDN)
* @param {string} name 文件名
* @returns {string} 如 /components/images/close.png
......
var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var S=_((le,M)=>{"use strict";M.exports=N;function y(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function N(t){if(t=t||{},t.circles)return Q(t);return t.proto?s:a;function e(f,i){for(var r=Object.keys(f),n=new Array(r.length),u=0;u<r.length;u++){var o=r[u],p=f[o];typeof p!="object"||p===null?n[o]=p:p instanceof Date?n[o]=new Date(p):ArrayBuffer.isView(p)?n[o]=y(p):n[o]=i(p)}return n}function a(f){if(typeof f!="object"||f===null)return f;if(f instanceof Date)return new Date(f);if(Array.isArray(f))return e(f,a);if(f instanceof Map)return new Map(e(Array.from(f),a));if(f instanceof Set)return new Set(e(Array.from(f),a));var i={};for(var r in f)if(Object.hasOwnProperty.call(f,r)!==!1){var n=f[r];typeof n!="object"||n===null?i[r]=n:n instanceof Date?i[r]=new Date(n):n instanceof Map?i[r]=new Map(e(Array.from(n),a)):n instanceof Set?i[r]=new Set(e(Array.from(n),a)):ArrayBuffer.isView(n)?i[r]=y(n):i[r]=a(n)}return i}function s(f){if(typeof f!="object"||f===null)return f;if(f instanceof Date)return new Date(f);if(Array.isArray(f))return e(f,s);if(f instanceof Map)return new Map(e(Array.from(f),s));if(f instanceof Set)return new Set(e(Array.from(f),s));var i={};for(var r in f){var n=f[r];typeof n!="object"||n===null?i[r]=n:n instanceof Date?i[r]=new Date(n):n instanceof Map?i[r]=new Map(e(Array.from(n),s)):n instanceof Set?i[r]=new Set(e(Array.from(n),s)):ArrayBuffer.isView(n)?i[r]=y(n):i[r]=s(n)}return i}}function Q(t){var e=[],a=[];return t.proto?i:f;function s(r,n){for(var u=Object.keys(r),o=new Array(u.length),p=0;p<u.length;p++){var c=u[p],l=r[c];if(typeof l!="object"||l===null)o[c]=l;else if(l instanceof Date)o[c]=new Date(l);else if(ArrayBuffer.isView(l))o[c]=y(l);else{var h=e.indexOf(l);h!==-1?o[c]=a[h]:o[c]=n(l)}}return o}function f(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return s(r,f);if(r instanceof Map)return new Map(s(Array.from(r),f));if(r instanceof Set)return new Set(s(Array.from(r),f));var n={};e.push(r),a.push(n);for(var u in r)if(Object.hasOwnProperty.call(r,u)!==!1){var o=r[u];if(typeof o!="object"||o===null)n[u]=o;else if(o instanceof Date)n[u]=new Date(o);else if(o instanceof Map)n[u]=new Map(s(Array.from(o),f));else if(o instanceof Set)n[u]=new Set(s(Array.from(o),f));else if(ArrayBuffer.isView(o))n[u]=y(o);else{var p=e.indexOf(o);p!==-1?n[u]=a[p]:n[u]=f(o)}}return e.pop(),a.pop(),n}function i(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return s(r,i);if(r instanceof Map)return new Map(s(Array.from(r),i));if(r instanceof Set)return new Set(s(Array.from(r),i));var n={};e.push(r),a.push(n);for(var u in r){var o=r[u];if(typeof o!="object"||o===null)n[u]=o;else if(o instanceof Date)n[u]=new Date(o);else if(o instanceof Map)n[u]=new Map(s(Array.from(o),i));else if(o instanceof Set)n[u]=new Set(s(Array.from(o),i));else if(ArrayBuffer.isView(o))n[u]=y(o);else{var p=e.indexOf(o);p!==-1?n[u]=a[p]:n[u]=i(o)}}return e.pop(),a.pop(),n}}});var V=_((ce,I)=>{"use strict";var C=Array.isArray,W=Object.keys,Z=Object.prototype.hasOwnProperty;I.exports=function t(e,a){if(e===a)return!0;if(e&&a&&typeof e=="object"&&typeof a=="object"){var s=C(e),f=C(a),i,r,n;if(s&&f){if(r=e.length,r!=a.length)return!1;for(i=r;i--!=0;)if(!t(e[i],a[i]))return!1;return!0}if(s!=f)return!1;var u=e instanceof Date,o=a instanceof Date;if(u!=o)return!1;if(u&&o)return e.getTime()==a.getTime();var p=e instanceof RegExp,c=a instanceof RegExp;if(p!=c)return!1;if(p&&c)return e.toString()==a.toString();var l=W(e);if(r=l.length,r!==W(a).length)return!1;for(i=r;i--!=0;)if(!Z.call(a,l[i]))return!1;for(i=r;i--!=0;)if(n=l[i],!t(e[n],a[n]))return!1;return!0}return e!==e&&a!==a}});var q=_(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0}),A.parseMultiDataPaths=ee,A.getDataOnPath=void 0;var E=/^\s/,b=function(t,e){throw new Error('Parsing data path "'+t+'" failed at char "'+t[e]+'" (index '+e+")")},L=function(t,e){for(var a=e.index;e.index<e.length;){var s=t[e.index];if(/^[0-9]/.test(s)){e.index++;continue}break}return a===e.index&&b(t,e.index),parseInt(t.slice(a,e.index),10)},R=function(t,e){var a=e.index,s=t[a];if(/^[_a-zA-Z$]/.test(s))for(e.index++;e.index<e.length;){var f=t[e.index];if(/^[_a-zA-Z0-9$]/.test(f)){e.index++;continue}break}else b(t,e.index);return t.slice(a,e.index)},B=function(t,e){for(var a=[R(t,e)],s={deepCmp:!1};e.index<e.length;){var f=t[e.index];if(f==="[")e.index++,a.push(L(t,e)),t[e.index]!=="]"&&b(t,e.index),e.index++;else if(f==="."){if(e.index++,t[e.index]==="*"){if(e.index++,t[e.index]==="*"){e.index++,s.deepCmp=!0;break}b(t,e.index)}a.push(R(t,e))}else break}return{path:a,options:s}},X=function(t,e){for(;E.test(t[e.index]);)e.index++;for(var a=[B(t,e)],s=!1;e.index<e.length;){var f=t[e.index];E.test(f)?e.index++:f===","?(s=!0,e.index++):s?(s=!1,a.push(B(t,e))):b(t,e.index)}return a},k=function(t,e){e.index<e.length&&b(t,e.index)};function ee(t){var e={length:t.length,index:0},a=X(t,e);return k(t,e),a}var te=function(t,e){var a=t;return e.forEach(function(s){a=typeof a!="object"||a===null?void 0:a[s]}),a};A.getDataOnPath=te});var H=_(m=>{"use strict";Object.defineProperty(m,"__esModule",{value:!0}),m.create=re,m.unwrap=ne;var z=function(t,e,a){if(typeof t!="object"||t===null)return t;var s={get:function(f,i){if(i==="__rawObject__")return t;var r=a.concat(i),n=t[i];return e.push({path:r,value:n}),z(n,e,r)}};return new Proxy(t,s)};function re(t,e){return z(t,e,[])}function ne(t){return typeof t!="object"||t===null||typeof t.__rawObject__!="object"?t:t.__rawObject__}});var K=_(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0}),x.behavior=void 0;var $,ae=G(S()),ie=G(V()),w=U(q()),j=U(H());function F(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function G(t){return t&&t.__esModule?t:{default:t}}function U(t){if(t&&t.__esModule)return t;var e={};if(t!=null){for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){var s=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,a):{};s.get||s.set?Object.defineProperty(e,a,s):e[a]=t[a]}}return e.default=t,e}var T=ae.default({proto:!0}),fe=0,oe=Behavior({lifetimes:{attached:function(){this.setData({_computedWatchInit:"attached"})},created:function(){this.setData({_computedWatchInit:"created"})}},definitionFilter:function(t){var e=t.computed,a=t.watch,s=[],f=fe++;s.push({fields:"_computedWatchInit",observer:function(){var i=this.data._computedWatchInit;if(i==="created"){var r={computedUpdaters:[],computedRelatedPathValues:{},watchCurVal:{}};this._computedWatchInfo||(this._computedWatchInfo={}),this._computedWatchInfo[f]=r,a&&Object.keys(a).forEach(function(u){var o=w.parseMultiDataPaths(u).map(function(p){var c=p.path,l=p.options,h=w.getDataOnPath(this.data,c);return l.deepCmp?T(h):h}.bind(this));r.watchCurVal[u]=o}.bind(this))}else if(i==="attached"){var n=this._computedWatchInfo[f];e&&Object.keys(e).forEach(function(u){var o=e[u],p=[],c=o(j.create(this.data,p)),l=p.map(function(d){var v=d.path;return{path:v,value:w.getDataOnPath(this.data,v)}}.bind(this));this.setData(F({},u,j.unwrap(c))),n.computedRelatedPathValues[u]=l;var h=function(){for(var d=n.computedRelatedPathValues[u],v=!1,D=0;D<d.length;D++){var P=d[D],Y=P.path;if(P.value!==w.getDataOnPath(this.data,Y)){v=!0;break}}if(!v)return!1;var g=[],J=o(j.create(this.data,g));return this.setData(F({},u,j.unwrap(J))),n.computedRelatedPathValues[u]=g,!0}.bind(this);n.computedUpdaters.push(h)}.bind(this))}}}),e&&s.push({fields:"**",observer:function(){if(this._computedWatchInfo){var i,r=this._computedWatchInfo[f];if(r)do i=r.computedUpdaters.some(function(n){return n.call(this)}.bind(this));while(i)}}}),a&&Object.keys(a).forEach(function(i){var r=w.parseMultiDataPaths(i);s.push({fields:i,observer:function(){if(this._computedWatchInfo){var n=this._computedWatchInfo[f];if(n){var u=n.watchCurVal[i],o=r.map(function(h){var d=h.path,v=h.options;return{val:w.getDataOnPath(this.data,d),options:v}}.bind(this)),p=o.map(function(h){var d=h.val;return h.options.deepCmp?T(d):d});n.watchCurVal[i]=p;for(var c=!1,l=0;l<p.length;l++)if(r[l].options.deepCmp?!ie.default(u[l],p[l]):u[l]!==p[l]){c=!0;break}c&&a[i].apply(this,o.map(function(h){return h.val}))}}}})}),typeof t.observers!="object"&&(t.observers={}),Array.isArray(t.observers)?($=t.observers).push.apply($,s):s.forEach(function(i){var r=t.observers[i.fields];r?t.observers[i.fields]=function(){i.observer.call(this),r.call(this)}:t.observers[i.fields]=i.observer})}});x.behavior=oe});"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"behavior",{enumerable:!0,get:function(){return O.behavior}}),exports.ComponentWithComputed=se,exports.BehaviorWithComputed=ue;var O=K();function se(t){return Array.isArray(t.behaviors)||(t.behaviors=[]),t.behaviors.unshift(O.behavior),Component(t)}function ue(t){return Array.isArray(t.behaviors)||(t.behaviors=[]),t.behaviors.unshift(O.behavior),Behavior(t)}
function e(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,a)}return o}function t(t){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?e(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var a=["canvasGetImageData","canvasPutImageData","canvasToTempFilePath","setEnableDebug","startAccelerometer","stopAccelerometer","getBatteryInfo","getClipboardData","setClipboardData","startCompass","stopCompass","addPhoneContact","startGyroscope","stopGyroscope","startBeaconDiscovery","stopBeaconDiscovery","getBeacons","startLocalServiceDiscovery","stopLocalServiceDiscovery","startDeviceMotionListening","stopDeviceMotionListening","getNetworkType","makePhoneCall","scanCode","getSystemInfo","vibrateShort","vibrateLong","getExtConfig","chooseLocation","getLocation","openLocation","chooseMessageFile","loadFontFace","chooseImage","previewImage","getImageInfo","saveImageToPhotosAlbum","compressImage","chooseVideo","saveVideoToPhotosAlbum","downloadFile","request","connectSocket","closeSocket","sendSocketMessage","uploadFile","login","checkSession","chooseAddress","authorize","addCard","openCard","chooseInvoice","chooseInvoiceTitle","getUserInfo","requestPayment","getWeRunData","showModal","showToast","hideToast","showLoading","hideLoading","showActionSheet","pageScrollTo","startPullDownRefresh","stopPullDownRefresh","setBackgroundColor","setBackgroundTextStyle","setTabBarBadge","removeTabBarBadge","showTabBarRedDot","hideTabBarRedDot","showTabBar","hideTabBar","setTabBarStyle","setTabBarItem","setTopBarText","saveFile","openDocument","getSavedFileList","getSavedFileInfo","removeSavedFile","getFileInfo","getStorage","setStorage","removeStorage","clearStorage","getStorageInfo","closeBLEConnection","closeBluetoothAdapter","createBLEConnection","getBLEDeviceCharacteristics","getBLEDeviceServices","getBluetoothAdapterState","getBluetoothDevices","getConnectedBluetoothDevices","notifyBLECharacteristicValueChange","openBluetoothAdapter","readBLECharacteristicValue","startBluetoothDevicesDiscovery","stopBluetoothDevicesDiscovery","writeBLECharacteristicValue","getHCEState","sendHCEMessage","startHCE","stopHCE","getScreenBrightness","setKeepScreenOn","setScreenBrightness","connectWifi","getConnectedWifi","getWifiList","setWifiList","startWifi","stopWifi","getBackgroundAudioPlayerState","playBackgroundAudio","pauseBackgroundAudio","seekBackgroundAudio","stopBackgroundAudio","getAvailableAudioSources","startRecord","stopRecord","setInnerAudioOption","playVoice","pauseVoice","stopVoice","getSetting","openSetting","getShareInfo","hideShareMenu","showShareMenu","updateShareMenu","checkIsSoterEnrolledInDevice","checkIsSupportSoterAuthentication","startSoterAuthentication","navigateBackMiniProgram","navigateToMiniProgram","setNavigationBarTitle","showNavigationBarLoading","hideNavigationBarLoading","setNavigationBarColor","redirectTo","reLaunch","navigateTo","switchTab","navigateBack"];Promise.prototype.finally||(Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(o){return t.resolve(e()).then((function(){return o}))}),(function(o){return t.resolve(e()).then((function(){throw o}))}))});var r=function(e){return function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise((function(a,r){e(t({fail:r,success:a},o))}))}},n=function(){wx.pro={},Object.keys(wx).forEach((function(e){a.indexOf(e)>=0?wx.pro[e]=r(wx[e]):"createSignal"!==e&&"lanDebug"!==e&&(wx.pro[e]=wx[e])}))};export{r as promisify,n as promisifyAll};
//# sourceMappingURL=wx-promise-pro.js.map
......@@ -23,11 +23,6 @@ export function invalidateMenuAndApiCaches() {
invalidateSharedMenuApiCaches()
}
/** @deprecated 使用 invalidateMenuAndApiCaches */
export function invalidateEquityMenuApiCaches() {
invalidateMenuAndApiCaches()
}
function cacheKey(prefix, id) {
return `${prefix}:${id == null ? '' : String(id)}`
}
......
/**
* @file ROP 请求签名;序列化依赖 lib/qs(indices / allowDots / encodeValuesOnly)。
* 替换 qs 前须跑 tests/httpSign.qs.test.mjs 并做全量接口回归。
*/
import environment from './environment.js'
import sha1 from '~/utils/lib/sha1'
import qs from '~/utils/lib/qs'
......
......@@ -2,7 +2,6 @@ import { secretKey, domain, path, sign } from "./http.js";
// console.log(secretKey, 'secretKey')
import util from "~/utils/util.js";
import { envIndex } from "~/config";
import qs from "~/utils/lib/qs";
/**接口 */
class Request {
get(method, data, noSignAttr, requestPath, domainName, failTips) {
......
......@@ -246,11 +246,6 @@ function isTodayReport(date) {
return formatDateStr(date) === getTodayDateStr()
}
function isPastReport(date) {
const target = formatDateStr(date)
return target < getTodayDateStr()
}
function isDateWithin7Days(date, limitDate) {
const oneDay = 24 * 60 * 60 * 1000
const currentDate = new Date()
......@@ -296,7 +291,6 @@ module.exports = {
formatDateStr: formatDateStr,
getTodayDateStr: getTodayDateStr,
isTodayReport: isTodayReport,
isPastReport: isPastReport,
isDateWithin7Days: isDateWithin7Days,
isDateWithin60Days: isDateWithin60Days
}
import api from '~/api/api'
import requestApi from '~/utils/request/request'
import { burialPointRecord } from '~/utils/burialPointApi'
import wxApi from '~/utils/utils_wx'
import format from '~/utils/utils_format'
import $router from '../router/index'
......@@ -89,12 +89,6 @@ const throttle = (fn, gapTime) => {
}
}
const promise = callBack => {
return new Promise((resolve, reject) => {
callBack(resolve, reject)
})
}
const getUserInfo = () => {
const user = wx.getStorageSync('dj_boutique_user_info') || null
const userInfo = user ? JSON.parse(user) : null
......@@ -103,9 +97,6 @@ const getUserInfo = () => {
}
return userInfo
}
const removeSellerInfo = () => {
wx.removeStorageSync('dj_boutique_seller_info')
}
const setUserInfo = userInfo => {
// console.log(userInfo)
// userInfo.loginrole
......@@ -166,24 +157,6 @@ const getSceneId = path => {
}
/**
* @description: 类型判断
* @param {data} 任意值
* @return: String
*/
var type = function (data) {
var toString = Object.prototype.toString
var dataType =
data instanceof Element ?
'element' // 为了统一DOM节点类型输出
:
toString
.call(data)
.replace(/\[object\s(.+)\]/, '$1')
.toLowerCase()
return dataType
}
/**
* 深克隆 所有原型链上的对象和属性
* 例: const bar=deepClone(foo)
* console.log(bar===foo) false
......@@ -197,25 +170,6 @@ const deepClone = obj => {
return clone(obj)
}
const getTimeState = () => {
let timeNow = new Date()
let hours = timeNow.getHours()
let text = ``
if (hours >= 0 && hours <= 6) {
text = `深夜了,不要熬夜太久哟`
} else if (hours > 6 && hours <= 8) {
text = `早上好`
} else if (hours > 8 && hours <= 10) {
text = `上午好`
} else if (hours > 10 && hours <= 13) {
text = `中午好`
} else if (hours > 13 && hours <= 17) {
text = `下午好`
} else if (hours > 17 && hours <= 23) {
text = `晚上好`
}
return text
}
const checkRule = function (obj, formRule) {
let target = Object.keys(formRule)
console.log(obj)
......@@ -245,15 +199,11 @@ const checkRule = function (obj, formRule) {
// 埋点
const pointRecord = clickEventType => {
let userInfo = getUserInfo()
// let sessionId = getSessionId()
let params = {
userId: userInfo.uuid,
clickEventType
}
console.log('burialPointRecord', params)
api.burialPointRecord(params).then(res => {
console.log('burialPointRecord', res)
})
burialPointRecord(params).catch(() => {})
}
/**
* 函数防抖:在指定的时间内,如果连续触发事件,则只执行一次,避免频繁触发。
......@@ -317,14 +267,12 @@ let mockRequestCount = null,
mockCache = null
const getMockData = async () => {
const MOCKDATA = $Storage.get('mock_data')
console.log(MOCKDATA)
let key
try {
if (MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
console.log(1)
return Promise.resolve(MOCKDATA)
} else {
if (!mockRequestCount) {
console.log(2)
mockCache = null
mockRequestCount = Date.now()
const data = await requestApi.getMock()
......@@ -333,8 +281,7 @@ const getMockData = async () => {
$Storage.set('mock_data', data)
return Promise.resolve(data)
} else {
console.log(3)
const key = Date.now()
key = Date.now()
return new Promise((resolve) => {
mockTimer[key] = setInterval(() => {
if (mockCache) {
......@@ -359,22 +306,18 @@ const util = {
haveEmoji,
replaceEmoji,
throttle,
promise,
getUserInfo,
setUserInfo,
getSessionId,
setOpenId,
getOpenId,
setSessionId,
removeSellerInfo,
removeStorage,
showNoAccess,
setStorageSync,
getStorageSync,
getSceneId,
type,
deepClone,
getTimeState,
checkRule,
pointRecord,
debounce,
......
......@@ -236,21 +236,11 @@ const isFullSucreen = isComponents => {
// }
// })
// }
/**获取设备信息 */
const getSystemInfoCallback = callBack => {
getSystemInfo({
success(res) {
callBack(res)
},
fail(err) {
callBack(err)
}
})
}
/**获取设备信息(委托 systemInfo,对齐 wx.getSystemInfo 回调形态) */
const wxApi = {
// getPhoneInfo,
previewImage,
getSystemInfo: getSystemInfoCallback,
getSystemInfo,
showLoading,
hideLoading,
setCopyData,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!