<script>
  import store from '@/store'
  import socketStore from '@/uni_modules/vrapile-im/store'
  import { getToken } from '@/utils/token'
  import { getNodeId } from '@/utils/nodeId'
  export default {
    globalData: {    
      appId: "nine-demo-im", 
      // 操作系统
      os: "android", 
      // 版本号
      version: "1.0.0", 
      // 手机信息
      systemInfo: {}, 
      // 消息页所在索引
      chatIndex: 0, 
    },
    // http://localhost:38081/udemo/im/#/?shopId=001&seatId=001
    onLaunch(options) {
      this.initSysConfig(options);
    },
    onShow() {
      this.initWebSocket();
    },
    onHide() {
    },
    methods: {
      initSysConfig(options) {
        // 获取手机信息
        this.globalData.systemInfo = uni.getDeviceInfo()
        this.globalData.os = this.globalData.systemInfo.platform
        // #ifdef APP-PLUS
        plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
          if(wgtinfo.version){
            this.globalData.version = wgtinfo.version;
          }else{
            this.globalData.version = plus.runtime.version;
          }
        });
        // #endif
        
        // 终端和节点
        this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_other";
        // #ifdef MP-WEIXIN
        this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_wx";
        // #endif
        // #ifdef H5
        this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_h5";
        // #endif
        // #ifdef APP-PLUS
        this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_app";
        // #endif
        getNodeId();
        
        // 扫码进来携带的数据
        if(options && options.query && options.query.invitee){
          this.globalData.invitee = options.query.invitee;
        }
      },
      initWebSocket(){
        if(getToken()){
          socketStore.dispatch('GetChatList').then(res => {
            socketStore.dispatch('ConnSocket');
          });
        }
      }
    }
  }
</script>

<style lang="scss">
html, body, #app{
  height: 100%;
  background-color: #f1f1f1;
}
.nine-content-001{
  padding: 0;
  margin: 0;
  width: 750rpx;
  height: calc(100vh - 0px);
  background-color: #f1f1f1;
  display: flex;
  flex-direction: column;
}
.nine-content-002{
  padding: 0;
  margin: 0;
  width: 750rpx;
  height: calc(100vh - 50px);
  /* #ifndef H5 */
  height: calc(100vh - 0px);
  /* #endif */
  background-color: #f1f1f1;
  display: flex;
  flex-direction: column;
}
// uni.showModal 左对齐
.uni-modal__bd{
  text-align: left
}

@import './static/style/nine-image-001.scss';
@import './static/style/nine-btn-001.scss';
@import './static/style/nine-list-001.scss';
@import './static/style/nine-nav-001.scss';
@import './static/style/nine-base-002.scss';
@import './static/style/nine-base-001.scss';
</style>
