report.uvue 3.3 KB
Newer Older
1 2 3 4
<template>
  <!-- #ifdef APP -->
  <scroll-view style="flex:1">
  <!-- #endif -->
M
mehaotian 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
    <page-head title="report"></page-head>

    <view class="tips">
      <view class="tips-title">调用信息:</view>
      <view class="tips-content">{{msg}}</view>
    </view>
    <view class="page">

      <button class="normal-button" type="default" @click="handleAppLaunch">
        模拟应用启动
      </button>
      <button class="normal-button" type="default" @click="handleAppHide">
        模拟应用切入后台
      </button>
      <button class="normal-button" type="default" @click="handleAppShow">
        模拟应用切入前台
      </button>
      <button class="normal-button" type="default" @click="handleAppError">
        模拟应用错误
      </button>
      <text class="instructions">
        当前页面调用API均为模拟,请查看文档,在特定场景下使用以上 API。请在main.uts中设置统计debug配置为true,并点击按钮查控制台输出。
      </text>
    </view>
29 30 31 32 33 34 35 36 37 38

  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>

<script>
  export default {
    data() {
      return {
M
mehaotian 已提交
39
        msg: '点击按钮,测试上报'
40 41 42
      }
    },
    methods: {
M
mehaotian 已提交
43 44
      handleAppLaunch() {
        const options = uni.getLaunchOptionsSync()
45 46 47
        uni.report({
          name: 'uni-app-launch',
          options: options,
M
mehaotian 已提交
48 49 50 51 52
          success:(res)=> {
            this.msg = 'onLaunch --> ' + res.errMsg
            console.log(res);
          }, fail:(err)=>  {
            this.msg = 'onLaunch --> ' + err.errMsg
53 54 55
            console.log(err);
          }
        })
M
mehaotian 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
      },
      handleAppHide() {
        uni.report({
          name: 'uni-app-hide',
          success:(res)=> {
            this.msg = 'onAppHide --> ' + res.errMsg
            console.log(res);
          }, fail:(err)=>  {
            this.msg = 'onAppHide --> ' + err.errMsg
            console.log(err);
          }
        })
      },
      handleAppShow() {
        // const options = uni.getLaunchOptionsSync()
        uni.report({
          name: 'uni-app-show',
          success:(res)=> {
            this.msg = 'onAppShow --> ' + res.errMsg
            console.log(res);
          }, fail:(err)=>  {
            this.msg = 'onAppShow --> ' + err.errMsg
            console.log(err);
          }
        })
      },
      handleAppError() {
        const errmsg = '测试错误'
        uni.report({
          name: 'uni-app-error',
          options: errmsg,
          success:(res)=> {
            this.msg = 'onAppError --> ' + res.errMsg
            console.log(res);
          }, fail:(err)=>  {
            this.msg = 'onAppError --> ' + err.errMsg
            console.log(err);
          }
        })
      },
96 97 98 99 100
    }
  }
</script>

<style>
M
mehaotian 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
  .page {
    padding: 15px;
  }

  .tips {
    margin: 15px;
    padding: 15px;
    background-color: #f5f5f5;
    font-size: 14px;
    text-align: center;
  }

  .tips-title {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
  }
  .tips-content {
    font-size: 14px;
    color: #999;
  }

123 124
  .normal-button {
    width: 100%;
M
mehaotian 已提交
125
    margin-bottom: 10px;
126 127 128 129 130 131 132
  }

  .instructions {
    margin-top: 10px;
    margin-left: 10px;
    margin-right: 10px;
    background-color: #eee;
M
mehaotian 已提交
133 134
    font-size: 12px;
    color: #999;
135 136
  }
</style>