@conecli/cone-render 0.8.21 → 0.8.22-beta.0

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 { isApp, getUrlQuery } from '../utils/jm-common'
1
+ import { isApp, getUrlQuery } from '../utils/jm-common'
@@ -0,0 +1 @@
1
+ import { JdJumpJdApp } from './jdJumpJdApp'
2
  reportClick,
1
3
  reportToCart,
2
4
  routerInfo: {
3
5
  params: {},
4
6
  },
5
7
  nativeEvent: null,
6
8
  jumpConfig: {
7
9
  venderId: null,
8
10
  shopId: null,
9
11
  sourceValue: '',
10
12
  sourceType: 'App-H5',
11
13
  activityType: 'shopx',
12
14
  moduleId: 'none',
13
15
  entrance: 'none',
14
16
  },
15
17
  logPageParamStr: '',
16
18
  public logPageId: string
17
19
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig
18
20
  constructor(opt = {}) {
19
21
  console.log("jdb加载==========")
20
22
  super(opt)
21
23
  this.getConfig(opt)
22
24
  }
23
25
 
24
26
  jdJumpToProduct(skuParams, logEventInfo) {
25
27
  if(typeof skuParams !== 'object') {
26
28
  console.error('万商app跳转商品详情参数需要对象,详情请查看文档')
27
29
  return
28
30
  }
29
31
 
30
32
  let { skuId, bMallTag, skuUniformBizInfo } = skuParams
31
33
  skuId = skuId.toString().trim()
32
34
  this.jdNavigateToNative({
33
35
  category: 'jump',
34
36
  des: 'skudetail',
35
37
  param: {
36
38
  skuId: skuId,
37
39
  bMallTag: bMallTag,
38
40
  skuUniformBizInfo
39
41
  },
40
42
  logEventInfo,
41
43
  })
42
44
  }
43
45
  jdNavigateToNative(
44
46
  console.log("otherParams", otherParams)
45
47
  const paramsStr = JSON.stringify(otherParams)
46
48
  console.log(
47
49
  '跳转web jd open协议',
48
50
  `${url}?params=${paramsStr}`,
49
51
  )
50
52
  console.log('catch', e)
51
53
  clickEventLog(
52
54
  getConfig(opt = {}) {
53
55
  return Object.assign(this, {}, defaultConfig, opt)
54
56
  }
@@ -1 +1 @@
1
- import * as device from './device'
1
+ import * as device from './device'
2
2
  device,
3
3
  environment,
4
4
  jump,
5
5
  storage,
6
6
  util,
7
7
  moduleUtil,
8
8
  track,
9
9
  trackPromise,
10
10
  global,
11
11
  http,
12
12
  shopMember,
13
13
  requestServer,
@@ -0,0 +1 @@
1
+ const userInfo =
2
  (window.WebViewCommon && window.WebViewCommon.getUserInfo()) || {}
1
3
  buId: userInfo.buId,
2
4
  process.env.NODE_ENV === 'development'
3
5
  ? {
4
6
  apolloId: '48ee955b0fb04d19b9f9fe8cb73d387f',
5
7
  apolloSecret: '0d9c76ee66b0487da4e17d3cf1d7af7a',
6
8
  }
7
9
  : {
8
10
  apolloId: '80c46fd06e4442998609d9f6a4ab96f0',
9
11
  apolloSecret: 'f36bef08bcba4683b409732095793fb2',
10
12
  }
11
13
  if (typeof window.crypto === 'object') {
12
14
  if (typeof (window.crypto as any).randomUUID === 'function') {
13
15
  return (window.crypto as any).randomUUID()
14
16
  }
15
17
  if (
16
18
  typeof (window.crypto as any).getRandomValues === 'function' &&
17
19
  typeof Uint8Array === 'function'
18
20
  ) {
19
21
  const callback = (c) => {
20
22
  const num = Number(c)
21
23
  return (
22
24
  num ^
23
25
  ((window.crypto as any).getRandomValues(new Uint8Array(1))[0] &
24
26
  (15 >> (num / 4)))
25
27
  ).toString(16)
26
28
  }
27
29
  return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, callback)
28
30
  }
29
31
  }
30
32
  let timestamp = new Date().getTime()
31
33
  let perforNow =
32
34
  (typeof window.performance !== 'undefined' &&
33
35
  window.performance.now &&
34
36
  window.performance.now() * 1000) ||
35
37
  0
36
38
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
37
39
  let random = Math.random() * 16
38
40
  if (timestamp > 0) {
39
41
  random = (timestamp + random) % 16 | 0
40
42
  timestamp = Math.floor(timestamp / 16)
41
43
  } else {
42
44
  random = (perforNow + random) % 16 | 0
43
45
  perforNow = Math.floor(perforNow / 16)
44
46
  }
45
47
  return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
46
48
  })
