index.js 955 字节
Newer Older
M
MicroMilo 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	
	const db = uniCloud.database();
	const collection = db.collection('mustgo-user');
	
	let res = await collection.where({
		phone_num: event.phone
	}).get()
	console.log(res.data[0])
	
	if (res.data[0]["password"] == event.password)
		return {
			code: 200,
			message: "登录成功",
			data: {
M
MicroMilo 已提交
19 20
				userId: res.data[0]["_id"],
				name: res.data[0]["name"],
M
MicroMilo 已提交
21
				icon: res.data[0]["icon"],
M
MicroMilo 已提交
22 23 24 25 26 27 28
				gender: res.data[0]["gender"],
				phone_num: res.data[0]["phone_num"],
				team_id: res.data[0]["team_id"],
				school: res.data[0]["school"],
				type: res.data[0]["type"],
				total_running_distance: res.data[0]["total_running_distance"],
				total_walking_distance: res.data[0]["total_walking_distance"]
M
MicroMilo 已提交
29 30 31 32 33 34 35 36 37 38 39
			}
		}
	
	//返回数据给客户端
	return {
			code: 400,
			message: "用户名或密码错误",
			data: {
			}
		}
};