提交 f323f573 编写于 作者: M MicroMilo

Merge branch 'backend' of https://gitcode.net/qq_50679803/great-teamwork into backend

......@@ -5,7 +5,7 @@ const validator = {
"start_date": {
"rules": [
{
"format": "string"
"format": "datetime"
}
],
"title": "开始时间",
......
......@@ -2,22 +2,30 @@
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="start_date" label="开始时间">
<uni-easyinput placeholder="运动开始时间" v-model="formData.start_date"></uni-easyinput>
<uni-datetime-picker
type="datetime"
v-model="formData.start_date"
/>
</uni-forms-item>
<uni-forms-item name="duration" label="持续时间">
<uni-easyinput placeholder="运动持续时间" type="number" v-model="formData.duration"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动持续时间" type="number" v-model="formData.duration"></uni-easyinput> -->
<uni-number-box :value="0" :step="1" max="100000" value="100000" v-model="formData.duration" />
</uni-forms-item>
<uni-forms-item name="feelings" label="感受">
<uni-easyinput placeholder="运动感受(good/normal/bad)" v-model="formData.feelings"/>
<uni-data-select v-model="formData.feelings"
:localdata="feelings" >
</uni-data-select>
</uni-forms-item>
<uni-forms-item name="owner_id" label="用户id">
<uni-easyinput placeholder="用户id" v-model="formData.owner_id"></uni-easyinput>
<uni-forms-item name="owner_id" label="用户">
<uni-easyinput placeholder="用户id" v-model="formData.owner_id" disabled></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="distance" label="距离">
<uni-easyinput placeholder="运动距离" type="number" v-model="formData.distance"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动距离" type="number" v-model="formData.distance"></uni-easyinput> -->
<uni-number-box :value="0.0" :step="0.01" max="100000.00" value="100000.00" v-model="formData.distance"/>
</uni-forms-item>
<uni-forms-item name="pace" label="配速">
<uni-easyinput placeholder="运动配速" type="number" v-model="formData.pace"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动配速" type="number" v-model="formData.pace"></uni-easyinput> -->
<uni-number-box :value="0.0" :step="0.01" max="100000.00" value="100000.00" v-model="formData.pace" />
</uni-forms-item>
<!-- <uni-forms-item name="path_line" label="路线">
<uni-data-checkbox :multiple="true" v-model="formData.path_line"></uni-data-checkbox>
......@@ -74,15 +82,22 @@
formData,
formOptions: {},
feelings: [
"good",
"normal",
"bad"
{value:'good',text:'good'},
{value:'normal',text:'normal'},
{value:'bad',text:'bad'},
],
rules: {
...getValidator(Object.keys(formData))
}
}
},
methods: {
change(e) {
console.log("e:",e);
}
},
onLoad(e) {
if (e.id) {
const id = e.id
......
......@@ -2,22 +2,31 @@
<view class="uni-container">
<uni-forms ref="form" :model="formData" validateTrigger="bind">
<uni-forms-item name="start_date" label="开始时间">
<uni-easyinput placeholder="运动开始时间" v-model="formData.start_date"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动开始时间" v-model="formData.start_date"></uni-easyinput> -->
<uni-datetime-picker
type="datetime"
v-model="formData.start_date"
/>
</uni-forms-item>
<uni-forms-item name="duration" label="持续时间">
<uni-easyinput placeholder="运动持续时间" type="number" v-model="formData.duration"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动持续时间" type="number" v-model="formData.duration"></uni-easyinput> -->
<uni-number-box :value="0" :step="1" max="100000" value="100000" v-model="formData.duration" />
</uni-forms-item>
<uni-forms-item name="feelings" label="感受">
<uni-easyinput placeholder="运动感受(good/normal/bad)" v-model="formData.feelings"></uni-easyinput>
<uni-data-select v-model="formData.feelings"
:localdata="feelings" >
</uni-data-select>
</uni-forms-item>
<uni-forms-item name="owner_id" label="用户id">
<uni-easyinput placeholder="用户id" v-model="formData.owner_id"></uni-easyinput>
<uni-easyinput placeholder="用户id" v-model="formData.owner_id" disabled></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="distance" label="距离">
<uni-easyinput placeholder="运动距离" type="number" v-model="formData.distance"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动距离" type="number" v-model="formData.distance"></uni-easyinput> -->
<uni-number-box :value="0.0" :step="0.01" max="100000.00" value="100000.00" v-model="formData.distance"/>
</uni-forms-item>
<uni-forms-item name="pace" label="配速">
<uni-easyinput placeholder="运动配速" type="number" v-model="formData.pace"></uni-easyinput>
<!-- <uni-easyinput placeholder="运动配速" type="number" v-model="formData.pace"></uni-easyinput> -->
<uni-number-box :value="0.0" :step="0.01" max="100000.00" value="100000.00" v-model="formData.pace" />
</uni-forms-item>
<!-- <uni-forms-item name="start_point" label="起始地点">
<undefined v-model="formData.start_point"></undefined>
......@@ -73,6 +82,11 @@
return {
formData,
formOptions: {},
feelings: [
{value:'good',text:'good'},
{value:'normal',text:'normal'},
{value:'bad',text:'bad'},
],
rules: {
...getValidator(Object.keys(formData))
}
......
......@@ -28,11 +28,11 @@
<!-- <uni-easyinput v-model="formData.type"></uni-easyinput> -->
</uni-forms-item>
<uni-forms-item name="total_running_distance" label="跑步总距离">
<uni-number-box :value="0.0" :step="0.1" v-model="formData.total_running_distance" />
<uni-number-box :value="0.0" :step="0.01" v-model="formData.total_running_distance" />
<!-- <uni-easyinput type="number" v-model="formData.total_running_distance"></uni-easyinput> -->
</uni-forms-item>
<uni-forms-item name="total_walking_distance" label="健走总距离">
<uni-number-box :value="0.0" :step="0.1" v-model="formData.total_walking_distance" />
<uni-number-box :value="0.0" :step="0.01" v-model="formData.total_walking_distance" />
<!-- <uni-easyinput type="number" v-model="formData.total_walking_distance"></uni-easyinput> -->
</uni-forms-item>
<view class="uni-button-group">
......
const clientInfo = { // 模拟clientInfo
uniPlatform: 'web',
source: 'client', // 调用来源,不传时默认为 client
// 客户端ip,不传时默认为 127.0.0.1
userAgent: 'xx MicroMessenger/xxx', // 客户端ua,不传时默认为 HBuilderX
uniIdToken: 'xxx'
}
information('645cd81228064a7587bd2abb') // 调用login方法传入参数'name-demo'和'password-demo'
\ No newline at end of file
// 云对象教程: 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": {}
}
},
}
{
"name": "fe-my",
"dependencies": {},
"extensions": {
"uni-cloud-jql": {}
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ exports.main = async (event, context) => {
_id: event.activityId
}).get()
if (res.affectedDocs == 1) {
const usercollection = db.collection('mustgo-user')
let res1 = await usercollection.where({
_id: res.data[0]["owner_id"]
......@@ -17,21 +17,70 @@ exports.main = async (event, context) => {
username = res1.data[0]["name"]
icon = res1.data[0]["icon"]
}
const reg = db.collection('mustgo-registration')
let res2 = await reg.where({
team_activity_id: event.activityId,
owner_id: event.userId
}).get()
if (res2.affectedDocs == 1) {
return {
code: 200,
message: "成功返回活动详情",
qualification: "取消报名",
data: {
"username": username,
"icon": icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
"place": res.data[0]["place"],
"participants": res.data[0]["participants"],
"contact": res.data[0]["contact"],
"enrollment":res.data[0]["enrollment"]
}
}
}
// console.log(res.date[0]["participants"])
// console.log(res.date[0]["enrollment"])
if (res.data[0]["participants"] <= res.data[0]["enrollment"]) {
return {
code: 200,
message: "成功返回活动详情",
qualification: "报名停止",
data: {
"username": username,
"icon": icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
"place": res.data[0]["place"],
"participants": res.data[0]["participants"],
"contact": res.data[0]["contact"],
"enrollment":res.data[0]["enrollment"]
}
}
}
return {
code: 200,
message: "成功返回活动详情",
qualification: "报名",
data: {
"username":username,
"icon":icon,
"username": username,
"icon": icon,
"content": res.data[0]["content"],
"startDate": res.data[0]["start_date"],
"endDate": res.data[0]["end_date"],
"place": res.data[0]["place"],
"participants": res.data[0]["participants"],
"contact": res.data[0]["contact"]
"contact": res.data[0]["contact"],
"enrollment":res.data[0]["enrollment"]
}
}
}
return {
"code": 400,
......
......@@ -3,10 +3,10 @@ exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-registration')
const activitycollection = db.collection('mustgo-team-activity')
let regres = await collection.where({
team_activity_id: event.activityId,
owner_id:event.userId
owner_id: event.userId
}).get()
if (regres.affectedDocs == 1) {
return {
......@@ -15,7 +15,7 @@ exports.main = async (event, context) => {
"data": {}
}
}
let activityres = await activitycollection.where({
_id: event.activityId
}).get()
......@@ -24,12 +24,19 @@ exports.main = async (event, context) => {
team_activity_id: event.activityId,
owner_id: event.userId
})
if (res.id.length > 0)
if (res.id.length > 0) {
const res = await activitycollection.doc(event.activityId).update({
enrollment: activityres.data[0]["enrollment"]+1
})
return {
"code": 200,
"message": "报名小队活动成功",
"data": {}
}
}
}
return {
"code": 400,
......
......@@ -29,7 +29,8 @@ exports.main = async (event, context) => {
status: 0,
participants: event.participants,
contact: event.contact,
team_id: teamid
team_id: teamid,
enrollment:0
})
if (res.id.length > 0)
return {
......
......@@ -2,7 +2,12 @@
exports.main = async (event, context) => {
const db = uniCloud.database()
const collection = db.collection('mustgo-user')
<<<<<<< HEAD
=======
const activitycollection = db.collection('mustgo-team-activity')
>>>>>>> 23cd157a5405ab804c346a27b655ccf7564925eb
let res1 = await collection.where({
_id: event.userId
}).get()
......@@ -17,24 +22,59 @@ exports.main = async (event, context) => {
if (res1.affectedDocs == 1) {
teamid = res1.data[0]["team_id"]
}
if(teamid == "") {
if (teamid == "") {
return {
"code": 400,
"message": "退出小队失败",
"data": {}
}
}
let res = await collection.where({
_id: event.userId,
team_id: teamid
}).get()
if (res.affectedDocs == 1) {
let tmp = await collection.where({
team_id: teamid
}).get()
if (tmp.affectedDocs == 1) {
const collection1 = db.collection('mustgo-team')
const res1 = await collection1.doc(teamid).remove()
}
const res = await collection.doc(event.userId).update({
team_id: ""
})
if (res.updated === 1) {
const activity = db.collection('mustgo-team-activity')
let res2 = await activity.where({
team_id: teamid
}).get()
var arr = new Array;
arr = res2.data
const registration = db.collection('mustgo-registration')
for (var i = 0; i < arr.length; i++) {
<<<<<<< HEAD
const tmp = await registration.where({
team_activity_id: arr[i]["_id"]
}).remove()
// doc(`${id}`).update({team_activity_id:{name:dbCmd.remove()}})
=======
const res = await activitycollection.doc(arr[i]["_id"]).update({
enrollment: arr[i]["enrollment"]-1
})
const tmp = await registration.where({
team_activity_id: arr[i]["_id"]
}).remove()
>>>>>>> 23cd157a5405ab804c346a27b655ccf7564925eb
}
return {
"code": 200,
"message": "退出小队成功",
......
......@@ -56,8 +56,13 @@
},
"participants": {
"bsonType": "int",
"title": "参与人数",
"description": "小队活动参与人数"
"title": "限制人数",
"description": "小队活动限制人数"
},
"enrollment": {
"bsonType": "int",
"title": "报名人数",
"description": "小队活动报名人数"
},
"contact": {
"bsonType": "string",
......
{
"name": "uni-id-co",
"version": "1.0.38",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
},
"ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"requires": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
}
},
"jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"requires": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
},
"lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
},
"lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
},
"lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
},
"lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
},
"lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
},
"lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
"lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
},
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
},
"uni-captcha": {
"version": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha",
"requires": {
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies": {
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
},
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"uni-id-common": {
"version": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common",
"requires": {
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies": {
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
},
"uni-open-bridge-common": {
"version": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common",
"requires": {
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies": {
"uni-config-center": {
"version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册