47
49
  let params = {
48
50
  uniformBizInfo: {
49
51
  tenantId: 1024,
50
52
  ua: 1,
51
53
  buId: commonParam.buId || 377,
52
54
  bMallTag: bMallTag,
53
55
  },
54
56
  commonParam: {
55
57
  pid: 100,
56
58
  verticalCode: 'cn_retail_bmall',
57
59
  ua: 1,
58
60
  language: 'zh',
59
61
  },
60
62
  operations: [{ TheSkus: [{ Id: skuId, num: num || 1 }] }],
61
63
  apolloId: APOLLO.apolloId,
62
64
  apolloSecret: APOLLO.apolloSecret,
63
65
  client: 'H5',
64
66
  verticalTag: 'cn_retail_bmall',
65
67
  carttype: bMallTag == 1 ? 21 : 22,
66
68
  bMallTag: bMallTag,
67
69
  traceId: getUuid(),
68
70
  noResponse: true,
69
71
  }
70
72
  if (skuUuid) {
71
73
  params.operations[0].TheSkus[0].skuUuid = skuUuid
72
74
  }
73
75
  if (window?.siteTransResult?.gridInfoList) {
74
76
  params = {
75
77
  ...params,
76
78
  cartLocationList: [
77
79
  {
78
80
  gridInfos:
79
81
  window?.siteTransResult?.gridInfoList &&
80
82
  JSON.parse(window?.siteTransResult?.gridInfoList),
81
83
  areaIdSet:
82
84
  window?.siteTransResult?.area &&
83
85
  window?.siteTransResult?.area?.split('-'),
84
86
  },
85
87
  ],
86
88
  }
87
89
  }
88
90
  return params
