Skip to content

Commit

Permalink
增加鸣谢者列表
Browse files Browse the repository at this point in the history
  • Loading branch information
darkSheep404 committed Mar 2, 2021
1 parent b7e49bf commit 5addccd
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 25 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- [ ] 对于冲突汉服店铺信息的公示与投票
- [ ] 获取更多的汉服山正店铺信息
- [ ] 学习并利用云开发CMS便捷管理数据库
### v0.2.5
* 增加了鸣谢者列表
## SupportBY

* **微信云开发**
Expand Down
10 changes: 10 additions & 0 deletions cloudfunctions/add_store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
//发布后第一次修改代码
//修正const wxContext = cloud.getWXContext()放到入口函数内,外面获取不到上下文

Expand All @@ -21,6 +22,15 @@ exports.main = async (event, context) => {
},
]
})
await db.collection('user').where({
openid:wxContext.OPENID
})
.update({
data: {
// 更新字段++
nums:_.inc(1)
},
})
}
catch(e){
console.error("发生了错误:\n")
Expand Down
15 changes: 9 additions & 6 deletions cloudfunctions/get_rank_list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ const db = cloud.database()
exports.main = async (event, context) => {

return {
rankList:db.collection('hanfuStore').aggregate()
.group({
_id: '$contributors',
num: test.sum(1)
})
.end()
rankList: await db.collection('user')
.orderBy('nums', 'desc')
.field({
nickName: true,
avatarUrl: true,
nums:true,
})
.limit(10)
.get()
}
}
9 changes: 8 additions & 1 deletion miniprogram/app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"pages": [

"pages/home/home",
"pages/rank/rank",
"pages/about/about",
"pages/about/log/log",
"pages/correct/correct",
Expand All @@ -18,6 +19,12 @@
},
"tabBar": {
"list": [
{
"pagePath": "pages/rank/rank",
"text": "鸣谢",
"iconPath": "images/thanks.png",
"selectedIconPath": "images/thanks2.png"
},
{
"pagePath": "pages/home/home",
"text": "首页",
Expand Down
Binary file added miniprogram/images/thanks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/thanks2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions miniprogram/pages/correct/correct.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Page({
*/
data: {
index: null,//更改为0是否默认为山店
picker: ['山', '正'],
picker: ['山', '正','我想知道'],
beizhu:"无",
storeName:null,
official:null,
isDisabled:false,
},
beizhuInput(e) {
this.setData({
Expand All @@ -31,15 +32,29 @@ Page({
official:false
})
}
else{
else if(e.detail.value==="1"){
this.setData({
index: e.detail.value,
official:true
})
}
else
{
this.setData({
index: e.detail.value,
official:"我想知道"
})
}
},
submit:function (){
var that = this
that.setData({
isDisabled:true
})
//触发事件时就弹出加载框
that.setData({
loadModal: true
})
console.log(this.data.storeName,this.data.beizhu,this.data.index,this.data.official)
wx.cloud.callFunction({
// 云函数名称
Expand All @@ -51,7 +66,7 @@ Page({
//提取数据
var data = res.result.storelist.data
//如果已经存在该店铺:进入冲突数据库
if(data.length>0){
if(data.length>0 ||that.data.index==="2"){
/*插入数据至待修改列表*/
{
wx.cloud.callFunction({
Expand All @@ -63,9 +78,6 @@ Page({
},
success:function(res)
{
that.setData({
loadModal: true
})
setTimeout(()=> {
that.setData({
loadModal: false
Expand Down
2 changes: 1 addition & 1 deletion miniprogram/pages/correct/correct.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<textarea maxlength="-1" bindinput="beizhuInput" placeholder="备注或一些简短的评价"></textarea>
</view>
<button class="cu-btn round bg-green button-hover" style="display:flex;margin-top:10rpx"
bindtap="submit"
bindtap="submit" disabled="{{isDisabled}}"
>提交</button>
<view class='cu-load load-modal' wx:if="{{loadModal}}">
<image src='/images/logo.png' class='png' mode='aspectFit'></image>
Expand Down
19 changes: 11 additions & 8 deletions miniprogram/pages/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Page({
included:true,
storelist: [ {_id: "3f1780f4603144780151fc2e5c318e46", beizhu: "均价: 300元。\n特点:平价店,大店,种类款式多,有男款", storeName: "重回汉唐",official:true}],
storeName:null,
showName:null,//未查询到时展示的名字,避免直接使用storename导致下方显示随着输入更改
userInfo: {},
hasUserInfo: false,
tips:null,
Expand Down Expand Up @@ -89,8 +90,12 @@ console.log("---------------->")

getStorelist:function(){
var that = this
var query="/"+that.data.storeName+"/i"
console.log(query)
//修复输入框为空时,提交空参数给云函数造成的卡死错误
if(that.data.storeName===null)
{
console.log("未输入")
return
}
/*wx.showLoading({
title: '查询中',
})*/
Expand All @@ -108,20 +113,18 @@ console.log("---------------->")
//提取数据
var data = res.result.storelist.data
console.log(res)
/*for (let i = 0; i < data.length; i++) {
console.log(data[i])
}*/
//wx.hideLoading()

if(data.length>0){
that.setData({
loadModal:false,
storelist: data
storelist: data,
included:true,
})}
else
{
//TODO 此处应该监听到输入后,把included设置为true
//TODO 未查询到数据时:更新字符串,显示未查询到的提示语
that.setData({
showName:that.data.storeName,
loadModal:false,
storelist: data,
included:false,
Expand Down
5 changes: 2 additions & 3 deletions miniprogram/pages/home/home.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
<view class="cu-item bg-gradual-green content shadow" wx:if="{{!included}}">
<image src="/images/logo.png" class="cu-avatar round"> </image>
<view class="content">
<view class="text-title">{{storeName}}</view>
<view class="text-title">{{showName}}</view>
<view class="text-title ">
<text wx:if="{{item.official}}">未收录</text>
<text>暂未收录</text>
</view>
<view class="bg-grey padding-sm radius margin-top-sm text-sm">
<view class="flex">
Expand All @@ -57,7 +57,6 @@
</view>
</view>
</view>

<navigator hover-class='none' url="/pages/correct/correct" >
<button class="bg-gradual-green round sm" style="font-size:small;width: fit-content">纠正or补充</button>
</navigator>
Expand Down
81 changes: 81 additions & 0 deletions miniprogram/pages/rank/rank.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// miniprogram/pages/rank/rank.js
Page({

/**
* 页面的初始数据
*/
data: {
rankList:null
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that=this;//进入云函数中this发生了变化,使用this.setData({})无效
wx.cloud.callFunction({
// 云函数名称
name: 'get_rank_list',
//成功后执行
success: function (res) {
//提取数据--返回的数据为res.result.云函数处定义的字段名.data
var data = res.result.rankList.data
//此处为了简略代码,删去了else情况的操作
that.setData({
rankList: data
})
},
fail: console.error
})

},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

}
})
3 changes: 3 additions & 0 deletions miniprogram/pages/rank/rank.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"usingComponents": {}
}
27 changes: 27 additions & 0 deletions miniprogram/pages/rank/rank.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<view>
<view class="padding bg-white">
<view class="solid-bottom text-xl padding text-center bg-gradual-green" style="border-radius: 15rpx;">
<text class="text-white ">店铺信息贡献者(前十位)</text>
</view>
</view>
<view class="cu-timeline bg-white">
<view class="cu-item cuIcon-evaluate_fill text-blue" wx:for-items="{{rankList}}" wx:for-item="item" wx:key="*this">
<view class="rankitem bg-gradual-green ">
<view class="cu-avatar round lg" style="background-image:url({{item.avatarUrl}});">
</view>
<view class="content">
<view class="text-white">{{item.nickName}}</view>
<view class="text-white text-sm flex">
<text >
<text class="margin-right "></text> 贡献店铺数目
</text>
</view>
</view>
<view class="ranknum text-white">
{{item.nums}}家
</view>

</view>
</view>
</view>
</view>
23 changes: 23 additions & 0 deletions miniprogram/pages/rank/rank.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* miniprogram/pages/rank/rank.wxss */
.rankitem{
border-radius: 16rpx;
position: relative;
display: flex;
padding: 30rpx,30rpx,30rpx,120rpx;
height: 140rpx;
justify-content: flex-end;
align-items: center;
}
.rankitem>.cu-avatar {
position: absolute;
left: 20rpx
}
.rankitem>.content {
position: absolute;
left: 126rpx;
width: calc(100% - 96rpx - 60rpx - 120rpx - 20rpx);
line-height: 1.6em;}
.ranknum{
letter-spacing:2px;
padding-right: 30rpx
}

0 comments on commit 5addccd

Please sign in to comment.