123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- // 在线状态
- export const getOnlineStateFromSvr = (userID) =>
- uni.$u?.http.post(
- "/user/get_users_status",
- JSON.stringify({
- userID,
- userIDs: [userID],
- }),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- token: uni.getStorageSync("IMToken"),
- },
- }
- );
- export const getRtcInvitaion = () =>
- uni.$u?.http.post(
- "/third/get_rtc_invitation_start_app",
- JSON.stringify({
- operationID: uuidv4(),
- }),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- token: uni.getStorageSync("IMToken"),
- },
- },
- );
- export const subUserOnlineStatus = (userID, targetID) =>
- uni.$u?.http.post(
- "/user/subscribe_users_status",
- JSON.stringify({
- userID,
- userIDs: [targetID],
- genre: 1,
- }),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- token: uni.getStorageSync("IMToken"),
- },
- }
- );
- export const unSubUserOnlineStatus = (userID, targetID) =>
- uni.$u?.http.post(
- "/user/unsubscribe_users_status",
- JSON.stringify({
- userID,
- userIDs: [targetID],
- genre: 2,
- }),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- token: uni.getStorageSync("IMToken"),
- },
- },
- );
-
- //获取超级管理员token
- export const getImAdminToken = () =>
- uni.$u?.http.post(
- "/auth/get_admin_token",
- JSON.stringify({ secret:"openIM123",userID: "imAdmin"}),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- //operationID: Date.now()
- }
- }
- );
-
- //注册IM用户
- export const registerImUser = (data) =>
- uni.$u?.http.post(
- "/user/user_register",
- data,
- {
- custom: {
- isIMApi: true,
- },
- header: {
- //operationID: Date.now(),
- token:uni.getStorageSync("IMAdminToken"),
- },
- }
- );
-
-
- //修改IM用户
- export const updateImUser = (data) =>
- uni.$u?.http.post(
- "/user/update_user_info_ex",
- data,
- {
- custom: {
- isIMApi: true,
- },
- header: {
- //operationID: Date.now(),
- token:uni.getStorageSync("IMAdminToken"),
- },
- }
- );
-
-
-
-
- //获取用户token
- export const getImUserToken = (userID) =>
- uni.$u?.http.post(
- "/auth/get_user_token",
- JSON.stringify(
- {"platformID": getRuntimePlatform(),"userID": userID}
- ),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- //operationID: Date.now(),
- token:uni.getStorageSync("IMAdminToken")
- },
- }
- );
-
-
- //查询用户是否注册
- export const imAccountCheck = (userID) =>
- uni.$u?.http.post(
- "/user/account_check",
- JSON.stringify({
- checkUserIDs:[ userID ]
- }),
- {
- custom: {
- isIMApi: true,
- },
- header: {
- //operationID: Date.now(),
- token:uni.getStorageSync("IMAdminToken")
- },
- }
- );
-
-
-
- function getRuntimePlatform() {
- const systemInfo = uni.getSystemInfoSync();
- const compilePlatform = process.env.UNI_PLATFORM;
- //1:iOS,2:Android,3:Windows,4:OSX,5:WEB,6:小程序,7:linux,8:AndroidPad,9:IPad,10:Admin
- let platformType=6;
- // H5 环境
- if (compilePlatform === 'h5') platformType= 5;
-
- // 小程序环境
- if (compilePlatform.startsWith('mp-')) {
- const mpType = compilePlatform.split('-')[1]; // 如 weixin/alipay
- platformType=6;
- // return `小程序(${mpType})- ${systemInfo.platform}`;
- }
-
- // App 环境
- if (compilePlatform === 'app-plus') {
- if(systemInfo.platform.toLowerCase() === 'android'){
- platformType=2;
- }
- if(systemInfo.platform.toLowerCase() === 'ios'){
- platformType=1;
- }
- }
-
- return platformType;
- }
|