|
@@ -0,0 +1,171 @@
|
|
|
+<template>
|
|
|
+ <safe-area class="page">
|
|
|
+ <view class="body">
|
|
|
+ <img id='loading' class="img" src="../../image/loading.gif" />
|
|
|
+ </view>
|
|
|
+ </safe-area>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ name: 'main',
|
|
|
+ apiready() {
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ api.openFrame({
|
|
|
+ name: 'main',
|
|
|
+ url: 'https://m.alipearlhair.com',
|
|
|
+ rect: {
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ w: 'auto',
|
|
|
+ h: 'auto'
|
|
|
+ },
|
|
|
+ useWKWebView: true,
|
|
|
+ historyGestureEnabled: true,
|
|
|
+ bounces: false,
|
|
|
+ progress:{
|
|
|
+ type:'page'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ api.setStatusBarStyle({
|
|
|
+ style: 'light'
|
|
|
+ });
|
|
|
+
|
|
|
+ api.setFrameClient({
|
|
|
+ frameName:'main'
|
|
|
+ },function(ret){
|
|
|
+ that.onBrowserStateChange(ret);
|
|
|
+ });
|
|
|
+ this.removeLogic();
|
|
|
+ api.addEventListener({
|
|
|
+ name: 'keyback'
|
|
|
+ }, function(ret, err){
|
|
|
+ api.historyBack({
|
|
|
+ frameName:'main'
|
|
|
+ },function(ret,err){
|
|
|
+ if(!ret.status){
|
|
|
+ api.closeWidget();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.removeLogic();
|
|
|
+
|
|
|
+ // this.googlePushInit();
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ msg: "Hello APICloud",
|
|
|
+ launchRemoved: false,
|
|
|
+ loadingRemoved: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ onBrowserStateChange(ret){
|
|
|
+ if(0 == ret.state){//开始加载
|
|
|
+ if(!this.launchRemoved){
|
|
|
+ this.launchRemoved = true;
|
|
|
+ this.removeLaunch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(2 == ret.state){
|
|
|
+ if(!this.loadingRemoved){
|
|
|
+ this.loadingRemoved = true;
|
|
|
+ document.getElementById('loading').style.display = 'none';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ removeLogic(){
|
|
|
+ var that = this;
|
|
|
+ setTimeout(function(){
|
|
|
+ if(!that.launchRemoved){
|
|
|
+ that.launchRemoved = true;
|
|
|
+ that.removeLaunch();
|
|
|
+ }
|
|
|
+ }, 3000);
|
|
|
+ },
|
|
|
+
|
|
|
+ removeLaunch(){
|
|
|
+ // 移除启动图
|
|
|
+ api.removeLaunchView({
|
|
|
+ animation:{
|
|
|
+ type:"fade",
|
|
|
+ subType:"from_right",
|
|
|
+ duration:300
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*
|
|
|
+ // google推送
|
|
|
+ googlePushInit() {
|
|
|
+ var googlePush = api.require('googlePush');
|
|
|
+ // 初始化
|
|
|
+ googlePush.initFcm(function(ret, err) {
|
|
|
+ console.log('---initFcm satrt---');
|
|
|
+ console.log(JSON.stringify(ret));
|
|
|
+ console.log(JSON.stringify(err));
|
|
|
+ console.log('---initFcm end---');
|
|
|
+ // 获取token
|
|
|
+ googlePush.registerToken(function(ret, err){
|
|
|
+ console.log('---registerToken satrt---');
|
|
|
+ console.log(JSON.stringify(ret));
|
|
|
+ console.log(JSON.stringify(err));
|
|
|
+ console.log('---registerToken end---');
|
|
|
+ });
|
|
|
+ // 收到消息时会触发
|
|
|
+ googlePush.addOnMessageLisener(function(ret){
|
|
|
+ console.log('---addOnMessageLisener satrt---');
|
|
|
+ console.log(JSON.stringify(ret));
|
|
|
+ console.log('---addOnMessageLisener end---');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 监听通知栏消息被点击
|
|
|
+ api.addEventListener({
|
|
|
+ name:'appintent'
|
|
|
+ },function(ret,err){
|
|
|
+ console.log('---appintent satrt---');
|
|
|
+ console.log(JSON.stringify(ret));
|
|
|
+ console.log(JSON.stringify(err));
|
|
|
+ console.log('---appintent end---');
|
|
|
+ var appParam = ret.appParam;
|
|
|
+ if(api.systemType == 'ios'){
|
|
|
+ var iosUrl = ret.iosUrl;
|
|
|
+ } else {
|
|
|
+ var sourceAppId = ret.sourceAppId;
|
|
|
+ console.log(JSON.stringify(appParam));
|
|
|
+ if(appParam.url) {
|
|
|
+ api.openWin({
|
|
|
+ name: 'WestKiss Sale',
|
|
|
+ url: appParam.url,
|
|
|
+ pageParam: {
|
|
|
+ name: 'test'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ */
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+.page {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background: #fff;
|
|
|
+ display:flex;
|
|
|
+ justify-content:center;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+.body{
|
|
|
+ position: relative;
|
|
|
+}
|
|
|
+.img{
|
|
|
+ display:block;
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|