user

user object

更新日期:4.25 19:26

更新日期:4.27 17.00

更新日期:5.10 16.12

  let User = {
   // '_id':'x',//String database main key
    'wechatopenid':'x'//
    'nickName':'x', // String every User need has unique nickName wechat name
    'avatarUrl':'x',
    'name':'X',//String real name
    'studentId':'',//String studient id
    'gender':'male|famale|*',//String
    'tasks':{ //Object the tasks which containd the user
      'joining':[task._id]//Strng Array the tasl._id that the user is joining the task and task has not verifed
      'doing':[task._id],//String Array the task._id that the user is doing right now
      'finished':[task._id],//String Array the task._id that the user finished

      'publishing':[task._id],// String Array the tasks._id that the publihser published
      'verifyed':[task._id]//Strng Array the tasl._id that the publish task has  verifed not end
      'ended':[task._id]//Strng Array the tasl._id that the publish task has  verifed and end
    },
    'balance':21,//Number free money coin
    'credit':100,//诚信度
    'isVerified': true,
    'personalStatement':'Hello World',
  }

  let user = {
   // '_id':'4565465',//String database main key
    'wechatopenid':'0001',
    'nickName':'蚊子', // String every User need has unique nickName wechat name
    'name':'庄蚊子',//String real name
    'studentId':'16340222',//String studient id
    'gender':'male',//String
    'tasks':{ //Object the tasks which containd the user
      'published':['2134574','56454'],// String Array the tasks that the user published
      'finished':['123','213','1231'],//String Array the tasks that the user finished
      'doing':['2134','411'],//String Array the tasks that the user is doing right now
    },
    'balance':21,//Number free money coin
    'credit':100
    'isVerified': True,
    'personalStatement':'Hello World'
  }

user methods

api
  .insertOneUser(user)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .queryOneById("users", user._id)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .updateOneById("users", user._id, { balance: 212 })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });

task object

  let Task = {
    //'_id':'x',//String database main key
    'title':'x', // String every task need a name Title
    'avatarId':'',//upload the avatar to server and get an id from the callback
    'type':'学习|生活|娱乐|',//String task type
    'description':'XXX',//String task detail description
    'state':'publishing|verifying|doing|finished',//String task state 任务发布中,任务确认中,任务执行中,任务完成
    'maxJoiner':1,//Number Max Nubmer of joiners
    'joiners':['x'],//String Array the joiners _id array
    'location':'x'
    'publish':{
      'publisher':'X',//String user._id
      'beginTime':Date,
      'endTime':Date,
    }
    'payment':200,
    'work':{
       'beginTime':Date,
       'endTime':Date,
    }
  'isQuestionnaire':true,
    'questionnaireId':X,
  }

  let task ={
        //'_id':'21231',//String database main key
    'title':'唱歌', // String every task need a name Title
    'avatarId':'../',//upload the avatar to server and get an id from the callback
    'type':'娱乐', //String task type
    'description':'唱一首情歌',//String task detail description
    'state':'publishing',//String task state 任务发布中,任务确认中,任务执行中,任务完成
    'maxJoiner':2,//Number Max Nubmer of joiners
    'joiners':[''],//String Array the joiners _id array
    'location':'广州中山大学'
    'publish':{
      'publisher':'X',//String user._id
      'beginTime':Date,
      'endTime':Date,
    }
    'payment':200,
    'work':{
       'beginTime':Date,
       'endTime':Date,
    }


  }

task methods

api.publishOneTask(task).then((result)=>{
  console.log(result)
}).catch((error)=>{
  console.warn(error)
})

```javascript
api
  .insertOneTask(task)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .updateOneById("tasks", task._id, {
    payment: 256
  })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .joinOneTask(task, user._id)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .verifyOneTask(task, user._id)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .verifyOneTask(task, user._id)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .queryOneById("tasks", task._id)
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .querySomeByModel("users", {
    'wechatopenid':
  })
  .then(result => {
    console.log(result);

  })
  .catch(error => {
    console.warn(error);
  });
api
  .querySomeByModel("tasks", {
    publish: {
      publisher: PublisherId
    }
  })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .querySomeByModel("tasks", {
    state: "finished",
    publish: {
      publisher: PublisherId
    }
  })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .querySomeByModel("tasks", {
    state: "doing",
    publish: {
      publisher: PublisherId
    }
  })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });

api
  .querySomeByModel("tasks", {
    state: "publishing",
    publish: {
      publisher: PublisherId
    }
  })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });
api
  .querySomeByModel("tasks", {
    state: "publishing"
  })
  .then(result => {
    console.log(result);
  })
  .catch(error => {
    console.warn(error);
  });

questionnaires object

  let task = {
    'title':'x', // String every task need a name Title
    'avatarId':'',//upload the avatar to server and get an id from the callback
    'type':'学习|生活|娱乐|',//String task type
    'description':'XXX',//String task detail description
    'state':'publishing|verifying|doing|finished',//String task state 任务发布中,任务确认中,任务执行中,任务完成
    'maxJoiner':1,//Number Max Nubmer of joiners
    'joiners':['x'],//String Array the joiners _id array
    'location':'x'
    'publish':{
      'publisher':'X',//String user._id
      'beginTime':Date,
      'endTime':Date,
    }
    'payment':200,
    'work':{
       'beginTime':Date,
       'endTime':Date,
    },
    'isQuestionnaire':true,
    'questionnaireId':X,
  }

  let questionnaire ={
    //'_id'
    'title':xx,
    'description':xx,
    'maxCount':50,
    'template':[
      {
        'type':Input,
        'description':'你的学号',
        'content':'',
      },
      {'type':SingleSelect,
      'description':'是否喜欢xx',
      'content':{
        '是':false,
        '否':false,
      }
      },
      {
        'type':MultiSelect,
        'description':'以下哪一个代表你现在的心情',
        'content':{
          '开心':false,
          '沮丧':false,
          '感激':false
        }
      }
    ],
    'results':[
      [
         {
        'type':Input,
        'description':'你的学号',
        'content':'16666',
      },
      {'type':SingleSelect,
      'description':'是否喜欢xx',
      'content':{
        '是':true,
        '否':false,
      }
      },
      {
        'type':MultiSelect,
        'description':'以下哪一个代表你现在的心情',
        'content':{
          '开心':true,
          '沮丧':false,
          '感激':true
        }
      }
      ],[
         {
        'type':Input,
        'description':'你的学号',
        'content':'12333',
      },
      {'type':SingleSelect,
      'description':'是否喜欢xx',
      'content':{
        '是':false,
        '否':true,
      }
      },
      {
        'type':MultiSelect,
        'description':'以下哪一个代表你现在的心情',
        'content':{
          '开心':false,
          '沮丧':true,
          '感激':false
        }
      }
      ]
    ]
  }

tool methods

api
  .getOpenId()
  .then(res => {
    console.log(res);

    res 的数据结构 {
          result: xxxx,
          msg: "get open id :ok",
          errMsg: null
        };

  })
  .catch(rej => {
    console.warn(rej);
    
 rej 的数据结构 {
          result: null,
          msg: "get open id :error",
          errMsg: xxx
        };
  });