@@ -1 +1 @@
1
- export const HttpStatus = {
2
1
  SUCCESS: 200,
3
2
  CREATED: 201,
4
3
  ACCEPTED: 202,
5
4
  CLIENT_ERROR: 400,
6
5
  AUTHENTICATE: 401,
7
6
  FORBIDDEN: 403,
8
7
  NOT_FOUND: 404,
9
8
  SERVER_ERROR: 500,
10
9
  BAD_GATEWAY: 502,
11
10
  SERVICE_UNAVAILABLE: 503,
12
11
  GATEWAY_TIMEOUT: 504
13
12
  [HttpStatus.NOT_FOUND]: "请求资源不存在",
14
13
  [HttpStatus.BAD_GATEWAY]: "服务端异常,请稍后重试",
15
14
  [HttpStatus.FORBIDDEN]: "没有权限访问",
16
15
  [HttpStatus.AUTHENTICATE]: "需要鉴权",
17
16
  [HttpStatus.SUCCESS]: "成功"
17
+ export const HttpStatus = {
18
18
  SUCCESS: 200,
19
19
  CREATED: 201,
20
20
  ACCEPTED: 202,
21
21
  CLIENT_ERROR: 400,
22
22
  AUTHENTICATE: 401,
23
23
  FORBIDDEN: 403,
24
24
  NOT_FOUND: 404,
25
25
  SERVER_ERROR: 500,
26
26
  BAD_GATEWAY: 502,
27
27
  SERVICE_UNAVAILABLE: 503,
28
28
  GATEWAY_TIMEOUT: 504
29
29
  [HttpStatus.NOT_FOUND]: "请求资源不存在",
30
30
  [HttpStatus.BAD_GATEWAY]: "服务端异常,请稍后重试",
31
31
  [HttpStatus.FORBIDDEN]: "没有权限访问",
32
32
  [HttpStatus.AUTHENTICATE]: "需要鉴权",
33
33
  [HttpStatus.SUCCESS]: "成功"
34
34
  "getPagePreview"
35
35
  "getShopHomeFloorInfo",
36
36
  "getShopCategory",
37
37
  "getShopNavigationCategory",
38
38
  "receiveShopCoupon",
39
39
  "getShopHomePromotionWebPage",
40
40
  "shopGuessYouLike",
41
41
  "addRemind",
42
42
  "cancelRemind",
43
43
  "getVipDetail",
44
44
  "shopDetail",
45
45
  "address_queryAddress",
46
46
  "shopMemberSprintJoinActivity",
47
47
  "shopMemberSprintReceivePrize"
@@ -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({url, method = "POST", timeout = 7000, ...otherOptions}): RequestTask<any> {
26
25
  const header = {
27
26
  "content-type": method === "POST" ? RequestHeaderContentType.formDataHeader : RequestHeaderContentType.jsonHeader
28
27
  }
29
28
  const requestTask = Taro.request({
30
29
  url,
31
30
  method,
32
31
  timeout,
33
32
  header,
34
33
  credentials: 'include',
35
34
  ...otherOptions,
36
35
  })
37
36
  const requestTimeoutPromise =
38
37
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
39
38
  setTimeout(() => {
40
39
  resolve({
41
40
  statusCode: 500,
42
41
  resTimeoutState: true,
43
42
  errMsg: 'request timeout',
44
43
  })
45
44
  }, timeout)
46
45
  })
47
46
  return Promise.race([requestTask, requestTimeoutPromise]).then(
48
47
  (res: any) => {
49
48
  if (res && res.statusCode === 500 && res.resTimeoutState) {
50
49
  console.log('request 请求超时 url:' + url)
51
50
  requestTask.abort && requestTask.abort()
52
51
  }
53
52
  return res
54
53
  }
55
54
  )
56
55
  }
56
+ import Taro, { RequestTask } from '@tarojs/taro'
57
57
  jsonHeader = 'application/json;charset=utf-8',
58
58
  formDataHeader = 'application/x-www-form-urlencoded',
59
59
  public fmInfo: {
60
60
  eid?: string
61
61
  fp?: string
62
62
  jsToken?: string
63
63
  sdkToken?: string
64
64
  }
65
65
  public api: ServiceInterFace.HttpApi
66
66
  constructor() {
67
67
  this._init()
68
68
  this.api = api
69
69
  this.fmInfo = {}
70
70
  }
71
71
  _init(): void {
72
72
  httpInterceptors.forEach((item) => {
73
73
  Taro.addInterceptor((chain) => item(chain))
74
74
  })
75
75
  }
76
76
 
77
77
  get(url: string, data: any = null, otherOptions = {}): Taro.RequestTask<any> {
78
78
  return this.request({ url, data, method: 'GET', ...otherOptions })
79
79
  }
80
80
 
81
81
  post(
82
82
  url: string,
83
83
  data: any = null,
84
84
  otherOptions = {},
85
85
  ): Taro.RequestTask<any> {
86
86
  return this.request({ url, data, method: 'POST', ...otherOptions })
87
87
  }
88
88
 
89
89
  _getMobileJsToken(): Promise<{
90
90
  ok: boolean
91
91
  data?: any
92
92
  error?: any
93
93
  }> {
94
94
  return new Promise((resolve, reject) => {
95
95
  try {
96
96
  if (window?.getJsToken) {
97
97
  window.getJsToken(function (res) {
98
98
  console.log('JS token 获取结果:', res)
99
99
  resolve({
100
100
  ok: true,
101
101
  data: res,
102
102
  })
103
103
  }, 600)
104
104
  } else {
105
105
  reject({
106
106
  ok: false,
107
107
  error: '没有识别到getJsToken全局方法',
108
108
  })
109
109
  }
110
110
  } catch (e) {
111
111
  console.log('获取指纹JS token 异常', e)
112
112
  reject({
113
113
  ok: false,
114
114
  error: e,
115
115
  })
116
116
  }
117
117
  })
118
118
  }
