@conecli/cone-render 0.8.20-shop.63 → 0.8.20-shop.65

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.
package/dist/api/index.ts CHANGED
@@ -1 +1 @@
1
- import { protocol, isBetaServer, isH5 } from '../config/env'
2
1
  ? redirectDomainList.includes(location?.hostname)
3
2
  ? defaultDomain
4
3
  : location?.hostname
5
4
  : defaultDomain
6
5
  mobileLogin: `${protocol}//plogin.m.jd.com`,
7
6
  isLogin: `${domain.mobileLogin}/cgi-bin/ml/islogin`,
7
+ import { protocol, isBetaServer, isH5 } from '../config/env'
8
8
  ? redirectDomainList.includes(location?.hostname)
9
9
  ? defaultDomain
10
10
  : location?.hostname
11
11
  : defaultDomain
12
12
  pcCoupon: `${protocol}//conecli.com`,
13
13
  pcSo: `${protocol}//conecli.com`,
14
14
  mobileLogin: `${protocol}//plogin.m.jd.com`,
15
15
  isLogin: `${domain.mobileLogin}/cgi-bin/ml/islogin`,
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  urlCookie
3
2
  public config: {
4
3
  [key: string]: any
5
4
  }
6
5
  public lazyContainer: CommonInterFace.lazyContainer
7
6
  this.config = {}
8
7
  pin: cookie.get('pin') || ''
9
8
  })
10
9
  if(!this.checkStatusAndLoginPromise){
11
10
  this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
12
11
  try {
13
12
  const getLoginState = await this.doCheckLoginStateAndForApiCheck()
14
13
  if(getLoginState){
15
14
  resolve(true)
16
15
  }else {
17
16
  this.toLogin(options)
18
17
  reject(false)
19
18
  }
20
19
  }catch (e) {
21
20
  this.toLogin(options)
22
21
  reject(false)
23
22
  }
24
23
  })
25
24
  return this.checkStatusAndLoginPromise
26
25
  }else {
27
26
  return this.checkStatusAndLoginPromise.then(() => {
28
27
  return Promise.resolve(true)
29
28
  }).catch (() => {
30
29
  this.toLogin(options)
31
30
  return Promise.reject(true)
32
31
  })
33
32
  }
34
33
 
35
34
  doCheckLoginStateAndForApiCheck() {
36
35
  if(this.info.loginState){
37
36
  return Promise.resolve(true)
38
37
  }else {
39
38
  return new Promise((resolve, reject) => {
40
39
  if(this.info.isJingGouMiniViewState){
41
40
  const getWqAuthToken = cookie.get("wq_auth_token")
42
41
  if(getWqAuthToken){
43
42
  this.info.loginState = true
44
43
  resolve(true)
45
44
  }else {
46
45
  reject(false)
47
46
  }
48
47
  }else{
49
48
  Taro.request({
50
49
  url: api.isLogin,
51
50
  jsonp:true,
52
51
  timeout: 3000,
53
52
  success: (res) => {
54
53
  const {statusCode,data} = res
55
54
  if (statusCode === 200 && data?.islogin && Number(data.islogin) === 1) {
56
55
  this.info.loginState = true
57
56
  resolve(true);
58
57
  } else {
59
58
  reject(false)
60
59
  }
61
60
  },
62
61
  fail:(err) => {
63
62
  console.log("登录检查异常", err)
64
63
  reject(false)
65
64
  }
66
65
  })
67
66
  }
68
67
  })
69
68
  }
70
69
  }
71
70
 
72
71
  try {
73
72
  const getLoginState = await this.doCheckLoginStateAndForApiCheck()
74
73
  if(getLoginState){
75
74
  const { pin } = await this.getLoginCookie();
76
75
  this.info.userInfo = {
77
76
  pin,
78
77
  encodePin: encodeURIComponent(pin),
79
78
  ptkey: '',
80
79
  }
81
80
  resolve(true)
82
81
  }else {
83
82
  reject(false)
84
83
  }
85
84
  }catch (e) {
86
85
  reject(false)
87
86
  }
88
87
  })
89
88
  if(un_area && un_area.length > 0){
90
89
  this.info.pageInfo.address = un_area
91
90
  this.info.pageInfo.un_area = un_area
92
91
  this.info.pageInfo.addressCommaStr = un_area.replace(/_/g, ',')
93
92
  }
93
+ import Taro from '@tarojs/taro'
94
94
  urlCookie
95
95
  public config: {
96
96
  [key: string]: any
97
97
  }
98
98
  public lazyContainer: CommonInterFace.lazyContainer
99
99
  this.config = {}
100
100
  ...info,
101
101
  pin: cookie.get('pin') || ''
102
102
  })
