zg-sdk-wechart 2.0.7 → 2.0.8

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/README.md CHANGED
@@ -1,71 +1,88 @@
1
- # 微信小程序SDK使用指南
2
- ### 配置sdk安全域名
3
- 登录「微信公众平台」在「开发-开发设置-服务器域名」的「request合法域名」中,增加诸葛域名:
1
+ # 微信小程序 SDK 使用指南
2
+
3
+ ### 配置 sdk 安全域名
4
+
5
+ 登录「微信公众平台」在「开发-开发设置-服务器域名」的「request 合法域名」中,增加诸葛域名:
4
6
 
5
7
  https://u.zhugeapi.net
6
8
 
7
9
  https://ubak.zhugeio.com
8
10
  ![](readme/6C930073-E8E0-4638-9F47-EFCC8070200B.png)
9
11
 
10
- ### 安装sdk
11
- 1.在小程序中执行命令安装sdk包
12
- ```bash
13
- npm install --production zg-sdk-wechart
14
- ```
12
+ ### 安装 sdk
13
+
14
+ 1.在小程序中执行命令安装 sdk 包
15
+
16
+ ```bash
17
+ npm install --production zg-sdk-wechart
18
+ ```
19
+
15
20
  2.点击开发者工具中的菜单栏:工具 --> 构建 npm
16
- ![](readme/7235C868-C404-489B-A948-2C287E2CBCBD.png)
17
- 3.勾选“使用 npm 模块”选项
18
- ![](readme/1922E90B-0CB3-4A45-BF46-41F57D49AD38.png)
19
- ### 引用sdk
20
- 1.在app.js文件头部,引入sdk
21
- ```js
22
- import 'zg-sdk-wechart'
23
- App.zhuge.load('AppKey', {
24
- // load配置参数,具体见下方
25
- })
26
- ```
27
- > mpvue引入方式见下方
28
- > 在`yourProject/src/main.js`文件顶部,引入SDK文件。
21
+ ![](readme/7235C868-C404-489B-A948-2C287E2CBCBD.png) 3.勾选“使用 npm 模块”选项
22
+ ![](readme/1922E90B-0CB3-4A45-BF46-41F57D49AD38.png)
23
+
24
+ ### 引用 sdk
25
+
26
+ 1.在 app.js 文件头部,引入 sdk
27
+
29
28
  ```js
30
- import zhuge from 'zg-sdk-wechart' // sdk的引用,需要在Vue和App之前
31
- import Vue from 'vue'
32
- import App from './App'
29
+ import "zg-sdk-wechart";
30
+ App.zhuge.load("AppKey", {
31
+ // load配置参数,具体见下方
32
+ });
33
+ ```
33
34
 
34
- zhuge.load('此处填写您在诸葛申请的APP KEY', { // load方法具体参数,参见下面的接口说明
35
- pv: true
36
- })
35
+ > mpvue 引入方式见下方
36
+ > 在`yourProject/src/main.js`文件顶部,引入 SDK 文件。
37
+
38
+ ```js
39
+ import zhuge from "zg-sdk-wechart"; // sdk的引用,需要在Vue和App之前
40
+ import Vue from "vue";
41
+ import App from "./App";
37
42
 
38
- Vue.config.productionTip = false
39
- App.mpType = 'app'
43
+ zhuge.load("此处填写您在诸葛申请的APP KEY", {
44
+ // load方法具体参数,参见下面的接口说明
45
+ pv: true,
46
+ });
40
47
 
41
- const app = new Vue(App)
42
- app.$mount()
48
+ Vue.config.productionTip = false;
49
+ App.mpType = "app";
43
50
 
51
+ const app = new Vue(App);
52
+ app.$mount();
44
53
  ```
45
- > wepy引入方式见下方
46
- > 在yourProject/app.wpy文件script标签中引入sdk文件
54
+
55
+ > wepy 引入方式见下方
56
+ > 在 yourProject/app.wpy 文件 script 标签中引入 sdk 文件
57
+
47
58
  ```js
48
59
  // app.wpy
49
- import 'zg-sdk-wechart'
60
+ import "zg-sdk-wechart";
50
61
 
51
- App.zhuge.load('此处填写您在诸葛申请的APP KEY', {
52
- pv: true
53
- })
62
+ App.zhuge.load("此处填写您在诸葛申请的APP KEY", {
63
+ pv: true,
64
+ });
54
65
  ```
66
+
55
67
  ```js
56
68
  //.eslintrc.js eslint配置增加App全局忽略
57
69
  module.exports = {
58
- globals: { App: true}
59
- }
70
+ globals: { App: true },
71
+ };
60
72
  ```
61
- 2.引入成功后,即可在全局任意地方,通过App.zhuge调用sdk函数,如:`App.zhuge.track('登录')`
62
- ### API列表
73
+
74
+ 2.引入成功后,即可在全局任意地方,通过 App.zhuge 调用 sdk 函数,如:`App.zhuge.track('登录')`
75
+
76
+ ### API 列表
77
+
63
78
  #### load(appkey, config)
64
- * appkey \<string\>
65
- 您在诸葛申请的APP KEY
66
- * config \<object\>
67
- sdk配置信息。不需要自定义的参数可忽略
68
- 完整默认配置如下:
79
+
80
+ - appkey \<string\>
81
+ 您在诸葛申请的 APP KEY
82
+ - config \<object\>
83
+ sdk 配置信息。不需要自定义的参数可忽略
84
+ 完整默认配置如下:
85
+
69
86
  ```js
70
87
  {
71
88
  debug: false, // 开启实时调试
@@ -100,94 +117,115 @@ sdk配置信息。不需要自定义的参数可忽略
100
117
  exposure: false // 是否启动元素曝光采集 详细请看下文
101
118
  }
102
119
  ```
120
+
103
121
  使用示例:
122
+
104
123
  ```js
105
- App.zhuge.load('AppKey', {
106
- pv: true
107
- })
124
+ App.zhuge.load("AppKey", {
125
+ pv: true,
126
+ });
108
127
  ```
109
- > 1. utm就近原则:每次打开小程序时,sdk即会再应用的onShow声明周期中,解析并更新utm信息。如果onShow时没有获取到有效utm信息,则utm信息保持不变。
110
- > 2. parseScene为true时,打开小程序时,sdk会自动根据[小程序场景值](https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html)生成utm_source与utm_medium,如果启动参数中包含有这两个utm信息,则以启动参数中的utm信息为准
111
- > 3. 当superProperty属性与上传事件时指定的属性冲突,则superProperty被覆盖
112
- > 4. 当页面onHide时,sdk会自动flush所有请求
128
+
129
+ > 1. utm 就近原则:每次打开小程序时,sdk 即会再应用的 onShow 声明周期中,解析并更新 utm 信息。如果 onShow 时没有获取到有效 utm 信息,则 utm 信息保持不变。
130
+ > 2. parseScene 为 true 时,打开小程序时,sdk 会自动根据[小程序场景值](https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html)生成 utm_source 与 utm_medium,如果启动参数中包含有这两个 utm 信息,则以启动参数中的 utm 信息为准
131
+ > 3. 当 superProperty 属性与上传事件时指定的属性冲突,则 superProperty 被覆盖
132
+ > 4. 当页面 onHide 时,sdk 会自动 flush 所有请求
113
133
 
114
134
  #### identify(cuid, props)
115
- * cuid \<string\>
116
- 用户唯一标识
117
- * props \<object\>
118
- 用户属性
119
135
 
120
- > 为了保持对用户的跟踪,你需要为他们记录一个识别码,可以使用手机号、email等唯一值来作为用户的识别码。另外,也可以在跟踪用户的时候, 记录用户更多的属性信息,便于你更了解你的用户
121
- 使用示例:
136
+ - cuid \<string\>
137
+ 用户唯一标识
138
+ - props \<object\>
139
+ 用户属性
140
+
141
+ > 为了保持对用户的跟踪,你需要为他们记录一个识别码,可以使用手机号、email 等唯一值来作为用户的识别码。另外,也可以在跟踪用户的时候, 记录用户更多的属性信息,便于你更了解你的用户
142
+ > 使用示例:
143
+
122
144
  ```js
123
- App.zhuge.identify('17711111111', {
124
- '性别': '',
125
- '会员级别': '白金'
126
- })
145
+ App.zhuge.identify("17711111111", {
146
+ 性别: "",
147
+ 会员级别: "白金",
148
+ });
127
149
  ```
128
150
 
129
151
  #### track(eventName, props)
130
- * eventName \<string\>
131
- 事件名称
132
- * props \<object\>
133
- 事件属性
134
- 使用示例:
152
+
153
+ - eventName \<string\>
154
+ 事件名称
155
+ - props \<object\>
156
+ 事件属性
157
+ 使用示例:
158
+
135
159
  ```js
136
- App.zhuge.track('加入购物车', {
137
- '商品名称': '华为P30',
138
- '商品分类': '3C'
139
- })
160
+ App.zhuge.track("加入购物车", {
161
+ 商品名称: "华为P30",
162
+ 商品分类: "3C",
163
+ });
140
164
  ```
141
- > 注意:在添加事件属性时,需注意事件属性类型。如果事件属性类型为「数值型属性」,需要在上传数据时修改数据类型为「数值型」,并且在诸葛io后台埋点管理中修改为「数值型」。
165
+
166
+ > 注意:在添加事件属性时,需注意事件属性类型。如果事件属性类型为「数值型属性」,需要在上传数据时修改数据类型为「数值型」,并且在诸葛 io 后台埋点管理中修改为「数值型」。
142
167
 
143
168
  #### trackCount
144
- * eventName \<string\>
145
- 事件名称
146
- * props \<object\>
147
- 事件属性
169
+
170
+ - eventName \<string\>
171
+ 事件名称
172
+ - props \<object\>
173
+ 事件属性
174
+
148
175
  ```js
149
- App.zhuge.trackCount('like', {
150
- '商品名称': '华为P30',
151
- '商品分类': '3C'
152
- })
176
+ App.zhuge.trackCount("like", {
177
+ 商品名称: "华为P30",
178
+ 商品分类: "3C",
179
+ });
153
180
  ```
154
- > trackCount是用来记录事件触发的次数,适用于频繁触发事件的场景比如视频直播点赞。
155
181
 
156
- > 函数连续触发时会记录执行的次数,当函数停止执行会等待集成sdk设置的countDuration时间,超时后会上传事件和事件属性,通过trackCount函数上传的事件会附带两个自定义属性count和countTime,分别代表执行的次数和连续触发持续的时间。
182
+ > trackCount 是用来记录事件触发的次数,适用于频繁触发事件的场景比如视频直播点赞。
183
+
184
+ > 函数连续触发时会记录执行的次数,当函数停止执行会等待集成 sdk 设置的 countDuration 时间,超时后会上传事件和事件属性,通过 trackCount 函数上传的事件会附带两个自定义属性 count 和 countTime,分别代表执行的次数和连续触发持续的时间。
157
185
 
158
- > **注意** 函数执行的过程中如果事件名称和事件属性发生变化trackCount函数会立刻上传上次的事件和属性,然后重新开始计数。
186
+ > **注意** 函数执行的过程中如果事件名称和事件属性发生变化 trackCount 函数会立刻上传上次的事件和属性,然后重新开始计数。
159
187
 
160
188
  #### setUtm(utm)
161
- * utm \<object\>
162
- 需要设置的utm信息。utm包括:utm_source, utm_medium, utm_campaign, utm_content, utm_term
163
- 使用示例:
189
+
190
+ - utm \<object\>
191
+ 需要设置的 utm 信息。utm 包括:utm_source, utm_medium, utm_campaign, utm_content, utm_term
192
+ 使用示例:
193
+
164
194
  ```js
165
195
  App.zhuge.setUtm({
166
- utm_source: '扫码',
167
- utm_medium: '长按图片识别二维码'
168
- })
196
+ utm_source: "扫码",
197
+ utm_medium: "长按图片识别二维码",
198
+ });
169
199
  ```
170
- > 调用setUtm方法时,utm信息会强制更新,不会受utmMode限制。设置后的utm信息,会在后续事件上传中生效。该方法本身不会上传任何事件。
200
+
201
+ > 调用 setUtm 方法时,utm 信息会强制更新,不会受 utmMode 限制。设置后的 utm 信息,会在后续事件上传中生效。该方法本身不会上传任何事件。
171
202
 
172
203
  #### setSuperProperty(superProperty)
173
- * superProperty \<object\>
174
- 全局事件属性
204
+
205
+ - superProperty \<object\>
206
+ 全局事件属性
175
207
 
176
208
  #### extendSuperPropertys(property)
177
- * 合并property到全局事件属性
209
+
210
+ - 合并 property 到全局事件属性
178
211
 
179
212
  #### removeSuperProperty(delList)
180
- * 移除全局事件属性,函数参数为数组
213
+
214
+ - 移除全局事件属性,函数参数为数组
181
215
 
182
216
  #### getSuperProperty
183
- * 获取全局事件属性
217
+
218
+ - 获取全局事件属性
184
219
 
185
220
  #### flush()
221
+
186
222
  手动批量上传已缓存的所有事件
187
223
 
188
224
  #### trackRevenue(props)
189
- * props \<object\>
225
+
226
+ - props \<object\>
190
227
  收入数据属性
228
+
191
229
  ```js
192
230
  {
193
231
  price: 0, // <number>价格
@@ -196,90 +234,116 @@ App.zhuge.setUtm({
196
234
  revenueType: null // <string>收入类别
197
235
  }
198
236
  ```
237
+
199
238
  收入数据采集
200
239
  使用示例:
240
+
201
241
  ```js
202
242
  App.zhuge.trackRevenue({
203
243
  price: 2000,
204
- productID: 'product001',
244
+ productID: "product001",
205
245
  productQuantity: 2,
206
- revenueType: '3c'
207
- })
246
+ revenueType: "3c",
247
+ });
208
248
  ```
