|
|
@@ -41,7 +41,8 @@
|
|
|
|
|
|
<view class="footer-bar" style="z-index: 1;">
|
|
|
<u-button @click="goVote" shape="circle" :custom-style="btnText=='给ta投票'?customStyle:disabledStyle">
|
|
|
- {{btnText}}</u-button>
|
|
|
+ {{btnText}}
|
|
|
+ </u-button>
|
|
|
</view>
|
|
|
</view>
|
|
|
<login ref="login" @signIn="signIn" @phoneSuccess="showVote"></login>
|
|
|
@@ -91,8 +92,16 @@
|
|
|
await this.fetchData()
|
|
|
//处理授权结果
|
|
|
this.handelAuthResult(props)
|
|
|
+
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
//处理创建订单结果
|
|
|
this.handelOrderResult(props)
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ // #ifdef H5
|
|
|
+ this.h5CreateOrder()
|
|
|
+ // #endif
|
|
|
+
|
|
|
//处理海报参数
|
|
|
this.handelShareParams()
|
|
|
//隐藏loading
|
|
|
@@ -122,6 +131,8 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ count: 0,
|
|
|
+
|
|
|
//是否自定义返回,防止授权时返回到webview页面
|
|
|
isCustomBack: true,
|
|
|
defaultAvatar: 'https://vote.guosen-fumao.cn/obsfile/446d9e043f3748e4a47ea4d0de81b140-3b748fea4150c469b8eb66f98cd29e2.png',
|
|
|
@@ -250,11 +261,13 @@
|
|
|
this.showVote()
|
|
|
return
|
|
|
}
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
if (this.authResult.resultCode == '9999') {
|
|
|
//授权失败
|
|
|
this.$refs.toast.error(this.authResult.message)
|
|
|
return
|
|
|
}
|
|
|
+ // #endif
|
|
|
},
|
|
|
handelOrderResult(options) {
|
|
|
if (options.orderPass && this.$cache.get('orderResult')) {
|
|
|
@@ -289,15 +302,16 @@
|
|
|
this.createOrder()
|
|
|
return
|
|
|
}
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
let params = {
|
|
|
url: 'https://vote.guosen-fumao.cn/order.html',
|
|
|
goodsId: this.selectGoods.id
|
|
|
}
|
|
|
this.$jump('/pages/webview/createOrder' + this.$u.queryParams(params))
|
|
|
+ // #endif
|
|
|
},
|
|
|
//移动积分创建订单
|
|
|
async createOrder() {
|
|
|
- console.log("123456");
|
|
|
if (this.$isEmpty(this.orderResult.fingerprint) ||
|
|
|
this.$isEmpty(this.orderResult.sessionId) ||
|
|
|
this.$isEmpty(this.orderResult.goodsId)) {
|
|
|
@@ -314,6 +328,7 @@
|
|
|
}
|
|
|
let res = await this.$api.order.create(params)
|
|
|
if (res.data.success) {
|
|
|
+ console.log("orderResult", this.orderResult);
|
|
|
this.orderResult.outOrderId = res.data.data
|
|
|
this.orderResult.mobile = this.vuex_phone
|
|
|
this.$refs.smsAlert.showSmsAndSend(this.orderResult)
|
|
|
@@ -409,7 +424,125 @@
|
|
|
// #ifndef MP-WEIXIN
|
|
|
this.showPoster()
|
|
|
// #endif
|
|
|
- }
|
|
|
+ },
|
|
|
+ // h5 创建订单 begin
|
|
|
+ h5CreateOrder() {
|
|
|
+ if (this.$cache.get('orderResult')) {
|
|
|
+ this.orderResult = this.$cache.get('orderResult')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //初始化js脚本
|
|
|
+ this.initScript()
|
|
|
+ //获取Fmopt
|
|
|
+ this.fetchFmopt()
|
|
|
+ //获取sessionId
|
|
|
+ this.loadScriptFunc("", this.fetchSessionId())
|
|
|
+ //打印数据
|
|
|
+ this.cacheOrderData()
|
|
|
+ },
|
|
|
+ cacheOrderData() {
|
|
|
+ let _this = this
|
|
|
+ setTimeout(() => {
|
|
|
+ _this.$nextTick(function() {
|
|
|
+ try {
|
|
|
+ _this.count++
|
|
|
+ console.log("sessionId:" + window.sessionId);
|
|
|
+ console.log("fingerprint:" + _fmOpt.getinfo());
|
|
|
+ console.log("获取成功啦");
|
|
|
+ _this.pushInCache(_fmOpt.getinfo(), window.sessionId)
|
|
|
+ } catch (e) {
|
|
|
+ console.log(_this.count);
|
|
|
+ if (_this.count < 10) {
|
|
|
+ _this.cacheOrderData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, 20)
|
|
|
+ },
|
|
|
+ pushInCache(fingerprint, sessionId) {
|
|
|
+ this.orderResult = {
|
|
|
+ fingerprint: encodeURIComponent(fingerprint),
|
|
|
+ sessionId,
|
|
|
+ goodsId: this.selectGoods.id
|
|
|
+ }
|
|
|
+ this.$cache.put('orderResult', this.orderResult)
|
|
|
+ },
|
|
|
+ initScript() {
|
|
|
+ let monitorURL = "https://static.tongdun.net/monitor/monitor.js"
|
|
|
+ this.loadScript(monitorURL)
|
|
|
+ let tfdURL = "https://j.changyoyo.com/static/js/common/tfd.js"
|
|
|
+ this.loadScript(tfdURL)
|
|
|
+ let jqueryURL = "https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"
|
|
|
+ this.loadScript(jqueryURL)
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchFmopt() {
|
|
|
+ window._fmOpt = {
|
|
|
+ partner: 'changyou',
|
|
|
+ appName: 'changyou_web',
|
|
|
+ token: 'changyou' + "-" + new Date().getTime() + "-" +
|
|
|
+ Math.random().toString(16).substr(2),
|
|
|
+ fmb: true,
|
|
|
+ success: function(data) {
|
|
|
+ console.log('blackbox: ', data)
|
|
|
+ },
|
|
|
+ fpHost: "https://fp.tongdun.net"
|
|
|
+ };
|
|
|
+ var cimg = new Image(1, 1);
|
|
|
+ cimg.onload = function() {
|
|
|
+ _fmOpt.imgLoaded = true;
|
|
|
+ };
|
|
|
+ cimg.src =
|
|
|
+ "https://fp.tongdun.net/fp/clear.png?partnerCode=changyou&appName=changyou_web&tokenId=" +
|
|
|
+ _fmOpt.token;
|
|
|
+ var fm = document.createElement('script');
|
|
|
+ fm.type = 'text/javascript';
|
|
|
+ fm.async = true;
|
|
|
+ fm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +
|
|
|
+ 'static.tongdun.net/v3/fm.js?ver=0.1&t=' + (new Date().getTime() / 3600000).toFixed(0);
|
|
|
+ var s = document.getElementsByTagName('script')[0];
|
|
|
+ s.parentNode.insertBefore(fm,
|
|
|
+ s);
|
|
|
+ },
|
|
|
+ loadScript(src) {
|
|
|
+ var script = document.createElement('script');
|
|
|
+ script.src = src;
|
|
|
+ document.body.appendChild(script);
|
|
|
+ },
|
|
|
+ loadScriptFunc(url, callback) {
|
|
|
+ callback = typeof callback === 'function' ? callback : function() {};
|
|
|
+ var head = document.getElementsByTagName('head')[0];
|
|
|
+ var script = document.createElement('script');
|
|
|
+ script.type = 'text/javascript';
|
|
|
+ script.src = url;
|
|
|
+ script.onreadystatechange = function() {
|
|
|
+ if (this.readyState == "loaded" || this.readyState == "complete") {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ script.onload = callback;
|
|
|
+ head.appendChild(script);
|
|
|
+ },
|
|
|
+ fetchSessionId() {
|
|
|
+ var url, ts, sessionId, appId, appkey;
|
|
|
+ if (document.domain === 'm.changyoyo.com') {
|
|
|
+ url = "tfd.changyoyo.com";
|
|
|
+ } else {
|
|
|
+ url = "101.132.237.10";
|
|
|
+ }
|
|
|
+ appId = "5308e20b";
|
|
|
+ appkey = "3daf27ea2fe840ada6af8e1ec0d7b760";
|
|
|
+ ts = new Date().getTime();
|
|
|
+ sessionId = "changyo-pc-" + ts + "-" + Math.random().toString(16).substr(2);
|
|
|
+ window.sessionId = sessionId;
|
|
|
+ [document.getElementsByTagName('script')[0].parentNode.appendChild(document.createElement('script')).src =
|
|
|
+ "http://" +
|
|
|
+ url + "/did/js/dp.js?appId=" + appId + "&appkey=" + appkey + "&sessionId=" + sessionId +
|
|
|
+ "&ts=" +
|
|
|
+ ts
|
|
|
+ ][0];
|
|
|
+ },
|
|
|
+ //h5 创建订单end
|
|
|
},
|
|
|
}
|
|
|
</script>
|