'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) if (res.affectedDocs > 0) { return { code: 400, message: "手机号重复", data: { } } } res = await collection.add({ name: event.username, gender: event.gender, password: event.password, phone_num: event.phone, team_id: "", icon: "https://mp-6f6feaec-a026-4402-8e8d-18f7572890da.cdn.bspapp.com/cloudstorage/433d3cc6-4b8f-475c-83e1-35acc747cab2.jpg", school: event.school, type: "644a64c228064a7587cd79bf", total_running_distance: 0, total_walking_distance: 0 }) console.log(res) if (res.id.length > 0) return { code: 200, message: "注册成功", data: { } } //返回数据给客户端 return { code: 400, message: "手机号重复", data: { } } };