class RestApi {
	//用户数据示例
	users = [{
			id: '00482',
			name: '李万涛',
			avatar: 'https://zhengda.oss-cn-chengdu.aliyuncs.com/uploads/20230417/GC5dqg8fUbgCqud5UHnKHQ5LjWymT7A0bq10XXTg.png',
			phone: '15609038521',
		},
		{
			id: '00483',
			name: '李万涛2',
			avatar: 'https://zhengda.oss-cn-chengdu.aliyuncs.com/uploads/20230319/bp8rBJyVqPWVpNaLpjLSoStk4JGmKi36tn69u8yk.png',
			phone: '18884559619',
		},
	];
	//群数据示例
	// groups = [{
	// 		id: 'group-a42b-47b2-bb1e-15e0f5f9a19a',
	// 		name: '家明交流群1',
	// 		avatar: '/static/images/wx.png',
	// 		userList: [{
	// 				id: '00482',
	// 				name: '李万涛',
	// 				avatar: 'https://zhengda.oss-cn-chengdu.aliyuncs.com/uploads/20230417/GC5dqg8fUbgCqud5UHnKHQ5LjWymT7A0bq10XXTg.png',
	// 				phone: '15609038521',
	// 			},
	// 			{
	// 				id: '00483',
	// 				name: '李万涛2',
	// 				avatar: 'https://zhengda.oss-cn-chengdu.aliyuncs.com/uploads/20230319/bp8rBJyVqPWVpNaLpjLSoStk4JGmKi36tn69u8yk.png',
	// 				phone: '18884559619',
	// 			}
	// 		],
	// 	},
	// 	{
	// 		id: 'group-4b01-4590-bdba-6586d7617f95',
	// 		name: '家明交流群2',
	// 		avatar: '/static/images/uniapp.png',
	// 		userList: [{
	// 				id: '00482',
	// 				name: '李万涛',
	// 				avatar: 'https://zhengda.oss-cn-chengdu.aliyuncs.com/uploads/20230417/GC5dqg8fUbgCqud5UHnKHQ5LjWymT7A0bq10XXTg.png',
	// 				phone: '15609038521',
	// 			},
	// 			{
	// 				id: '00483',
	// 				name: '李万涛2',
	// 				avatar: 'https://zhengda.oss-cn-chengdu.aliyuncs.com/uploads/20230319/bp8rBJyVqPWVpNaLpjLSoStk4JGmKi36tn69u8yk.png',
	// 				phone: '18884559619',
	// 			}
	// 		]
	// 	}
	// ];

	groups = [{
			id: 'group-a42b-47b2-bb1e-15e0f5f9a19a',
			name: '家明交流群1',
			avatar: '/static/images/wx.png',
			userList: [
				'00482',
				'00483'
			],
		},
		{
			id: 'group-4b01-4590-bdba-6586d7617f95',
			name: '家明交流群2',
			avatar: '/static/images/uniapp.png',
			userList: [
				'00482',
				'00483'
			],
		},
		{
			id: 'group-dbb0-4bc9-99c6-fa77b9eb763f',
			name: '家明交流群3',
			avatar: '/static/images/goeasy.jpeg',
			userList: [
				'00482',
				'00483'
			],
		}
	];
	// 订单
	// orders = [{
	// 		id: '252364104325',
	// 		url: '/static/images/goods1-1.jpg',
	// 		name: '青桔柠檬气泡美式',
	// 		price: '￥23',
	// 		count: 1
	// 	},
	// 	{
	// 		id: '251662058022',
	// 		url: '/static/images/goods1-2.jpg',
	// 		name: '咸柠七',
	// 		price: '￥8',
	// 		count: 2
	// 	},
	// 	{
	// 		id: '250676186141',
	// 		url: '/static/images/goods1-3.jpg',
	// 		name: '黑糖波波鲜奶茶',
	// 		price: '￥12',
	// 		count: 1
	// 	}
	// ];

	findUsers() {
		return this.users;
	};

	findFriends(user) {
		return this.users.filter((v) => v.id !== user.id);
	}

	findGroups(user) {
		return this.groups.filter((v) => v.userList.find((id) => id === user.id));
	}
	findAllGroups(user) {
		return this.groups;
	}

	findUser(username, password) {
		return this.users.find((user) => user.name === username && user.password === password);
	}

	getOrderList() {
		return this.orders;
	}

	findGroupById(groupId) {
		return this.groups.find((group) => group.id === groupId);
	}

	findUserById(userId) {
		return this.users.find((user) => user.id === userId);
	}

	findGroupMembers(groupId) {
		let group = this.groups.find(v => v.id === groupId);
		let userIds = group.userList
		let members = []
		this.users.forEach((item, index) => {
			if (userIds.includes(item.id)) {
				members.push(item)
			}
		})
		return members;
	}
}

export default new RestApi();