import 'package:chat/data/UserData.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:chat/utils/TokenMgr.dart';
import 'package:dio/dio.dart';

class AnalyzeUtils {
  //访问页面
  static vistPage(int pageIndex) {
    print('vistPage');
  }

  //聊天时长
  static Future<bool> commitChatDuration(int startTime, int endTime) async {
    print('commitChatDuration ${endTime - startTime}');

    Map data = {
      "userId": UserData().basicInfo.userId,
    };
    data['sign'] = TokenMgr().getSign(data);

    data["startTime"] = startTime;
    data["endTime"] = endTime;

    Response res = await HttpUtil().post('duration/user/insert', data: data);
    if (res == null) {
      return false;
    }
    Map resData = res.data;
    if (resData['code'] == 0) {
      print('提交时长${endTime - startTime}秒成功');
      return true;
    }

    return false;
  }
}