119
119
 
120
120
  async _getFmInfo() {
121
121
  try {
122
122
  const { ok, data } = await this._getMobileJsToken()
123
123
  this.fmInfo = ok && data ? data : this.fmInfo
124
124
  return this.fmInfo
125
125
  } catch (e) {
126
126
  console.log('获取指纹信息异常', e)
127
127
  return this.fmInfo
128
128
  }
129
129
  }
130
130
 
131
131
  async request({
132
132
  url,
133
133
  method = 'POST',
134
134
  timeout = 7000,
135
135
  ...otherOptions
136
136
  }): RequestTask<any> {
137
137
  const header = {
138
138
  'content-type':
139
139
  method === 'POST'
140
140
  ? RequestHeaderContentType.formDataHeader
141
141
  : RequestHeaderContentType.jsonHeader,
142
142
  }
143
143
  const getReqData = otherOptions.data
144
144
  if (url === this.api.apiFunc && typeof getReqData === 'object') {
145
145
  const { jsToken } = await this._getFmInfo()
146
146
  jsToken && (getReqData['x-api-eid-token'] = jsToken)
147
147
  }
148
148
  const requestTask = Taro.request({
149
149
  url,
150
150
  method,
151
151
  timeout,
152
152
  header,
153
153
  credentials: 'include',
154
154
  ...otherOptions,
155
155
  })
156
156
  const requestTimeoutPromise =
157
157
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
158
158
  setTimeout(() => {
159
159
  resolve({
160
160
  statusCode: 500,
161
161
  resTimeoutState: true,
162
162
  errMsg: 'request timeout',
163
163
  })
164
164
  }, timeout)
165
165
  })
166
166
  return Promise.race([requestTask, requestTimeoutPromise]).then(
167
167
  (res: any) => {
168
168
  if (res && res.statusCode === 500 && res.resTimeoutState) {
169
169
  console.log('request 请求超时 url:' + url)
170
170
  requestTask.abort && requestTask.abort()
171
171
  }
172
172
  return res
173
173
  },
174
174
  )
175
175
  }
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro'
2
  SHOP_COLOR_APPID,
1
3
  JshopxColorFunctionIdList,
2
4
  PagesColorFunctionIdList,
3
5
  JSHOPX_COLOR_APPID,
4
6
  PAGES_COLOR_APPID,
5
7
  PAGES_DOMAIN,
6
8
  B2BColorFunctionIdList,
7
9
  B2B_COLOR_APPID,
8
10
  cookiesStr: '',
9
11
  requestHeaderContentType: {
10
12
  jsonHeader: {
11
13
  'content-type': 'application/json;charset=utf-8',
12
14
  },
13
15
  formDataHeader: {
14
16
  'content-type': 'application/x-www-form-urlencoded',
15
17
  },
16
18
  },
17
19
  requestBaseParam: {
18
20
  data: null,
19
21
  header: {
20
22
  'content-type': 'application/json;charset=utf-8',
21
23
  },
22
24
  },
23
25
  timeOut: 7000,
24
26
  apiClientParams: {
25
27
  appid: SHOP_COLOR_APPID,
26
28
  clientVersion:
27
29
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
28
30
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
29
31
  area: '1_72_2799_0',
30
32
  uuid: UUID,
31
33
  },
32
34
  public addressFetchInfo: {
33
35
  reqState: boolean
34
36
  promiseInstance: null | Promise<any>
35
37
  }
36
38
  public getPromotionConfig: {
37
39
  projectId: null | string | number
38
40
  pageId: null | string | number
39
41
  }
40
42
  public resInfo: ServiceInterFace.HttpRequestInfo
41
43
  public api: ServiceInterFace.HttpApi
42
44
  public isPageDomain: boolean
43
45
  constructor(opt) {
44
46
  this._init()
45
47
  this.addressFetchInfo = {
46
48
  reqState: false,
47
49
  promiseInstance: null,
48
50
  }
49
51
  this.getPromotionConfig = {
50
52
  projectId: null,
51
53
  pageId: null,
52
54
  }
53
55
  this._userAreaUpdateListen()
54
56
  this.resInfo = this._getResConfig(opt)
55
57
  this.api = api
56
58
  this.isPageDomain = window.location.hostname === PAGES_DOMAIN
57
59
  }
