200 lines
4.7 KiB
Vue
200 lines
4.7 KiB
Vue
<template>
|
||
<view style="width: 100%;">
|
||
<web-view id="webview" :src="url" style="width: 100%;"></web-view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import httpsRequest from '@/common/httpRequest.js'
|
||
export default {
|
||
data() {
|
||
return {
|
||
ordersId: '',
|
||
timer: null,
|
||
maxAjaxNum: 5,
|
||
ajaxNum: 0,
|
||
url: null, //要打开的外部链接
|
||
viewerUrl: '/hybrid/html/web/viewer.html',
|
||
webviewStyles: {
|
||
width: '750px',
|
||
height: '100%',
|
||
},
|
||
|
||
}
|
||
},
|
||
onReady() {},
|
||
onShow() {
|
||
console.log(this.ordersId);
|
||
|
||
httpsRequest.getT("/app/wuyou/queryOrder/" + this.ordersId, {}).then(res => {
|
||
console.log(res.data);
|
||
|
||
if (res.data == 1) {
|
||
uni.hideLoading()
|
||
const sysInfo = uni.getSystemInfoSync();
|
||
let isIos = sysInfo.platform == 'ios'
|
||
console.log("is ios ", isIos);
|
||
if (isIos) {
|
||
uni.navigateBack()
|
||
uni.showToast({
|
||
title: '支付成功',
|
||
icon: 'none'
|
||
})
|
||
setTimeout(() => {
|
||
uni.navigateBack()
|
||
}, 1500)
|
||
} else {
|
||
uni.showToast({
|
||
title: '支付成功',
|
||
icon: 'none'
|
||
})
|
||
this.timer = setTimeout(() => {
|
||
clearTimeout(this.timer)
|
||
uni.navigateBack()
|
||
}, 500)
|
||
}
|
||
} else {
|
||
// #ifdef APP
|
||
uni.showLoading({
|
||
title: '支付中'
|
||
})
|
||
// #endif
|
||
}
|
||
});
|
||
},
|
||
onHide() {
|
||
clearInterval(this.timer)
|
||
uni.hideLoading()
|
||
},
|
||
onUnload() {
|
||
uni.hideLoading()
|
||
},
|
||
onLoad: function(option) {
|
||
console.log(option)
|
||
this.url = option.url
|
||
this.ordersId = option.ordersId
|
||
console.log('this.ordersId' + this.ordersId);
|
||
|
||
|
||
this.asdasdasd(1212, 5)
|
||
this.cac(1212.5)
|
||
this.muls(1212, 5)
|
||
this.addaasas(1212, 5)
|
||
this.divs(1212, 5)
|
||
},
|
||
methods: {
|
||
//乘法函数,用来得到精确的乘法结果
|
||
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||
//调用:mul(arg1,arg2)
|
||
//返回值:arg1乘以arg2的精确结果
|
||
//
|
||
muls(arg1, arg2) {
|
||
var m = 0,
|
||
s1 = arg1.toString(),
|
||
s2 = arg2.toString();
|
||
try {
|
||
m += s1.split(".")[1].length;
|
||
} catch (e) {
|
||
m = 0;
|
||
}
|
||
try {
|
||
m += s2.split(".")[1].length;
|
||
} catch (e) {
|
||
m = m || 0;
|
||
}
|
||
return (
|
||
(Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
|
||
Math.pow(10, m)
|
||
);
|
||
}, //除法函数,用来得到精确的除法结果
|
||
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
|
||
//调用:div(arg1,arg2)
|
||
//返回值:arg1除以arg2的精确结果
|
||
asdasdasd(arg1, arg2) {
|
||
var r1, r2, m, n;
|
||
try {
|
||
r1 = arg1.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r1 = 0;
|
||
}
|
||
try {
|
||
r2 = arg2.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r2 = 0;
|
||
}
|
||
m = Math.pow(10, Math.max(r1, r2));
|
||
//动态控制精度长度
|
||
n = r1 >= r2 ? r1 : r2;
|
||
return ((arg1 * m - arg2 * m) / m).toFixed(n);
|
||
},
|
||
addaasas(arg1, arg2) {
|
||
var r1, r2, m, n;
|
||
try {
|
||
r1 = arg1.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r1 = 0;
|
||
}
|
||
try {
|
||
r2 = arg2.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r2 = 0;
|
||
}
|
||
m = Math.pow(10, Math.max(r1, r2));
|
||
n = r1 >= r2 ? r1 : r2;
|
||
return ((arg1 * m + arg2 * m) / m).toFixed(n);
|
||
},
|
||
divs(arg1, arg2) {
|
||
var t1 = 0,
|
||
t2 = 0,
|
||
r1,
|
||
r2;
|
||
try {
|
||
t1 = arg1.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
t1 = 0;
|
||
}
|
||
try {
|
||
t2 = arg2.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
t2 = 0;
|
||
}
|
||
r1 = Number(arg1.toString().replace(".", ""));
|
||
r2 = Number(arg2.toString().replace(".", ""));
|
||
},
|
||
/**
|
||
* 保留小数n位,不进行四舍五入
|
||
* num你传递过来的数字,
|
||
* decimal你保留的几位,默认保留小数后两位
|
||
* isInt 是否保留0。如:12.20 是否保留0
|
||
* this.cac(1212.05)
|
||
*/
|
||
cac(num, decimal = 2, isInt = false) {
|
||
num = num.toFixed(3).toString();
|
||
const index = num.indexOf(".");
|
||
if (index !== -1) {
|
||
num = num.substring(0, decimal + index + 1);
|
||
} else {
|
||
num = num.substring(0);
|
||
}
|
||
//截取后保留两位小数
|
||
if (isInt) {
|
||
return parseFloat(num);
|
||
} else {
|
||
return parseFloat(num).toFixed(decimal);
|
||
}
|
||
},
|
||
|
||
//乘法函数,用来得到精确的乘法结果
|
||
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||
//调用:mul(arg1,arg2)
|
||
//返回值:arg1乘以arg2的精确结果
|
||
|
||
}
|
||
}
|
||
</script>
|
||
<style lang="scss">
|
||
.webview {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
</style> |