@conecli/cone-render 0.8.26 → 0.8.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import Taro, { RequestTask } from '@tarojs/taro'
2
1
  jsonHeader = 'application/json;charset=utf-8',
3
2
  formDataHeader = 'application/x-www-form-urlencoded',
4
3
  constructor() {
5
4
  this._init()
6
5
  }
7
6
  _init(): void {
8
7
  httpInterceptors.forEach((item) => {
9
8
  Taro.addInterceptor((chain) => item(chain))
10
9
  })
11
10
  }
12
11
 
13
12
  get(url: string, data: any = null, otherOptions = {}): Taro.RequestTask<any> {
14
13
  return this.request({ url, data, method: 'GET', ...otherOptions })
15
14
  }
16
15
 
17
16
  post(
18
17
  url: string,
19
18
  data: any = null,
20
19
  otherOptions = {},
21
20
  ): Taro.RequestTask<any> {
22
21
  return this.request({ url, data, method: 'POST', ...otherOptions })
23
22
  }
24
23
 
25
24
  request({
26
25
  url,
27
26
  method = 'POST',
28
27
  timeout = 7000,
29
28
  ...otherOptions
30
29
  }): RequestTask<any> {
31
30
  const { header: otherHeader, ...otherOpts } = otherOptions
32
31
  const header = {
33
32
  'content-type':
34
33
  method === 'POST'
35
34
  ? RequestHeaderContentType.formDataHeader
36
35
  : RequestHeaderContentType.jsonHeader,
37
36
  ...otherHeader,
38
37
  }
39
38
  const param: any = {
40
39
  url,
41
40
  method,
42
41
  timeout,
43
42
  header,
44
43
  credentials: 'include',
45
44
  ...otherOpts,
46
45
  }
47
46
  const requestTask = Taro.request(param)
48
47
  const requestTimeoutPromise =
49
48
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
50
49
  setTimeout(() => {
51
50
  resolve({
52
51
  statusCode: 500,
53
52
  resTimeoutState: true,
54
53
  errMsg: 'request timeout',
55
54
  })
56
55
  }, timeout)
57
56
  })
58
57
  return Promise.race([requestTask, requestTimeoutPromise]).then(
59
58
  (res: any) => {
60
59
  if (res && res.statusCode === 500 && res.resTimeoutState) {
61
60
  console.warn('request 请求超时 url:' + url)
62
61
  requestTask.abort && requestTask.abort()
63
62
  }
64
63
  return res
65
64
  },
66
65
  )
67
66
  }
67
+ import Taro, { RequestTask } from '@tarojs/taro'
68
68
  jsonHeader = 'application/json;charset=utf-8',
69
69
  formDataHeader = 'application/x-www-form-urlencoded',
70
70
  public fmInfo: {
71
71
  eid?: string
72
72
  fp?: string
73
73
  jsToken?: string
74
74
  sdkToken?: string
75
75
  }
76
76
  public api: ServiceInterFace.HttpApi
77
77
  constructor() {
78
78
  this._init()
79
79
  this.api = api
80
80
  }
81
81
  _init(): void {
82
82
  httpInterceptors.forEach((item) => {
83
83
  Taro.addInterceptor((chain) => item(chain))
84
84
  })
85
85
  }
86
86
 
87
87
  get(
88
88
  url: string,
89
89
  data: any = null,
90
90
  otherOptions = {},
91
91
  ): Promise<Taro.request.SuccessCallbackResult<any>> {
92
92
  return this.request({ url, data, method: 'GET', ...otherOptions })
93
93
  }
94
94
 
95
95
  post(
96
96
  url: string,
97
97
  data: any = null,
98
98
  otherOptions = {},
99
99
  ): Promise<Taro.request.SuccessCallbackResult<any>> {
100
100
  return this.request({ url, data, method: 'POST', ...otherOptions })
101
101
  }
102
102
 
