From d9f7bd3ff35e91359e4a01dd6d8d37ff61f98a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B2=BB=E9=9C=96?= <3201455247@qq.com> Date: Thu, 5 Oct 2023 14:56:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 2 +- subpkg/dishDetail/dishDetail.vue | 55 ++++++++++--------- .../cloudfunctions/scoreUpdate/index.js | 7 +++ .../cloudfunctions/scoreUpdate/package.json | 7 +++ 4 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 uniCloud-aliyun/cloudfunctions/scoreUpdate/index.js create mode 100644 uniCloud-aliyun/cloudfunctions/scoreUpdate/package.json diff --git a/manifest.json b/manifest.json index a2fa99b..400580d 100644 --- a/manifest.json +++ b/manifest.json @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "wxcfebd67cf993c6f3", + "appid" : "航大菜品圈", "setting" : { "urlCheck" : false, "es6" : true diff --git a/subpkg/dishDetail/dishDetail.vue b/subpkg/dishDetail/dishDetail.vue index a245c79..d82be78 100644 --- a/subpkg/dishDetail/dishDetail.vue +++ b/subpkg/dishDetail/dishDetail.vue @@ -7,17 +7,19 @@ {{"菜品名称:" + dish_name + '\n'}} {{"菜品位置:" + dish_location + dish_window_name + '\n'}} + {{"菜品类别:" + dish_label + '\n'}} + {{"菜品评分:" + dish_avg_score + '\n'}} - - - - - {{"评分:\n"}} - - - + + + + + {{"菜品打分:\n"}} + + + @@ -32,16 +34,17 @@ dish_location: '', dish_window_name: '', value: 4, - comentData:[], - dish_id:'' + comentData: [], + dish_id: '', + dish_avg_score: 5.0 }; }, onLoad(option) { - + //this.getLabels() this.dish_id = JSON.parse(decodeURIComponent(option._id)) this.getImage() - console.log(this.dish_id ) + console.log(this.dish_id) }, methods: { getImage() { @@ -55,8 +58,9 @@ success: function(res) { that.dish_image_src = res.result.data[0].dish_src that.dish_name = res.result.data[0].dish_name - that.dish_location =res.result.data[0].location - that.dish_window_name =res.result.data[0].window_name + that.dish_location = res.result.data[0].location + that.dish_window_name = res.result.data[0].window_name + that.dish_avg_score = res.result.data[0].avg_score console.log(res) } }) @@ -75,25 +79,23 @@ } }) }, - onChange() { - this.value = e.value - - }, - updateScore() { + onChange(e) { + let that = this uniCloud.callFunction({ name: 'scoreUpdate', data: { - //用户信息和获取的评分 + score: that.value, + dish_id: that.dish_id } }) }, - add(commentReq){ + add(commentReq) { console.log(commentReq) }, - del(commentid){ + del(commentid) { console.log(commentid) }, - like(commentid){ + like(commentid) { console.log(commentid) } } @@ -116,7 +118,6 @@ width: 600rpx; } - - .evaluete{ - } + + .evaluete {} \ No newline at end of file diff --git a/uniCloud-aliyun/cloudfunctions/scoreUpdate/index.js b/uniCloud-aliyun/cloudfunctions/scoreUpdate/index.js new file mode 100644 index 0000000..a6659a8 --- /dev/null +++ b/uniCloud-aliyun/cloudfunctions/scoreUpdate/index.js @@ -0,0 +1,7 @@ +'use strict'; +exports.main = async (event, context) => { + const db = uniCloud.database() + db.collection('dish-score').add({dish_id:event.dish_id,score:event.score}) + //返回数据给客户端 + return event +}; diff --git a/uniCloud-aliyun/cloudfunctions/scoreUpdate/package.json b/uniCloud-aliyun/cloudfunctions/scoreUpdate/package.json new file mode 100644 index 0000000..a73921b --- /dev/null +++ b/uniCloud-aliyun/cloudfunctions/scoreUpdate/package.json @@ -0,0 +1,7 @@ +{ + "name": "scoreUpdate", + "dependencies": {}, + "extensions": { + "uni-cloud-jql": {} + } +} \ No newline at end of file