@conecli/cone-render 0.10.1-shop-beta.40 → 0.10.1-shop-beta.41
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 from '@tarojs/taro';
|
|
2
1
|
TaroEventType,
|
|
3
2
|
JUMP_MEMBER_CHANNEL,
|
|
4
3
|
CENTERDISPATCH_JUMPPAGE_VALUE,
|
|
5
4
|
|
|
6
5
|
CARD_BANNER = 'shopMemberCardVenderCardBanner',
|
|
7
6
|
|
|
8
7
|
CARD_NAME = 'shopMemberCardVenderCardName',
|
|
9
8
|
|
|
10
9
|
MEMBERSHIP_LEVEL = 'shopMemberCardMembershipLevel',
|
|
11
10
|
|
|
12
11
|
MEMBERSHIP_RULE_ENTRANCE = 'shopMemberCardMembershipRuleEntrance',
|
|
13
12
|
|
|
14
13
|
MEMBERSHIP_POINT = 'shopMemberCardMembershipPoint',
|
|
15
14
|
return new Promise((resolve) => {
|
|
16
15
|
requestServer
|
|
17
16
|
.getCustomerCenterDispatch(params)
|
|
18
17
|
.then((response) => {
|
|
19
18
|
if (response.result && response.code === '0') {
|
|
20
19
|
resolve(response.result);
|
|
21
20
|
} else {
|
|
22
21
|
resolve({
|
|
23
22
|
jumpPage:
|
|
24
23
|
response.code === '1'
|
|
25
24
|
? CENTERDISPATCH_JUMPPAGE_VALUE.NOT_LOGGED_IN
|
|
26
25
|
: CENTERDISPATCH_JUMPPAGE_VALUE.SYSTEM_ERROR,
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
})
|
|
30
29
|
.catch((err) => {
|
|
31
30
|
resolve({ jumpPage: CENTERDISPATCH_JUMPPAGE_VALUE.NETWORK_ERROR });
|
|
32
31
|
console.log('oneKeyJoinMember getcustomerCenterDispatch err', err);
|
|
33
32
|
});
|
|
34
33
|
});
|
|
35
34
|
const currentVenderId = global.info.queryInfo.venderId;
|
|
36
35
|
const currentShopId = global.info.queryInfo.shopId;
|
|
37
36
|
const channel = JUMP_MEMBER_CHANNEL.POP_WEBVIEW;
|
|
38
37
|
const forceMemberCardPopup = options?.forceMemberCardPopup;
|
|
39
38
|
const toastOpt = {
|
|
40
39
|
duration: 3000,
|
|
41
40
|
image:
|
|
42
41
|
'https://img13.360buyimg.com/img/jfs/t1/196933/39/19850/1479/61b059aaEe969b8db/acb37a47b9034333.png',
|
|
43
42
|
};
|
|
44
43
|
if (forceMemberCardPopup) {
|
|
45
44
|
showFailToast({
|
|
46
45
|
title: '临时调试模拟入会成功',
|
|
47
46
|
});
|
|
48
47
|
return new Promise((resolve) => {
|
|
49
48
|
resolve(true);
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
if (isAppHomeForMarketPage) {
|
|
53
52
|
JumpEventReport.jdJumpToBottomTabBrandMember({
|
|
54
53
|
shopId: currentShopId,
|
|
55
54
|
venderId: currentVenderId,
|
|
56
55
|
});
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
58
|
const params = {
|
|
60
59
|
venderId: currentVenderId,
|
|
61
60
|
channel,
|
|
62
61
|
queryVersion: isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '9.2.0',
|
|
63
62
|
};
|
|
64
63
|
const centerDispatchResult = await getCenterDispatchResult(params);
|
|
65
64
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口返回值', centerDispatchResult);
|
|
66
65
|
const { jumpPage } = centerDispatchResult;
|
|
67
66
|
if (typeof jumpPage !== 'number') {
|
|
68
67
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口返回 jumpPage 值类型异常,非数字');
|
|
69
68
|
showFailToast({
|
|
70
69
|
title: '网络繁忙,稍后再试吧~',
|
|
71
70
|
...toastOpt,
|
|
72
71
|
});
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
74
|
const centerDispatchJumpPageValue = Number(jumpPage);
|
|
76
75
|
if (
|
|
77
76
|
centerDispatchJumpPageValue === CENTERDISPATCH_JUMPPAGE_VALUE.NETWORK_ERROR ||
|
|
78
77
|
centerDispatchJumpPageValue === CENTERDISPATCH_JUMPPAGE_VALUE.SYSTEM_ERROR
|
|
79
78
|
) {
|
|
80
79
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口网络异常或接口异常', jumpPage);
|
|
81
80
|
showFailToast({
|
|
82
81
|
title: '网络繁忙,稍后再试吧~',
|
|
83
82
|
...toastOpt,
|
|
84
83
|
});
|
|
85
84
|
return;
|
|
86
85
|
}
|
|
87
86
|
if (centerDispatchJumpPageValue === CENTERDISPATCH_JUMPPAGE_VALUE.NOT_LOGGED_IN) {
|
|
88
87
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口返回未登录,跳登录页');
|
|
89
88
|
global
|
|
90
89
|
.doLogin()
|
|
91
90
|
.then((res) => {
|
|
92
91
|
console.log('登录成功', res);
|
|
93
92
|
})
|
|
94
93
|
.catch((err) => {
|
|
95
94
|
console.log('登录失败', err);
|
|
96
95
|
});
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
99
98
|
const memberRoleJumpPageValueArr = [
|
|
100
99
|
CENTERDISPATCH_JUMPPAGE_VALUE.MEMBER_CENTER,
|
|
101
100
|
CENTERDISPATCH_JUMPPAGE_VALUE.ISV_MEMBER,
|
|
102
101
|
CENTERDISPATCH_JUMPPAGE_VALUE.JSHOP_ISV_PAGE,
|
|
103
102
|
];
|
|
104
103
|
const isMemberRole = memberRoleJumpPageValueArr.includes(centerDispatchJumpPageValue);
|
|
105
104
|
if (isMemberRole) {
|
|
106
105
|
showFailToast({
|
|
107
106
|
title: '您已是本店会员,无需再次入会',
|
|
108
107
|
...toastOpt,
|
|
109
108
|
});
|
|
110
109
|
return;
|
|
111
110
|
}
|
|
112
111
|
if (!isH5AndJdShopView && !forceMemberCardPopup) {
|
|
113
112
|
JumpEventReport.jdJumpToNewH5MemberCard();
|
|
114
113
|
return;
|
|
115
114
|
}
|
|
116
115
|
const { isDegrade = true, isLowVersion = true } = centerDispatchResult;
|
|
117
116
|
console.log('一键入会,是否已降级', isDegrade);
|
|
118
117
|
console.log('一键入会,是否低版本', isLowVersion);
|
|
119
118
|
if (isDegrade) {
|
|
120
119
|
console.log('一键入会,已降级');
|
|
121
120
|
showFailToast({
|
|
122
121
|
title: '网络繁忙,稍后再试吧~',
|
|
123
122
|
...toastOpt,
|
|
124
123
|
});
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
126
|
if (isLowVersion && !forceMemberCardPopup) {
|
|
128
127
|
console.log('一键入会,低版本');
|
|
129
128
|
JumpEventReport.jdJumpToMemberTab();
|
|
130
129
|
return;
|
|
131
130
|
}
|
|
132
131
|
return new Promise((resolve) => {
|
|
133
132
|
const getOpenCardUrlParams = {
|
|
134
133
|
venderId: currentVenderId,
|
|
135
134
|
shopId: currentShopId,
|
|
136
135
|
channel: JUMP_MEMBER_CHANNEL.POP_WEBVIEW,
|
|
137
136
|
device: global.info.sysInfo?.isJdTabletDevice ? 'tablet' : 'all',
|
|
138
137
|
memberSceneType: 'view',
|
|
139
138
|
...options,
|
|
140
139
|
};
|
|
141
140
|
const memberCardurl =
|
|
142
141
|
window?.shopGlobalSwitch?.openNewMemberEntry === 'true'
|
|
143
142
|
? `${JumpWebUrl.memberCard}?${objectToUrlEncode(getOpenCardUrlParams)}`
|
|
144
143
|
: `${JumpWebUrl.shopH5MemberCardAPP}?${objectToUrlEncode(getOpenCardUrlParams)}`;
|
|
145
144
|
const sourceUrl = encodeURIComponent(window.location.href || '');
|
|
146
145
|
let url =
|
|
147
146
|
sourceUrl && sourceUrl !== '' ? `${memberCardurl}&sourceUrl=${sourceUrl}` : memberCardurl;
|
|
148
147
|
if (!url.includes('http')) {
|
|
149
148
|
url = 'https:' + url;
|
|
150
149
|
}
|
|
151
150
|
console.log('openPopWebview url', url);
|
|
152
151
|
nativeOpenPopWebView({
|
|
153
152
|
url,
|
|
154
153
|
});
|
|
155
154
|
Taro.eventCenter.off(TaroEventType.JOIN_MEMBER_SUCCESS);
|
|
156
155
|
Taro.eventCenter.on(TaroEventType.JOIN_MEMBER_SUCCESS, (res) => {
|
|
157
156
|
console.log('TaroEventType.JOIN_MEMBER_SUCCESS res', res);
|
|
158
157
|
const { shopId, venderId } = res;
|
|
159
158
|
if (shopId === currentShopId && venderId === currentVenderId) {
|
|
160
159
|
resolve(true);
|
|
161
160
|
} else {
|
|
162
161
|
console.log(
|
|
163
162
|
'TaroEventType.JOIN_MEMBER_SUCCESS shopId venderId 不匹配,currentShopId, currentVenderId',
|
|
164
163
|
currentShopId,
|
|
165
164
|
currentVenderId,
|
|
166
165
|
);
|
|
167
166
|
resolve(false);
|
|
168
167
|
}
|
|
169
168
|
});
|
|
170
169
|
});
|
|
170
|
+
import Taro from '@tarojs/taro';
|
|
171
171
|
TaroEventType,
|
|
172
172
|
JUMP_MEMBER_CHANNEL,
|
|
173
173
|
CENTERDISPATCH_JUMPPAGE_VALUE,
|
|
174
174
|
|
|
175
175
|
CARD_BANNER = 'shopMemberCardVenderCardBanner',
|
|
176
176
|
|
|
177
177
|
CARD_NAME = 'shopMemberCardVenderCardName',
|
|
178
178
|
|
|
179
179
|
MEMBERSHIP_LEVEL = 'shopMemberCardMembershipLevel',
|
|
180
180
|
|
|
181
181
|
MEMBERSHIP_RULE_ENTRANCE = 'shopMemberCardMembershipRuleEntrance',
|
|
182
182
|
|
|
183
183
|
MEMBERSHIP_POINT = 'shopMemberCardMembershipPoint',
|
|
184
184
|
return new Promise((resolve) => {
|
|
185
185
|
requestServer
|
|
186
186
|
.getCustomerCenterDispatch(params)
|
|
187
187
|
.then((response) => {
|
|
188
188
|
if (response.result && response.code === '0') {
|
|
189
189
|
resolve(response.result);
|
|
190
190
|
} else {
|
|
191
191
|
resolve({
|
|
192
192
|
jumpPage:
|
|
193
193
|
response.code === '1'
|
|
194
194
|
? CENTERDISPATCH_JUMPPAGE_VALUE.NOT_LOGGED_IN
|
|
195
195
|
: CENTERDISPATCH_JUMPPAGE_VALUE.SYSTEM_ERROR,
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
})
|
|
199
199
|
.catch((err) => {
|
|
200
200
|
resolve({ jumpPage: CENTERDISPATCH_JUMPPAGE_VALUE.NETWORK_ERROR });
|
|
201
201
|
console.log('oneKeyJoinMember getcustomerCenterDispatch err', err);
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
const currentVenderId = global.info.queryInfo.venderId;
|
|
205
205
|
const currentShopId = global.info.queryInfo.shopId;
|
|
206
206
|
const channel = JUMP_MEMBER_CHANNEL.POP_WEBVIEW;
|
|
207
207
|
const forceMemberCardPopup = options?.forceMemberCardPopup;
|
|
208
208
|
const toastOpt = {
|
|
209
209
|
duration: 3000,
|
|
210
210
|
image:
|
|
211
211
|
'https://img13.360buyimg.com/img/jfs/t1/196933/39/19850/1479/61b059aaEe969b8db/acb37a47b9034333.png',
|
|
212
212
|
};
|
|
213
213
|
if (forceMemberCardPopup) {
|
|
214
214
|
showFailToast({
|
|
215
215
|
title: '临时调试模拟入会成功',
|
|
216
216
|
});
|
|
217
217
|
return new Promise((resolve, reject) => {
|
|
218
218
|
reject();
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
if (isAppHomeForMarketPage) {
|
|
222
222
|
JumpEventReport.jdJumpToBottomTabBrandMember({
|
|
223
223
|
shopId: currentShopId,
|
|
224
224
|
venderId: currentVenderId,
|
|
225
225
|
});
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
228
|
const params = {
|
|
229
229
|
venderId: currentVenderId,
|
|
230
230
|
channel,
|
|
231
231
|
queryVersion: isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '9.2.0',
|
|
232
232
|
};
|
|
233
233
|
const centerDispatchResult = await getCenterDispatchResult(params);
|
|
234
234
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口返回值', centerDispatchResult);
|
|
235
235
|
const { jumpPage } = centerDispatchResult;
|
|
236
236
|
if (typeof jumpPage !== 'number') {
|
|
237
237
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口返回 jumpPage 值类型异常,非数字');
|
|
238
238
|
showFailToast({
|
|
239
239
|
title: '网络繁忙,稍后再试吧~',
|
|
240
240
|
...toastOpt,
|
|
241
241
|
});
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
const centerDispatchJumpPageValue = Number(jumpPage);
|
|
245
245
|
if (
|
|
246
246
|
centerDispatchJumpPageValue === CENTERDISPATCH_JUMPPAGE_VALUE.NETWORK_ERROR ||
|
|
247
247
|
centerDispatchJumpPageValue === CENTERDISPATCH_JUMPPAGE_VALUE.SYSTEM_ERROR
|
|
248
248
|
) {
|
|
249
249
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口网络异常或接口异常', jumpPage);
|
|
250
250
|
showFailToast({
|
|
251
251
|
title: '网络繁忙,稍后再试吧~',
|
|
252
252
|
...toastOpt,
|
|
253
253
|
});
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
256
|
if (centerDispatchJumpPageValue === CENTERDISPATCH_JUMPPAGE_VALUE.NOT_LOGGED_IN) {
|
|
257
257
|
console.log('oneKeyJoinMember getcustomerCenterDispatch 接口返回未登录,跳登录页');
|
|
258
258
|
global
|
|
259
259
|
.doLogin()
|
|
260
260
|
.then((res) => {
|
|
261
261
|
console.log('登录成功', res);
|
|
262
262
|
})
|
|
263
263
|
.catch((err) => {
|
|
264
264
|
console.log('登录失败', err);
|
|
265
265
|
});
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
268
|
const memberRoleJumpPageValueArr = [
|
|
269
269
|
CENTERDISPATCH_JUMPPAGE_VALUE.MEMBER_CENTER,
|
|
270
270
|
CENTERDISPATCH_JUMPPAGE_VALUE.ISV_MEMBER,
|
|
271
271
|
CENTERDISPATCH_JUMPPAGE_VALUE.JSHOP_ISV_PAGE,
|
|
272
272
|
];
|
|
273
273
|
const isMemberRole = memberRoleJumpPageValueArr.includes(centerDispatchJumpPageValue);
|
|
274
274
|
if (isMemberRole) {
|
|
275
275
|
showFailToast({
|
|
276
276
|
title: '您已是本店会员,无需再次入会',
|
|
277
277
|
...toastOpt,
|
|
278
278
|
});
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
if (!isH5AndJdShopView && !forceMemberCardPopup) {
|
|
282
282
|
JumpEventReport.jdJumpToNewH5MemberCard();
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
const { isDegrade = true, isLowVersion = true } = centerDispatchResult;
|
|
286
286
|
console.log('一键入会,是否已降级', isDegrade);
|
|
287
287
|
console.log('一键入会,是否低版本', isLowVersion);
|
|
288
288
|
if (isDegrade) {
|
|
289
289
|
console.log('一键入会,已降级');
|
|
290
290
|
showFailToast({
|
|
291
291
|
title: '网络繁忙,稍后再试吧~',
|
|
292
292
|
...toastOpt,
|
|
293
293
|
});
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
296
|
if (isLowVersion && !forceMemberCardPopup) {
|
|
297
297
|
console.log('一键入会,低版本');
|
|
298
298
|
JumpEventReport.jdJumpToMemberTab();
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
301
|
return new Promise((resolve) => {
|
|
302
302
|
const getOpenCardUrlParams = {
|
|
303
303
|
venderId: currentVenderId,
|
|
304
304
|
shopId: currentShopId,
|
|
305
305
|
channel: JUMP_MEMBER_CHANNEL.POP_WEBVIEW,
|
|
306
306
|
device: global.info.sysInfo?.isJdTabletDevice ? 'tablet' : 'all',
|
|
307
307
|
memberSceneType: 'view',
|
|
308
308
|
...options,
|
|
309
309
|
};
|
|
310
310
|
const memberCardurl =
|
|
311
311
|
window?.shopGlobalSwitch?.openNewMemberEntry === 'true'
|
|
312
312
|
? `${JumpWebUrl.memberCard}?${objectToUrlEncode(getOpenCardUrlParams)}`
|
|
313
313
|
: `${JumpWebUrl.shopH5MemberCardAPP}?${objectToUrlEncode(getOpenCardUrlParams)}`;
|
|
314
314
|
const sourceUrl = encodeURIComponent(window.location.href || '');
|
|
315
315
|
let url =
|
|
316
316
|
sourceUrl && sourceUrl !== '' ? `${memberCardurl}&sourceUrl=${sourceUrl}` : memberCardurl;
|
|
317
317
|
if (!url.includes('http')) {
|
|
318
318
|
url = 'https:' + url;
|
|
319
319
|
}
|
|
320
320
|
console.log('openPopWebview url', url);
|
|
321
321
|
nativeOpenPopWebView({
|
|
322
322
|
url,
|
|
323
323
|
});
|
|
324
324
|
Taro.eventCenter.off(TaroEventType.JOIN_MEMBER_SUCCESS);
|
|
325
325
|
Taro.eventCenter.on(TaroEventType.JOIN_MEMBER_SUCCESS, (res) => {
|
|
326
326
|
console.log('TaroEventType.JOIN_MEMBER_SUCCESS res', res);
|
|
327
327
|
const { shopId, venderId } = res;
|
|
328
328
|
if (shopId === currentShopId && venderId === currentVenderId) {
|
|
329
329
|
resolve(true);
|
|
330
330
|
} else {
|
|
331
331
|
console.log(
|
|
332
332
|
'TaroEventType.JOIN_MEMBER_SUCCESS shopId venderId 不匹配,currentShopId, currentVenderId',
|
|
333
333
|
currentShopId,
|
|
334
334
|
currentVenderId,
|
|
335
335
|
);
|
|
336
336
|
resolve(false);
|
|
337
337
|
}
|
|
338
338
|
});
|
|
339
339
|
});
|