103
103
  async request({
104
104
  url,
105
105
  method = 'POST',
106
106
  timeout = 7000,
107
107
  isColorVerify = false,
108
108
  ...otherOptions
109
109
  }): Promise<Taro.request.SuccessCallbackResult<any>> {
110
110
  const { header: otherHeader, ...otherOpts } = otherOptions
111
111
  const header = {
112
112
  'content-type':
113
113
  method === 'POST'
114
114
  ? RequestHeaderContentType.formDataHeader
115
115
  : RequestHeaderContentType.jsonHeader,
116
116
  ...otherHeader,
117
117
  }
118
118
  const getReqData = otherOptions.data
119
119
  if (url === this.api.apiFunc && typeof getReqData === 'object') {
120
120
  const { functionId } = getReqData
121
121
  console.log('获取当前是否需要color加固', isColorVerify, functionId)
122
122
  if (isColorVerify) {
123
123
  const { h5st } = await colorSign.paramsSign(getReqData)
124
124
  h5st && (getReqData.h5st = encodeURI(h5st))
125
125
  console.log(`${functionId}的apiReq_h5st===>:${h5st}`)
126
126
  }
127
127
  const { jsToken } = await colorSign.getFmInfo()
128
128
  jsToken && (getReqData['x-api-eid-token'] = jsToken)
129
129
  }
130
130
  const param: any = {
131
131
  url,
132
132
  method,
133
133
  timeout,
134
134
  header,
135
135
  credentials: 'include',
136
136
  ...otherOpts,
137
137
  }
138
138
  const requestTask = Taro.request(param)
139
139
  const requestTimeoutPromise =
140
140
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
141
141
  setTimeout(() => {
142
142
  resolve({
143
143
  statusCode: 500,
144
144
  resTimeoutState: true,
145
145
  errMsg: 'request timeout',
146
146
  })
147
147
  }, timeout)
148
148
  })
149
149
  return Promise.race([requestTask, requestTimeoutPromise]).then(
150
150
  (res: any) => {
151
151
  if (res && res.statusCode === 500 && res.resTimeoutState) {
152
152
  console.warn('request 请求超时 url:' + url)
153
153
  requestTask.abort && requestTask.abort()
154
154
  }
155
155
  return res
156
156
  },
157
157
  )
158
158
  }
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro'
2
  APPID,
1
3
  JshopxColorFunctionIdList,
2
4
  PagesColorFunctionIdList,
3
5
  PAGES_DOMAIN,
4
6
  B2BColorFunctionIdList,
5
7
  MobileVerifyColorList,
6
8
  AppVerifyColorList,
7
9
  JshopxVerifyColorList,
8
10
  BMallVerifyColorList,
9
11
  shopMemberColorFunctionIdList
10
12
  cookiesStr: '',
11
13
  requestHeaderContentType: {
12
14
  jsonHeader: {
13
15
  'content-type': 'application/json;charset=utf-8',
14
16
  },
15
17
  formDataHeader: {
16
18
  'content-type': 'application/x-www-form-urlencoded',
17
19
  },
18
20
  },
19
21
  requestBaseParam: {
20
22
  data: null,
21
23
  header: {
22
24
  'content-type': 'application/json;charset=utf-8',
23
25
  },
24
26
  },
25
27
  timeOut: 7000,
26
28
  apiClientParams: {
27
29
  appid: APPID.SHOP_COLOR_APPID,
28
30
  clientVersion:
29
31
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
30
32
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
31
33
  area: '1_72_2799_0',
32
34
  uuid: UUID,
33
35
  },
34
36
  public addressFetchInfo: {
35
37
  reqState: boolean
36
38
  promiseInstance: null | Promise<any>
37
39
  }
38
40
  public getPromotionConfig: {
39
41
  projectId: null | string | number
40
42
  pageId: null | string | number
41
43
  }
42
44
  public resInfo: ServiceInterFace.HttpRequestInfo
43
45
  public api: ServiceInterFace.HttpApi
44
46
  public isPageDomain: boolean
45
47
  public verifyColorList: string[]
