@conecli/cone-render 0.8.19-beta.0 → 0.8.19-beta.1

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'
@@ -0,0 +1 @@
1
+ import Taro, { RequestTask } 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
  cookiesStr: '',
7
9
  requestHeaderContentType: {
8
10
  jsonHeader: {
9
11
  'content-type': 'application/json;charset=utf-8',
10
12
  },
11
13
  formDataHeader: {
12
14
  'content-type': 'application/x-www-form-urlencoded',
13
15
  },
14
16
  },
15
17
  requestBaseParam: {
16
18
  data: null,
17
19
  header: {
18
20
  'content-type': 'application/json;charset=utf-8',
19
21
  },
20
22
  },
21
23
  timeOut: 7000,
22
24
  apiClientParams: {
23
25
  appid: SHOP_COLOR_APPID,
24
26
  clientVersion:
25
27
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
26
28
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
27
29
  area: '1_72_2799_0',
28
30
  uuid: UUID,
29
31
  loginType: "11",
30
32
  },
31
33
  public addressFetchInfo: {
32
34
  reqState: boolean
33
35
  promiseInstance: null | Promise<any>
34
36
  }
35
37
  public getPromotionConfig: {
36
38
  projectId: null | string | number
37
39
  pageId: null | string | number
38
40
  }
39
41
  public resInfo: ServiceInterFace.HttpRequestInfo
40
42
  public api: ServiceInterFace.HttpApi
41
43
  public isPageDomain: boolean
42
44
  constructor(opt) {
43
45
  this._init()
44
46
  this.addressFetchInfo = {
45
47
  reqState: false,
46
48
  promiseInstance: null,
47
49
  }
48
50
  this.getPromotionConfig = {
49
51
  projectId: null,
50
52
  pageId: null,
51
53
  }
52
54
  this._userAreaUpdateListen()
53
55
  this.resInfo = this._getResConfig(opt)
54
56
  this.api = api
55
57
  this.isPageDomain = window.location.hostname === PAGES_DOMAIN
56
58
  }
57
59
  _init(): void {
58
60
  httpInterceptors.forEach((item) => {
59
61
  Taro.addInterceptor((chain) => item(chain))
60
62
  })
61
63
  }
62
64
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
63
65
  return Object.assign({}, DefaultConfig, opt)
64
66
  }
65
67
 
66
68
  _userAreaUpdateListen() {
67
69
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
68
70
  this.updateApiClientParamsResInfo({
69
71
  area,
70
72
  })
71
73
  })
72
74
  }
73
75
  updateApiClientParamsResInfo(opt = {}) {
74
76
  this.resInfo.apiClientParams = {
75
77
  ...this.resInfo.apiClientParams,
76
78
  ...opt,
77
79
  }
78
80
  }
79
81
 
80
82
  _paramsSign(data) {
81
83
  return Promise.resolve(data)
82
84
  }
83
85
 
84
86
  checkFunctionIdToReturnAppId(functionId) {
85
87
  return JshopxColorFunctionIdList.includes(functionId)
86
88
  ? JSHOPX_COLOR_APPID
87
89
  : this.isPageDomain && PagesColorFunctionIdList.includes(functionId)
88
90
  ? PAGES_COLOR_APPID
89
91
  : SHOP_COLOR_APPID
90
92
  }
91
93
 
92
94
  apiReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
93
95
  if (
94
96
  functionId === 'receiveShopCoupon' &&
95
97
  ((isH5 && window.isJingGouMiniViewState) || isWxMinAndWxapp)
96
98
  ) {
97
99
  clientParams = Object.assign(
98
100
  {},
99
101
  {
100
102
  loginType: '1',
101
103
  loginWQBiz: WXAPP_BIZ_KEY,
102
104
  },
103
105
  clientParams,
104
106
  )
105
107
  }
