Skip to content

Commit

Permalink
feature: 添加评价功能
Browse files Browse the repository at this point in the history
  • Loading branch information
xumengqi committed Apr 3, 2021
1 parent bb726d8 commit 5a2444a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 22 deletions.
3 changes: 2 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"van-count-down": "@vant/weapp/count-down/index",
"van-search": "@vant/weapp/search/index",
"van-notice-bar": "@vant/weapp/notice-bar/index",
"van-sticky": "@vant/weapp/sticky/index"
"van-sticky": "@vant/weapp/sticky/index",
"van-rate": "@vant/weapp/rate/index"
}
}
33 changes: 32 additions & 1 deletion pages/borrow_progress/borrow_progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,38 @@ Page({
],
activeIndex: 0,
countDownTime: 0,
countDownTimeData: {}
countDownTimeData: {},
star: 5
},
onStarChange(e) {
this.setData({
star: e.detail
})
let me = this
Dialog.confirm({
title: '确认评价',
message: '您确认要评价吗?',
confirmButtonText: '确认评价'
}).then(() => {
wx.request({
url: globalData.serverUrl + '/shareRecord/score',
data: { shareRecordId: me.data.shareRecordId, score: me.data.star },
method: 'POST',
header: {
"Content-Type": "application/json",
'authorization': globalData.token
},
success: function (res) {
let dts = res.data
if (!dts.success) {
Toast("评价失败," + dts.errorInfo)
return;
}
Toast("评价成功~")
me.getShareLogList()
}
})
})
},
onCountDownTimeChange(e) {
this.setData({
Expand Down
64 changes: 44 additions & 20 deletions pages/borrow_progress/borrow_progress.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
<van-col span="24">
<view class="view-center">
<van-image fit="heightFix" height="100" src="{{ shareRecord.bookImageUrl }}" />
<van-tag mark type="primary" color="#ff8260" wx:if="{{ shareRecord.recordStatus == '1' }}" slot="tag" custom-class="custom-tag-of-card">
已下单</van-tag>
<van-tag mark type="danger" color="#ff4057" wx:if="{{ shareRecord.recordStatus == '2' }}" slot="tag" custom-class="custom-tag-of-card">借阅中
</van-tag>
<van-tag mark type="success" wx:if="{{ shareRecord.recordStatus == '3' }}" slot="tag" custom-class="custom-tag-of-card">
已归还</van-tag>
<van-tag mark type="success" wx:if="{{ shareRecord.recordStatus == '4' }}" slot="tag" custom-class="custom-tag-of-card">
逾期归还</van-tag>
<van-tag mark type="success" wx:if="{{ shareRecord.recordStatus == '5' }}" slot="tag" custom-class="custom-tag-of-card">
已取消</van-tag>
<van-tag mark type="success" color="#900048" wx:if="{{ shareRecord.recordStatus == '6' }}" slot="tag" custom-class="custom-tag-of-card">
书籍丢失</van-tag>
<van-tag mark type="success" color="#900048" wx:if="{{ shareRecord.recordStatus == '7' }}" slot="tag" custom-class="custom-tag-of-card">
严重超时</van-tag>
<van-tag mark type="primary" color="#ff8260" wx:if="{{ shareRecord.recordStatus == '1' }}" slot="tag"
custom-class="custom-tag-of-card">
已下单</van-tag>
<van-tag mark type="danger" color="#ff4057" wx:if="{{ shareRecord.recordStatus == '2' }}" slot="tag"
custom-class="custom-tag-of-card">借阅中
</van-tag>
<van-tag mark type="success" wx:if="{{ shareRecord.recordStatus == '3' }}" slot="tag"
custom-class="custom-tag-of-card">
已归还</van-tag>
<van-tag mark type="success" wx:if="{{ shareRecord.recordStatus == '4' }}" slot="tag"
custom-class="custom-tag-of-card">
逾期归还</van-tag>
<van-tag mark type="success" wx:if="{{ shareRecord.recordStatus == '5' }}" slot="tag"
custom-class="custom-tag-of-card">
已取消</van-tag>
<van-tag mark type="success" color="#900048" wx:if="{{ shareRecord.recordStatus == '6' }}" slot="tag"
custom-class="custom-tag-of-card">
书籍丢失</van-tag>
<van-tag mark type="success" color="#900048" wx:if="{{ shareRecord.recordStatus == '7' }}" slot="tag"
custom-class="custom-tag-of-card">
严重超时</van-tag>
</view>
</van-col>
</van-row>
Expand All @@ -36,11 +43,18 @@
<van-count-down use-slot time="{{ countDownTime }}" bind:change="onCountDownTimeChange">
<text class="countDownItem" style="background-color: #ff8260"
wx:if="{{ countDownTimeData.days > 0 }}">{{ countDownTimeData.days }} 天</text>
<text class="countDownItem">{{ countDownTimeData.hours <= 9 ? '0' + countDownTimeData.hours : countDownTimeData.hours }}</text>
<text class="countDownItem">{{countDownTimeData.minutes <= 9 ? '0' + countDownTimeData.minutes : countDownTimeData.minutes}}</text>
<text class="countDownItem">{{ countDownTimeData.seconds <= 9 ? '0' + countDownTimeData.seconds : countDownTimeData.seconds }}</text>
<text
class="countDownItem">{{ countDownTimeData.hours <= 9 ? '0' + countDownTimeData.hours : countDownTimeData.hours }}</text>
<text
class="countDownItem">{{countDownTimeData.minutes <= 9 ? '0' + countDownTimeData.minutes : countDownTimeData.minutes}}</text>
<text
class="countDownItem">{{ countDownTimeData.seconds <= 9 ? '0' + countDownTimeData.seconds : countDownTimeData.seconds }}</text>
</van-count-down>
</van-cell>
<van-cell title="书籍评价:" wx:if="{{ shareRecord.score > 0 }}">
<van-rate value="{{ shareRecord.score }}" size="{{ 16 }}" allow-half color="#ee0a24" void-color="#eee"
void-icon="star" />
</van-cell>
</van-cell-group>
</van-col>
</van-row>
Expand Down Expand Up @@ -80,10 +94,20 @@
</view>
</van-col>
</van-row>
<van-row style="margin: 12px" wx:if="{{ shareRecord.recordStatus == 3 || shareRecord.recordStatus == 4 || shareRecord.recordStatus == 5 || shareRecord.recordStatus == 6 || shareRecord.recordStatus == 7}}">
<van-row style="margin: 12px" wx:if="{{ isBorrow == true && (shareRecord.recordStatus == 3 || shareRecord.recordStatus == 4) && !(shareRecord.score > 0)}}">
<van-col span="22" offset="1">
<view class="view-center">
<text style="color: #666; font-size: 14px">尚未评价:</text>
<van-rate value="{{ star }}" size="{{ 16 }}" allow-half color="#ee0a24" void-color="#eee" void-icon="star"
bind:change="onStarChange" />
</view>
</van-col>
</van-row>
<van-row style="margin: 12px"
wx:if="{{ shareRecord.recordStatus == 3 || shareRecord.recordStatus == 4 || shareRecord.recordStatus == 5 || shareRecord.recordStatus == 6 || shareRecord.recordStatus == 7}}">
<van-col span="8" offset="8">
<van-divider contentPosition="center" dashed>交易已完成~</van-divider>
</van-col>
<van-divider contentPosition="center" dashed>交易已完成~</van-divider>
</van-col>
</van-row>
<van-toast id="van-toast" />
<van-dialog id="van-dialog" />
Expand Down

0 comments on commit 5a2444a

Please sign in to comment.