46
48
  constructor(opt) {
47
49
  this._init()
48
50
  this.addressFetchInfo = {
49
51
  reqState: false,
50
52
  promiseInstance: null,
51
53
  }
52
54
  this.getPromotionConfig = {
53
55
  projectId: null,
54
56
  pageId: null,
55
57
  }
56
58
  this._userAreaUpdateListen()
57
59
  this.resInfo = this._getResConfig(opt)
58
60
  this.api = api
59
61
  this.isPageDomain = window.location.hostname === PAGES_DOMAIN
60
62
  this.verifyColorList = [
61
63
  ...MobileVerifyColorList,
62
64
  ...AppVerifyColorList,
63
65
  ...JshopxVerifyColorList,
64
66
  ...BMallVerifyColorList,
65
67
  ]
66
68
  }
67
69
  _init(): void {
68
70
  httpInterceptors.forEach((item) => {
69
71
  Taro.addInterceptor((chain) => item(chain))
70
72
  })
71
73
  }
72
74
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
73
75
  return Object.assign({}, DefaultConfig, opt)
74
76
  }
75
77
 
76
78
  _userAreaUpdateListen() {
77
79
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
78
80
  this.updateApiClientParamsResInfo({
79
81
  area,
80
82
  })
81
83
  })
82
84
  }
83
85
  updateApiClientParamsResInfo(opt = {}) {
84
86
  this.resInfo.apiClientParams = {
85
87
  ...this.resInfo.apiClientParams,
86
88
  ...opt,
87
89
  }
88
90
  }
89
91
 
90
92
  checkFunctionIdToReturnAppId(functionId) {
91
93
  if (JshopxColorFunctionIdList.includes(functionId)) {
92
94
  return APPID.JSHOPX_COLOR_APPID
93
95
  } else if (
94
96
  this.isPageDomain &&
95
97
  PagesColorFunctionIdList.includes(functionId)
96
98
  ) {
97
99
  return APPID.PAGES_COLOR_APPID
98
100
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
99
101
  return APPID.SHOP_MEMBER_COLOR_APPID
100
102
  }else if (B2BColorFunctionIdList.includes(functionId)) {
101
103
  return APPID.B2B_COLOR_APPID
102
104
  } else {
103
105
  return APPID.SHOP_COLOR_APPID
104
106
  }
105
107
  }
106
108
 
107
109
  gatewayReq(
108
110
  functionId: string,
109
111
  bodyParams = {},
110
112
  clientParams = {},
111
113
  ): Promise<any> {
112
114
  if (
113
115
  functionId === 'receiveShopCoupon' &&
114
116
  ((isH5 && window.isJingGouMiniViewState) || isWxMinAndWxapp)
115
117
  ) {
116
118
  clientParams = Object.assign(
117
119
  {},
118
120
  {
119
121
  loginType: '1',
120
122
  loginWQBiz: WXAPP_BIZ_KEY,
121
123
  },
122
124
  clientParams,
123
125
  )
124
126
  }
125
127
  const apiClientParams = Object.assign(
126
128
  {},
127
129
  this.resInfo.apiClientParams,
128
130
  clientParams,
129
131
  )
130
132
  typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
131
133
  const isColorVerify = this.verifyColorList.includes(functionId)
132
134
  const getReqData = {
133
135
  functionId: functionId,
134
136
  body: JSON.stringify(bodyParams),
135
137
  t: Date.now(),
136
138
  ...apiClientParams,
137
139
  }
138
140
  return http
139
141
  .request({
140
142
  url: this.api.apiFunc,
141
143
  data: getReqData,
142
144
  isColorVerify,
143
145
  })
144
146
  .then((res: ServiceInterFace.RequestPromiseRes) => {
145
147
  const { statusCode, data } = res
146
148
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
147
149
  ok: true,
148
150
  }
149
151
  if (statusCode === 200 && data) {
150
152
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
151
153
  ? Number(res.data.code)
152
154
  : -1
153
155
  const subCode = Object.prototype.hasOwnProperty.call(
154
156
  res.data,
155
157
  'subCode',
156
158
  )
157
159
  ? Number(res.data.subCode)
158
160
  : -1
159
161
  if (
160
162
  data.success === true ||
161
163
  data.isSuccess ||
162
164
  resCode === 0 ||
163
165
  resCode === 200 ||
164
166
  subCode === 0
165
167
  ) {
166
168
  changeRes = {
167
169
  result: Object.prototype.hasOwnProperty.call(data, 'result')
168
170
  ? data.result
169
171
  : Object.prototype.hasOwnProperty.call(data, 'data')
170
172
  ? data.data
171
173
  : data,
172
174
  code: data.code || 200,
173
175
  ok: true,
174
176
  source: data,
175
177
  }
176
178
  return changeRes
177
179
  } else {
178
180
  changeRes = {
179
181
  ...data,
180
182
  ok: false,
181
183
  statusCode: res.statusCode,
182
184
  }
183
185
  return changeRes
184
186
  }
185
187
  } else {
186
188
  changeRes = {
187
189
  ...data,
188
190
  ok: false,
189
191
  statusCode: res.statusCode,
190
192
  }
191
193
  return changeRes
192
194
  }
193
195
  })
