banner.blade.php 2.52 KB
@extends('layout')

@section('title', $name)

@pushonce('style')
    <style>
        img {
            height: auto !important;
            max-width: 100%;
            object-fit: contain;
        }

        video {
            max-width: 100%;
            height: auto !important;
            display: block;
            margin: 0 auto;
        }
    </style>
@endpushonce

@section('body')
    <body style="padding: 10px;font-size: 14px">
    @if(is_string($content))
        {!! $content !!}
    @endif
    </body>
@endsection

@pushonce('script')
    <script type="text/javascript" src="https://hising-cdn.hikoon.com/vendor/jweixin-1.3.2.js" defer></script>
    <script lang="ts">
        const isInWechatMP = () => {
            return (navigator.userAgent.match(/micromessenger/i) && navigator.userAgent.match(/miniprogram/i)) || window.__wxjs_environment === 'miniprogram';
        };

        const isAndroid = () => {
            return (navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1) && window.android?.invokeFun;
        }

        const isIos = () => {
            return (!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) && window.webkit?.messageHandlers?.invokeFun
        }

        function toShow(type, id) {
            if (isInWechatMP()) {
                return wx.miniProgram.navigateTo({url: `/packageApp/pages/h5/index?type=${type}&id=${id}`});
            }
            if (isAndroid()) {
                return window.android.invokeFun(type, id)
            }
            if (isIos()) {
                return window.webkit.messageHandlers.invokeFun.postMessage({type, id});
            }
        }

        [].forEach.call(document.querySelectorAll('video'), function (el) {
            el.setAttribute('playsinline', true);
            el.setAttribute('webkit-playsinline', true);
        });

        [].forEach.call(document.querySelectorAll('span[data-w-e-type="user-card"]'), function (el) {
            el.addEventListener('click', (e) => toShow('user', e.currentTarget.getAttribute('data-id')));
        });

        [].forEach.call(document.querySelectorAll('span[data-w-e-type="project-card"]'), function (el) {
            el.addEventListener('click', (e) => toShow('project', e.currentTarget.getAttribute('data-id')));
        });

        [].forEach.call(document.querySelectorAll('span[data-w-e-type="activity-card"]'), function (el) {
            el.addEventListener('click', (e) => toShow('activity', e.currentTarget.getAttribute('data-id')));
        });
    </script>
@endpushonce