forked from 6dylan6/jdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_wx_centerDraw.js
212 lines (205 loc) · 8.17 KB
/
jd_wx_centerDraw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
7 7 7 7 7 jd_wx_centerDraw.js
*/
let mode = __dirname.includes('magic')
const {Env} = mode ? require('./magic') : require('./magic')
const $ = new Env('M老虎机抽奖');
$.lz = 'LZ_TOKEN_KEY=lztokef1eb8494b0af868bd18bdaf8;LZ_TOKEN_VALUE=Aa5RE8RuY4X3zA==;';
$.activityUrl = process.env.M_WX_CENTER_DRAW_URL
? process.env.M_WX_CENTER_DRAW_URL
: '';
if (mode) {
$.activityUrl = 'https://lzkj-isv.isvjcloud.com/lzclient/8e5f3ebaf6e545959aa6311d14be5dfa/cjwx/common/entry.html?activityId=8e5f3ebaf6e545959aa6311d14be5dfa&gameType=wxTurnTable'
// $.activityUrl = 'https://lzkj-isv.isvjcloud.com/wxDrawActivity/activity?activityId=37c4c35255a84522bc944974edeef960'
// $.activityUrl = 'https://lzkj-isv.isvjcloud.com/wxDrawActivity/activity?activityId=1155ac7d4ec74a8ba31238d846866599'
$.activityUrl = 'https://lzkj-isv.isvjcloud.com/wxDrawActivity/activity?activityId=a5b7b7b8196e4dc192c4ffd3221a7866'
$.activityUrl = 'https://lzkj-isv.isvjcloud.com/drawCenter/activity/75f5617c3c844163b8ccb1b410eb23e8?activityId=75f5617c3c844163b8ccb1b410eb23e8'
$.activityUrl = 'https://lzkj-isv.isvjcloud.com/drawCenter/activity?activityId=7113c86ee0b94fbbb803a76c8bda6065'
}
$.activityUrl = $.match(
/(https?:\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])/,
$.activityUrl)
$.domain = $.match(/https?:\/\/([^/]+)/, $.activityUrl)
$.activityId = $.getQueryString($.activityUrl, 'activityId')
let shopInfo = ''
$.uid = ''//全都助力1号
$.logic = async function () {
if (!$.activityId || !$.activityUrl) {
$.expire = true;
$.putMsg(`activityId|activityUrl不存在`);
return
}
$.log(`活动id: ${$.activityId}`, `活动url: ${$.activityUrl}`)
$.UA = $.ua();
let token = await $.isvObfuscator();
if (token.code !== '0') {
$.putMsg(`获取Token失败`);
return
}
$.Token = token?.token
let actInfo = await $.api('customer/getSimpleActInfoVo',
`activityId=${$.activityId}`);
if (!actInfo.result || !actInfo.data) {
$.log(`获取活动信息失败`);
return
}
$.venderId = actInfo.data.venderId;
$.shopId = actInfo.data.shopId;
$.activityType = actInfo.data.activityType;
let myPing = await $.api('customer/getMyPing',
`userId=${$.venderId}&token=${$.Token}&fromType=APP`)
if (!myPing.result) {
$.putMsg(`获取pin失败`);
return
}
$.Pin = $.domain.includes('cjhy') ? encodeURIComponent(
encodeURIComponent(myPing.data.secretPin)) : encodeURIComponent(
myPing.data.secretPin);
await $.api(
`common/${$.domain.includes('cjhy') ? 'accessLog' : 'accessLogWithAD'}`,
`venderId=${$.venderId}&code=${$.activityType}&pin=${
$.Pin}&activityId=${$.activityId}&pageUrl=${encodeURIComponent($.activityUrl)}&subType=app&adSource=`);
let userInfo = await $.api('wxActionCommon/getUserInfo',
`pin=${$.Pin}`);
if (!userInfo.result) {
$.putMsg('获取用户信息,结束运行')
return
}
$.nickname = userInfo.data.nickname;
//助力暂且不弄
let activityContent = await $.api(
'drawCenter/activityContent',
`activityId=${$.activityId}&pin=${
$.Pin}&nick=${$.nickname}&pinImg=${encodeURIComponent(
'https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg')}&shareUuid=${$.uid}`,
true);
if (!activityContent.result || !activityContent.data) {
$.putMsg(activityContent.errorMessage || '活动可能已结束')
return
}
if (!$.uid) {
$.uid = activityContent.data.uid//大概率助力码
}
let prizeList = await $.api('drawCenter/getPrizeList',
`activityId=${$.activityId}&activityType=${$.activityType}&venderId=${$.venderId}`);
if (prizeList.result) {
$.content = prizeList.data;
}
let myInfo = await $.api('drawCenter/myInfo',
`activityId=${$.activityId}&pin=${$.Pin}`);
if (!myInfo.result) {
$.putMsg('获取任务列表失败')
return
}
for (let ele of myInfo?.data?.taskList || []) {
if (ele.curNum >= ele.maxNeed) {
//完成了
continue;
}
let count = ele.maxNeed - ele.curNum;
if (ele.taskId === 'followsku') {
$.log('followsku')
let products = await $.api('drawCenter/getProduct',
`activityId=${$.activityId}&pin=${
$.Pin}&type=3`);
for (let pd of products?.data.filter(o => !o.taskDone)) {
if (count <= 0) {
break;
}
await $.api('drawCenter/doTask',
`activityId=${$.activityId}&pin=${
$.Pin}&taskId=followsku¶m=${pd.skuId}`)
await $.wait(200, 500)
count--
}
}
if (ele.taskId === 'add2cart') {
$.log('add2cart')
let products = await $.api('drawCenter/getProduct',
`activityId=${$.activityId}&pin=${
$.Pin}&type=1`);
for (let pd of products?.data.filter(o => !o.taskDone)) {
if (count <= 0) {
break;
}
await $.api('drawCenter/doTask',
`activityId=${$.activityId}&pin=${
$.Pin}&taskId=add2cart¶m=${pd.skuId}`)
await $.wait(200, 500)
count--
}
}
if (ele.taskId === 'scansku') {
$.log('scansku')
let products = await $.api('drawCenter/getProduct',
`activityId=${$.activityId}&pin=${
$.Pin}&type=2`);
for (let pd of products?.data.filter(o => !o.taskDone)) {
if (count <= 0) {
break;
}
await $.api('drawCenter/doTask',
`activityId=${$.activityId}&pin=${
$.Pin}&taskId=scansku¶m=${pd.skuId}`)
await $.wait(200, 500)
count--
}
}
if (ele.taskId === 'followshop') {
$.log('followshop')
await $.api('drawCenter/doTask',
`activityId=${$.activityId}&pin=${
$.Pin}&taskId=followshop¶m=`)
}
if (ele.taskId === 'joinvip') {
$.log('joinvip')
await $.api('drawCenter/doTask',
`activityId=${$.activityId}&pin=${
$.Pin}&taskId=joinvip¶m=`)
}
}
activityContent = await $.api(
'drawCenter/activityContent',
`activityId=${$.activityId}&pin=${
$.Pin}&nick=${$.nickname}&pinImg=${encodeURIComponent(
'https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg')}&shareUuid=${$.uid}`,
true);
if (!activityContent.result) {
$.putMsg('获取不到活动信息,结束运行')
return
}
$.canDrawTimes = activityContent.data.chance || 0
if ($.canDrawTimes === 0) {
$.putMsg(`抽奖次数 ${$.canDrawTimes}`)
return
}
for (let i = 0; i < $.canDrawTimes; i++) {
let prize = await $.api('/drawCenter/draw/luckyDraw',
`activityId=${$.activityId}&pin=${$.Pin}`);
if (prize.result) {
let msg = prize.data.drawOk ? prize.data.name
: prize.data.errorMessage || '空气';
$.putMsg(msg)
} else {
if (prize.errorMessage) {
await $.wxStop(prize.errorMessage) ? $.expire = true : ''
$.putMsg(`${prize.errorMessage}`);
}
break
}
}
}
$.after = async function () {
if ($.msg.length > 0) {
let message = `\n${(await $.getShopInfo()).shopName || ''}\n`;
for (let ele of $.content || []) {
if (ele.name.includes('谢谢') || ele.name.includes('再来')) {
continue;
}
message += ` ${ele.name}${ele?.type === 8 ? '专享价' : ''}\n`
}
$.msg.push(message)
$.msg.push($.activityUrl);
}
}
$.run({whitelist: ['1-5'], wait: [1000, 3000]}).catch(reason => $.log(reason));