106
108
  const apiClientParams = Object.assign(
107
109
  {},
108
110
  this.resInfo.apiClientParams,
109
111
  clientParams,
110
112
  )
111
113
  const getReqData = {
112
114
  functionId: functionId,
113
115
  body: JSON.stringify(bodyParams),
114
116
  t: Date.now(),
115
117
  ...apiClientParams,
116
118
  }
117
119
  console.log(`apiReq:${this.api.apiFunc}`)
118
120
  return this.request(this.api.apiFunc, getReqData, {}, 'GET')
119
121
  .then((res: ServiceInterFace.RequestPromiseRes) => {
120
122
  const { statusCode, data } = res
121
123
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
122
124
  ok: true,
123
125
  }
124
126
  if (statusCode === 200 && data) {
125
127
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
126
128
  ? Number(res.data.code)
127
129
  : -1
128
130
  const subCode = Object.prototype.hasOwnProperty.call(
129
131
  res.data,
130
132
  'subCode',
131
133
  )
132
134
  ? Number(res.data.subCode)
133
135
  : -1
134
136
  if (
135
137
  data.success === true ||
136
138
  data.isSuccess ||
137
139
  resCode === 0 ||
138
140
  resCode === 200 ||
139
141
  subCode === 0
140
142
  ) {
141
143
  changeRes = {
142
144
  result: Object.prototype.hasOwnProperty.call(data, 'result')
143
145
  ? data.result
144
146
  : Object.prototype.hasOwnProperty.call(data, 'data')
145
147
  ? data.data
146
148
  : data,
147
149
  code: data.code || 200,
148
150
  ok: true,
149
151
  source: data,
150
152
  }
151
153
  return changeRes
152
154
  } else {
153
155
  changeRes = {
154
156
  ...data,
155
157
  ok: false,
156
158
  statusCode: res.statusCode,
157
159
  }
158
160
  return changeRes
159
161
  }
160
162
  } else {
161
163
  changeRes = {
162
164
  ...data,
163
165
  ok: false,
164
166
  statusCode: res.statusCode,
165
167
  }
166
168
  return changeRes
167
169
  }
168
170
  })
169
171
  .catch((res) => {
170
172
  return {
171
173
  ...res,
172
174
  ok: false,
173
175
  } as ServiceInterFace.RequestResponseFormatRes
174
176
  })
175
177
  }
176
178
 
177
179
  request(
178
180
  url: string,
179
181
  data: string | object,
180
182
  otherOptions = {},
181
183
  method: keyof ServiceInterFace.Method = 'POST',
182
184
  ): RequestTask<any> {
183
185
  const header =
184
186
  method === 'POST'
185
187
  ? this.resInfo.requestHeaderContentType.formDataHeader
186
188
  : {}
187
189
  return Taro.request({
188
190
  ...this.resInfo.requestBaseParam,
189
191
  url,
190
192
  data,
191
193
  method,
192
194
  timeout: this.resInfo.timeOut,
193
195
  header,
194
196
  ...otherOptions,
195
197
  })
196
198
  }
197
199
 
198
200
  async receiveCoupon(param = {}, clientParams) {
199
201
  console.log(process.env.NODE_ENV)
200
202
  if(process.env.NODE_ENV === 'development'){
201
203
  return Promise.reject('本地环境不能领券')
202
204
  }
203
205
  return await this.apiReq(
204
206
  'receiveShopCoupon',
205
207
  {
206
208
  operation: '3',
207
209
  ...param,
208
210
  },
209
211
  clientParams,
210
212
  )
211
213
  }