103
103
  if(!this.checkStatusAndLoginPromise){
104
104
  this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
105
105
  try {
106
106
  const getLoginState = await this.doCheckLoginStateAndForApiCheck()
107
107
  if(getLoginState){
108
108
  resolve(true)
109
109
  }else {
110
110
  this.toLogin(options)
111
111
  reject(false)
112
112
  }
113
113
  }catch (e) {
114
114
  this.toLogin(options)
115
115
  reject(false)
116
116
  }
117
117
  })
118
118
  return this.checkStatusAndLoginPromise
119
119
  }else {
120
120
  return this.checkStatusAndLoginPromise.then(() => {
121
121
  return Promise.resolve(true)
122
122
  }).catch (() => {
123
123
  this.toLogin(options)
124
124
  return Promise.reject(true)
125
125
  })
126
126
  }
127
127
 
128
128
  doCheckLoginStateAndForApiCheck() {
129
129
  if(this.info.loginState){
130
130
  return Promise.resolve(true)
131
131
  }else {
132
132
  return new Promise((resolve, reject) => {
133
133
  if(this.info.isJingGouMiniViewState){
134
134
  const getWqAuthToken = cookie.get("wq_auth_token")
135
135
  if(getWqAuthToken){
136
136
  this.info.loginState = true
137
137
  resolve(true)
138
138
  }else {
139
139
  reject(false)
140
140
  }
141
141
  }else{
142
142
  Taro.request({
143
143
  url: api.isLogin,
144
144
  jsonp:true,
145
145
  timeout: 3000,
146
146
  success: (res) => {
147
147
  const {statusCode,data} = res
148
148
  if (statusCode === 200 && data?.islogin && Number(data.islogin) === 1) {
149
149
  this.info.loginState = true
150
150
  resolve(true);
151
151
  } else {
152
152
  reject(false)
153
153
  }
154
154
  },
155
155
  fail:(err) => {
156
156
  console.log("登录检查异常", err)
157
157
  reject(false)
158
158
  }
159
159
  })
160
160
  }
161
161
  })
162
162
  }
163
163
  }
164
164
 
165
165
  try {
166
166
  const getLoginState = await this.doCheckLoginStateAndForApiCheck()
167
167
  if(getLoginState){
168
168
  const { pin } = await this.getLoginCookie();
169
169
  this.info.userInfo = {
170
170
  pin,
171
171
  encodePin: encodeURIComponent(pin),
172
172
  ptkey: '',
173
173
  }
174
174
  resolve(true)
175
175
  }else {
176
176
  reject(false)
177
177
  }
178
178
  }catch (e) {
179
179
  reject(false)
180
180
  }
181
181
  })
182
182
  if(un_area && un_area.length > 0){
183
183
  this.info.pageInfo.address = un_area
184
184
  this.info.pageInfo.un_area = un_area
185
185
  this.info.pageInfo.addressCommaStr = un_area.replace(/_/g, ',')
186
186
  }
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  TaroEventType,
3
2
  WEBVIEW_STATE,
4
3
  M_H5_ROOT_ELE_NODE,
5
4
  latestFromNativeMsgStorage,
6
5
  getNativePageScrollRes,
7
6
  props: ComponentInterFace.InOrOutViewObserverProps,
8
7
  const {
9
8
  children,
10
9
  style,
11
10
  inViewCallback,
12
11
  outViewCallback,
13
12
  threshold = 0,
14
13
  } = props
15
14
  const [componentShowState, setComponentShowState] = useState(false)
16
15
  const componentObserverRef = useRef<HTMLElement | null>(null)
17
16
  const componentShowStateRef = useRef(false)
18
17
  const needShowHighVersion = isAppClassifyPage || (isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true"))
19
18
  const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
20
19
  if (isH5AndJdShopView && !needShowHighVersion) {
21
20
  console.log('视频========属于app原生滚动')
22
21
  useEffect(() => {
23
22
  const latestRes =
24
23
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
25
24
  dealPageScrollInfo(latestRes)
26
25
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
27
26
  dealPageScrollInfo(res)
28
27
  })
29
28
  Taro.eventCenter.on(
30
29
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
31
30
  (state) => {
32
31
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
33
32
  },
34
33
  )
35
34
  return function cleanup() {
36
35
  Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
37
36
  dealPageScrollInfo(res)
38
37
  })
39
38
  Taro.eventCenter.off(
40
39
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
41
40
  (state) => {
42
41
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
43
42
  },
44
43
  )
45
44
  }
46
45
  }, [])
47
46
  useEffect(() => {
48
47
  if (componentShowState) {
49
48
  typeof inViewCallback === 'function' && inViewCallback()
50
49
  console.log('app=>in可视区域')
51
50
  } else {
52
51
  typeof outViewCallback === 'function' && outViewCallback()
53
52
  console.log('app=>out可视区域')
54
53
  }
55
54
  }, [componentShowState])