194
196
  .catch((res) => {
195
197
  return {
196
198
  ...res,
197
199
  ok: false,
198
200
  } as ServiceInterFace.RequestResponseFormatRes
199
201
  })
200
202
  }
201
203
 
202
204
  async receiveCoupon(param = {}, clientParams) {
203
205
  return await this.gatewayReq(
204
206
  'receiveShopCoupon',
205
207
  {
206
208
  operation: '3',
207
209
  ...param,
208
210
  },
209
211
  clientParams,
210
212
  )
211
213
  }
212
214
 
213
215
  getCustomerCenterDispatch(params = {}) {
214
216
  return this.gatewayReq('customerCenterDispatch', params, {
215
217
  clientVersion: '9.2.0',
216
218
  client: 'H5',
217
219
  uuid: 88888,
218
220
  appid: 'shopmember_m_jd_com',
219
221
  })
220
222
  }
221
223
  bMallGetUserInfo = () => {
222
224
  return bMallUserInfo
223
225
  }
224
226
  async bMallAddCart(params = {}) {
225
227
  return await this.gatewayReq('bmall_cartAdd', params, {
226
228
  client: 'H5',
227
229
  clientVersion: '5.5.0'
228
230
  })
229
231
  }
230
232
  async bMallChangeCart(params = {}) {
231
233
  return await this.gatewayReq('bmall_cartChange', params, {
232
234
  client: 'H5',
233
235
  clientVersion: '5.5.0'
234
236
  })
235
237
  }
236
238
  async bMallRemoveCart(params = {}) {
237
239
  return await this.gatewayReq(
238
240
  'bmall_cartRemove',
239
241
  params,
240
242
  {
241
243
  client: 'H5',
242
244
  clientVersion: '5.5.0'
243
245
  },
244
246
  )
245
247
  }
246
248
  async bMallGetOmittedProduct(params = {}) {
247
249
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
248
250
  client: 'H5',
249
251
  clientVersion: '5.5.0'
250
252
  })
251
253
  }
252
254
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
253
255
  const params = await getParams({ ...data, skuId, bMallTag, num })
254
256
  return await this.bMallAddCart(params)
255
257
  }
256
258
  async bMallGetSkuNumService(bMallTag = 1) {
257
259
  const params = await getParams({ bMallTag })
258
260
  delete params.operations
259
261
  return await this.bMallGetOmittedProduct(params)
260
262
  }
261
263
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
262
264
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
263
265
  return await this.bMallRemoveCart(params)
264
266
  }
265
267
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
266
268
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
267
269
  return await this.bMallChangeCart(params)
268
270
  }
269
271
 
270
272
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
271
273
  if (!needRequest && window.bMallCartData) {
272
274
  return window.bMallCartData
273
275
  }
274
276
  const cartData = await this.bMallGetSkuNumService(bMallTag)
275
277
  let items
276
278
  if (cartData.ok && cartData.result) {
277
279
  items = cartData?.result?.items || {}
278
280
  }