209
- > price和productQuantity属性,只能为数值类型。
249
+
250
+ > price 和 productQuantity 属性,只能为数值类型。
251
+
210
252
  #### weixinIdentify()
253
+
211
254
  通过「微信授权」登录小程序,可使用快捷绑定微信用户信息方法,在「微信授权成功」后调用如下方法:
255
+
212
256
  ```js
213
- App.zhuge.weixinIdentify()
257
+ App.zhuge.weixinIdentify();
214
258
  ```
259
+
215
260
  说明:内置绑定的信息内容如下
261
+
216
262
  ```js
217
263
  {
218
264
  'user_id':unionid, // 用户唯一标识
219
265
  'name': userInfo.nickName, // 名称
220
266
  'avatar': userInfo.avatarUrl, // 头像
221
267
  '微信-昵称': userInfo.nickName,
222
- '微信-性别': gender,
268
+ '微信-性别': gender,
223
269
  '微信-城市': userInfo.city,
224
270
  '微信-省': userInfo.province,
225
271
  '微信-国家': userInfo.country
226
272
  }
227
273
  ```
228
- > 1. 使用weixinIdentify()方法,需要提供「AppSecret」给诸葛io技术支持人员,用来获取unionid标识用户;登录「微信公众平台」,在「设置-开发者设置-开发者ID」中生成获取。
229
- > 2. 如可自行获取到unionID,可调用自定义identify方法,绑定微信用户信息
274
+
275
+ > 1. 使用 weixinIdentify()方法,需要提供「AppSecret」给诸葛 io 技术支持人员,用来获取 unionid 标识用户;登录「微信公众平台」,在「设置-开发者设置-开发者 ID」中生成获取。
276
+ > 2. 如可自行获取到 unionID,可调用自定义 identify 方法,绑定微信用户信息
230
277
 
231
278
  ### 记录转发分享
232
- 转发分享数据默认不采集,如需采集,需要在调用load方法时,设置**forwardShare**为true
279
+
280
+ 转发分享数据默认不采集,如需采集,需要在调用 load 方法时,设置**forwardShare**为 true
281
+
233
282
  ### 启动元素曝光采集
234
- 用户使用约定的规则标记元素,元素由**不可见变为可见时**(页面滚动,显示隐藏)sdk会自动采集配置在元素上的自定义事件名称和事件属性,会以自定义事件的方式采上传数据。
235
283
 
236
- sdk配置```exposure```设置为true,在小程序元素中增加```zhuge-expo-track```类名,使用```data-expo-xxx="yyy"```的形式设置自定义事件名称和事件属性,其中```data-expo-name="evt"```会被识别为事件名其他标记会识别为事件属性。
284
+ 用户使用约定的规则标记元素,元素由**不可见变为可见时**(页面滚动,显示隐藏)sdk 会自动采集配置在元素上的自定义事件名称和事件属性,会以自定义事件的方式采上传数据。
285
+
286
+ 将 sdk 配置`exposure`设置为 true,在小程序元素中增加`zhuge-expo-track`类名,使用`data-expo-xxx="yyy"`的形式设置自定义事件名称和事件属性,其中`data-expo-name="evt"`会被识别为事件名其他标记会识别为事件属性。
287
+
237
288
  ```js
238
- zhuge.load('test-appkey', {
239
- exposure: true
240
- })
289
+ zhuge.load("test-appkey", {
290
+ exposure: true,
291
+ });
241
292
  ```
293
+
242
294
  ```html
243
- <view
244
- class="zhuge-expo-track"
295
+ <view
296
+ class="zhuge-expo-track"
245
297
  data-expo-name="首页banner曝光" // 事件名称 “首页banner曝光”
246
298
  data-expo-pos="页头" // 事件属性 pos: "页头"
247
299
  data-expo-type="商品" // 事件属性 type: "商品"
248
300
  >
249
- xxxx
301
+ xxx
250
302
  </view>
251
303
  ```
252
304
 
253
305
  ### 常见问题
306
+
254
307
  #### 1. 接入微信插件的小程序,集成方式有什么变化?
255
- 新版的sdk不再区分插件版与标准版,按照当前文档集成即可。
256
- #### 2. 老版本sdk升级(插件版与标准版通用)
257
- 按照现有方式,使用npm安装并且编译完成后,将下载到项目中的老版本sdk文件内容替换为下方代码,即可完成升级。
308
+
309
+ 新版的 sdk 不再区分插件版与标准版,按照当前文档集成即可。
310
+
311
+ #### 2. 老版本 sdk 升级(插件版与标准版通用)
312
+
313
+ 按照现有方式,使用 npm 安装并且编译完成后,将下载到项目中的老版本 sdk 文件内容替换为下方代码,即可完成升级。
314
+
258
315
  ```js
259
- const zg = require('zg-sdk-wechart')
316
+ const zg = require("zg-sdk-wechart");
260
317
 
261
318
  module.exports = {
262
319
  App: zg.default.App,
263
- Page: zg.default.Page
264
- }
320
+ Page: zg.default.Page,
321
+ };
265
322
  ```
266
- #### 3. 集成sdk后,小程序开发工具提示报错
323
+
324
+ #### 3. 集成 sdk 后,小程序开发工具提示报错
325
+
267
326
  需要检查小程序开发工具是否为最新版,如果不是的话一般更新后就可以正常运行。
268
327
 
269
328
  #### 4. 集成后报错:Uncaught ReferenceError: regeneratorRuntime is not defined
329
+
270
330
  检查小程序开发工具是否开启增强编译,没开启的话,开启后即可避免报错。如果由于生产环境原因,
271
- 不能开启增强编译,可以使用es5版本的sdk:
331
+ 不能开启增强编译,可以使用 es5 版本的 sdk:
332
+
272
333
  ```bash
273
- npm install --production zg-sdk-wechart@es5
334
+ npm install --production zg-sdk-wechart@es5
274
335
  ```
275
- > es5版本的sdk文件会略大于latest版本
276
336
 
277
- #### 5. 页面事件无法上传,或duration无法监听
278
- 这类问题通常是一些小程序框架集成中,sdk无法有效监听页面生命周期导致的,如taro1.x、2.x版本,
337
+ > es5 版本的 sdk 文件会略大于 latest 版本
338
+
339
+ #### 5. 页面事件无法上传,或 duration 无法监听
340
+
341
+ 这类问题通常是一些小程序框架集成中,sdk 无法有效监听页面生命周期导致的,如 taro1.x、2.x 版本,
279
342
  此时可以手动在各个页面组件中,对生命周期进行监听,示例代码如下:
280
- ```js
281
- import { Component } from '@tarojs/taro';
282
- import { View } from '@tarojs/components';
343
+
344
+ ```js
345
+ import { Component } from "@tarojs/taro";
346
+ import { View } from "@tarojs/components";
283
347
  class Index extends Component {
284
348
  constructor(props) {
285
349
  super(props);
@@ -302,15 +366,13 @@ class Index extends Component {
302
366
  }
303
367
 
304
368
  render() {
305
- return (
306
- <View>首页</View>
307
- );
369
+ return <View>首页</View>;
308
370
  }
309
371
  }
310
372
 
311
373
  export default Index;
312
-
313
374
  ```
314
375
 
315
- #### 6. sendLimit批量上传时,上传时机是什么时候?
316
- 当设置了sendLimit时,触发的所有埋点请求,会达到limit指定数量时,将所有埋点数据合并为一个请求进行上传。另外为避免数据丢失的可能性,当页面触发Page的onHide、onUnload生命周期时,不管请求数量是否达到limit限制,都会将已缓存数据进行上传。
376
+ #### 6. sendLimit 批量上传时,上传时机是什么时候?
377
+
378
+ 当设置了 sendLimit 时,触发的所有埋点请求,会达到 limit 指定数量时,将所有埋点数据合并为一个请求进行上传。另外为避免数据丢失的可能性,当页面触发 Page 的 onHide、onUnload 生命周期时,不管请求数量是否达到 limit 限制,都会将已缓存数据进行上传。
@@ -1,4 +1,4 @@
1
- var t=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),u=new T(n||[]);return o._invoke=function(t,e,r){var n=l;return function(i,o){if(n===p)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw o;return j()}for(r.method=i,r.arg=o;;){var u=r.delegate;if(u){var a=P(u,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?m:h,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=m,r.method="throw",r.arg=s.arg)}}}(t,r,u),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l="suspendedStart",h="suspendedYield",p="executing",m="completed",d={};function v(){}function g(){}function y(){}var _={};_[o]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w($([])));b&&b!==r&&n.call(b,o)&&(_=b);var x=y.prototype=v.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(i,o,u,a){var s=f(t[i],t,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,u,a)}),(function(t){r("throw",t,u,a)})):e.resolve(l).then((function(t){c.value=t,u(c)}),(function(t){return r("throw",t,u,a)}))}a(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function P(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function $(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,u=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return u.next=u}}return{next:j}}function j(){return{value:e,done:!0}}return g.prototype=x.constructor=y,y.constructor=g,g.displayName=s(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,a,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},k(S.prototype),S.prototype[u]=function(){return this},t.AsyncIterator=S,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var u=new S(c(e,r,n,i),o);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},k(x),s(x,a,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=$,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var u=this.tryEntries[o],a=u.completion;if("root"===u.tryLoc)return i("end");if(u.tryLoc<=this.prev){var s=n.call(u,"catchLoc"),c=n.call(u,"finallyLoc");if(s&&c){if(this.prev<u.catchLoc)return i(u.catchLoc,!0);if(this.prev<u.finallyLoc)return i(u.finallyLoc)}else if(s){if(this.prev<u.catchLoc)return i(u.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return i(u.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var u=o?o.completion:{};return u.type=t,u.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),D(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;D(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:$(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}({});function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=a(t);if(e){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}function l(t,e,r){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}})(t,e,r||t)}function h(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||p(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}
1
+ var t=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),u=new $(n||[]);return o._invoke=function(t,e,r){var n=l;return function(i,o){if(n===p)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw o;return j()}for(r.method=i,r.arg=o;;){var u=r.delegate;if(u){var a=P(u,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?m:h,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=m,r.method="throw",r.arg=s.arg)}}}(t,r,u),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l="suspendedStart",h="suspendedYield",p="executing",m="completed",d={};function v(){}function g(){}function y(){}var _={};_[o]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w(T([])));b&&b!==r&&n.call(b,o)&&(_=b);var x=y.prototype=v.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(i,o,u,a){var s=f(t[i],t,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,u,a)}),(function(t){r("throw",t,u,a)})):e.resolve(l).then((function(t){c.value=t,u(c)}),(function(t){return r("throw",t,u,a)}))}a(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function P(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function $(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function T(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,u=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return u.next=u}}return{next:j}}function j(){return{value:e,done:!0}}return g.prototype=x.constructor=y,y.constructor=g,g.displayName=s(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,a,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},k(S.prototype),S.prototype[u]=function(){return this},t.AsyncIterator=S,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var u=new S(c(e,r,n,i),o);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},k(x),s(x,a,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=T,$.prototype={constructor:$,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var u=this.tryEntries[o],a=u.completion;if("root"===u.tryLoc)return i("end");if(u.tryLoc<=this.prev){var s=n.call(u,"catchLoc"),c=n.call(u,"finallyLoc");if(s&&c){if(this.prev<u.catchLoc)return i(u.catchLoc,!0);if(this.prev<u.finallyLoc)return i(u.finallyLoc)}else if(s){if(this.prev<u.catchLoc)return i(u.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return i(u.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var u=o?o.completion:{};return u.type=t,u.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),D(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;D(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:T(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}({});function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=a(t);if(e){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}function l(t,e,r){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}})(t,e,r||t)}function h(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||p(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -13,4 +13,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- function d(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function v(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,y,_,w={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(t){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function t(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==e(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(e){s.add(t(e,o))})),s):"Map"===a?(s=new Map,i.forEach((function(e,r){s.set(r,t(e,o))})),s):("Array"===a&&(s=new Array,u(i,(function(e,r){s[r]=t(e,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(e){s[e]=t(i[e],o)}))),s))};return a(t)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e,r,n,i="";t.data&&t.data.title&&t.data.title.length>0&&(i=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!i.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(e){e.pagePath==="".concat(t.route,".html")&&e.text&&(i=e.text)})),!i.length)){var o=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];i=o?null===(e=o.window)||void 0===e?void 0:e.navigationBarTitleText:null===(n=null===(r=null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.global)||void 0===r?void 0:r.window)||void 0===n?void 0:n.navigationBarTitleText}}catch(t){}return i||t.route}},b=function(){function t(e,n){r(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.requestTimeout=n.config.requestTimeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=e}return i(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0.7",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:w.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:h(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t,{timeout:this.requestTimeout})}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r,{timeout:e.requestTimeout}).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),x=function(){function e(t,n,i){r(this,e),this.storageFunction=t,this.allData=i||{},this.allData.did||this.set("did",n.config.did||w.UUID()),this.allData.cuid||this.set("cuid",void 0),w.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return i(e,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.allData[e]=r,t.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return t.stop()}}),n,this)})))}}]),e}();function k(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var S=function(){function e(t,n,i){r(this,e),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,y=t,g=n,_=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:6e4,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return i(e,[{key:"load",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.appKey=e,this.config=w.merge(this.config,r||{}),t.prev=2,t.next=5,g.get();case 5:if((i=t.sent)&&i.did){t.next=10;break}return t.next=9,g.getDid();case 9:i.did=t.sent;case 10:this.storage=new x(g,this,i),this.request=new b(y,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),t.next=20;break;case 17:t.prev=17,t.t0=t.catch(2),console.error("sdk初始化失败,缓存读取失败",t.t0);case 20:case"end":return t.stop()}}),n,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var t=this.buffer.shift();if(t)(e.prototype[t.fnName]||this[t.fnName]).apply(this,t.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Date,t.t0=e,t.t1=n.getTime(),t.t2=this.storage.allData.sid,t.t3=this.storage.allData.cuid,t.t4=this.cn,t.t5=w.getTimezone(n),t.t6=this.currentPage.url,t.t7=this.prevPage.url,t.t8=_.os(),t.t9=_.ov(),t.t10=_.version(),t.next=14,_.mnet();case 14:return t.t11=t.sent,t.next=17,_.net();case 17:return t.t12=t.sent,t.t13=this.config.vn,t.t14=this.referrerDomain,t.t15=this.config.appId,t.t16={$eid:t.t0,$ct:t.t1,$sid:t.t2,$cuid:t.t3,$cn:t.t4,$tz:t.t5,$url:t.t6,$ref:t.t7,$os:t.t8,$ov:t.t9,$wv:t.t10,$mnet:t.t11,$net:t.t12,$vn:t.t13,$referrer_domain:t.t14,$wxeid:t.t15},(i={dt:"evt",pr:t.t16}).pr=w.merge(i.pr,w.encode(this.config.superProperty)),t.abrupt("return",i);case 25:case"end":return t.stop()}}),r,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(_.windowWidth(),"x").concat(_.windowHeight()),$tz:w.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid}};this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:w.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n,i,o,u;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Date,n=this.storage.allData,i=n.sid,o=n.cuid,t.t0=i,t.t1=i,t.t2=o,t.t3=this.cn,t.t4=w.getTimezone(r),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=_.os(),t.t8=_.ov(),t.t9=_.version(),t.next=14,_.mnet();case 14:return t.t10=t.sent,t.next=17,_.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},u={dt:"ss",pr:t.t15},this.send(u),this.environmentInfo();case 25:case"end":return t.stop()}}),e,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=w.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return v(this,void 0,void 0,t.mark((function e(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},r),t.next=10,this.send(n);case 10:case"end":return t.stop()}}),e,this)})))}},{key:"pv",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.pv){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("pv"),t.next=5,this.trackBaseData("pv");case 5:return(n=t.sent).dt="abp",i={$page_title:this.currentPage.title},n.pr=w.merge(n.pr,i,e||{}),t.next=11,this.send(n);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"duration",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),w.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),r=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$dr:r,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(n);case 12:w.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),e,this)})))}},{key:"track",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track"),t.next=3,this.trackBaseData(e);case 3:return(i=t.sent).pr=w.merge(i.pr,w.encode(r)),t.next=7,this.send(i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"identify",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i,o;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.storage.set("cuid",e),this.updateSession("identify"),i=new Date,(o={dt:"usr",pr:{$ct:i.getTime(),$tz:w.getTimezone(i),$cuid:e,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=w.merge(o.pr,w.encode(r)),t.next=7,this.trackBaseData("usr");case 7:return t.next=9,this.send(o);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e)),this.previousCountEvent.name===t&&w.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(e,r,n){return v(this,void 0,void 0,t.mark((function i(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track count"),o=Date.now()-this.countStartTime,n&&(o-=this.config.countDuration),u=this.count,this.count=n?0:1,t.next=7,this.trackBaseData(e);case 7:return a=t.sent,s={},w.isObject(r)&&(s=w.clone(r)),a.pr=w.merge(a.pr,w.encode(s),w.encode({count:u,countTime:o})),t.next=13,this.send(a);case 13:case"end":return t.stop()}}),i,this)})))}},{key:"trackRevenue",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),r.next=4,this.trackBaseData("revenue");case 4:(n=r.sent).dt="abp",(i=w.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},e)).total=o(i.price,i.productQuantity),u=["productID","revenueType"],a=["price","total","productQuantity"],s={},r.t0=t.keys(i);case 12:if((r.t1=r.t0()).done){r.next=21;break}if(c=r.t1.value,-1!==u.indexOf(c)||-1!==a.indexOf(c)){r.next=16;break}return r.abrupt("continue",12);case 16:f=i[c],a.indexOf(c)>-1&&((f=Number(f))||(f=0)),s["$"+c]=f,r.next=12;break;case 21:return n.pr=w.merge(n.pr,s),r.next=24,this.send(n);case 24:case"end":return r.stop()}}),r,this)})))}},{key:"setUtm",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null!==(n=w.filterUtm(e))&&(this.storage.set("utm",n),this.updateSession("setUtm"));case 2:case"end":return t.stop()}}),r,this)})))}},{key:"setSuperProperty",value:function(t){w.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){w.isObject(t)&&(this.config.superProperty=w.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=p(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}},{key:"flush",value:function(){this.request.clear()}}]),e}();d([k],S.prototype,"environmentInfo",null),d([k],S.prototype,"sessionEnd",null),d([k],S.prototype,"sessionStart",null),d([k],S.prototype,"updateSession",null),d([k],S.prototype,"click",null),d([k],S.prototype,"pv",null),d([k],S.prototype,"duration",null),d([k],S.prototype,"track",null),d([k],S.prototype,"identify",null),d([k],S.prototype,"trackCount",null),d([k],S.prototype,"trackRevenue",null),d([k],S.prototype,"setUtm",null);var P=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],O=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],D=function(t){return w.wxGetTitle(t)},T=function(t,e,r){return new Promise((function(n,i){var u;wx.request((o(u={url:t,data:e,method:"POST",timeout:null==r?void 0:r.timeout},"header",{"content-type":"application/x-www-form-urlencoded"}),o(u,"dataType","json"),o(u,"responseType","arraybuffer"),o(u,"success",(function(t){n(t)})),o(u,"fail",(function(t){i(t)})),u))}))},$={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data||""),wx.removeStorage({key:"zg-did"})},fail:function(e){t("")}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data||{})},fail:function(e){t({})}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},j=!1,E=wx.getSystemInfoSync(),C=E.system.split(/\s/),A={os:C[0],ov:C[1],version:E.version,windowHeight:E.windowHeight,windowWidth:E.windowWidth,net:0,mnet:0};function z(t){var e=t.toLowerCase();"wifi"===e?(A.net=1,A.mnet=0):(A.net=0,A.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function I(t){return new Promise((function(e,r){if(j)return e(A[t]);wx.getNetworkType({success:function(r){j=!0,z(r.networkType),e(A[t])}})}))}wx.onNetworkStatusChange((function(t){z(t.networkType)}));var L,q,R={os:function(){return A.os},ov:function(){return A.ov},version:function(){return A.version},net:function(){return I("net")},mnet:function(){return I("mnet")},windowWidth:function(){return A.windowWidth},windowHeight:function(){return A.windowHeight}},U=App,N=Page,F=Component,M=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function B(t,e,r){if(t[r]&&w.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function K(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(L===t||t&&L&&L.timeStamp===t.timeStamp)return n.apply(this,arguments);if(L=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var H=function(e){u(o,S);var n=f(o);function o(t){var e;return r(this,o),(e=n.call(this,T,$,R)).openData={path:"",props:{}},e.shared=!1,e.semiAutoTrackEventCatch={},e.isShareOperation=!1,q=t,e.initLifeCycleHook(),e}return i(o,[{key:"initLifeCycleHook",value:function(){var t,e=this,r=(t=e,{App:{onShow:function(e){t.sceneToUtm(e),t.openOptions=e,t.updateSession("appOnShow")},onHide:function(){t.flush(),t.config.duration&&!t.isShareOperation&&(t.pageReady=!0,t.currentPage.time=Date.now(),t.duration().then((function(){t.pageReady=!1,t.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(e){t.currentPage.query=w.parseQuery(e),t.currentPage.queryObj=e},onShow:function(){var e=getCurrentPages(),r=e[e.length-1];t.currentPage.route=r.__route__||r.route,t.currentPage.time=Date.now(),t.currentPage.url="".concat(t.currentPage.route);var n=D;if(t.currentPage.title="function"==typeof n?n(r):"",t.currentPage.query&&(t.currentPage.url+="?".concat(t.currentPage.query)),t.pageReady=!0,t.freeBuffer(),t.currentPage.url!==t.prevPage.url){""!==t.prevPage.url&&t.duration();try{t.trackOpenShare(t.openOptions)}catch(e){console.warn(e,"".concat(t.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}t.pv()}t.startObserveMarkElement(r),t.openOptions=null,t.isShareOperation=!1},onHide:function(){t.semiAutoTrackEventCatch={},t.prevPage=w.clone(t.currentPage),t.pageReady=!1,t.flush()},onUnload:function(){t.semiAutoTrackEventCatch={},t.prevPage=w.clone(t.currentPage),t.pageReady=!1,t.flush()}}});this.lifecycle=r;var n=function(t){for(var n in r.App)B(t,r.App,n);for(var i in t)!P.includes(i)&&w.isFunction(t[i])&&K(t,i,e);return U(t)};for(var i in App)n[i]=App[i];App=n;var o=function(t){for(var n in r.Page)B(t,r.Page,n);for(var i in t)!O.includes(i)&&w.isFunction(t[i])&&"onShareAppMessage"!==i&&K(t,i,e);var o=t.onShareAppMessage;return w.isFunction(o)&&(t.onShareAppMessage=e.onShareAppMessage(o)),N(t)};for(var u in Page)o[u]=Page[u];Page=o,Component=function(t){if(void 0!==t.methods)for(var r in t.methods)K(t.methods,r,e);return F(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=e}},{key:"load",value:function(t,e){return l(a(o.prototype),"load",this).call(this,t,e)}},{key:"pv",value:function(e){var r=this,n=Object.create(null,{pv:{get:function(){return l(a(o.prototype),"pv",r)}}});return v(this,void 0,void 0,t.mark((function e(){var r,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={},i=w.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(r.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(r.$share_level=Number(this.openOptions.query.zg_share_level)),i.data&&i.data.zg_share_data&&(r=w.merge(r,w.encode(i.data.zg_share_data)))),t.next=5,n.pv.call(this,r);case 5:case"end":return t.stop()}}),e,this)})))}},{key:"click",value:function(e,r){var n=this,i=Object.create(null,{click:{get:function(){return l(a(o.prototype),"click",n)}}});return v(this,void 0,void 0,t.mark((function n(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.target,u=o.dataset.title,a=o.dataset.index,s=[],s="alipay-miniprogram"===this.referrerDomain?["","",e.detail.pageX,e.detail.pageY]:["","",e.detail.x,e.detail.y],t.next=7,i.click.call(this,e,w.merge({$element_content:u||"",$element_selector:a||"",$element_style:s},r||{}));case 7:case"end":return t.stop()}}),n,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=w.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&q){var r=t.scene;this.cn=r+"";var n=q[r],i={},o=null,u=q.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};q.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=w.merge(i,e)}"fresh"===this.config.utmMode&&w.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f,l,h,p;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e&&this.config.forwardShare){t.next=2;break}return t.abrupt("return");case 2:if(!this.shared){t.next=5;break}return this.shared=!1,t.abrupt("return");case 5:if(n=e.query||{},i=this.currentPage.route,!(q.isCartShare(e.scene)&&n.zg_uid&&n.zg_share_id)){t.next=24;break}for(a in o={$uid:n.zg_uid,$share_id:n.zg_share_id,$title:this.currentPage.title,$path:i,$share_open_type:1008===e.scene?"群聊":"聊天",$share_level:Number(n.zg_share_level)},this.shareId=n.zg_share_id,this.shareLevel=Number(n.zg_share_level),u={},n)s=a.replace(/^zg_/,""),-1===M.indexOf(s)&&/^zg_/.test(a)&&(u[s]=n[a]);if(c=this.config.shareToUtm,w.isObject(c)&&!w.isEmpty(c)){for(l in f={},c)null!==u[l]&&void 0!==u[l]&&(h=c[l],f[h]=u[l]);w.isEmpty(w)||(f.utm_campaign||(f.utm_campaign="分享打开"),this.setUtm(f))}return this.openData={path:i,props:u},o=w.merge(o,w.encode(u)),t.next=19,this.trackBaseData("wxsopen");case 19:return(p=t.sent).dt="abp",p.pr=w.merge(p.pr,o),t.next=24,this.request.send(p);case 24:case"end":return t.stop()}}),r,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&w.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var h in o)-1===M.indexOf(h)&&(c["_".concat(h)]=f["zg_".concat(h)]=o[h]);return r.path=w.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=w.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=l(a(o.prototype),"track",e)).call.apply(r,[e].concat(h(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),o}();d([k],H.prototype,"sceneToUtm",null),d([k],H.prototype,"trackOpenShare",null);var G={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},W=new(function(t){u(n,H);var e=f(n);function n(){return r(this,n),e.call(this,G)}return i(n,[{key:"load",value:function(t,e){var r=e||{};if(wx.getAccountInfoSync){var i=wx.getAccountInfoSync();i&&i.miniProgram&&i.miniProgram.appId&&(r.appId=i.miniProgram.appId)}return l(a(n.prototype),"load",this).call(this,t,r)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var h=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function p(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function m(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},v=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},g=[m,l,p,h,d,v],y=Array.prototype.pop.call(arguments);"function"==typeof y&&g.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(g,this)}}]),n}());App.zhuge=W;export default W;
16
+ function d(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function v(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,y,_,w={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(t){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function t(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==e(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(e){s.add(t(e,o))})),s):"Map"===a?(s=new Map,i.forEach((function(e,r){s.set(r,t(e,o))})),s):("Array"===a&&(s=new Array,u(i,(function(e,r){s[r]=t(e,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(e){s[e]=t(i[e],o)}))),s))};return a(t)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e,r,n,i="";t.data&&t.data.title&&t.data.title.length>0&&(i=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!i.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(e){e.pagePath==="".concat(t.route,".html")&&e.text&&(i=e.text)})),!i.length)){var o=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];i=o?null===(e=o.window)||void 0===e?void 0:e.navigationBarTitleText:null===(n=null===(r=null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.global)||void 0===r?void 0:r.window)||void 0===n?void 0:n.navigationBarTitleText}}catch(t){}return i||t.route}},b=function(){function t(e,n){r(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.requestTimeout=n.config.requestTimeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=e}return i(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0.8",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:w.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:h(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t,{timeout:this.requestTimeout})}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r,{timeout:e.requestTimeout}).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),x=function(){function e(t,n,i){r(this,e),this.storageFunction=t,this.allData=i||{},this.allData.did||this.set("did",n.config.did||w.UUID()),this.allData.cuid||this.set("cuid",void 0),w.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return i(e,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.allData[e]=r,t.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return t.stop()}}),n,this)})))}}]),e}();function k(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var S=function(){function e(t,n,i){r(this,e),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,y=t,g=n,_=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:6e4,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return i(e,[{key:"load",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.appKey=e,this.config=w.merge(this.config,r||{}),t.prev=2,t.next=5,g.get();case 5:if((i=t.sent)&&i.did){t.next=10;break}return t.next=9,g.getDid();case 9:i.did=t.sent;case 10:this.storage=new x(g,this,i),this.request=new b(y,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),t.next=20;break;case 17:t.prev=17,t.t0=t.catch(2),console.error("sdk初始化失败,缓存读取失败",t.t0);case 20:case"end":return t.stop()}}),n,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var t=this.buffer.shift();if(t)(e.prototype[t.fnName]||this[t.fnName]).apply(this,t.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Date,t.t0=e,t.t1=n.getTime(),t.t2=this.storage.allData.sid,t.t3=this.storage.allData.cuid,t.t4=this.cn,t.t5=w.getTimezone(n),t.t6=this.currentPage.url,t.t7=this.prevPage.url,t.t8=_.os(),t.t9=_.ov(),t.t10=_.version(),t.next=14,_.mnet();case 14:return t.t11=t.sent,t.next=17,_.net();case 17:return t.t12=t.sent,t.t13=this.config.vn,t.t14=this.referrerDomain,t.t15=this.config.appId,t.t16={$eid:t.t0,$ct:t.t1,$sid:t.t2,$cuid:t.t3,$cn:t.t4,$tz:t.t5,$url:t.t6,$ref:t.t7,$os:t.t8,$ov:t.t9,$wv:t.t10,$mnet:t.t11,$net:t.t12,$vn:t.t13,$referrer_domain:t.t14,$wxeid:t.t15},(i={dt:"evt",pr:t.t16}).pr=w.merge(i.pr,w.encode(this.config.superProperty)),t.abrupt("return",i);case 25:case"end":return t.stop()}}),r,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(_.windowWidth(),"x").concat(_.windowHeight()),$tz:w.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid,$dv:void 0,$br:void 0}};if(wx.getDeviceInfo){var r=wx.getDeviceInfo();e.pr.$dv=r.model,e.pr.$br=r.brand}else delete e.pr.$dv,delete e.pr.$br;this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:w.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n,i,o,u;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Date,n=this.storage.allData,i=n.sid,o=n.cuid,t.t0=i,t.t1=i,t.t2=o,t.t3=this.cn,t.t4=w.getTimezone(r),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=_.os(),t.t8=_.ov(),t.t9=_.version(),t.next=14,_.mnet();case 14:return t.t10=t.sent,t.next=17,_.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},u={dt:"ss",pr:t.t15},this.send(u),this.environmentInfo();case 25:case"end":return t.stop()}}),e,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=w.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return v(this,void 0,void 0,t.mark((function e(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},r),t.next=10,this.send(n);case 10:case"end":return t.stop()}}),e,this)})))}},{key:"pv",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.pv){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("pv"),t.next=5,this.trackBaseData("pv");case 5:return(n=t.sent).dt="abp",i={$page_title:this.currentPage.title},n.pr=w.merge(n.pr,i,e||{}),t.next=11,this.send(n);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"duration",value:function(){return v(this,void 0,void 0,t.mark((function e(){var r,n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),w.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),r=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(n=t.sent).dt="abp",n.pr=w.merge(n.pr,{$dr:r,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(n);case 12:w.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),e,this)})))}},{key:"track",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track"),t.next=3,this.trackBaseData(e);case 3:return(i=t.sent).pr=w.merge(i.pr,w.encode(r)),t.next=7,this.send(i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"identify",value:function(e,r){return v(this,void 0,void 0,t.mark((function n(){var i,o;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.storage.set("cuid",e),this.updateSession("identify"),i=new Date,(o={dt:"usr",pr:{$ct:i.getTime(),$tz:w.getTimezone(i),$cuid:e,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=w.merge(o.pr,w.encode(r)),t.next=7,this.trackBaseData("usr");case 7:return t.next=9,this.send(o);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e)),this.previousCountEvent.name===t&&w.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=w.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(e,r,n){return v(this,void 0,void 0,t.mark((function i(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.updateSession("track count"),o=Date.now()-this.countStartTime,n&&(o-=this.config.countDuration),u=this.count,this.count=n?0:1,t.next=7,this.trackBaseData(e);case 7:return a=t.sent,s={},w.isObject(r)&&(s=w.clone(r)),a.pr=w.merge(a.pr,w.encode(s),w.encode({count:u,countTime:o})),t.next=13,this.send(a);case 13:case"end":return t.stop()}}),i,this)})))}},{key:"trackRevenue",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),r.next=4,this.trackBaseData("revenue");case 4:(n=r.sent).dt="abp",(i=w.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},e)).total=o(i.price,i.productQuantity),u=["productID","revenueType"],a=["price","total","productQuantity"],s={},r.t0=t.keys(i);case 12:if((r.t1=r.t0()).done){r.next=21;break}if(c=r.t1.value,-1!==u.indexOf(c)||-1!==a.indexOf(c)){r.next=16;break}return r.abrupt("continue",12);case 16:f=i[c],a.indexOf(c)>-1&&((f=Number(f))||(f=0)),s["$"+c]=f,r.next=12;break;case 21:return n.pr=w.merge(n.pr,s),r.next=24,this.send(n);case 24:case"end":return r.stop()}}),r,this)})))}},{key:"setUtm",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null!==(n=w.filterUtm(e))&&(this.storage.set("utm",n),this.updateSession("setUtm"));case 2:case"end":return t.stop()}}),r,this)})))}},{key:"setSuperProperty",value:function(t){w.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){w.isObject(t)&&(this.config.superProperty=w.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=p(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}},{key:"flush",value:function(){this.request.clear()}}]),e}();d([k],S.prototype,"environmentInfo",null),d([k],S.prototype,"sessionEnd",null),d([k],S.prototype,"sessionStart",null),d([k],S.prototype,"updateSession",null),d([k],S.prototype,"click",null),d([k],S.prototype,"pv",null),d([k],S.prototype,"duration",null),d([k],S.prototype,"track",null),d([k],S.prototype,"identify",null),d([k],S.prototype,"trackCount",null),d([k],S.prototype,"trackRevenue",null),d([k],S.prototype,"setUtm",null);var P=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],O=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],D=function(t){return w.wxGetTitle(t)},$=function(t,e,r){return new Promise((function(n,i){var u;wx.request((o(u={url:t,data:e,method:"POST",timeout:null==r?void 0:r.timeout},"header",{"content-type":"application/x-www-form-urlencoded"}),o(u,"dataType","json"),o(u,"responseType","arraybuffer"),o(u,"success",(function(t){n(t)})),o(u,"fail",(function(t){i(t)})),u))}))},T={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data||""),wx.removeStorage({key:"zg-did"})},fail:function(e){t("")}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data||{})},fail:function(e){t({})}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},j=!1,E=wx.getSystemInfoSync(),C=E.system.split(/\s/),A={os:C[0],ov:C[1],version:E.version,windowHeight:E.windowHeight,windowWidth:E.windowWidth,net:0,mnet:0};function z(t){var e=t.toLowerCase();"wifi"===e?(A.net=1,A.mnet=0):(A.net=0,A.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function I(t){return new Promise((function(e,r){if(j)return e(A[t]);wx.getNetworkType({success:function(r){j=!0,z(r.networkType),e(A[t])}})}))}wx.onNetworkStatusChange((function(t){z(t.networkType)}));var L,q,R={os:function(){return A.os},ov:function(){return A.ov},version:function(){return A.version},net:function(){return I("net")},mnet:function(){return I("mnet")},windowWidth:function(){return A.windowWidth},windowHeight:function(){return A.windowHeight}},U=App,N=Page,F=Component,M=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function B(t,e,r){if(t[r]&&w.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function K(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(L===t||t&&L&&L.timeStamp===t.timeStamp)return n.apply(this,arguments);if(L=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var H=function(e){u(o,S);var n=f(o);function o(t){var e;return r(this,o),(e=n.call(this,$,T,R)).openData={path:"",props:{}},e.shared=!1,e.semiAutoTrackEventCatch={},e.isShareOperation=!1,q=t,e.initLifeCycleHook(),e}return i(o,[{key:"initLifeCycleHook",value:function(){var t,e=this,r=(t=e,{App:{onShow:function(e){t.sceneToUtm(e),t.openOptions=e,t.updateSession("appOnShow")},onHide:function(){t.flush(),t.config.duration&&!t.isShareOperation&&(t.pageReady=!0,t.currentPage.time=Date.now(),t.duration().then((function(){t.pageReady=!1,t.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(e){t.currentPage.query=w.parseQuery(e),t.currentPage.queryObj=e},onShow:function(){var e=getCurrentPages(),r=e[e.length-1];t.currentPage.route=r.__route__||r.route,t.currentPage.time=Date.now(),t.currentPage.url="".concat(t.currentPage.route);var n=D;if(t.currentPage.title="function"==typeof n?n(r):"",t.currentPage.query&&(t.currentPage.url+="?".concat(t.currentPage.query)),t.pageReady=!0,t.freeBuffer(),t.currentPage.url!==t.prevPage.url){""!==t.prevPage.url&&t.duration();try{t.trackOpenShare(t.openOptions)}catch(e){console.warn(e,"".concat(t.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}t.pv()}t.startObserveMarkElement(r),t.openOptions=null,t.isShareOperation=!1},onHide:function(){t.semiAutoTrackEventCatch={},t.prevPage=w.clone(t.currentPage),t.pageReady=!1,t.flush()},onUnload:function(){t.semiAutoTrackEventCatch={},t.prevPage=w.clone(t.currentPage),t.pageReady=!1,t.flush()}}});this.lifecycle=r;var n=function(t){for(var n in r.App)B(t,r.App,n);for(var i in t)!P.includes(i)&&w.isFunction(t[i])&&K(t,i,e);return U(t)};for(var i in App)n[i]=App[i];App=n;var o=function(t){for(var n in r.Page)B(t,r.Page,n);for(var i in t)!O.includes(i)&&w.isFunction(t[i])&&"onShareAppMessage"!==i&&K(t,i,e);var o=t.onShareAppMessage;return w.isFunction(o)&&(t.onShareAppMessage=e.onShareAppMessage(o)),N(t)};for(var u in Page)o[u]=Page[u];Page=o,Component=function(t){if(void 0!==t.methods)for(var r in t.methods)K(t.methods,r,e);return F(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=e}},{key:"load",value:function(t,e){return l(a(o.prototype),"load",this).call(this,t,e)}},{key:"pv",value:function(e){var r=this,n=Object.create(null,{pv:{get:function(){return l(a(o.prototype),"pv",r)}}});return v(this,void 0,void 0,t.mark((function e(){var r,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={},i=w.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(r.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(r.$share_level=Number(this.openOptions.query.zg_share_level)),i.data&&i.data.zg_share_data&&(r=w.merge(r,w.encode(i.data.zg_share_data)))),t.next=5,n.pv.call(this,r);case 5:case"end":return t.stop()}}),e,this)})))}},{key:"click",value:function(e,r){var n=this,i=Object.create(null,{click:{get:function(){return l(a(o.prototype),"click",n)}}});return v(this,void 0,void 0,t.mark((function n(){var o,u,a,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.target,u=o.dataset.title,a=o.dataset.index,s=[],s="alipay-miniprogram"===this.referrerDomain?["","",e.detail.pageX,e.detail.pageY]:["","",e.detail.x,e.detail.y],t.next=7,i.click.call(this,e,w.merge({$element_content:u||"",$element_selector:a||"",$element_style:s},r||{}));case 7:case"end":return t.stop()}}),n,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=w.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&q){var r=t.scene;this.cn=r+"";var n=q[r],i={},o=null,u=q.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};q.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=w.merge(i,e)}"fresh"===this.config.utmMode&&w.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(e){return v(this,void 0,void 0,t.mark((function r(){var n,i,o,u,a,s,c,f,l,h,p;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e&&this.config.forwardShare){t.next=2;break}return t.abrupt("return");case 2:if(!this.shared){t.next=5;break}return this.shared=!1,t.abrupt("return");case 5:if(n=e.query||{},i=this.currentPage.route,!(q.isCartShare(e.scene)&&n.zg_uid&&n.zg_share_id)){t.next=24;break}for(a in o={$uid:n.zg_uid,$share_id:n.zg_share_id,$title:this.currentPage.title,$path:i,$share_open_type:1008===e.scene?"群聊":"聊天",$share_level:Number(n.zg_share_level)},this.shareId=n.zg_share_id,this.shareLevel=Number(n.zg_share_level),u={},n)s=a.replace(/^zg_/,""),-1===M.indexOf(s)&&/^zg_/.test(a)&&(u[s]=n[a]);if(c=this.config.shareToUtm,w.isObject(c)&&!w.isEmpty(c)){for(l in f={},c)null!==u[l]&&void 0!==u[l]&&(h=c[l],f[h]=u[l]);w.isEmpty(w)||(f.utm_campaign||(f.utm_campaign="分享打开"),this.setUtm(f))}return this.openData={path:i,props:u},o=w.merge(o,w.encode(u)),t.next=19,this.trackBaseData("wxsopen");case 19:return(p=t.sent).dt="abp",p.pr=w.merge(p.pr,o),t.next=24,this.request.send(p);case 24:case"end":return t.stop()}}),r,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&w.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var h in o)-1===M.indexOf(h)&&(c["_".concat(h)]=f["zg_".concat(h)]=o[h]);return r.path=w.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=w.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=l(a(o.prototype),"track",e)).call.apply(r,[e].concat(h(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),o}();d([k],H.prototype,"sceneToUtm",null),d([k],H.prototype,"trackOpenShare",null);var G={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},W=new(function(t){u(n,H);var e=f(n);function n(){return r(this,n),e.call(this,G)}return i(n,[{key:"load",value:function(t,e){var r=e||{};if(wx.getAccountInfoSync){var i=wx.getAccountInfoSync();i&&i.miniProgram&&i.miniProgram.appId&&(r.appId=i.miniProgram.appId)}return l(a(n.prototype),"load",this).call(this,t,r)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var h=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function p(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function m(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},v=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},g=[m,l,p,h,d,v],y=Array.prototype.pop.call(arguments);"function"==typeof y&&g.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(g,this)}}]),n}());App.zhuge=W;export default W;
package/dist/zhuge.min.js CHANGED
@@ -13,4 +13,4 @@ var regeneratorRuntime=function(t){"use strict";var e,r=Object.prototype,n=r.has
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- function p(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function d(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,v,y,_={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(e){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function e(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==t(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(t){s.add(e(t,o))})),s):"Map"===a?(s=new Map,i.forEach((function(t,r){s.set(r,e(t,o))})),s):("Array"===a&&(s=new Array,u(i,(function(t,r){s[r]=e(t,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(t){s[t]=e(i[t],o)}))),s))};return a(e)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e,r,n,i="";t.data&&t.data.title&&t.data.title.length>0&&(i=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!i.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(e){e.pagePath==="".concat(t.route,".html")&&e.text&&(i=e.text)})),!i.length)){var o=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];i=o?null===(e=o.window)||void 0===e?void 0:e.navigationBarTitleText:null===(n=null===(r=null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.global)||void 0===r?void 0:r.window)||void 0===n?void 0:n.navigationBarTitleText}}catch(t){}return i||t.route}},w=function(){function t(r,n){e(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.requestTimeout=n.config.requestTimeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=r}return n(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0.7",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:_.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:l(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t,{timeout:this.requestTimeout})}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r,{timeout:e.requestTimeout}).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),b=function(){function t(r,n,i){e(this,t),this.storageFunction=r,this.allData=i||{},this.allData.did||this.set("did",n.config.did||_.UUID()),this.allData.cuid||this.set("cuid",void 0),_.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return n(t,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.allData[t]=e,r.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return r.stop()}}),r,this)})))}}]),t}();function x(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var k=function(){function t(r,n,i){e(this,t),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,v=r,g=n,y=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:6e4,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return n(t,[{key:"load",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.appKey=t,this.config=_.merge(this.config,e||{}),r.prev=2,r.next=5,g.get();case 5:if((n=r.sent)&&n.did){r.next=10;break}return r.next=9,g.getDid();case 9:n.did=r.sent;case 10:this.storage=new b(g,this,n),this.request=new w(v,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),r.next=20;break;case 17:r.prev=17,r.t0=r.catch(2),console.error("sdk初始化失败,缓存读取失败",r.t0);case 20:case"end":return r.stop()}}),r,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var e=this.buffer.shift();if(e)(t.prototype[e.fnName]||this[e.fnName]).apply(this,e.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Date,e.t0=t,e.t1=r.getTime(),e.t2=this.storage.allData.sid,e.t3=this.storage.allData.cuid,e.t4=this.cn,e.t5=_.getTimezone(r),e.t6=this.currentPage.url,e.t7=this.prevPage.url,e.t8=y.os(),e.t9=y.ov(),e.t10=y.version(),e.next=14,y.mnet();case 14:return e.t11=e.sent,e.next=17,y.net();case 17:return e.t12=e.sent,e.t13=this.config.vn,e.t14=this.referrerDomain,e.t15=this.config.appId,e.t16={$eid:e.t0,$ct:e.t1,$sid:e.t2,$cuid:e.t3,$cn:e.t4,$tz:e.t5,$url:e.t6,$ref:e.t7,$os:e.t8,$ov:e.t9,$wv:e.t10,$mnet:e.t11,$net:e.t12,$vn:e.t13,$referrer_domain:e.t14,$wxeid:e.t15},(n={dt:"evt",pr:e.t16}).pr=_.merge(n.pr,_.encode(this.config.superProperty)),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(y.windowWidth(),"x").concat(y.windowHeight()),$tz:_.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid}};this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:_.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r,n,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new Date,r=this.storage.allData,n=r.sid,i=r.cuid,t.t0=n,t.t1=n,t.t2=i,t.t3=this.cn,t.t4=_.getTimezone(e),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=y.os(),t.t8=y.ov(),t.t9=y.version(),t.next=14,y.mnet();case 14:return t.t10=t.sent,t.next=17,y.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},o={dt:"ss",pr:t.t15},this.send(o),this.environmentInfo();case 25:case"end":return t.stop()}}),t,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=_.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},e),t.next=10,this.send(r);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"pv",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.config.pv){e.next=2;break}return e.abrupt("return");case 2:return this.updateSession("pv"),e.next=5,this.trackBaseData("pv");case 5:return(r=e.sent).dt="abp",n={$page_title:this.currentPage.title},r.pr=_.merge(r.pr,n,t||{}),e.next=11,this.send(r);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"duration",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),_.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),e=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$dr:e,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(r);case 12:_.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),t,this)})))}},{key:"track",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.updateSession("track"),r.next=3,this.trackBaseData(t);case 3:return(n=r.sent).pr=_.merge(n.pr,_.encode(e)),r.next=7,this.send(n);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"identify",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n,i;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.storage.set("cuid",t),this.updateSession("identify"),n=new Date,(i={dt:"usr",pr:{$ct:n.getTime(),$tz:_.getTimezone(n),$cuid:t,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=_.merge(i.pr,_.encode(e)),r.next=7,this.trackBaseData("usr");case 7:return r.next=9,this.send(i);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e)),this.previousCountEvent.name===t&&_.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(t,e,r){return d(this,void 0,void 0,regeneratorRuntime.mark((function n(){var i,o,u,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this.updateSession("track count"),i=Date.now()-this.countStartTime,r&&(i-=this.config.countDuration),o=this.count,this.count=r?0:1,n.next=7,this.trackBaseData(t);case 7:return u=n.sent,a={},_.isObject(e)&&(a=_.clone(e)),u.pr=_.merge(u.pr,_.encode(a),_.encode({count:o,countTime:i})),n.next=13,this.send(u);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"trackRevenue",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),e.next=4,this.trackBaseData("revenue");case 4:(r=e.sent).dt="abp",(n=_.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},t)).total=i(n.price,n.productQuantity),o=["productID","revenueType"],u=["price","total","productQuantity"],a={},e.t0=regeneratorRuntime.keys(n);case 12:if((e.t1=e.t0()).done){e.next=21;break}if(s=e.t1.value,-1!==o.indexOf(s)||-1!==u.indexOf(s)){e.next=16;break}return e.abrupt("continue",12);case 16:c=n[s],u.indexOf(s)>-1&&((c=Number(c))||(c=0)),a["$"+s]=c,e.next=12;break;case 21:return r.pr=_.merge(r.pr,a),e.next=24,this.send(r);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"setUtm",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=_.filterUtm(t))&&(this.storage.set("utm",r),this.updateSession("setUtm"));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"setSuperProperty",value:function(t){_.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){_.isObject(t)&&(this.config.superProperty=_.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=m(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}},{key:"flush",value:function(){this.request.clear()}}]),t}();p([x],k.prototype,"environmentInfo",null),p([x],k.prototype,"sessionEnd",null),p([x],k.prototype,"sessionStart",null),p([x],k.prototype,"updateSession",null),p([x],k.prototype,"click",null),p([x],k.prototype,"pv",null),p([x],k.prototype,"duration",null),p([x],k.prototype,"track",null),p([x],k.prototype,"identify",null),p([x],k.prototype,"trackCount",null),p([x],k.prototype,"trackRevenue",null),p([x],k.prototype,"setUtm",null);var S=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],P=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],O=function(t){return _.wxGetTitle(t)},D=function(t,e,r){return new Promise((function(n,o){var u;wx.request((i(u={url:t,data:e,method:"POST",timeout:null==r?void 0:r.timeout},"header",{"content-type":"application/x-www-form-urlencoded"}),i(u,"dataType","json"),i(u,"responseType","arraybuffer"),i(u,"success",(function(t){n(t)})),i(u,"fail",(function(t){o(t)})),u))}))},T={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data||""),wx.removeStorage({key:"zg-did"})},fail:function(e){t("")}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data||{})},fail:function(e){t({})}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},$=!1,j=wx.getSystemInfoSync(),R=j.system.split(/\s/),E={os:R[0],ov:R[1],version:j.version,windowHeight:j.windowHeight,windowWidth:j.windowWidth,net:0,mnet:0};function C(t){var e=t.toLowerCase();"wifi"===e?(E.net=1,E.mnet=0):(E.net=0,E.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function z(t){return new Promise((function(e,r){if($)return e(E[t]);wx.getNetworkType({success:function(r){$=!0,C(r.networkType),e(E[t])}})}))}wx.onNetworkStatusChange((function(t){C(t.networkType)}));var A,I,L={os:function(){return E.os},ov:function(){return E.ov},version:function(){return E.version},net:function(){return z("net")},mnet:function(){return z("mnet")},windowWidth:function(){return E.windowWidth},windowHeight:function(){return E.windowHeight}},q=App,U=Page,N=Component,F=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function M(t,e,r){if(t[r]&&_.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function B(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(A===t||t&&A&&A.timeStamp===t.timeStamp)return n.apply(this,arguments);if(A=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var K=function(t){o(i,t);var r=c(i);function i(t){var n;return e(this,i),(n=r.call(this,D,T,L)).openData={path:"",props:{}},n.shared=!1,n.semiAutoTrackEventCatch={},n.isShareOperation=!1,I=t,n.initLifeCycleHook(),n}return n(i,[{key:"initLifeCycleHook",value:function(){var t,e=this,r=(t=e,{App:{onShow:function(e){t.sceneToUtm(e),t.openOptions=e,t.updateSession("appOnShow")},onHide:function(){t.flush(),t.config.duration&&!t.isShareOperation&&(t.pageReady=!0,t.currentPage.time=Date.now(),t.duration().then((function(){t.pageReady=!1,t.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(e){t.currentPage.query=_.parseQuery(e),t.currentPage.queryObj=e},onShow:function(){var e=getCurrentPages(),r=e[e.length-1];t.currentPage.route=r.__route__||r.route,t.currentPage.time=Date.now(),t.currentPage.url="".concat(t.currentPage.route);var n=O;if(t.currentPage.title="function"==typeof n?n(r):"",t.currentPage.query&&(t.currentPage.url+="?".concat(t.currentPage.query)),t.pageReady=!0,t.freeBuffer(),t.currentPage.url!==t.prevPage.url){""!==t.prevPage.url&&t.duration();try{t.trackOpenShare(t.openOptions)}catch(e){console.warn(e,"".concat(t.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}t.pv()}t.startObserveMarkElement(r),t.openOptions=null,t.isShareOperation=!1},onHide:function(){t.semiAutoTrackEventCatch={},t.prevPage=_.clone(t.currentPage),t.pageReady=!1,t.flush()},onUnload:function(){t.semiAutoTrackEventCatch={},t.prevPage=_.clone(t.currentPage),t.pageReady=!1,t.flush()}}});this.lifecycle=r;var n=function(t){for(var n in r.App)M(t,r.App,n);for(var i in t)!S.includes(i)&&_.isFunction(t[i])&&B(t,i,e);return q(t)};for(var i in App)n[i]=App[i];App=n;var o=function(t){for(var n in r.Page)M(t,r.Page,n);for(var i in t)!P.includes(i)&&_.isFunction(t[i])&&"onShareAppMessage"!==i&&B(t,i,e);var o=t.onShareAppMessage;return _.isFunction(o)&&(t.onShareAppMessage=e.onShareAppMessage(o)),U(t)};for(var u in Page)o[u]=Page[u];Page=o,Component=function(t){if(void 0!==t.methods)for(var r in t.methods)B(t.methods,r,e);return N(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=e}},{key:"load",value:function(t,e){return f(u(i.prototype),"load",this).call(this,t,e)}},{key:"pv",value:function(t){var e=this,r=Object.create(null,{pv:{get:function(){return f(u(i.prototype),"pv",e)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={},n=_.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(e.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(e.$share_level=Number(this.openOptions.query.zg_share_level)),n.data&&n.data.zg_share_data&&(e=_.merge(e,_.encode(n.data.zg_share_data)))),t.next=5,r.pv.call(this,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"click",value:function(t,e){var r=this,n=Object.create(null,{click:{get:function(){return f(u(i.prototype),"click",r)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,o,u,a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=t.target,o=i.dataset.title,u=i.dataset.index,a=[],a="alipay-miniprogram"===this.referrerDomain?["","",t.detail.pageX,t.detail.pageY]:["","",t.detail.x,t.detail.y],r.next=7,n.click.call(this,t,_.merge({$element_content:o||"",$element_selector:u||"",$element_style:a},e||{}));case 7:case"end":return r.stop()}}),r,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=_.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&I){var r=t.scene;this.cn=r+"";var n=I[r],i={},o=null,u=I.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};I.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=_.merge(i,e)}"fresh"===this.config.utmMode&&_.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c,f,l,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&this.config.forwardShare){e.next=2;break}return e.abrupt("return");case 2:if(!this.shared){e.next=5;break}return this.shared=!1,e.abrupt("return");case 5:if(r=t.query||{},n=this.currentPage.route,!(I.isCartShare(t.scene)&&r.zg_uid&&r.zg_share_id)){e.next=24;break}for(u in i={$uid:r.zg_uid,$share_id:r.zg_share_id,$title:this.currentPage.title,$path:n,$share_open_type:1008===t.scene?"群聊":"聊天",$share_level:Number(r.zg_share_level)},this.shareId=r.zg_share_id,this.shareLevel=Number(r.zg_share_level),o={},r)a=u.replace(/^zg_/,""),-1===F.indexOf(a)&&/^zg_/.test(u)&&(o[a]=r[u]);if(s=this.config.shareToUtm,_.isObject(s)&&!_.isEmpty(s)){for(f in c={},s)null!==o[f]&&void 0!==o[f]&&(l=s[f],c[l]=o[f]);_.isEmpty(_)||(c.utm_campaign||(c.utm_campaign="分享打开"),this.setUtm(c))}return this.openData={path:n,props:o},i=_.merge(i,_.encode(o)),e.next=19,this.trackBaseData("wxsopen");case 19:return(m=e.sent).dt="abp",m.pr=_.merge(m.pr,i),e.next=24,this.request.send(m);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&_.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var m in o)-1===F.indexOf(m)&&(c["_".concat(m)]=f["zg_".concat(m)]=o[m]);return r.path=_.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=_.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=f(u(i.prototype),"track",e)).call.apply(r,[e].concat(l(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),i}(k);p([x],K.prototype,"sceneToUtm",null),p([x],K.prototype,"trackOpenShare",null);var H={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},G=new(function(t){o(i,t);var r=c(i);function i(){return e(this,i),r.call(this,H)}return n(i,[{key:"load",value:function(t,e){var r=e||{};if(wx.getAccountInfoSync){var n=wx.getAccountInfoSync();n&&n.miniProgram&&n.miniProgram.appId&&(r.appId=n.miniProgram.appId)}return f(u(i.prototype),"load",this).call(this,t,r)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var m=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function h(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function p(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},g=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},v=[p,l,h,m,d,g],y=Array.prototype.pop.call(arguments);"function"==typeof y&&v.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(v,this)}}]),i}(K));return App.zhuge=G,G}));
16
+ function p(t,e,r,n){var i,o=arguments.length,u=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(e,r,u):i(e,r))||u);return o>3&&u&&Object.defineProperty(e,r,u),u}function d(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{s(n.next(t))}catch(t){o(t)}}function a(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}s((n=n.apply(t,e||[])).next())}))}var g,v,y,_={utmKeys:["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],isValid:function(t){return null==t},type:function(t){return Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===this.type(t)},isArray:function(t){return"[object Array]"===this.type(t)},isString:function(t){return"[object String]"===this.type(t)},isNumber:function(t){return"[object Number]"===this.type(t)},isDate:function(t){return"[object Date]"===this.type(t)},isFunction:function(t){return"[object Function]"===this.type(t)},isEmpty:function(t){return Array.isArray(t)||"string"==typeof t||t instanceof String?0===t.length:t instanceof Map||t instanceof Set?0===t.size:"[object Object]"===Object.prototype.toString.call(t)&&0===Object.keys(t).length},merge:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.reduce((function(e,r){return Object.keys(r).forEach((function(n){Array.isArray(e[n])&&Array.isArray(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):t.isObject(e[n])&&t.isObject(r[n])?e[n]=t.merge(e[n],r[n]):e[n]=r[n]})),e}),{})},UUID:function(){var t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},clone:function(e){var r=function(t){var e=t.constructor;switch(n(t)){case"Boolean":case"Number":case"String":case"Error":case"Date":return new e(t);case"RegExp":return o(t);case"Symbol":return i(t);case"Function":return t;default:return null}},n=function(t){return Object.prototype.toString.call(t).slice(8,-1)},i=function(t){return Object(Symbol.prototype.valueOf.call(t))},o=function(t){var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},u=function(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r);return t},a=function e(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!==t(i)||null===i)return i;var a=n(i),s=null;return o.get(i)?o.get(i):(o.set(i,s),"Set"!==a&&"Map"!==a&&"Array"!==a&&"Object"!==a?r(i):"Set"===a?(s=new Set,i.forEach((function(t){s.add(e(t,o))})),s):"Map"===a?(s=new Map,i.forEach((function(t,r){s.set(r,e(t,o))})),s):("Array"===a&&(s=new Array,u(i,(function(t,r){s[r]=e(t,o)}))),"Object"===a&&(s=new Object,u(Object.keys(i),(function(t){s[t]=e(i[t],o)}))),s))};return a(e)},parseQuery:function(t){if(this.isEmpty(t))return"";var e=[];for(var r in t)e.push("".concat(r,"=").concat(t[r]));return e.join("&")},getTimezone:function(t){return 6e4*-t.getTimezoneOffset()},encode:function(t){var e={};for(var r in t)e["_"+r]=t[r];return e},isEqual:function(t,e){if(this.type(t)!==this.type(e))return!1;var r=!0;for(var n in t)t[n]!==e[n]&&(r=!1);return r},getUtmByQuery:function(t){var e={};for(var r in t)this.utmKeys.includes(r)&&(e[r]=t[r]);return e},filterUtm:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],r=!1,n={};for(var i in t)e.indexOf(i)>-1&&(r=!0,n[i]=t[i]);return r?n:null},deleteQueryParams:function(t,e){var r=t.split("&"),n=[];return r.forEach((function(t){var r=new RegExp(e+"=.*"),i="";r.test(t)?(i=t.replace(r,""))&&n.push(i):n.push(t)})),n.join("&")},addUrlParam:function(t,e){var r=t,n="";for(var i in e)n&&(n+="&"),r=this.deleteQueryParams(r,i),n+=i+"="+e[i];var o=r.split("?");return o.length>1?o[1]?o[1]=n+"&"+o[1]:o[1]=n:1===o.length&&o.push(n),o.join("?")},getCurrentPage:function(){var t=getCurrentPages();return t[t.length-1]},wxGetTitle:function(t){var e,r,n,i="";t.data&&t.data.title&&t.data.title.length>0&&(i=Array.isArray(t.data.title)?t.data.title.join(" "):t.data.title);try{if(!i.length&&__wxConfig&&(__wxConfig.tabBar&&__wxConfig.tabBar.list.forEach((function(e){e.pagePath==="".concat(t.route,".html")&&e.text&&(i=e.text)})),!i.length)){var o=__wxConfig.page[t.route]||__wxConfig.page["".concat(t.route,".html")];i=o?null===(e=o.window)||void 0===e?void 0:e.navigationBarTitleText:null===(n=null===(r=null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.global)||void 0===r?void 0:r.window)||void 0===n?void 0:n.navigationBarTitleText}}catch(t){}return i||t.route}},w=function(){function t(r,n){e(this,t),this.timeout=500,this.catch=[],this.clearCatchTimer=null,this.url="".concat(n.config.serverUrl.normal,"/apipool"),this.timeout=n.config.timeout||this.timeout,this.requestTimeout=n.config.requestTimeout,this.debug=n.config.debug?1:0,this.appKey=n.appKey,this.did=n.storage.allData.did,this.sendLimit=n.config.sendLimit,this.requestFunction=r}return n(t,[{key:"generateRequestData",value:function(){var t=new Date,e={method:"web_event_sr.upload",event:JSON.stringify({sln:"itn",pl:"js",sdk:"sys",sdkv:"2.0.8",owner:"zg",ut:"".concat(t.getFullYear(),"-").concat(t.getMonth()+1,"-").concat(t.getDate()," ").concat(t.getHours(),":").concat(t.getMinutes(),":").concat(t.getSeconds()),tz:_.getTimezone(t),debug:this.debug?1:0,ak:this.appKey,usr:{did:this.did},data:l(this.catch)}),_:t.getTime()+""};return this.catch=[],e}},{key:"clear",value:function(){var t=this.generateRequestData();this.requestFunction(this.url,t,{timeout:this.requestTimeout})}},{key:"send",value:function(t){var e=this;if(this.catch.push(t),this.clearCatchTimer&&clearTimeout(this.clearCatchTimer),this.clearCatchTimer=setTimeout((function(){e.clear()}),3e4),!(this.catch.length<this.sendLimit)){this.clearCatchTimer&&clearTimeout(this.clearCatchTimer);var r=this.generateRequestData();return new Promise((function(t,n){var i,o=!1;i=setTimeout((function(){o=!0,t(null)}),e.timeout),e.requestFunction(e.url,r,{timeout:e.requestTimeout}).then((function(e){o||(clearTimeout(i),t(e))})).catch((function(t){n(t)}))}))}}}]),t}(),b=function(){function t(r,n,i){e(this,t),this.storageFunction=r,this.allData=i||{},this.allData.did||this.set("did",n.config.did||_.UUID()),this.allData.cuid||this.set("cuid",void 0),_.isEmpty(n.config.utm)||this.set("utm",n.config.utm)}return n(t,[{key:"get",value:function(t){return this.allData[t]}},{key:"set",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.allData[t]=e,r.next=3,this.storageFunction.set("zg",this.allData);case 3:case"end":return r.stop()}}),r,this)})))}}]),t}();function x(t,e,r){var n=r.value;return r.value=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.pageReady&&this.loadReady)return n.apply(this,r);this.buffer.push({fnName:e,args:r})},r}var k=function(){function t(r,n,i){e(this,t),this.buffer=[],this.currentPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""},this.cn="",this.previousCountEvent={name:"",props:{}},this.count=0,this.countTimer=null,this.pageReady=!1,this.loadReady=!1,v=r,g=n,y=i,this.referrerDomain="miniprogram",this.appKey="",this.config={serverUrl:{normal:"https://u.zhugeapi.net",bac:"https://ubak.zhugeio.com"},debug:!1,pv:!1,click:!1,timeout:18e5,requestTimeout:6e4,did:"",duration:!1,vn:"1.0",appId:"",sendLimit:1,superProperty:{},forwardShare:!1,beforeDuration:function(){},afterDuration:function(){},countDuration:3e3,parseScene:!0,utm:{},utmMode:"session",shareToUtm:{},exposure:!1}}return n(t,[{key:"load",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.appKey=t,this.config=_.merge(this.config,e||{}),r.prev=2,r.next=5,g.get();case 5:if((n=r.sent)&&n.did){r.next=10;break}return r.next=9,g.getDid();case 9:n.did=r.sent;case 10:this.storage=new b(g,this,n),this.request=new w(v,this),this.loadReady=!0,this.updateSession("load"),this.freeBuffer(),r.next=20;break;case 17:r.prev=17,r.t0=r.catch(2),console.error("sdk初始化失败,缓存读取失败",r.t0);case 20:case"end":return r.stop()}}),r,this,[[2,17]])})))}},{key:"freeBuffer",value:function(){if(this.loadReady&&this.pageReady)for(;this.buffer.length;){var e=this.buffer.shift();if(e)(t.prototype[e.fnName]||this[e.fnName]).apply(this,e.args)}}},{key:"send",value:function(t){var e=this.storage.allData.utm;if(e)for(var r in e)e[r]&&(t.pr["$".concat(r)]=e[r]);return this.request.send(t)}},{key:"trackBaseData",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Date,e.t0=t,e.t1=r.getTime(),e.t2=this.storage.allData.sid,e.t3=this.storage.allData.cuid,e.t4=this.cn,e.t5=_.getTimezone(r),e.t6=this.currentPage.url,e.t7=this.prevPage.url,e.t8=y.os(),e.t9=y.ov(),e.t10=y.version(),e.next=14,y.mnet();case 14:return e.t11=e.sent,e.next=17,y.net();case 17:return e.t12=e.sent,e.t13=this.config.vn,e.t14=this.referrerDomain,e.t15=this.config.appId,e.t16={$eid:e.t0,$ct:e.t1,$sid:e.t2,$cuid:e.t3,$cn:e.t4,$tz:e.t5,$url:e.t6,$ref:e.t7,$os:e.t8,$ov:e.t9,$wv:e.t10,$mnet:e.t11,$net:e.t12,$vn:e.t13,$referrer_domain:e.t14,$wxeid:e.t15},(n={dt:"evt",pr:e.t16}).pr=_.merge(n.pr,_.encode(this.config.superProperty)),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)})))}},{key:"environmentInfo",value:function(){var t=new Date,e={dt:"pl",pr:{$rs:"".concat(y.windowWidth(),"x").concat(y.windowHeight()),$tz:_.getTimezone(t),$ct:t.getTime(),$cuid:this.storage.allData.cuid,$sid:this.storage.allData.sid,$dv:void 0,$br:void 0}};if(wx.getDeviceInfo){var r=wx.getDeviceInfo();e.pr.$dv=r.model,e.pr.$br=r.brand}else delete e.pr.$dv,delete e.pr.$br;this.send(e)}},{key:"sessionEnd",value:function(t){var e=new Date,r=t.update-t.sid,n={dt:"se",pr:{$ct:t.update,$cn:this.cn,$tz:_.getTimezone(e),$dru:r,$sid:t.sid,$cuid:t.cuid,$referrer_domain:this.referrerDomain}};this.send(n)}},{key:"sessionStart",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r,n,i,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new Date,r=this.storage.allData,n=r.sid,i=r.cuid,t.t0=n,t.t1=n,t.t2=i,t.t3=this.cn,t.t4=_.getTimezone(e),t.t5=this.currentPage.url,t.t6=this.prevPage.url,t.t7=y.os(),t.t8=y.ov(),t.t9=y.version(),t.next=14,y.mnet();case 14:return t.t10=t.sent,t.next=17,y.net();case 17:t.t11=t.sent,t.t12=this.config.vn,t.t13=this.referrerDomain,t.t14=this.config.appId,t.t15={$ct:t.t0,$sid:t.t1,$cuid:t.t2,$cn:t.t3,$tz:t.t4,$url:t.t5,$ref:t.t6,$os:t.t7,$ov:t.t8,$wv:t.t9,$mnet:t.t10,$net:t.t11,$vn:t.t12,$referrer_domain:t.t13,$wxeid:t.t14},o={dt:"ss",pr:t.t15},this.send(o),this.environmentInfo();case 25:case"end":return t.stop()}}),t,this)})))}},{key:"updateSession",value:function(t){var e=this.storage.allData,r=Date.now();if(e.sid&&e.update)if(r-e.update>this.config.timeout){var n=_.clone(e);this.storage.set("sid",r),this.storage.set("update",r),this.sessionEnd(n),this.sessionStart()}else this.storage.set("update",r);else this.storage.set("sid",r),this.storage.set("update",r),this.sessionStart()}},{key:"click",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{$element_content:"",$element_selector:"",$element_style:[]};return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.click){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("click"),t.next=5,this.trackBaseData("click");case 5:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$page_url:this.currentPage.url,$page_title:this.currentPage.title},e),t.next=10,this.send(r);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"pv",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.config.pv){e.next=2;break}return e.abrupt("return");case 2:return this.updateSession("pv"),e.next=5,this.trackBaseData("pv");case 5:return(r=e.sent).dt="abp",n={$page_title:this.currentPage.title},r.pr=_.merge(r.pr,n,t||{}),e.next=11,this.send(r);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"duration",value:function(){return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.config.duration){t.next=2;break}return t.abrupt("return");case 2:return this.updateSession("duration"),_.isFunction(this.config.beforeDuration)&&this.config.beforeDuration(),e=this.currentPage.time-this.prevPage.time,t.next=7,this.trackBaseData("dr");case 7:return(r=t.sent).dt="abp",r.pr=_.merge(r.pr,{$dr:e,$url:this.prevPage.url,$title:this.prevPage.title}),t.next=12,this.send(r);case 12:_.isFunction(this.config.afterDuration)&&this.config.afterDuration();case 13:case"end":return t.stop()}}),t,this)})))}},{key:"track",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.updateSession("track"),r.next=3,this.trackBaseData(t);case 3:return(n=r.sent).pr=_.merge(n.pr,_.encode(e)),r.next=7,this.send(n);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"identify",value:function(t,e){return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var n,i;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this.storage.set("cuid",t),this.updateSession("identify"),n=new Date,(i={dt:"usr",pr:{$ct:n.getTime(),$tz:_.getTimezone(n),$cuid:t,$sid:this.storage.allData.sid,$url:this.currentPage.url}}).pr=_.merge(i.pr,_.encode(e)),r.next=7,this.trackBaseData("usr");case 7:return r.next=9,this.send(i);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"trackCount",value:function(t,e){var r=this;0===this.count&&(this.countStartTime=Date.now(),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e)),this.previousCountEvent.name===t&&_.isEqual(this.previousCountEvent.props,e)||(this.sendCountEvent(this.previousCountEvent.name,this.previousCountEvent.props,!1),this.previousCountEvent.name=t,this.previousCountEvent.props=_.clone(e),this.countStartTime=Date.now(),this.count=0),this.count+=1,this.countTimer&&clearTimeout(this.countTimer),this.countTimer=setTimeout((function(){r.sendCountEvent(t,e,!0)}),this.config.countDuration)}},{key:"sendCountEvent",value:function(t,e,r){return d(this,void 0,void 0,regeneratorRuntime.mark((function n(){var i,o,u,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this.updateSession("track count"),i=Date.now()-this.countStartTime,r&&(i-=this.config.countDuration),o=this.count,this.count=r?0:1,n.next=7,this.trackBaseData(t);case 7:return u=n.sent,a={},_.isObject(e)&&(a=_.clone(e)),u.pr=_.merge(u.pr,_.encode(a),_.encode({count:o,countTime:i})),n.next=13,this.send(u);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"trackRevenue",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=function(t,e){var r=0;try{t.toString().split(".")[1]&&(r+=t.toString().split(".")[1].length)}catch(t){console.error(t)}try{e.toString().split(".")[1]&&(r+=e.toString().split(".")[1].length)}catch(t){console.error(t)}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,r)},this.updateSession("track revenue"),e.next=4,this.trackBaseData("revenue");case 4:(r=e.sent).dt="abp",(n=_.merge({price:0,total:0,productID:null,productQuantity:0,revenueType:null},t)).total=i(n.price,n.productQuantity),o=["productID","revenueType"],u=["price","total","productQuantity"],a={},e.t0=regeneratorRuntime.keys(n);case 12:if((e.t1=e.t0()).done){e.next=21;break}if(s=e.t1.value,-1!==o.indexOf(s)||-1!==u.indexOf(s)){e.next=16;break}return e.abrupt("continue",12);case 16:c=n[s],u.indexOf(s)>-1&&((c=Number(c))||(c=0)),a["$"+s]=c,e.next=12;break;case 21:return r.pr=_.merge(r.pr,a),e.next=24,this.send(r);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"setUtm",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=_.filterUtm(t))&&(this.storage.set("utm",r),this.updateSession("setUtm"));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"setSuperProperty",value:function(t){_.isObject(t)&&(this.config.superProperty=t)}},{key:"extendSuperPropertys",value:function(t){_.isObject(t)&&(this.config.superProperty=_.merge(this.config.superProperty,t))}},{key:"removeSuperProperty",value:function(t){var e,r=function(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=m(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;delete this.config.superProperty[n]}}catch(t){r.e(t)}finally{r.f()}}},{key:"getSuperProperty",value:function(){return this.config.superProperty}},{key:"flush",value:function(){this.request.clear()}}]),t}();p([x],k.prototype,"environmentInfo",null),p([x],k.prototype,"sessionEnd",null),p([x],k.prototype,"sessionStart",null),p([x],k.prototype,"updateSession",null),p([x],k.prototype,"click",null),p([x],k.prototype,"pv",null),p([x],k.prototype,"duration",null),p([x],k.prototype,"track",null),p([x],k.prototype,"identify",null),p([x],k.prototype,"trackCount",null),p([x],k.prototype,"trackRevenue",null),p([x],k.prototype,"setUtm",null);var S=["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange","onShareAppMessage","onLogin"],P=["onLoad","onShow","onReady","onHide","onUnload","onShareAppMessage","onReachBottom","onPageScroll","onPullDownRefresh","onTabItemTap","onInit","onShareTimeline","onAddToFavorites","onResize","onTitleClick","onOptionMenuClick","onPullIntercept","onURLQueryChange"],O=function(t){return _.wxGetTitle(t)},D=function(t,e,r){return new Promise((function(n,o){var u;wx.request((i(u={url:t,data:e,method:"POST",timeout:null==r?void 0:r.timeout},"header",{"content-type":"application/x-www-form-urlencoded"}),i(u,"dataType","json"),i(u,"responseType","arraybuffer"),i(u,"success",(function(t){n(t)})),i(u,"fail",(function(t){o(t)})),u))}))},T={getDid:function(){return new Promise((function(t,e){wx.getStorage({key:"zg-did",success:function(e){t(e.data||""),wx.removeStorage({key:"zg-did"})},fail:function(e){t("")}})}))},get:function(){return new Promise((function(t,e){wx.getStorage({key:"zg",success:function(e){t(e.data||{})},fail:function(e){t({})}})}))},set:function(t,e){return new Promise((function(r,n){wx.setStorage({key:t,data:e,success:r,fail:n})}))}},$=!1,j=wx.getSystemInfoSync(),R=j.system.split(/\s/),E={os:R[0],ov:R[1],version:j.version,windowHeight:j.windowHeight,windowWidth:j.windowWidth,net:0,mnet:0};function C(t){var e=t.toLowerCase();"wifi"===e?(E.net=1,E.mnet=0):(E.net=0,E.mnet={"2g":1,"3g":3,"4g":13}[e]||0)}function z(t){return new Promise((function(e,r){if($)return e(E[t]);wx.getNetworkType({success:function(r){$=!0,C(r.networkType),e(E[t])}})}))}wx.onNetworkStatusChange((function(t){C(t.networkType)}));var A,I,L={os:function(){return E.os},ov:function(){return E.ov},version:function(){return E.version},net:function(){return z("net")},mnet:function(){return z("mnet")},windowWidth:function(){return E.windowWidth},windowHeight:function(){return E.windowHeight}},q=App,U=Page,N=Component,F=["eid","ct","tz","cuid","cn","sid","url","os","ov","wv","mnet","referrer_domain","net","vn","wxeid","uid","share_id","share_title","share_level","title","path"];function M(t,e,r){if(t[r]&&_.isFunction(t[r])){var n=t[r];t[r]=function(){n.apply(this,arguments),e[r].apply(this,arguments)}}else t[r]=function(){e[r].apply(this,arguments)}}function B(t,e,r){var n=t[e];t[e]=function(){var t=arguments[0];if(A===t||t&&A&&A.timeStamp===t.timeStamp)return n.apply(this,arguments);if(A=t,t){var e=t.type;"tap"===e&&r.click(t)}return n.apply(this,arguments)}}var K=function(t){o(i,t);var r=c(i);function i(t){var n;return e(this,i),(n=r.call(this,D,T,L)).openData={path:"",props:{}},n.shared=!1,n.semiAutoTrackEventCatch={},n.isShareOperation=!1,I=t,n.initLifeCycleHook(),n}return n(i,[{key:"initLifeCycleHook",value:function(){var t,e=this,r=(t=e,{App:{onShow:function(e){t.sceneToUtm(e),t.openOptions=e,t.updateSession("appOnShow")},onHide:function(){t.flush(),t.config.duration&&!t.isShareOperation&&(t.pageReady=!0,t.currentPage.time=Date.now(),t.duration().then((function(){t.pageReady=!1,t.prevPage={queryObj:{},query:"",route:"",time:0,url:"",title:""}})))}},Page:{onLoad:function(e){t.currentPage.query=_.parseQuery(e),t.currentPage.queryObj=e},onShow:function(){var e=getCurrentPages(),r=e[e.length-1];t.currentPage.route=r.__route__||r.route,t.currentPage.time=Date.now(),t.currentPage.url="".concat(t.currentPage.route);var n=O;if(t.currentPage.title="function"==typeof n?n(r):"",t.currentPage.query&&(t.currentPage.url+="?".concat(t.currentPage.query)),t.pageReady=!0,t.freeBuffer(),t.currentPage.url!==t.prevPage.url){""!==t.prevPage.url&&t.duration();try{t.trackOpenShare(t.openOptions)}catch(e){console.warn(e,"".concat(t.referrerDomain," ","zhuge"," sdk trackOpenShare error"))}t.pv()}t.startObserveMarkElement(r),t.openOptions=null,t.isShareOperation=!1},onHide:function(){t.semiAutoTrackEventCatch={},t.prevPage=_.clone(t.currentPage),t.pageReady=!1,t.flush()},onUnload:function(){t.semiAutoTrackEventCatch={},t.prevPage=_.clone(t.currentPage),t.pageReady=!1,t.flush()}}});this.lifecycle=r;var n=function(t){for(var n in r.App)M(t,r.App,n);for(var i in t)!S.includes(i)&&_.isFunction(t[i])&&B(t,i,e);return q(t)};for(var i in App)n[i]=App[i];App=n;var o=function(t){for(var n in r.Page)M(t,r.Page,n);for(var i in t)!P.includes(i)&&_.isFunction(t[i])&&"onShareAppMessage"!==i&&B(t,i,e);var o=t.onShareAppMessage;return _.isFunction(o)&&(t.onShareAppMessage=e.onShareAppMessage(o)),U(t)};for(var u in Page)o[u]=Page[u];Page=o,Component=function(t){if(void 0!==t.methods)for(var r in t.methods)B(t.methods,r,e);return N(t)},global.mpvue&&(global.App=App,global.Page=Page,global.Component=Component),App.zhuge=e}},{key:"load",value:function(t,e){return f(u(i.prototype),"load",this).call(this,t,e)}},{key:"pv",value:function(t){var e=this,r=Object.create(null,{pv:{get:function(){return f(u(i.prototype),"pv",e)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function t(){var e,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={},n=_.getCurrentPage(),this.config.forwardShare&&this.openOptions&&(e.$share_open_type=1008===this.openOptions.scene?"群聊":"聊天",this.openOptions.query&&this.openOptions.query.zg_share_level&&(e.$share_level=Number(this.openOptions.query.zg_share_level)),n.data&&n.data.zg_share_data&&(e=_.merge(e,_.encode(n.data.zg_share_data)))),t.next=5,r.pv.call(this,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"click",value:function(t,e){var r=this,n=Object.create(null,{click:{get:function(){return f(u(i.prototype),"click",r)}}});return d(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,o,u,a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=t.target,o=i.dataset.title,u=i.dataset.index,a=[],a="alipay-miniprogram"===this.referrerDomain?["","",t.detail.pageX,t.detail.pageY]:["","",t.detail.x,t.detail.y],r.next=7,n.click.call(this,t,_.merge({$element_content:o||"",$element_selector:u||"",$element_style:a},e||{}));case 7:case"end":return r.stop()}}),r,this)})))}},{key:"sceneToUtm",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=_.getUtmByQuery(t.query);if(this.config.parseScene&&t.scene&&I){var r=t.scene;this.cn=r+"";var n=I[r],i={},o=null,u=I.isShare(r);if(u&&t.referrerInfo&&(o=t.referrerInfo.appId),n){i={utm_source:n.utm_source,utm_medium:n.utm_medium,utm_campaign:o};var a=t.query||{};I.isCartShare(r)&&a.zg_uid&&a.zg_share_id&&(i.utm_term=a.zg_uid,i.utm_content=a.zg_share_id)}e=_.merge(i,e)}"fresh"===this.config.utmMode&&_.isEmpty(this.config.utm)&&this.storage.set("utm",e)}},{key:"trackOpenShare",value:function(t){return d(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,n,i,o,u,a,s,c,f,l,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&this.config.forwardShare){e.next=2;break}return e.abrupt("return");case 2:if(!this.shared){e.next=5;break}return this.shared=!1,e.abrupt("return");case 5:if(r=t.query||{},n=this.currentPage.route,!(I.isCartShare(t.scene)&&r.zg_uid&&r.zg_share_id)){e.next=24;break}for(u in i={$uid:r.zg_uid,$share_id:r.zg_share_id,$title:this.currentPage.title,$path:n,$share_open_type:1008===t.scene?"群聊":"聊天",$share_level:Number(r.zg_share_level)},this.shareId=r.zg_share_id,this.shareLevel=Number(r.zg_share_level),o={},r)a=u.replace(/^zg_/,""),-1===F.indexOf(a)&&/^zg_/.test(u)&&(o[a]=r[u]);if(s=this.config.shareToUtm,_.isObject(s)&&!_.isEmpty(s)){for(f in c={},s)null!==o[f]&&void 0!==o[f]&&(l=s[f],c[l]=o[f]);_.isEmpty(_)||(c.utm_campaign||(c.utm_campaign="分享打开"),this.setUtm(c))}return this.openData={path:n,props:o},i=_.merge(i,_.encode(o)),e.next=19,this.trackBaseData("wxsopen");case 19:return(m=e.sent).dt="abp",m.pr=_.merge(m.pr,i),e.next=24,this.request.send(m);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"onShareAppMessage",value:function(t){var e=this;return function(){e.isShareOperation=!0;var r=t.apply(this,arguments)||{};if(!e.config.forwardShare)return r;r.path=r.path||e.currentPage.url;var n=r.title||e.currentPage.title,i=r.path.split("?")[0],o=this.data.zg_share_data,u=(new Date).getTime(),a=1;!this.data.newShare&&e.openData&&e.openData.path===i&&_.isEqual(o||{},e.openData.props)&&(u=e.shareId,a=e.shareLevel+1);var s={share_id:u,uid:e.storage.allData.cuid||e.storage.allData.did,share_level:a},c={$share_title:n,$title:e.currentPage.title||"",$path:i},f={};for(var l in s)c["$".concat(l)]=f["zg_".concat(l)]=s[l];for(var m in o)-1===F.indexOf(m)&&(c["_".concat(m)]=f["zg_".concat(m)]=o[m]);return r.path=_.addUrlParam(r.path,f),e.trackBaseData("wxshare").then((function(t){t.dt="abp",t.pr=_.merge(t.pr,c),e.request.send(t)})),e.shared=!0,r}}},{key:"startObserveMarkElement",value:function(t){var e=this;this.config.exposure&&(this.elementObserver&&this.elementObserver.disconnect(),t.isComponent?this.elementObserver=t.createIntersectionObserver({observeAll:!0}):this.elementObserver=wx.createIntersectionObserver(t,{observeAll:!0}),this.elementObserver.relativeToViewport().observe(".zhuge-expo-track",(function(t){if(t.intersectionRatio>0){var r,n=e.getEventDataFromDataset(t.dataset);(r=f(u(i.prototype),"track",e)).call.apply(r,[e].concat(l(n)))}})))}},{key:"getEventDataFromDataset",value:function(t){var e={},r="";for(var n in t){if(n.startsWith("expo"))if("expoName"===n)r=t[n];else e[n.replace(/^expo(.*)/,(function(t,e,r,n){return e.replace(e[0],e[0].toLocaleLowerCase())}))]=t[n]}return[r,e]}}]),i}(k);p([x],K.prototype,"sceneToUtm",null),p([x],K.prototype,"trackOpenShare",null);var H={1001:{utm_source:"微信主程序",utm_medium:"发现栏小程序主入口"},1005:{utm_source:"搜索",utm_medium:"顶部搜索框的搜索结果页"},1006:{utm_source:"搜索",utm_medium:"发现栏小程序主入口搜索框的搜索结果页"},1007:{utm_source:"分享",utm_medium:"单人聊天会话中的小程序消息卡片"},1008:{utm_source:"分享",utm_medium:"群聊会话中的小程序消息卡片"},1011:{utm_source:"扫码",utm_medium:"扫描二维码"},1012:{utm_source:"扫码",utm_medium:"长按图片识别二维码"},1013:{utm_source:"扫码",utm_medium:"手机相册选取二维码"},1014:{utm_source:"小程序模板消息",utm_medium:"小程序模板消息"},1017:{utm_source:"体验版",utm_medium:"前往体验版的入口页"},1019:{utm_source:"微信支付",utm_medium:"微信钱包"},1020:{utm_source:"公众号",utm_medium:"公众号profile页相关小程序列表"},1022:{utm_source:"微信主程序",utm_medium:"聊天顶部置顶小程序入口"},1023:{utm_source:"桌面图标",utm_medium:"安卓系统桌面图标"},1024:{utm_source:"微信主程序",utm_medium:"小程序 profile 页"},1025:{utm_source:"扫码",utm_medium:"扫描一维码"},1026:{utm_source:"微信主程序",utm_medium:"附近小程序列表"},1027:{utm_source:"搜索",utm_medium:"顶部搜索框搜索结果页“使用过的小程序”列表"},1028:{utm_source:"微信卡券",utm_medium:"我的卡包"},1029:{utm_source:"微信卡券",utm_medium:"卡券详情页"},1030:{utm_source:"测试",utm_medium:"自动化测试下打开小程序"},1031:{utm_source:"扫码",utm_medium:"长按图片识别一维码"},1032:{utm_source:"扫码",utm_medium:"手机相册选取一维码"},1034:{utm_source:"微信支付",utm_medium:"微信支付完成页"},1035:{utm_source:"公众号",utm_medium:"公众号自定义菜单"},1036:{utm_source:"分享",utm_medium:"App分享消息卡片"},1037:{utm_source:"小程序",utm_medium:"小程序打开小程序"},1038:{utm_source:"小程序",utm_medium:"从另一个小程序返回"},1039:{utm_source:"摇电视",utm_medium:"摇电视"},1042:{utm_source:"搜索",utm_medium:"添加好友搜索框的搜索结果页"},1043:{utm_source:"公众号",utm_medium:"公众号模板消息"},1044:{utm_source:"分享",utm_medium:"带shareTicket的小程序消息卡片(详情)"},1045:{utm_source:"广告",utm_medium:"朋友圈广告"},1046:{utm_source:"广告",utm_medium:"朋友圈广告详情页"},1047:{utm_source:"扫码",utm_medium:"扫描小程序码"},1048:{utm_source:"扫码",utm_medium:"长按图片识别小程序码"},1049:{utm_source:"扫码",utm_medium:"手机相册选取小程序码"},1052:{utm_source:"微信卡券",utm_medium:"卡券的适用门店列表"},1053:{utm_source:"搜索",utm_medium:"搜一搜的结果页"},1054:{utm_source:"搜索",utm_medium:"顶部搜索框小程序快捷入口"},1056:{utm_source:"音乐播放器菜单",utm_medium:"音乐播放器菜单"},1057:{utm_source:"微信支付",utm_medium:"钱包中的银行卡详情页"},1058:{utm_source:"公众号",utm_medium:"公众号文章"},1059:{utm_source:"体验版",utm_medium:"体验版小程序绑定邀请页"},1064:{utm_source:"微信WIFI",utm_medium:"微信连Wi-Fi状态栏"},1067:{utm_source:"广告",utm_medium:"公众号文章广告"},1068:{utm_source:"广告",utm_medium:"附近小程序列表广告"},1069:{utm_source:"移动应用",utm_medium:"移动应用"},1071:{utm_source:"微信支付",utm_medium:"钱包中的银行卡列表页"},1072:{utm_source:"微信支付",utm_medium:"二维码收款页面"},1073:{utm_source:"客服消息",utm_medium:"客服消息列表下发的小程序消息卡片"},1074:{utm_source:"公众号会话",utm_medium:"公众号会话下发的小程序消息卡片"},1077:{utm_source:"摇周边",utm_medium:"摇周边"},1078:{utm_source:"微信WIFI",utm_medium:"连Wi-Fi成功页"},1079:{utm_source:"微信游戏中心",utm_medium:"微信游戏中心"},1081:{utm_source:"客服消息",utm_medium:"客服消息下发的文字链"},1082:{utm_source:"公众号",utm_medium:"公众号会话下发的文字链"},1084:{utm_source:"广告",utm_medium:"朋友圈广告原生页"},1089:{utm_source:"微信主程序",utm_medium:"微信聊天主界面下拉"},1090:{utm_source:"小程序",utm_medium:"长按小程序右上角菜单唤出最近使用历史"},1091:{utm_source:"公众号",utm_medium:"公众号文章商品卡片"},1092:{utm_source:"微信城市服务",utm_medium:"城市服务入口"},1095:{utm_source:"广告",utm_medium:"小程序广告组件"},1096:{utm_source:"分享",utm_medium:"聊天记录"},1097:{utm_source:"微信支付",utm_medium:"微信支付签约页"},1099:{utm_source:"小程序",utm_medium:"页面内嵌插件"},1102:{utm_source:"公众号",utm_medium:"公众号profile页服务预览"},1129:{utm_source:"爬虫",utm_medium:"微信爬虫"},isShare:function(t){return[1020,1035,1036,1037,1038,1043].includes(t)},isCartShare:function(t){return[1044,1007,1008,1036].includes(t)}},G=new(function(t){o(i,t);var r=c(i);function i(){return e(this,i),r.call(this,H)}return n(i,[{key:"load",value:function(t,e){var r=e||{};if(wx.getAccountInfoSync){var n=wx.getAccountInfoSync();n&&n.miniProgram&&n.miniProgram.appId&&(r.appId=n.miniProgram.appId)}return f(u(i.prototype),"load",this).call(this,t,r)}},{key:"weixinIdentify",value:function(){var t=this,e=this.config.appId;arguments[0]&&"string"==typeof arguments[0]&&(e=arguments[0]);var r,n=this.config.serverUrl.normal,i="",o="",u="",a="",s="",c="";function f(t,e,r){if(!(r&&t.length<=r)){var n=r||0;t[n].call(e,(function(){f(t,e,n+1)}))}}function l(t){wx.login({success:function(e){i=e.code,t&&t()},fail:function(t){console.error("诸葛SDK提示:","登录失败",t)}})}var m=function(r){var s=t,c={url:n+"/zgwx/user/code2session",method:"GET",data:{code:i,appId:e},success:function(t){o=t.data.openid,u=t.data.unionid,a=t.data.session_key,r&&r()},fail:function(t){n!==s.config.serverUrl.bac?(c.url=s.config.serverUrl.bac+"/zgwx/user/code2session",wx.request(c)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(c)};function h(t){wx.getSetting({success:function(e){e.authSetting["scope.userInfo"]?wx.getUserInfo({lang:"zh_CN",success:function(e){r=e.userInfo,s=e.iv,c=e.encryptedData,t&&t()}}):console.error("诸葛SDK提示:","未授权",e)}})}function p(t){wx.getUserProfile?wx.getUserProfile({desc:arguments[0]||"用于完善会员资料",lang:"zh_CN",success:function(e){r=e.userInfo,t&&t()},fail:function(e){console.error("userProfile错误",e),t&&t()}}):t&&t()}var d=function(e){var r=t,i={url:n+"/zgwx/data/decrypt",method:"POST",data:{sessionKey:a,iv:s,encryptData:c},success:function(t){u=t.data.unionId,e&&e(t.data||{})},fail:function(t){n!==r.config.serverUrl.bac?(i.url=r.config.serverUrl.bac+"/zgwx/data/decrypt",wx.request(i)):console.error("诸葛SDK提示:","获取codeSession失败",t)}};wx.request(i)},g=function(e){var n="";switch(r.gender){case 1:n="男";break;case 2:n="女"}t.identify(u||o,{name:r.nickName,avatar:r.avatarUrl,"微信-昵称":r.nickName,"微信-性别":n,"微信-城市":r.city,"微信-省":r.province,"微信-国家":r.country}),e&&e()},v=[p,l,h,m,d,g],y=Array.prototype.pop.call(arguments);"function"==typeof y&&v.push((function(){y({userInfo:r,unionid:u,openid:o,sessionKey:a})})),f(v,this)}}]),i}(K));return App.zhuge=G,G}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zg-sdk-wechart",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "诸葛智能微信小程序sdk",
5
5
  "main": "./dist/zhuge.min.js",
6
6
  "module": "./dist/zhuge.es.min.js",
@@ -13,5 +13,5 @@
13
13
  "keywords": [],
14
14
  "author": "",
15
15
  "license": "ISC",
16
- "gitHead": "99a4c7af23d9734afbd639044ce02fbf08d4f10f"
16
+ "gitHead": "7962610d593bc61b5d0cd2693d95b38e0967d747"
17
17
  }