56
55
 
57
56
  const handleInOrOutView = (type: boolean) => {
58
57
  componentShowStateRef.current = type
59
58
  setComponentShowState(type)
60
59
  console.log('handleInOrOutView', type)
61
60
  }
62
61
 
63
62
  const dealPageScrollInfo = (res) => {
64
63
  console.log('dealPageScrollInfo===', res)
65
64
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
66
65
  if (
67
66
  typeof displayHeight === 'undefined' ||
68
67
  typeof offSetY === 'undefined'
69
68
  )
70
69
  return
71
70
  console.log(
72
71
  '处理后dealPageScrollInfo===displayHeight=offSetY',
73
72
  displayHeight,
74
73
  offSetY,
75
74
  )
76
75
  if (componentObserverRef.current) {
77
76
  const eleClientRect =
78
77
  componentObserverRef.current.getBoundingClientRect()
79
78
  const eleOffsetTop = Math.ceil(eleClientRect.top)
80
79
  const eleHeight = Math.ceil(eleClientRect.height)
81
80
  console.log(
82
81
  '==========================eleOffsetTop, eleHeight',
83
82
  eleOffsetTop,
84
83
  eleHeight,
85
84
  )
86
85
  if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
87
86
  const isOutView =
88
87
  offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
89
88
  displayHeight - (eleOffsetTop - offSetY) <
90
89
  Math.ceil(eleHeight * threshold)
91
90
  console.log(
92
91
  '比较isOutView',
93
92
  isOutView,
94
93
  offSetY,
95
94
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
96
95
  displayHeight - (eleOffsetTop - offSetY),
97
96
  Math.ceil(eleHeight * threshold),
98
97
  )
99
98
  handleInOrOutView(!isOutView)
100
99
  } else {
101
100
  const isInView =
102
101
  offSetY >
103
102
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
104
103
  offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
105
104
  console.log(
106
105
  '比较isInView',
107
106
  isInView,
108
107
  offSetY,
109
108
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
110
109
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
111
110
  )
112
111
  handleInOrOutView(isInView)
113
112
  }
114
113
  }
115
114
  }
116
115
  return (
117
116
  <View ref={componentObserverRef} style={style}>
118
117
  {children}
119
118
  </View>
120
119
  )
121
120
  } else {
122
121
  console.log('视频========h5滚动')
123
122
  const { ref, inView } = useInView({
124
123
  threshold,
125
124
  triggerOnce: false,
126
125
  root: rootDom || null,
127
126
  rootMargin: `0px 0px 0px 0px`,
128
127
  })
129
128
  useEffect(() => {
130
129
  if (inView) {
131
130
  typeof inViewCallback === 'function' && inViewCallback()
132
131
  console.log('其他h5=>in可视区域')
133
132
  } else {
134
133
  typeof outViewCallback === 'function' && outViewCallback()
135
134
  console.log('其他h5=>out可视区域')
136
135
  }
137
136
  }, [inView])
138
137
 
139
138
  const handleInOrOutView = (type: boolean) => {
140
139
  if (type) {
141
140
  typeof inViewCallback === 'function' && inViewCallback()
142
141
  console.log('其他h5=>in可视区域')
143
142
  } else {
144
143
  typeof outViewCallback === 'function' && outViewCallback()
145
144
  console.log('其他h5=>out可视区域')
146
145
  }
147
146
  }
148
147
  useEffect(() => {
149
148
  Taro.eventCenter.on(
150
149
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
151
150
  (state) => {
152
151
  handleInOrOutView(state == 1 ? true : false)
153
152
  },
154
153
  )
155
154
  return function cleanup() {
156
155
  Taro.eventCenter.off(
157
156
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
158
157
  (state) => {
159
158
  handleInOrOutView(state == 1 ? true : false)
160
159
  },
161
160
  )
162
161
  }
163
162
  }, [])
164
163
  return (
165
164
  <View ref={ref} style={style}>
166
165
  {children}
167
166
  </View>
168
167
  )
169
168
  }
170
169
  children: null,
171
170
  style: {},
172
171
  className: '',
173
172
  inViewCallback: null,
174
173
  outViewCallback: null,
175
174
  threshold: 0,
175
+ import Taro from '@tarojs/taro'
176
176
  TaroEventType,
177
177
  WEBVIEW_STATE,
178
178
  M_H5_ROOT_ELE_NODE,
179
179
  latestFromNativeMsgStorage,
180
180
  getNativePageScrollRes,
181
181
  props: ComponentInterFace.InOrOutViewObserverProps,
182
182
  const {
183
183
  children,
184
184
  style,
185
185
  inViewCallback,
186
186
  outViewCallback,
187
187
  threshold = 0,
188
188
  } = props