279
281
  window.bMallCartData = items
280
282
  return items
281
283
  }
282
284
 
283
285
  async bMallCartHandle(goodItem, num) {
284
286
  try {
285
287
  const {
286
288
  skuUuid,
287
289
  limitUpper,
288
290
  limitLower,
289
291
  } = goodItem
290
292
  let cartNum = Number(num)
291
293
  if (limitLower && cartNum && cartNum < limitLower) {
292
294
  cartNum = limitLower
293
295
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
294
296
  cartNum = limitUpper
295
297
  }
296
298
  if (skuUuid && cartNum > 0) {
297
299
  return this.bMallChangeCartService({
298
300
  ...goodItem,
299
301
  skuUuid,
300
302
  num: cartNum,
301
303
  })
302
304
  } else if (!skuUuid && cartNum > 0) {
303
305
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
304
306
  } else if (skuUuid && !cartNum) {
305
307
  return this.bMallRemoveCartService({
306
308
  ...goodItem,
307
309
  skuUuid,
308
310
  num: cartNum,
309
311
  })
310
312
  } else {
311
313
  console.error('参数不全')
312
314
  return false
313
315
  }
314
316
  } catch (e) {
315
317
  console.error(e)
316
318
  }
317
319
  }
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
3
2
  displayHeight: 1920,
4
3
  offSetY: 0
5
4
  }
6
5
  console.log('>>>>>>>>>>>>>>>>>>> render taroEventSendPageScrollInfo origin time:', Date.now(), 'res:', options)
7
6
  if(options){
8
7
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options
9
8
  }
10
9
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
11
10
  const { displayHeight, offSetY } = res
12
11
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
13
12
 
14
13
  if (isIosDevice) return res
15
14
 
16
15
  if (isAndroidDevice) {
17
16
  const deviceRatio = window.devicePixelRatio
18
17
  const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio)
19
18
  const cssOffsetY = Math.ceil(offSetY / deviceRatio)
20
19
  return {
21
20
  displayHeight: cssDisplayHeight,
22
21
  offSetY: cssOffsetY
23
22
  }
24
23
  }
24
+ import Taro from '@tarojs/taro'
25
25
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
26
26
  displayHeight: 1920,
27
27
  offSetY: 0
28
28
  }
29
29
  console.log('>>>>>>>>>>>>>>>>>>> render taroEventSendPageScrollInfo origin time:', Date.now(), 'res:', options)
30
30
  if(options){
31
31
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options
32
32
  }
33
33
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
34
34
  PAGE_PV_PARAM: 'pagePvParam'
35
35
  const { displayHeight, offSetY } = res
36
36
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
37
37
 
38
38
  if (isIosDevice) return res
39
39
 
40
40
  if (isAndroidDevice) {
41
41
  const deviceRatio = window.devicePixelRatio
42
42
  const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio)
43
43
  const cssOffsetY = Math.ceil(offSetY / deviceRatio)
44
44
  return {
45
45
  displayHeight: cssDisplayHeight,
46
46
  offSetY: cssOffsetY
47
47
  }
48
48
  }
