123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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();
|