189
189
  const [componentShowState, setComponentShowState] = useState(false)
190
190
  const componentObserverRef = useRef<HTMLElement | null>(null)
191
191
  const componentShowStateRef = useRef(false)
192
192
  const needShowHighVersion = isAppClassifyPage || (isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true"))
193
193
  const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
194
194
  if (isH5AndJdShopView && !needShowHighVersion) {
195
195
  console.log('视频========属于app原生滚动')
196
196
  useEffect(() => {
197
197
  const latestRes =
198
198
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
199
199
  dealPageScrollInfo(latestRes)
200
200
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
201
201
  dealPageScrollInfo(res)
202
202
  })
203
203
  Taro.eventCenter.on(
204
204
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
205
205
  (state) => {
206
206
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
207
207
  },
208
208
  )
209
209
  return function cleanup() {
210
210
  Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
211
211
  dealPageScrollInfo(res)
212
212
  })
213
213
  Taro.eventCenter.off(
214
214
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
215
215
  (state) => {
216
216
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
217
217
  },
218
218
  )
219
219
  }
220
220
  }, [])
221
221
  useEffect(() => {
222
222
  if (componentShowState) {
223
223
  typeof inViewCallback === 'function' && inViewCallback()
224
224
  console.log('app=>in可视区域')
225
225
  } else {
226
226
  typeof outViewCallback === 'function' && outViewCallback()
227
227
  console.log('app=>out可视区域')
228
228
  }
229
229
  }, [componentShowState])
230
230
 
231
231
  const handleInOrOutView = (type: boolean) => {
232
232
  componentShowStateRef.current = type
233
233
  setComponentShowState(type)
234
234
  console.log('handleInOrOutView', type)
235
235
  }
236
236
 
237
237
  const dealPageScrollInfo = (res) => {
238
238
  console.log('dealPageScrollInfo===', res)
239
239
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
240
240
  if (
241
241
  typeof displayHeight === 'undefined' ||
242
242
  typeof offSetY === 'undefined'
243
243
  )
244
244
  return
245
245
  console.log(
246
246
  '处理后dealPageScrollInfo===displayHeight=offSetY',
247
247
  displayHeight,
248
248
  offSetY,
249
249
  )
250
250
  if (componentObserverRef.current) {
251
251
  const eleClientRect =
252
252
  componentObserverRef.current.getBoundingClientRect()
253
253
  const eleOffsetTop = Math.ceil(eleClientRect.top)
254
254
  const eleHeight = Math.ceil(eleClientRect.height)
255
255
  console.log(
256
256
  '==========================eleOffsetTop, eleHeight',
257
257
  eleOffsetTop,
258
258
  eleHeight,
259
259
  )
260
260
  if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
261
261
  const isOutView =
262
262
  offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
263
263
  displayHeight - (eleOffsetTop - offSetY) <
264
264
  Math.ceil(eleHeight * threshold)
265
265
  console.log(
266
266
  '比较isOutView',
267
267
  isOutView,
268
268
  offSetY,
269
269
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
270
270
  displayHeight - (eleOffsetTop - offSetY),
271
271
  Math.ceil(eleHeight * threshold),
272
272
  )
273
273
  handleInOrOutView(!isOutView)
274
274
  } else {
275
275
  const isInView =
276
276
  offSetY >
277
277
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
278
278
  offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
279
279
  console.log(
280
280
  '比较isInView',
281
281
  isInView,
282
282
  offSetY,
283
283
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
284
284
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
285
285
  )
286
286
  handleInOrOutView(isInView)
287
287
  }
288
288
  }
289
289
  }
290
290
  return (
291
291
  <View ref={componentObserverRef} style={style}>
292
292
  {children}
293
293
  </View>
294
294
  )
295
295
  } else {
296
296
  console.log('视频========h5滚动')
297
297
  const { ref, inView } = useInView({
298
298
  threshold,
299
299
  triggerOnce: false,
300
300
  root: rootDom || null,
301
301
  rootMargin: `0px 0px 0px 0px`,
302
302
  })
303
303
  useEffect(() => {
304
304
  if (inView) {
305
305
  typeof inViewCallback === 'function' && inViewCallback()
306
306
  console.log('其他h5=>in可视区域')
307
307
  } else {
308
308
  typeof outViewCallback === 'function' && outViewCallback()
309
309
  console.log('其他h5=>out可视区域')
310
310
  }
311
311
  }, [inView])
312
312
  return (
313
313
  <View ref={ref} style={style}>
314
314
  {children}
315
315
  </View>
316
316
  )
317
317
  }
318
318
  children: null,
319
319
  style: {},
320
320
  className: '',
321
321
  inViewCallback: null,
322
322
  outViewCallback: null,
323
323
  threshold: 0,