<script>
import { genTestUserSig, aegisID } from './debug/index.js'
import { TIM, TIMUploadPlugin, Aegis } from './debug/tim.js'
import UseSetCidHandler from '@/hooks/useSetCidHandler'
import { getLocationHandler } from './utils/getLocation'
import { getDeviceType } from './utils/getDeviceType'
const aegis = new Aegis({
  id: aegisID, // 项目key
  reportApiSpeed: true // 接口测速
})
uni.$aegis = aegis
const config = {
  userID: uni.getStorageSync('ImUserId'), //User ID
  SDKAppID: 1600012854, //
  secretKey: '2e7e8e1ce49fa0586060df9846cc449d954b9fd923912f50ee8b138745500a04' //
}
const userSig = genTestUserSig(config).userSig
uni.$chat_SDKAppID = config.SDKAppID
uni.$chat_userID = config.userID
uni.$chat_userSig = userSig
// 创建 sdk 实例
uni.$TUIKit = TIM.create({
  SDKAppID: uni.$chat_SDKAppID
})
uni.$TIM = TIM
// 注册文件上传插件
uni.$TUIKit.registerPlugin({
  'tim-upload-plugin': TIMUploadPlugin
})
// #ifdef APP-PLUS
const TUICallKit = uni.requireNativePlugin('TencentCloud-TUICallKit')
console.warn(TUICallKit, 'TUICallKit | ok') // 本地日志
uni.$TUICallKit = TUICallKit // 全局引入
// #endif
export default {
  onLaunch: function () {
    getDeviceType()
    // this.bindTIMEvent()
    // this.login()
    // #ifdef APP-PLUS
    // 获取cid信息
    // 监听消息推送
    // uni.onPushMessage(pushMessageCallback)
    // #endif
    // getLocationHandler()

    uni.onPushMessage(res => {
      console.log('收到推送消息------------------------------', res)
      const { data } = res
      // 创建通知栏消息,并监听到推送时显示
      if (res.type === 'receive') {
        uni.createPushMessage({
          title: data.title,
          content: data.content,
          payload: data.payload,
          // sound: "system",
          cover: false
        })
      } else if (res.type === 'click') {
        // click 点击状态栏的消息时,进行跳转页面
        console.log(res)
        uni.navigateTo({
          url: '/pages2/order/index?orderState=0&subOrderState=1'
        })
      }
    })
  },
  methods: {}
}
</script>
<style lang="scss">
@import 'uview-plus/index.scss';
@import '@/static/css/common.scss';
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
</style>