// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj // jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129 module.exports = { _before: function () { // 通用预处理器 }, /** * method1方法描述 * @param {string} param1 参数1描述 * @returns {object} 返回值描述 */ /* method1(param1) { // 参数校验,如无参数则不需要 if (!param1) { return { errCode: 'PARAM_IS_NULL', errMsg: '参数不能为空' } } // 业务逻辑 // 返回结果 return { param1 //请根据实际需要返回值 } } */ information(userId){ const db = uniCloud.database(); const user_table = db.collection('mustgo-user') const team_table = db.collection('mustgo-team') let res = await user_table.where({ _id:userId }).get() var team = "" if (res.affectedDocs == 1) { var team_id = res.data[0]["team_id"] if(team_id != null){ let res2 = await team_table.where({ _id: res.data[0]["team_id"] }).get() if(res2.affectedDocs == 1){ team = res2.data[0]["name"] } } return { code: 200, message: "成功返回用户信息", data: { "icon": res.data[0]["icon"], "username": res.data[0]["name"], "school": res.data[0]["school"], "team": team } } } return { "code": 400, "message": "返回用户信息失败", "data": {} } }, }