提交 d3ac95f8 编写于 作者: zhongyao.qiao's avatar zhongyao.qiao

Merge branch 'feature/qiao' into 'release'

Feature/qiao

See merge request !292
......@@ -16,6 +16,7 @@ import JsEncrypt from 'jsencrypt/bin/jsencrypt';
window.JSEncrypt = JsEncrypt;
window.CryptoJS = CryptoJS;
var lastTouchEnd = 0;
document.addEventListener('touchstart', function (event) {
if (event.touches.length > 1) {
event.preventDefault();
......@@ -43,7 +44,6 @@ document.documentElement.addEventListener(
passive: false,
}
);
console.log('z', vueApp.$rocNative);
vueApp.$rocNative.appInit();
vueApp.$rocNative.on('wx_ready', function () {
console.log('-wx_ready-', window._picaWechat);
......@@ -53,7 +53,6 @@ vueApp.$rocNative.on('wx_ready', function () {
window._miniprogram = res.miniprogram;
});
});
console.log('---', isWeixin());
if (isWeixin()) {
window._picaWechat = 'wechat';
}
......
......@@ -26,14 +26,47 @@ export const formatDay = (datetime) => {
// 判断是否是微信
export function isWeixin() {
const ua = window.navigator.userAgent.toLowerCase();
// if(ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/_SQ_/i) == '_sq_') {
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
const ua = window.navigator.userAgent;
console.log('🚀 ~ ua:', ua);
if (ua.match(/MicroMessenger/i) == 'MicroMessenger') {
return true;
} else {
return false;
}
}
export function isMobile() {
const ua = window.navigator.userAgent || window.opera;
// 移动端设备列表,可以根据需要扩展
const mobileDevices = [
'Android',
'iPhone',
'iPad',
'iPod',
'BlackBerry',
'Windows Phone',
'IEMobile',
'Opera Mini',
'Mobile',
'Mobile Safari',
'Silk-Accelerated',
'Firefox Mobile',
'Kindle',
'Silk',
'Opera Mobi',
'Chrome Mobile',
'UC Browser',
'Mobile Safari',
'Mobile Chrome',
];
// 遍历移动端设备列表,检查用户代理字符串中是否包含这些关键词
for (let i = 0; i < mobileDevices.length; i++) {
if (ua.indexOf(mobileDevices[i]) !== -1) {
return true; // 是移动端
}
}
return false;
}
// 时间戳 格式化为 时分秒(00: 00: 00)
export const formatDuring = (time) => {
......
......@@ -74,7 +74,7 @@
<script>
import { getBanner, getRequestParm } from '@/api/entitlement';
import { uploadPointData } from '@/api/question';
import { isWeixin } from '@/utils/index';
import { isWeixin, isMobile } from '@/utils/index';
export default {
data() {
......@@ -104,7 +104,20 @@ export default {
};
},
created() {
if (!isWeixin()) {
console.log('🚀 isMobile', isMobile());
console.log('🚀 isWeixin', isWeixin());
if (!isMobile()) {
this.$dialog
.alert({
type: 'warning',
title: '提示',
message: '请使用手机微信打开!',
confirmButtonText: '我知道了',
})
.then(() => {
// on close
});
} else if (!isWeixin()) {
this.$dialog
.alert({
type: 'warning',
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册