diff --git a/app.js b/app.js index dc892fe..e94d28d 100644 --- a/app.js +++ b/app.js @@ -1,36 +1,42 @@ //app.js wx9c68fbf7886ea9c4 租房的 wxcf0a799771cf2ae6 港校的 var initial_url = 'https://app.gter.net/tenement'; var __ = require('./utils/miucms.js'); +import './utils/xstat'; -// 保存原始的Page构造器 -const originPage = Page; +// // 保存原始的Page构造器 +// const originPage = Page; -// 重写Page构造器 -Page = function (pageConfig) { - // 添加全局的onShow逻辑 - const originOnLoad = pageConfig.onLoad; - pageConfig.onLoad = function () { - __.statistics({}) - if (originOnLoad) originOnLoad.apply(this, arguments); - }; +// // 重写Page构造器 +// Page = function (pageConfig) { +// // 添加全局的onShow逻辑 +// const originOnLoad = pageConfig.onLoad; +// pageConfig.onLoad = function () { +// __.statistics({}) +// if (originOnLoad) originOnLoad.apply(this, arguments); +// }; - const originOnShare = pageConfig.onShareAppMessage; - if (originOnShare) { - // pageConfig.onShareAppMessage = function () { - pageConfig.onShareAppMessage = function (e) { - __.statistics({ - name: "share" - }) - // if (originOnShare) originOnShare.apply(this, arguments); - return originOnShare.apply(this, [e]); - }; - } +// const originOnShare = pageConfig.onShareAppMessage; +// if (originOnShare) { +// // pageConfig.onShareAppMessage = function () { +// pageConfig.onShareAppMessage = function (e) { +// __.statistics({ +// name: "share" +// }) +// // if (originOnShare) originOnShare.apply(this, arguments); +// return originOnShare.apply(this, [e]); +// }; +// } - // 调用原始的Page函数 - return originPage(pageConfig); -}; +// // 调用原始的Page函数 +// return originPage(pageConfig); +// }; App({ + xstatConfig: { + appKey: wx.getAccountInfoSync().miniProgram.appId, // 自动获取 小程序appid + debug: true, //是否打开调试模式 + LOG_URL: 'https://stat.gter.net/send', // 上报地址 + }, randomString(n) { let str = 'abcdefghijklmnopqrstuvwxyz9876543210'; let tmp = '', @@ -94,14 +100,14 @@ App({ }) }, onLaunch: function (options) { - __.statistics({ - data: { - scene: options.scene - }, - path: options.path, - query: options.query, - name: "onLaunch" - }) + // __.statistics({ + // data: { + // scene: options.scene + // }, + // path: options.path, + // query: options.query, + // name: "onLaunch" + // }) this.globalData.options = options; diff --git a/mapFind/pages/placeMap/index.js b/mapFind/pages/placeMap/index.js index 10f0342..8335036 100644 --- a/mapFind/pages/placeMap/index.js +++ b/mapFind/pages/placeMap/index.js @@ -882,8 +882,5 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) }, }) \ No newline at end of file diff --git a/pages/ad/ad.js b/pages/ad/ad.js index ae285f1..1c8d9f0 100644 --- a/pages/ad/ad.js +++ b/pages/ad/ad.js @@ -41,9 +41,6 @@ Page({ } }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) }, get_config() { var that = this; diff --git a/pages/agentList/agentList.js b/pages/agentList/agentList.js index 34c69e3..d26938d 100644 --- a/pages/agentList/agentList.js +++ b/pages/agentList/agentList.js @@ -402,9 +402,6 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) let res = this.getTitle() return { path: res.path, diff --git a/pages/brandApartmentDetail/brandApartmentDetail.js b/pages/brandApartmentDetail/brandApartmentDetail.js index 5790925..c32348d 100644 --- a/pages/brandApartmentDetail/brandApartmentDetail.js +++ b/pages/brandApartmentDetail/brandApartmentDetail.js @@ -98,6 +98,15 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { + if (options.q) { + let decodedUrl = options.q; + while (decodedUrl !== decodeURIComponent(decodedUrl)) { + decodedUrl = decodeURIComponent(decodedUrl); + } + options.q = decodedUrl + } + + console.log("options.q", options.q); wx.getSystemInfo({ success: function (res) { windowWidth = res.windowWidth @@ -165,13 +174,15 @@ Page({ // 来自页面内转发按钮 if (res.from === 'button') var types = res.from === 'button' ? 'share_btn' : 'show'; - let that = this; - var title = that.data.data.title; - if (that.data.data.isquarantine) title = this.data.listTab.quarantineLists + '-' + that.data.data.title + // let that = this; + // var title = that.data.data.title; + // if (that.data.data.isquarantine) title = this.data.listTab.quarantineLists + '-' + that.data.data.title + + let title = `中国香港 > ${ this.data.data.address }` return { - title: title, - imageUrl: that.data.data.thumbnail, + title, + // imageUrl: that.data.data.thumbnail, success: function (res) { miucms.share(app, types) }, @@ -179,19 +190,19 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) - let that = this; - var title = that.data.data.title; - if (that.data.data.isquarantine) title = this.data.listTab.quarantineLists + '-' + that.data.data.title + // let that = this; + // var title = that.data.data.title; + // if (that.data.data.isquarantine) title = this.data.listTab.quarantineLists + '-' + that.data.data.title + let title = `中国香港 > ${ this.data.data.address }` + return { - title: title, - imageUrl: that.data.data.thumbnail, + title, + // imageUrl: that.data.data.thumbnail, } }, get_content: function () { + console.log("get_content"); let that = this; var sendData = Object.assign({}, this.data.options, { session: wx.getStorageSync('session'), @@ -200,6 +211,8 @@ Page({ // source: that.data.source, // q: that.data.q }) + + console.log("sendData", sendData); let url = `${app.globalData.baseURL}/tenement/v2/api/apartment/details` // url = app.globalData.config.studentapartment.details miucms.wxget(url, sendData).then(data => { @@ -209,13 +222,7 @@ Page({ title: '提示', content: data.message, success(res) { - wx.navigateBack({ - fail: function () { - wx.navigateTo({ - url: '/pages/index/index', - }) - } - }) + this.backOrIndex() } }) } else { @@ -296,21 +303,19 @@ Page({ } }).catch(res => { wx.hideLoading() + that.setData({ + isloding: false, + }) wx.showModal({ title: '提示', - content: '抱歉,网络出错。请稍后重试~', + content: res.message || '抱歉,网络出错。请稍后重试~', success(res) { - wx.navigateBack({ - fail: function () { - wx.navigateTo({ - url: '/pages/index/index', - }) - } - }) + miucms.backOrIndex() } }) }) }, + getList() { let that = this; var sendData = Object.assign({}, this.data.options, { @@ -337,7 +342,7 @@ Page({ }) wx.showModal({ title: '提示', - content: '抱歉,网络出错。请稍后重试~', + content: res.message || '抱歉,网络出错。请稍后重试~', }) }) }, diff --git a/pages/brandApartmentDetail/brandApartmentDetail.wxml b/pages/brandApartmentDetail/brandApartmentDetail.wxml index 081b5ff..a1537ff 100644 --- a/pages/brandApartmentDetail/brandApartmentDetail.wxml +++ b/pages/brandApartmentDetail/brandApartmentDetail.wxml @@ -135,10 +135,10 @@ - + + {{ data.collectnum == 0 ? '收藏' : data.collectnum }} diff --git a/pages/brandApartmentDetail/brandApartmentDetail.wxss b/pages/brandApartmentDetail/brandApartmentDetail.wxss index 0245930..b65dc3c 100644 --- a/pages/brandApartmentDetail/brandApartmentDetail.wxss +++ b/pages/brandApartmentDetail/brandApartmentDetail.wxss @@ -1245,7 +1245,23 @@ map .clickmap { height: 45rpx; } -.bottom-bar .bottom-bar-share .bottom-bar-icon { +.bottom-bar .bottom-bar-icon { width: 39rpx; height: 39rpx; +} + +.bottom-bar .bottom-bar-share { + line-height: 1; + margin: 0; + border: none; + outline: none; + padding: 0; + overflow: auto; + border-radius: revert; + background: #fff; +} + +.bottom-bar .bottom-bar-share::after { + border: none; + height: 0; } \ No newline at end of file diff --git a/pages/brandApartmentList/brandApartmentList.js b/pages/brandApartmentList/brandApartmentList.js index 57a1b4b..a3558d4 100644 --- a/pages/brandApartmentList/brandApartmentList.js +++ b/pages/brandApartmentList/brandApartmentList.js @@ -69,6 +69,7 @@ Page({ QRCodePopState: false, // 二维码弹窗状态 popwindow: {}, // 弹窗信息 popwindowBtnState: true, // 弹窗按钮状态 + scrollView: "", }, @@ -123,6 +124,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { + console.log("options", options); wx.showLoading() // 获取全局筛选的值 let brandSelectionObj = app.globalData.brandSelectionObj @@ -308,9 +310,6 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) let res = this.getTitle() return { title: res.title, @@ -380,8 +379,14 @@ Page({ wx.nextTick(() => { let index = this.data.school || 0 if (index == 0) return + + this.setData({ + scrollView: `item${ index }` + }) + return wx.createSelectorQuery().select('#annex-school').boundingClientRect((parentRect) => { wx.createSelectorQuery().select(`.annex-school-item.item${index}`).boundingClientRect((childRect) => { + console.log("childRect", childRect); const distance = childRect.left - parentRect.left - parentRect.width + childRect.width + 10 if (distance <= 0) return this.setData({ diff --git a/pages/brandApartmentList/brandApartmentList.wxml b/pages/brandApartmentList/brandApartmentList.wxml index c521021..c03a3a0 100644 --- a/pages/brandApartmentList/brandApartmentList.wxml +++ b/pages/brandApartmentList/brandApartmentList.wxml @@ -8,8 +8,7 @@ {{ miniProgram == 'xg' ? '寄托香港租房' : '寄托港校租房' }} - + @@ -25,21 +24,16 @@ 学校附近 - - 不限 - - {{ item.name }} + + 不限 + + {{ item.name }} + - - + + @@ -48,14 +42,12 @@ - + - 求公寓?来找{{ contact.nickname }}! + 求公寓?来找{{ contact.nickname }}! 马上联系 @@ -86,8 +78,7 @@ 欢迎联系{{ wechat.nickname }}咨询房源 - + 长按二维码添加好友 @@ -99,7 +90,6 @@ - + \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 0ab078b..813fa17 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -152,9 +152,6 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) return { title: this.data.topTitle } @@ -223,12 +220,12 @@ Page({ const type = combination[value]?.field - miucms.statistics({ - name: "combination", - data: { - type - } - }) + // miucms.statistics({ + // name: "combination", + // data: { + // type + // } + // }) }, // 公共跳转 @@ -452,12 +449,12 @@ Page({ this.dataCount = 0 this.getListData() - miucms.statistics({ - name: 'recommendedTab', - data: { - type - } - }) + // miucms.statistics({ + // name: 'recommendedTab', + // data: { + // type + // } + // }) }, @@ -749,9 +746,9 @@ Page({ this.openPopwindow() - miucms.statistics({ - name: "popwindow" - }) + // miucms.statistics({ + // name: "popwindow" + // }) }, // 打开弹窗 diff --git a/pages/intermediaryList/intermediaryList.js b/pages/intermediaryList/intermediaryList.js index ad0b28c..f2c1fdd 100644 --- a/pages/intermediaryList/intermediaryList.js +++ b/pages/intermediaryList/intermediaryList.js @@ -77,9 +77,4 @@ Page({ onShareAppMessage() { }, - // onShareTimeline() { - // miucms.statistics({ - // name: "share-timeline" - // }) - // }, }) \ No newline at end of file diff --git a/pages/irentPark/irentPark.js b/pages/irentPark/irentPark.js index d4d503b..d2da9ad 100644 --- a/pages/irentPark/irentPark.js +++ b/pages/irentPark/irentPark.js @@ -119,9 +119,7 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) + }, get_content(){ let that = this; diff --git a/pages/needHousing/needHousing.js b/pages/needHousing/needHousing.js index ec705e7..6d3ea2b 100644 --- a/pages/needHousing/needHousing.js +++ b/pages/needHousing/needHousing.js @@ -312,9 +312,6 @@ Page({ } }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) const res = this.getTitle() return { path: res.path, diff --git a/pages/needHousing/needHousing.wxml b/pages/needHousing/needHousing.wxml index 60f9f67..92696cf 100644 --- a/pages/needHousing/needHousing.wxml +++ b/pages/needHousing/needHousing.wxml @@ -1,12 +1,10 @@ - 求房源 + 求房源 - - + + @@ -14,16 +12,9 @@ - - - + + + @@ -31,8 +22,7 @@ - {{ item['keyword'] }} + {{ item['keyword'] }} @@ -84,6 +74,5 @@ - + \ No newline at end of file diff --git a/pages/personList/personList.js b/pages/personList/personList.js index e67313e..e1158b5 100644 --- a/pages/personList/personList.js +++ b/pages/personList/personList.js @@ -452,9 +452,6 @@ Page({ }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) const res = this.getTitle() return { path: res.path, diff --git a/pages/report/report.js b/pages/report/report.js index b6a106f..6e38e7c 100644 --- a/pages/report/report.js +++ b/pages/report/report.js @@ -102,7 +102,7 @@ Page({ }) wx.showModal({ title: '提示', - content: '抱歉,网络出错。请稍后重试~', + content: res.message || '抱歉,网络出错。请稍后重试~', }) }) diff --git a/pages/search/search.js b/pages/search/search.js index 64343b2..76c10dc 100644 --- a/pages/search/search.js +++ b/pages/search/search.js @@ -298,9 +298,6 @@ Page({ } }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) let url = `/pages/search/search?kw=${this.data.kw}&tab=${this.data.tab}`; return { path: url, @@ -446,12 +443,12 @@ Page({ this.setTabData() this.searchKW() - miucms.statistics({ - name: "search", - data: { - kw: this.data.kw, - } - }) + // miucms.statistics({ + // name: "search", + // data: { + // kw: this.data.kw, + // } + // }) }, setTabData() { let tab = this.data.tab; diff --git a/pages/show/show.js b/pages/show/show.js index 601296a..32b3df3 100644 --- a/pages/show/show.js +++ b/pages/show/show.js @@ -231,24 +231,28 @@ Page({ // 来自页面内转发按钮 if (res.from === 'button') var types = res.from === 'button' ? 'share_btn' : 'show'; let that = this; - console.log("res", that.data.info.share_img); + console.log("res", that.data.info.share_img); + const info = this.data.info + let title = `中国香港 > ${ info.locationList[0].head } > ${ info.locationList[0].end }` + if (info.address) title += ' > ' + info.address return { - title: that.data.info.subject, - imageUrl: that.data.info.share_img, + // title: that.data.info.subject, + title, + // imageUrl: that.data.info.share_img, success: function (res) { miucms.share(app, types) }, - fail: function (res) {} // 转发失败 } }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) + let title = `中国香港 > ${ info.locationList[0].head } > ${ info.locationList[0].end }` + if (info.address) title += ' > ' + info.address + return { - title: this.data.info.subject, - imageUrl: this.data.info.share_img, + // title: this.data.info.subject, + title, + // imageUrl: this.data.info.share_img, } }, get_content: function () { @@ -363,7 +367,7 @@ Page({ wx.hideLoading() wx.showModal({ title: '提示', - content: '抱歉,网络出错。请稍后重试~', + content: res.message || '抱歉,网络出错。请稍后重试~', }) }) diff --git a/pages/show/show.wxml b/pages/show/show.wxml index f64812d..93b1e12 100644 --- a/pages/show/show.wxml +++ b/pages/show/show.wxml @@ -475,7 +475,8 @@ {{ info.count_fav == 0 ? '收藏' : info.count_fav }} - diff --git a/pages/webViewwebweb/index.js b/pages/webViewwebweb/index.js index 24cedad..565e677 100644 --- a/pages/webViewwebweb/index.js +++ b/pages/webViewwebweb/index.js @@ -73,9 +73,7 @@ Page({ } }, onShareTimeline() { - miucms.statistics({ - name: "share-timeline" - }) + return { title: app.globalData.topTitle, path: `/pages/webViewwebweb/index?url=${this.data.url}` diff --git a/template/indexSidebar/indexSidebar.js b/template/indexSidebar/indexSidebar.js index beea11d..db4de0a 100644 --- a/template/indexSidebar/indexSidebar.js +++ b/template/indexSidebar/indexSidebar.js @@ -80,9 +80,9 @@ Component({ this.setData({ groupState: true, }) - miucms.statistics({ - name: "side-group" - }) + // miucms.statistics({ + // name: "side-group" + // }) return } diff --git a/template/nearbySchool/nearbySchool.wxml b/template/nearbySchool/nearbySchool.wxml index d15659e..8f21961 100644 --- a/template/nearbySchool/nearbySchool.wxml +++ b/template/nearbySchool/nearbySchool.wxml @@ -83,7 +83,7 @@ - + diff --git a/template/open-ad/open-ad.js b/template/open-ad/open-ad.js index 27a26ca..3ba06dc 100644 --- a/template/open-ad/open-ad.js +++ b/template/open-ad/open-ad.js @@ -9,7 +9,6 @@ Component({ openDate: { type: Object, observer: function (res) { - console.log("res", res); if (res && res.image && !this.data.load) { this.data.load = true wx.setStorage({ diff --git a/template/open-ad/open-ad.wxml b/template/open-ad/open-ad.wxml index 5634179..748140b 100644 --- a/template/open-ad/open-ad.wxml +++ b/template/open-ad/open-ad.wxml @@ -4,7 +4,7 @@ {{ num }} 跳过 - + 点击查看详情 diff --git a/utils/miucms.js b/utils/miucms.js index 881f727..87c68c4 100644 --- a/utils/miucms.js +++ b/utils/miucms.js @@ -361,7 +361,7 @@ const wxget = function (url, data = {}) { wx.hideLoading() wx.showModal({ title: '提示', - content: res.data.message, + content: res.message || res.data.message, }) reject(res.data) } @@ -571,6 +571,7 @@ function getTitleName(url) { // 调用 统计接口 function statistics(obj) { + return let url = "" let options = {} @@ -660,15 +661,16 @@ function statistics(obj) { // 判断是否登录 如果登录需要发送 绑定微信信息埋点 function bindingUser(user = {}) { if (user.uid <= 0) return; - setTimeout(() => { - statistics({ - data: { - uid: user.uid, - uin: user.uin - }, - type: "identify", - }); - }, 600); + wx.xstat && wx.xstat.setUserid(user.uid); // 登录后手动设置用户id , 如果有 + // setTimeout(() => { + // statistics({ + // data: { + // uid: user.uid, + // uin: user.uin + // }, + // type: "identify", + // }); + // }, 600); } // 将一个JavaScript对象转换为路由参数的形式将键值对转换为key=value的形式 @@ -677,6 +679,17 @@ function objectToQueryString(obj = {}) { return queryString ? '?' + queryString : ''; } +// 返回上一页或者首页 +function backOrIndex() { + wx.navigateBack({ + fail: function () { + wx.redirectTo({ + url: '/pages/index/index', + }) + } + }) +} + module.exports = { initial: initial, share: share, @@ -721,4 +734,5 @@ module.exports = { bindingUser, objectToQueryString, gtergreenonionqrcode: "https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-d_pIqcXjqqsgFptxhcq_cQnrlcvd3DQYcBq_D-81qNDQyOQ~~", + backOrIndex, } \ No newline at end of file diff --git a/utils/xstat.js b/utils/xstat.js new file mode 100644 index 0000000..0a5a1a6 --- /dev/null +++ b/utils/xstat.js @@ -0,0 +1 @@ +"use strict";var e="[X-STAT] -- ",t=function(){var t=null,n=!1;return function(){return null===t&&(t=new function(){this.setDebug=function(e){n=e},this.d=function(){if(n)try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.debug.apply(console,arguments)}catch(e){}},this.i=function(){try{if(n)try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.info.apply(console,arguments)}catch(e){}}catch(e){}},this.e=function(){if(n)try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.error.apply(console,arguments)}catch(e){}},this.w=function(){if(n)try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.warn.apply(console,arguments)}catch(e){}},this.v=function(){if(n)try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.log.apply(console,arguments)}catch(e){}},this.t=function(){if(n)try{console.table.apply(console,arguments)}catch(e){}},this.tip=function(){try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.log.apply(console,arguments)}catch(e){}},this.tip_w=function(e){try{console.log("%c [UMENG] -- "+e,"background:red; padding: 4px; padding-right: 8px; border-radius: 4px; color: #fff;")}catch(e){}},this.err=function(){try{"string"==typeof arguments[0]&&(arguments[0]=e+arguments[0]),console.error.apply(console,arguments)}catch(e){}},this.repeat=function(e){for(var t=e;t.length<86;)t+=e;return t}}),t}}(),n=function(){var e=null;return function(){return e||(e=new function(){var e={};this.useOpenid=function(){return!!e.useOpenid},this.useSwanid=function(){return!!e.useSwanid},this.autoGetOpenid=function(){return!!e.autoGetOpenid},this.appKey=function(){return e.appKey},this.url=function(){return e.url},this.uploadUserInfo=function(){return e.uploadUserInfo},this.enableVerify=function(){return e.enableVerify},this.set=function(t){e=t},this.get=function(){return e},this.setItem=function(t,n){e[t]=n},this.getItem=function(t){return e[t]}}),e}}();function i(){}i.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function i(){r.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,i=n.length;rs?o+"*"+s:s+"*"+o,"function"==typeof e&&e(r)},fail:function(){"function"==typeof e&&e()}})},e.prototype.getDeviceInfo=function(e){"function"==typeof e&&e("")},e.prototype.checkNetworkAvailable=function(e){wx.getNetworkType({success:function(t){"function"==typeof e&&e(t&&"none"!==t.networkType)},fail:function(){"function"==typeof e&&e(!1)}})},e.prototype.getNetworkInfo=function(e){wx.getNetworkType({success:function(t){"function"==typeof e&&e({networkAvailable:"none"!==t.networkType,networkType:t.networkType})},fail:function(){"function"==typeof e&&e()}})},e.prototype.getDeviceId=function(e){e("")},e.prototype.getAdvertisingId=function(e){"function"==typeof e&&e("")},e.prototype.onNetworkStatusChange=function(e){wx.onNetworkStatusChange(function(t){"function"==typeof e&&e(t.isConnected)})},e.prototype.request=function(e){var t=e.success,n=e.fail,r=!1,i=null;e.success=function(e){r||(i&&clearTimeout(i),"function"==typeof t&&t(e))},e.fail=function(){r||(i&&clearTimeout(i),"function"==typeof n&&n(!1))},wx.request(e),i=setTimeout(function(){i&&clearTimeout(i),r=!0,"function"==typeof n&&n(r)},e.timeout||5e3)},e.prototype.getSdkType=function(){return"wxmp"},e.prototype.getPlatform=function(){return"wx"},e.prototype.getUserInfo=function(e){e()},e.prototype.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},e.prototype.onShareAppMessage=function(e){wx.onShareAppMessage(e)},e.prototype.shareAppMessage=function(e){wx.shareAppMessage(e)},e.prototype.getLaunchOptionsSync=function(){var e=null;if(e)return e;if(!wx.getLaunchOptionsSync)return{};try{e=wx.getLaunchOptionsSync()}catch(t){e=null}return e||{}},e}()),s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}console.log(e);var c,u={SESSION_INTERVAL:3e4,LOG_URL:"https://stat.x-php.com/stat",GET_OPENID_URL:"https://stat.x-php.com/stat/wx/getuut",USERINFO_URL:"https://stat.x-php.com/stat/comm/uif",FETCHURL:"https://stat.x-php.com/stat/fetch",GETVALUEURL:"https://stat.x-php.com/stat/getVlue",DEVICE_INFO_KEY:"device_info",ADVERTISING_ID:"mobile_ad_id",ANDROID_ID:"android_id",CURRENT_SESSION:"current_session",SESSION_PAUSE_TIME:"session_pause_time",EVENT_SEND_DEFAULT_INTERVAL:15e3,EVENT_LAST_SEND_TIME:"last_send_time",MAX_EVENTID_LENGTH:128,MAX_PROPERTY_KEY_LENGTH:256,MAX_PROPERTY_KEYS_COUNT:100,REPORT_POLICY:"report_policy",REPORT_INTERVAL_TIME:"report_interval_time",REPORT_POLICY_START_SEND:"1",REPORT_POLICY_INTERVAL:"6",IMPRINT:"imprint",SEED_VERSION:"1.0.0",IMPL_VERSION:"2.8.0",ALIPAY_AVAILABLE_VERSION:"10.1.52",SHARE_PATH:"xphp_share_path",SHARES:"shares",REQUESTS:"requests",UUID:"xphp_uuid",UUID_SUFFIX:"ud",OPENID:"xphp_od",UNIONID:"xphp_unid",ALIPAYID:"xphp_alipayid",USERID:"xphp_userid",SWANID:"xphp_swanid",ANONYMOUSID:"xphp_anonymousid",LAUNCH_OPTIONS:"LAUNCH_OPTIONS",XPHP_SSRC:"_xphp_ssrc",USER_INFO:"user_info",IS_ALIYUN:!1},f={isNumber:function(e){return!Number.isNaN(parseInt(e,10))},compareVersion:function(e,t){for(var n=String(e).split("."),r=String(t).split("."),i=0;is)return 1;if(oe.length)&&e.substr(0,t.length)===t},endsWith:function(e,t){return!(!t||0===e.length||t.length>e.length)&&e.substring(e.length-t.length)===t},assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n1&&f.startsWith(o.path,"/")&&(o.path=f.trimStart(o.path,"/"));var s=e.path||"",a=l().getId();if(a){var u=r.split(","),c=(u=u.filter(function(e){return e.length>0})).indexOf(a);c>=0&&(u=u.slice(0,c)),u.length<3&&u.push(a);var p=u.join(",");-1!==s.indexOf("?")?s+="&_xphp_ssrc="+p:s+="?_xphp_ssrc="+p;var h=Date.now();if(s+="&_xphp_sts="+h,i){var g=function(e){var t=[];for(var n in e)"_xphp_ssrc"!==n&&"_xphp_sts"!==n&&t.push(n+"="+e[n]);return t.join("&")}(d),v=g?g+"&_xphp_ssrc="+p+"&_xphp_sts="+h:"_xphp_ssrc="+p+"&_xphp_sts="+h;e.query=e.query?e.query+"&_xphp_ssrc="+p+"&_xphp_sts="+h:v}else e.path=s;o._xphp_ssrc=p,o._xphp_sts=h}return n.push(o),t().v("share: %o",e),e},setShareSource:function(e){r=e},clear:function(){n.length=0},get:function(){return n}}}),e}}(),v=function(e){if(e)try{return JSON.stringify(e)}catch(e){}return""},_=function(e){if(e)try{return JSON.parse(e)}catch(e){}return null},y=function(){var e=null,t="",r=null,i=!1;return function(){return e||(e=new function(){this.load=function(e){r?(o.removeStorage(t),e()):(t="xphp_cache_"+n().appKey(),o.getStorage(t,function(n){r=_(n)||{},i=!0,o.removeStorage(t),e()}))},this.save=function(){r&&o.setStorage(t,v(r))},this.set=function(e,t){r&&(r[e]=t)},this.get=function(e){return(r||{})[e]},this.remove=function(e){r&&r[e]&&delete r[e]},this.getAll=function(){return r},this.clear=function(){r=null},this.has=function(e){return!!this.get(e)},this.isLoaded=function(){return i}}),e}}(),m=function(){var e,n,r=[],i=[];function o(e,t){var r=(e=e||{})[n];return Array.isArray(r)&&r.length?e[n]=r.concat(t):e[n]=[].concat(t),e}return function(){return e||(e={addEvent:function(e){n?(r.unshift(e),r.length>1&&(!function(){if(r.length){var e=y().get("ekvs");(function(e){var t=0;for(var n in e)Array.isArray(e[n])&&(t+=e[n].length);return t})(e)+r.length<=1e4&&(e=o(e,r),y().set("ekvs",e))}}(),r.length=0)):(t().w("session id is null: ",n),i.unshift(e))},setSessionId:function(e){if(n=e,t().v("setSessionId: ",n),Array.isArray(i)&&i.length&&n){for(var r=0;ru.SESSION_INTERVAL?(i=!0,function(e){try{var n=(r||{}).options||{},i=f.assign({},function(e){var n={};for(var r in e)0===r.indexOf("_xphp_")&&(n[r]=e[r]);return t().v("query: ",e),t().v("_xphp_params: ",n),n}(e.query));i.path=e.path||n.path,"gaode"!==o.getPlatform()&&(i.scene=e.scene?o.getPlatform()+"_"+e.scene:n.scene);var s=e.referrerInfo;s&&(i.referrerAppId=s.appId),t().v("session options: ",i);var a=i[u.XPHP_SSRC];a&&g().setShareSource(a);var c=Date.now();r={id:f.getRandomStr(10)+c,start_time:c,options:i}}catch(e){t().e("生成新session失败: ",e)}}(e),t().v("开始新的session(%s): ",r.id,r)):t().v("延续上一次session(%s): %s ",r.id,s.toLocaleTimeString(),r),i},pause:function(){!function(){if(r){var e=new Date;r.end_time=e.getTime(),"number"!=typeof r.duration&&(r.duration=0),r.duration=r.end_time-n,y().set(u.CURRENT_SESSION,r),t().v("退出会话(%s): %s ",r.id,e.toLocaleTimeString(),r)}}()},getCurrentSessionId:function(){return(r||{}).id},getCurrentSession:function(){return r},cloneCurrentSession:function(){return f.clone(r)}}),e}}();function b(e){var t=null;switch(e){case A:t=function(){var e=null,t=k().cloneCurrentSession();return t&&(e={header:{st:"1"},analytics:{sessions:[t]}}),e}();break;case E:t=function(){var e=null,t={},n=k().cloneCurrentSession();if(n){var r=h().get(),i=g().get();Array.isArray(r)&&r.length&&(n.pages=f.clone(r)),Array.isArray(i)&&i.length&&(n.shares=f.clone(i)),h().clear(),g().clear(),t.sessions=[n]}var o=m().getEkvs();return o&&(t.ekvs=f.clone(o),m().clear()),(t.sessions||t.ekvs)&&(e={analytics:t}),e}();break;case N:t=function(){var e=null,t=m().getEkvs();return t&&(e={analytics:{ekvs:f.clone(t)}},m().clear()),e}()}return t}var D={sessions:"sn",ekvs:"e",active_user:"active_user"},U={sdk_type:"sdt",access:"ac",access_subtype:"acs",device_model:"dm",language:"lang",device_type:"dt",device_manufacturer:"dmf",device_name:"dn",platform_version:"pv",id_type:"it",font_size_setting:"fss",os_version:"ov",device_manuid:"did",platform_sdk_version:"psv",device_brand:"db",appkey:"ak",_id:"id",id_tracking:"itr",imprint:"imp",sdk_version:"sv",resolution:"rl",testToken:"ttn",theme:"t5",benchmark_level:"bml",screen_width:"sw",screen_height:"sh",status_bar_height:"sbh",safe_area_top:"sat",safe_area_left:"sal",safe_area_right:"sar",safe_area_bottom:"sab",safe_area_height:"sah",safe_area_width:"saw",pixel_ratio:"pr",storage:"s7",host:"hs"},P={uuid:"ud",unionid:"und",openid:"od",anonymousid:"nd",alipay_id:"ad",device_id:"dd",userid:"puid"};function R(e,t){var n=L(e,t);return e&&e.id_tracking&&(n[t.id_tracking||"id_tracking"]=L(e.id_tracking,P)),n}function L(e,t){var n={};for(var r in e)t[r]?n[t[r]]=e[r]:n[r]=e[r];return n}function C(e,t){var n={};if(e)for(var r in e)e[r]&&(n[t[r]]=e[r]);return n}var M="";function x(){return M}var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=function(e){for(var t={},n=0,r=e.length;n>>6)+F(128|63&t):F(224|t>>>12&15)+F(128|t>>>6&63)+F(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return F(240|t>>>18&7)+F(128|t>>>12&63)+F(128|t>>>6&63)+F(128|63&t)},q=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,K=function(e){var t=[0,2,1][e.length%3],n=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[V.charAt(n>>>18),V.charAt(n>>>12&63),t>=2?"=":V.charAt(n>>>6&63),t>=1?"=":V.charAt(63&n)].join("")},H=function(e){return function(e){return e.replace(q,G)}(e).replace(/[\s\S]{1,3}/g,K)},Y=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),J=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return F(55296+(t>>>10))+F(56320+(1023&t));case 3:return F((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return F((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},B=function(e){var t=e.length,n=t%4,r=(t>0?j[e.charAt(0)]<<18:0)|(t>1?j[e.charAt(1)]<<12:0)|(t>2?j[e.charAt(2)]<<6:0)|(t>3?j[e.charAt(3)]:0),i=[F(r>>>16),F(r>>>8&255),F(255&r)];return i.length-=[0,0,2,1][n],i.join("")},X=function(e){return function(e){return e.replace(/[\s\S]{1,4}/g,B)}(e).replace(Y,J)},W=function(e,t){return t?H(String(e)).replace(/[+\/]/g,function(e){return"+"==e?"-":"_"}).replace(/=/g,""):H(String(e))},z=function(e){return X(String(e).replace(/[-_]/g,function(e){return"-"==e?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},Q=new function(){var e="",t=this;this.set=function(t){e=t},this.get=function(){return e},this.getImpObj=function(){return _(z(e))},this.getItem=function(e){var n=t.getImpObj();return n&&n[e]||""},this.load=function(){e=y().get(u.IMPRINT)},this.save=function(){e&&y().set(u.IMPRINT,e)}};function Z(e,n,r,i){w.instance().setIdType(l().getIdType()),w.instance().setIdTracking(l().getIdTracking());var s=l().getUserId();s&&e.analytics&&(e.analytics.active_user={uid:s});var a=f.clone(w.instance().get());e.header=f.assign(a,e.header,{ts:Date.now(),testToken:x(),traceId:f.getRandomStr(10)+Date.now()+f.getRandomStr(9)});var c=function(e){return{h:R(e.header,U),a:C(e.analytics,D)}}(e),p=v(c),h={url:u.LOG_URL,method:"POST",data:c,success:function(i){var o=i.code||i.status||i.statusCode;200===o||413===o?(t().i("数据发送成功: ",e,p),function(e){e&&(w.instance().setItem(u.IMPRINT,e),Q.set(e),Q.save(),t().v("imprint: ",Q.getImpObj()),Q.getItem("ttn_invalid")&&(M=""))}((i.data||{}).imprint),"function"==typeof n&&n(i)):(t().w("数据发送失败: ",p),"function"==typeof r&&r())},fail:function(e){t().w("超时: ",p),"function"==typeof r&&r()},complete:function(){"function"==typeof i&&i()}};o.request(f.assign(h,{header:{"Msg-Type":o.getSdkType()+"/json","disable-base64":"Y"}}))}function $(e){var t=e,n=[];this.enqueue=function(e){"number"==typeof t&&this.size()>=t&&this.dequeue(),n.push(e)},this.dequeue=function(){return n.shift()},this.front=function(){return n[0]},this.isEmpty=function(){return 0===n.length},this.clear=function(){n.length=0},this.size=function(){return n.length},this.items=function(){return n},this.print=function(){console.log(n.toString())}}var ee=function(){var e=null,n=!1,r=[],i=new $(50);function o(e){l().getId()?n?t().i("队列正在发送中"):(n=!0,function e(t){var n=i.front();n?Z(n,function(){i.dequeue(),e(t)},function(){var n=i.dequeue();n&&!n.noCache&&r.push(n),e(t)}):(r.forEach(function(e){i.enqueue(e)}),r.length=0,t())}(function(){n=!1,"function"==typeof e&&e()})):(t().i("获取id标识失败,暂缓发送"),"function"==typeof e&&e())}function s(){this.send=function(e,t,n){e?this.add(e,t,function(){o(n)}):o(n)},this.add=function(e,t,n){!function e(t,n,r){if(w.instance().isLoaded()){n=n||{};var o=b(t);if(o){var s=w.instance().getRealtimeFields();o.header=f.assign({},o.header,s),o.noCache=n.noCache,i.enqueue(o)}"function"==typeof r&&r()}else setTimeout(function(){e(t,n,r)},100)}(e,t,n)},this.load=function(){var e=y().get(u.REQUESTS);e&&e.length&&e.forEach(function(e){i.enqueue(e)}),y().remove(u.REQUESTS)},this.save=function(){y().set(u.REQUESTS,f.clone(i.items())),i.clear()}}return function(){return e||(e=new s),e}}(),te=function(){var e=null,r=null;return function(){return e||(e=new function(){function e(e){if(e&&"object"==typeof e){var r=y().get(u.USER_INFO);return r&&f.deepEqual(e,r)||function(e,r){var i=n().appKey(),s=o.getSdkType(),a=l().getId(),c=l().getIdType();if(i&&s&&a&&c){var f={ak:n().appKey(),sdt:o.getSdkType(),uin:e.nickName,uia:e.avatar||e.avatarUrl,uig:e.gender,uit:e.country,uip:e.province,uic:e.city,uil:e.language,id:l().getId(),it:l().getIdType(),age:e.age,cln:e.constellation},p=JSON.stringify(f);p=W(p),o.request({url:u.USERINFO_URL,method:"POST",header:{"content-type":"application/x-www-form-urlencoded"},data:"ui="+p,success:function(n){t().v("用户信息上传成功: ",e),r&&r(n&&n.data&&200===n.data.code)},fail:function(){t().e("用户信息上传失败: ",e),r&&r(!1)}})}}(e,function(t){t&&y().set(u.USER_INFO,e)}),!0}return!1}this.setUserInfo=function(e){r=e},this.update=function(){e(r)||o.getUserInfo(function(t){e(t)})}}),e}}();function ne(e,t){this.id=e,this.ts=Date.now();var n=typeof t;if("string"===n&&t)this[e]=t;else if("object"===n)for(var r in t)({}).hasOwnProperty.call(t,r)&&(this[r]=t[r])}function ie(){var e=!1,r=!1,i=0;this.init=function(r){t().v("sdk version: "+u.IMPL_VERSION),e?t().v("Lib重复实例化"):y().load(function(){t().v("cache初始化成功: ",y().getAll()),l().setUseOpenid&&l().setUseOpenid(n().useOpenid()),l().init(function(){w.instance().init(),t().v("Header初始化成功")}),e=!0,"function"==typeof r&&r(),t().tip("SDK集成成功")})},this.resume=function(i){var o;e&&!r&&(t().v("showOptions: ",i),r=!0,n().enableVerify()&&i&&i.query&&(o=i.query._ttn,M=o||M),this._resume(i))},this._resume=function(e){ee().load();var r=k().resume(e),i=k().getCurrentSessionId();m().setSessionId(i),r&&ee().add(A,{},function(){l().setUseOpenid&&l().setUseOpenid(n().useOpenid()),n().useOpenid()&&n().autoGetOpenid()&&!l().getId()?(t().v("get id async"),function e(r,i){l().getId()||r<=0||l().getOpenIdAsync(n().appKey(),function(n){n?(t().v("获取id成功"),ee().send()):(t().v("获取openid失败,启动重试,剩余可用次数",r-1),setTimeout(function(){e(r-1,i)},i))})}(10,3e3)):(t().v("session auto send"),ee().send())})},this.pause=function(o){e&&(r=!1,i=0,k().pause(),n().uploadUserInfo()&&te().update(),ee().send(E,{},function(){ee().save(),y().save(),t().v("cache save success"),"function"==typeof o&&o()}))},this.setOpenid=function(e){t().v("setOpenId: %s",e),l().setOpenid(e),ee().send()},this.setUnionid=function(e){t().v("setUnionid: %s",e),l().setUnionid(e)},this.setUserid=function(e,n){t().v("setUserid: %s",e,n),l().setUserid(e,n)},this.removeUserid=function(){t().v("removeUserid"),l().removeUserid()},this.setUserInfo=function(e){t().v("setUserInfo: %s",e),te().setUserInfo(e)},this.setAnonymousid=function(e){t().v("setAnonymousId: %s",e),l().setAnonymousid(e),ee().send()},this.setAppVersion=function(e){e&&"string"!=typeof e?t().w("setAppVersion方法只接受字符串类型参数"):w.instance().setAppVersion(e)},this.setAlipayUserid=function(e){e&&"string"!=typeof e?t().w("setAlipayUserid方法只接受字符串类型参数"):(t().v("setAlipayUserid: %s",e),l().setAlipayUserid(e))},this.setDeviceId=function(e){if("string"==typeof e)return l().setDeviceId(e),e},this.setSuperProperty=function(e){if(e&&"string"!=typeof e)t().w("超级属性只支持字符串类型");else{var n=this;w.instance().getSuperProperty()!==e&&(w.instance().setSuperProperty(e),n.pause(function(){n.resume()}))}},this.trackEvent=function(n,r){if(e&&(t().v("event: ",n,r),function(e,n){if(!e||"string"!=typeof e)return t().e('please check trackEvent id. id should be "string" and not null'),!1;var r=["id","ts","du"],i={};if(r.forEach(function(e){i[e]=1}),i[e])return t().e("eventId不能与以下保留字冲突: "+r.join(",")),!1;if(e.length>u.MAX_EVENTID_LENGTH)return t().e("The maximum length of event id shall not exceed "+u.MAX_EVENTID_LENGTH),!1;if(n&&("object"!=typeof n||Array.isArray(n))&&"string"!=typeof n)return t().e("please check trackEvent properties. properties should be string or object(not include Array)"),!1;if("object"==typeof n){var o=0;for(var s in n)if({}.hasOwnProperty.call(n,s)){if(s.length>u.MAX_PROPERTY_KEY_LENGTH)return t().e("The maximum length of property key shall not exceed "+u.MAX_PROPERTY_KEY_LENGTH),!1;if(o>=u.MAX_PROPERTY_KEYS_COUNT)return t().e("The maximum count of properties shall not exceed "+u.MAX_PROPERTY_KEYS_COUNT),!1;if(i[s])return t().e("属性中的key不能与以下保留字冲突: "+r.join(",")),!1;o+=1}}return!0}(n,r))){var o=new ne(n,r);m().addEvent(o);var s=!!x(),a=s?0:u.EVENT_SEND_DEFAULT_INTERVAL,c=Date.now();("number"!=typeof i||"number"!=typeof a||i<=0||c-i>a)&&(i=c,ee().send(N,{noCache:s},function(){}))}},this.trackShare=function(n){if(e)try{o.getSdkType().indexOf("game")>-1?(n=g().add(n,!0),t().v("shareQuery: ",n)):(n=g().add(n,!1),t().v("sharePath: ",n.path))}catch(e){t().v("shareAppMessage: ",e)}return n},this.trackPageStart=function(t){e&&h().addPageStart(t)},this.trackPageEnd=function(t){e&&h().addPageEnd(t)},this.onShareAppMessage=function(e){var t=this;o.onShareAppMessage(function(){return t.trackShare(e())})},this.shareAppMessage=function(e){this.trackShare(e),o.shareAppMessage(e)}}var re=[];function oe(){}oe.prototype={createMethod:function(e,n,r){try{e[n]=r&&r[n]?function(){return r[n].apply(r,arguments)}:function(){re.push([n,[].slice.call(arguments)])}}catch(e){t().v("create method errror: ",e)}},installApi:function(e,n){try{var r,i,o="resume,pause,trackEvent,trackPageStart,trackPageEnd,trackShare,setUserid,setOpenid,setUnionid,setSuperProperty,setUserInfo".split(",");for(r=0,i=o.length;r