58
60
  _init(): void {
59
61
  httpInterceptors.forEach((item) => {
60
62
  Taro.addInterceptor((chain) => item(chain))
61
63
  })
62
64
  }
63
65
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
64
66
  return Object.assign({}, DefaultConfig, opt)
65
67
  }
66
68
 
67
69
  _userAreaUpdateListen() {
68
70
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
69
71
  this.updateApiClientParamsResInfo({
70
72
  area,
71
73
  })
72
74
  })
73
75
  }
74
76
  updateApiClientParamsResInfo(opt = {}) {
75
77
  this.resInfo.apiClientParams = {
76
78
  ...this.resInfo.apiClientParams,
77
79
  ...opt,
78
80
  }
79
81
  }
80
82
 
81
83
  _paramsSign(data) {
82
84
  return Promise.resolve(data)
83
85
  }
84
86
 
85
87
  checkFunctionIdToReturnAppId(functionId) {
86
88
  if (JshopxColorFunctionIdList.includes(functionId)) {
87
89
  return JSHOPX_COLOR_APPID
88
90
  } else if (
89
91
  this.isPageDomain &&
90
92
  PagesColorFunctionIdList.includes(functionId)
91
93
  ) {
92
94
  return PAGES_COLOR_APPID
93
95
  } else if (B2BColorFunctionIdList.includes(functionId)) {
94
96
  return B2B_COLOR_APPID
95
97
  } else {
96
98
  return SHOP_COLOR_APPID
97
99
  }
98
100
  }
99
101
 
100
102
  gatewayReq(
101
103
  functionId: string,
102
104
  bodyParams = {},
103
105
  clientParams = {},
104
106
  ): Promise<any> {
105
107
  if (
106
108
  functionId === 'receiveShopCoupon' &&
107
109
  ((isH5 && window.isJingGouMiniViewState) || isWxMinAndWxapp)
108
110
  ) {
109
111
  clientParams = Object.assign(
110
112
  {},
111
113
  {
112
114
  loginType: '1',
113
115
  loginWQBiz: WXAPP_BIZ_KEY,
114
116
  },
115
117
  clientParams,
116
118
  )
117
119
  }
118
120
  const apiClientParams = Object.assign(
119
121
  {},
120
122
  this.resInfo.apiClientParams,
121
123
  clientParams,
122
124
  )
123
125
  apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId)
124
126
  const getReqData = {
125
127
  functionId: functionId,
126
128
  body: JSON.stringify(bodyParams),
127
129
  t: Date.now(),
128
130
  ...apiClientParams,
129
131
  }
130
132
  return http
131
133
  .request({
132
134
  url: this.api.apiFunc,
133
135
  data: getReqData,
134
136
  method: 'GET',
135
137
  })
136
138
  .then((res: ServiceInterFace.RequestPromiseRes) => {
137
139
  const { statusCode, data } = res
138
140
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
139
141
  ok: true,
140
142
  }
141
143
  if (statusCode === 200 && data) {
142
144
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
143
145
  ? Number(res.data.code)
144
146
  : -1
145
147
  const subCode = Object.prototype.hasOwnProperty.call(
146
148
  res.data,
147
149
  'subCode',
148
150
  )
149
151
  ? Number(res.data.subCode)
150
152
  : -1
151
153
  if (
152
154
  data.success === true ||
153
155
  data.isSuccess ||
154
156
  resCode === 0 ||
155
157
  resCode === 200 ||
156
158
  subCode === 0
157
159
  ) {
158
160
  changeRes = {
159
161
  result: Object.prototype.hasOwnProperty.call(data, 'result')
160
162
  ? data.result
161
163
  : Object.prototype.hasOwnProperty.call(data, 'data')
162
164
  ? data.data
163
165
  : data,
164
166
  code: data.code || 200,
165
167
  ok: true,
166
168
  source: data,
167
169
  }
168
170
  return changeRes
169
171
  } else {
170
172
  changeRes = {
171
173
  ...data,
172
174
  ok: false,
173
175
  statusCode: res.statusCode,
174
176
  }
175
177
  return changeRes
176
178
  }
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
  })