@@ -1 +1 @@
1
- var splitOnFirst = function splitOnFirst(string, separator) {
2
1
  return Object.prototype.toString.call(obj);
3
2
  return typeof obj === 'function';
4
3
  return '[object Object]' === getType(obj);
5
4
  return '[object Array]' == getType(obj);
6
5
  return '[object Undefined]' === getType(obj);
7
6
  return '[object Null]' == getType(obj);
8
7
  return typeof obj === 'string';
9
8
  return typeof obj === 'boolean';
10
9
  return '[object Number]' === getType(num);
11
10
  ua = ua || navigator.userAgent;
12
11
  if (name === 'wx') return (/micromessenger/i.test(ua)
13
12
  );
14
13
  if (name === 'qq') return (/qq\//i.test(ua)
15
14
  );
16
15
  if (name === 'weibo') return (/weibo/i.test(ua)
17
16
  );
18
17
  if (name === 'jd') return (/^jdapp/i.test(ua)
19
18
  );
20
19
  if (name === 'jdlittle') return (/^jdltapp/i.test(ua)
21
20
  );
22
21
  if (name === 'mp') return navigator.userAgent.match(/micromessenger/i) && navigator.userAgent.match(/miniprogram/i) || window.__wxjs_environment === 'miniprogram';
23
22
  return false;
24
23
  ua = ua || navigator.userAgent;
25
24
  return (/android/i.test(ua) && !isIOS()
26
25
  );
27
26
  ua = ua || navigator.userAgent;
28
27
  return (/ip(hone|od)|ipad/i.test(ua)
29
28
  );
30
29
  ua = ua || navigator.userAgent;
31
30
  return (/ipad/i.test(ua) || /android/i.test(ua) && !/mobi|mini|fennec/i.test(ua)
32
31
  );
33
32
  ua = ua || navigator.userAgent;
34
33
  return !!ua.match(/ip(hone|od)|android.+mobile|windows (ce|phone)|blackberry|bb10|symbian|webos|firefox.+fennec|opera m(ob|in)i|polaris|iemobile|lgtelecom|nokia|sonyericsson|dolfin|uzard|natebrowser|ktf;|skt;/i);
35
34
  ua = ua || navigator.userAgent;
36
35
  return !!ua.match(/iphone/i);
37
36
  ua = ua || navigator.userAgent;
38
37
  return !!ua.match(/ipad/i);
39
38
  ua = ua || navigator.userAgent;
40
39
  if (name === 'xview') return typeof window.XView !== 'undefined';
41
40
  if (name === 'wk') return !!ua.match(/supportjdshwk/i) || window._is_jdsh_wkwebview == 1;
42
41
  return false;
43
42
  ua = ua || navigator.userAgent;
44
43
  var re = /nettype\/([\S]*)/i;
45
44
  if (isApp('jd', ua)) re = /network\/([^;]*)/i;
46
45
  return re.test(ua) ? RegExp.$1.toLowerCase() : 'unknown';
47
46
  ua = ua || navigator.userAgent;
48
47
  if (!isApp('jd', ua)) return null;
49
48
  return ua.split(';')[4];
50
49
  ua = ua || navigator.userAgent;
51
50
  if (appName === 'jd') return ua.split(';')[2] || null;
52
51
  if (appName === 'wx') return (/micromessenger\/([\S]*)/i.test(ua) ? RegExp.$1 : null
53
52
  );
54
53
  if (appName === 'qq') return (/qq\/([\S]*)/i.test(ua) ? RegExp.$1 : null
55
54
  );
56
55
  return null;
57
56
  ua = ua || navigator.userAgent;
58
57
  var match = ua.match(/android\s([0-9\.]*)/i);
59
58
  return match ? match[1] : 'unknown';
60
59
  ua = ua || navigator.userAgent;
61
60
  var match = ua.match(/OS ((\d+_?){2,3})\s/i);
62
61
  return match ? match[1].replace(/_/g, '.') : 'unknown';
62
+ var splitOnFirst = function splitOnFirst(string, separator) {
63
63
  return Object.prototype.toString.call(obj);
64
64
  return typeof obj === 'function';
65
65
  return '[object Object]' === getType(obj);
66
66
  return '[object Array]' == getType(obj);
67
67
  return '[object Undefined]' === getType(obj);
68
68
  return '[object Null]' == getType(obj);
69
69
  return typeof obj === 'string';
70
70
  return typeof obj === 'boolean';
71
71
  return '[object Number]' === getType(num);
72
72
  ua = ua || navigator.userAgent;
73
73
  if (name === 'wx') return (/micromessenger/i.test(ua)
74
74
  );
75
75
  if (name === 'qq') return (/qq\//i.test(ua)
76
76
  );
77
77
  if (name === 'weibo') return (/weibo/i.test(ua)
78
78
  );
79
79
  if (name === 'jd') return (/^jdapp/i.test(ua)
80
80
  );
81
81
  if (name === 'jdlittle') return (/^jdltapp/i.test(ua)
82
82
  );
83
83
  if (name === 'mp') return navigator.userAgent.match(/micromessenger/i) && navigator.userAgent.match(/miniprogram/i) || window.__wxjs_environment === 'miniprogram';
84
84
  if (name === 'jdb') return (/JDBmall/i.test(ua)
85
85
  );
86
86
  return false;
87
87
  ua = ua || navigator.userAgent;
88
88
  return (/android/i.test(ua) && !isIOS()
89
89
  );
90
90
  ua = ua || navigator.userAgent;
91
91
  return (/ip(hone|od)|ipad/i.test(ua)
92
92
  );
93
93
  ua = ua || navigator.userAgent;
94
94
  return (/ipad/i.test(ua) || /android/i.test(ua) && !/mobi|mini|fennec/i.test(ua)
95
95
  );
96
96
  ua = ua || navigator.userAgent;
97
97
  return !!ua.match(/ip(hone|od)|android.+mobile|windows (ce|phone)|blackberry|bb10|symbian|webos|firefox.+fennec|opera m(ob|in)i|polaris|iemobile|lgtelecom|nokia|sonyericsson|dolfin|uzard|natebrowser|ktf;|skt;/i);
98
98
  ua = ua || navigator.userAgent;
99
99
  return !!ua.match(/iphone/i);
100
100
  ua = ua || navigator.userAgent;
101
101
  return !!ua.match(/ipad/i);
102
102
  ua = ua || navigator.userAgent;
103
103
  if (name === 'xview') return typeof window.XView !== 'undefined';
104
104
  if (name === 'wk') return !!ua.match(/supportjdshwk/i) || window._is_jdsh_wkwebview == 1;
105
105
  return false;
106
106
  ua = ua || navigator.userAgent;
107
107
  var re = /nettype\/([\S]*)/i;
108
108
  if (isApp('jd', ua)) re = /network\/([^;]*)/i;
109
109
  return re.test(ua) ? RegExp.$1.toLowerCase() : 'unknown';
110
110
  ua = ua || navigator.userAgent;
111
111
  if (!isApp('jd', ua)) return null;
112
112
  return ua.split(';')[4];
113
113
  ua = ua || navigator.userAgent;
114
114
  if (appName === 'jd') return ua.split(';')[2] || null;
115
115
  if (appName === 'wx') return (/micromessenger\/([\S]*)/i.test(ua) ? RegExp.$1 : null
116
116
  );
117
117
  if (appName === 'qq') return (/qq\/([\S]*)/i.test(ua) ? RegExp.$1 : null
118
118
  );
119
119
  return null;
120
120
  ua = ua || navigator.userAgent;
121
121
  var match = ua.match(/android\s([0-9\.]*)/i);
122
122
  return match ? match[1] : 'unknown';
123
123
  ua = ua || navigator.userAgent;
124
124
  var match = ua.match(/OS ((\d+_?){2,3})\s/i);
125
125
  return match ? match[1].replace(/_/g, '.') : 'unknown';
@@ -0,0 +1 @@
1
+ function checkExpression(expression: any, context: any = window) {
2
  let isExist = false
1
3
  const isFunction = typeof expression === 'function'
2
4
  if (isFunction) {
3
5
  if (expression()) {
4
6
  isExist = true
5
7
  }
6
8
  } else {
7
9
  if (context[expression] !== undefined) {
8
10
  isExist = true
9
11
  }
10
12
  }
11
13
  return isExist
12
14
  expression: any,
13
15
  timeout: number = 1000,
14
16
  context: any = window,
15
17
  return new Promise((resolve, reject) => {
16
18
  const interval = 16 * 5
17
19
  const endTime = Date.now() + timeout
18
20
  function checkReady() {
19
21
  if (checkExpression(expression, context)) {
20
22
  resolve()
21
23
  } else if (Date.now() < endTime) {
22
24
  setTimeout(checkReady, interval)
23
25
  } else {
24
26
  reject('ready check timeout')
25
27
  }
26
28
  }
27
29
  checkReady()
28
30
  })