@@ -0,0 +1 @@
1
+ export const HttpStatus = {
2
  SUCCESS: 200,
1
3
  CREATED: 201,
2
4
  ACCEPTED: 202,
3
5
  CLIENT_ERROR: 400,
4
6
  AUTHENTICATE: 401,
5
7
  FORBIDDEN: 403,
6
8
  NOT_FOUND: 404,
7
9
  SERVER_ERROR: 500,
8
10
  BAD_GATEWAY: 502,
9
11
  SERVICE_UNAVAILABLE: 503,
10
12
  GATEWAY_TIMEOUT: 504
11
13
  [HttpStatus.NOT_FOUND]: "请求资源不存在",
12
14
  [HttpStatus.BAD_GATEWAY]: "服务端异常,请稍后重试",
13
15
  [HttpStatus.FORBIDDEN]: "没有权限访问",
14
16
  [HttpStatus.AUTHENTICATE]: "需要鉴权",
15
17
  [HttpStatus.SUCCESS]: "成功"
16
18
  "getPagePreview"
17
19
  "getShopHomeFloorInfo",
18
20
  "getShopCategory",
19
21
  "getShopNavigationCategory",
20
22
  "receiveShopCoupon",
21
23
  "getShopHomePromotionWebPage",
22
24
  "shopGuessYouLike",
23
25
  "addRemind",
24
26
  "cancelRemind",
25
27
  "getVipDetail",
26
28
  "shopDetail",
27
29
  "address_queryAddress",
28
30
  "shopMemberSprintJoinActivity",
29
31
  "shopMemberSprintReceivePrize"
@@ -0,0 +1 @@
1
+ import HttpBase from './http'
2
  constructor() {
1
3
  super()
2
4
  }
3
5
 
4
6
  request({url, timeout = 7000, ...otherOptions}): any {
5
7
  const requestTask = super.request({url, timeout, ...otherOptions})
6
8
  const requestTimeoutPromise =
7
9
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
8
10
  setTimeout(() => {
9
11
  resolve({
10
12
  statusCode: 500,
11
13
  resTimeoutState: true,
12
14
  errMsg: 'request timeout',
13
15
  })
14
16
  }, timeout)
15
17
  })
16
18
  return Promise.race([requestTask, requestTimeoutPromise]).then(
17
19
  (res: ServiceInterFace.RequestPromiseRes) => {
18
20
  if (res && res.statusCode === 500 && res.resTimeoutState) {
19
21
  console.log('request 请求超时 url:' + url)
20
22
  requestTask.abort()
21
23
  }
22
24
  return res
23
25
  }
24
26
  )
25
27
  }
@@ -0,0 +1 @@
1
+ import Taro, { RequestTask } from "@tarojs/taro";
2
  jsonHeader = "application/json;charset=utf-8",
1
3
  formDataHeader = "application/x-www-form-urlencoded"
2
4
  constructor() {
3
5
  this._init()
4
6
  }
5
7
  _init(): void {
6
8
  httpInterceptors.forEach((item) => {
7
9
  Taro.addInterceptor((chain) => item(chain))
8
10
  })
9
11
  }
10
12
 
11
13
  get(url: string, data: any = null, otherOptions = {}): Taro.RequestTask<any> {
12
14
  return this.request({url, data, method:"GET", ...otherOptions})
13
15
  }
14
16
 
15
17
  post(
16
18
  url: string,
17
19
  data: any = null,
18
20
  otherOptions = {}
19
21
  ): Taro.RequestTask<any> {
20
22
  return this.request({url, data, method:"POST", ...otherOptions})
21
23
  }
22
24
 
23
25
  request({url, method = "POST", timeout = 7000, ...otherOptions}): RequestTask<any> {
24
26
  const header = {
25
27
  "content-type": method === "POST" ? RequestHeaderContentType.formDataHeader : RequestHeaderContentType.jsonHeader
26
28
  }
27
29
  return Taro.request({
28
30
  url,
29
31
  method,
30
32
  timeout,
31
33
  header,
32
34
  credentials: 'include',
33
35
  ...otherOptions,
34
36
  })
35
37
  }
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro'
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro'
@@ -0,0 +1 @@
1
+ import Http from './http'
@@ -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.19-beta.0",
3
+ "version": "0.8.19-beta.1",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"