186
188
  .catch((res) => {
187
189
  return {
188
190
  ...res,
189
191
  ok: false,
190
192
  } as ServiceInterFace.RequestResponseFormatRes
191
193
  })
192
194
  }
193
195
 
194
196
  async receiveCoupon(param = {}, clientParams) {
195
197
  return await this.gatewayReq(
196
198
  'receiveShopCoupon',
197
199
  {
198
200
  operation: '3',
199
201
  ...param,
200
202
  },
201
203
  clientParams,
202
204
  )
203
205
  }
204
206
  async bMallAddCart(params = {}) {
205
207
  return await this.gatewayReq('bmall_cartAdd', params, {
206
208
  client: 'H5',
207
209
  })
208
210
  }
209
211
  async bMallChangeCart(params = {}) {
210
212
  return await this.gatewayReq('bmall_cartChange', params, {
211
213
  client: 'H5',
212
214
  })
213
215
  }
214
216
  async bMallRemoveCart(params = {}) {
215
217
  return await this.gatewayReq(
216
218
  'bmall_cartRemove',
217
219
  params,
218
220
  {
219
221
  client: 'H5',
220
222
  },
221
223
  )
222
224
  }
223
225
  async bMallGetOmittedProduct(params = {}) {
224
226
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
225
227
  client: 'H5',
226
228
  })
227
229
  }
228
230
  async bMallAddCartService({ skuId, bMallTag, num }) {
229
231
  const params = getParams({ skuId, bMallTag, num })
230
232
  return await this.bMallAddCart(params)
231
233
  }
232
234
  async bMallGetSkuNumService(bMallTag = 1) {
233
235
  const params = getParams({ bMallTag })
234
236
  delete params.operations
235
237
  return await this.bMallGetOmittedProduct(params)
236
238
  }
237
239
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid }) {
238
240
  let params = getParams({ skuId, bMallTag, num, skuUuid })
239
241
  return await this.bMallRemoveCart(params)
240
242
  }
241
243
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid }) {
242
244
  let params = getParams({ skuId, bMallTag, num, skuUuid })
243
245
  return await this.bMallChangeCart(params)
244
246
  }
245
247
 
246
248
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
247
249
  if (!needRequest && window.bMallCartData) {
248
250
  return window.bMallCartData
249
251
  }
250
252
  const cartData = await this.bMallGetSkuNumService(bMallTag)
251
253
  let items
252
254
  if (cartData.ok && cartData.result) {
253
255
  items = cartData?.result?.items || {}
254
256
  }
255
257
  window.bMallCartData = items
256
258
  return items
257
259
  }
258
260
 
259
261
  async bMallCartHandle(goodItem, num) {
260
262
  try {
261
263
  const {
262
264
  skuUuid,
263
265
  limitUpper,
264
266
  limitLower,
265
267
  } = goodItem
266
268
  let cartNum = Number(num)
267
269
  if (limitLower && cartNum && cartNum < limitLower) {
268
270
  cartNum = limitLower
269
271
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
270
272
  cartNum = limitUpper
271
273
  }
272
274
  if (skuUuid && cartNum > 0) {
273
275
  return this.bMallChangeCartService({
274
276
  ...goodItem,
275
277
  skuUuid,
276
278
  num: cartNum,
277
279
  })
278
280
  } else if (!skuUuid && cartNum > 0) {
279
281
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
280
282
  } else if (skuUuid && !cartNum) {
281
283
  return this.bMallRemoveCartService({
282
284
  ...goodItem,
283
285
  skuUuid,
284
286
  num: cartNum,
285
287
  })
286
288
  } else {
287
289
  console.error('参数不全')
288
290
  return false
289
291
  }
290
292
  } catch (e) {
291
293
  console.error(e)
292
294
  }
293
295
  }
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.8.21",
3
+ "version": "0.8.22-beta.0",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"