mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-07 10:22:38 +08:00
商品评论
This commit is contained in:
@ -56,6 +56,7 @@ App({
|
||||
"message": "消息",
|
||||
"user_integral": "我的积分",
|
||||
"user_goods_browse": "我的足迹",
|
||||
"goods_comment": "商品评论",
|
||||
},
|
||||
|
||||
// 请求地址
|
||||
@ -610,4 +611,25 @@ App({
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 默认弱提示方法
|
||||
* msg [string] 提示信息
|
||||
* status [string] 状态 默认error [正确success, 错误error]
|
||||
*/
|
||||
showToast(msg, status)
|
||||
{
|
||||
if ((status || 'error') == 'success')
|
||||
{
|
||||
my.showToast({
|
||||
type: "success",
|
||||
content: msg
|
||||
});
|
||||
} else {
|
||||
my.showToast({
|
||||
type: "fail",
|
||||
content: msg
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
"pages/paytips/paytips",
|
||||
"pages/goods-search/goods-search",
|
||||
"pages/goods-detail/goods-detail",
|
||||
"pages/goods-comment/goods-comment",
|
||||
"pages/goods-attribute/goods-attribute",
|
||||
"pages/buy/buy",
|
||||
"pages/user-address/user-address",
|
||||
|
||||
@ -13,6 +13,6 @@
|
||||
<!-- 0 默认没有数据 -->
|
||||
<view a:elif="{{status == 0}}" class="no-data-box tc">
|
||||
<image src="/images/empty.png" mode="widthFix" />
|
||||
<view class="no-data-tips">{{msg || '这里人迹罕至,什么都没有'}}</view>
|
||||
<view class="no-data-tips">{{msg || '没有相关数据'}}</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 评分
|
||||
*/
|
||||
.score-container {
|
||||
padding: 10rpx;
|
||||
}
|
||||
.score-container .score {
|
||||
width: 180rpx;
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
.score-container .score .value {
|
||||
color: #f03726;
|
||||
font-weight: bold;
|
||||
font-size: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.progress {
|
||||
overflow: hidden;
|
||||
height: 40rpx;
|
||||
margin-top: 35rpx;
|
||||
background-color: #eee;
|
||||
border-radius: 0;
|
||||
width: calc(100% - 200rpx);
|
||||
}
|
||||
.progress .cr-888 {
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.progress-bar {
|
||||
float: left;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
background-color: #0e90d2;
|
||||
}
|
||||
.progress-bar-danger {
|
||||
background-color: #dd514c;
|
||||
}
|
||||
.progress-bar-warning {
|
||||
background-color: #F37B1D;
|
||||
}
|
||||
.progress-bar-secondary {
|
||||
background-color: #3bb4f2;
|
||||
}
|
||||
.progress-bar-success {
|
||||
background-color: #5eb95e;
|
||||
}
|
||||
|
||||
/*
|
||||
* 列表
|
||||
*/
|
||||
.scroll-box {
|
||||
height: calc(100vh - 125rpx);
|
||||
}
|
||||
.comment-item {
|
||||
padding: 0 10rpx 10rpx 10rpx;
|
||||
border-bottom:solid 1px #eee;
|
||||
}
|
||||
.comment-item .nav {
|
||||
background: #ebebeb;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
.comment-item .avatar {
|
||||
width: 70rpx;
|
||||
height: 70rpx;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #e2e2e2;
|
||||
}
|
||||
.comment-item .base-nav {
|
||||
width: calc(100% - 90rpx);
|
||||
line-height: 70rpx;
|
||||
}
|
||||
.comment-item .base-nav text:not(:last-child) {
|
||||
margin-right: 5rpx;
|
||||
}
|
||||
|
||||
.base-content {
|
||||
padding: 10rpx;
|
||||
}
|
||||
.base-content .content, .base-content .reply {
|
||||
line-height: 46rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.base-content .spec {
|
||||
margin-top: 20rpx;
|
||||
color: #B0B0B0;
|
||||
}
|
||||
.base-content .reply {
|
||||
margin-top: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.base-content .reply-desc {
|
||||
color: #905602;
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<!-- 评分 -->
|
||||
<view a:if="{{goods_score != null}}" class="score-container oh br-b">
|
||||
<view class="score fl tc">
|
||||
<view class="cr-666">动态评分</view>
|
||||
<view class="value">{{goods_score.avg || '0.0'}}</view>
|
||||
</view>
|
||||
<view class="progress fr tc">
|
||||
<block a:if="{{goods_score.avg > 0}}">
|
||||
<block a:for="{{goods_score.rating}}">
|
||||
<view class="progress-bar {{progress_class[index]}}" style="width: {{item.portion}}%;">{{item.name}}</view>
|
||||
</block>
|
||||
</block>
|
||||
<text a:else class="cr-888">暂无评分</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 列表 -->
|
||||
<scroll-view scroll-y="{{true}}" class="scroll-box" bindscrolltolower="scroll_lower" lower-threshold="30">
|
||||
<view a:for="{{data_list}}" class="comment-item spacing-mt">
|
||||
<view class="oh nav">
|
||||
<image class="avatar dis-block fl" src="{{item.user.avatar || '/images/default-user.png'}}" mode="aspectFit"></image>
|
||||
<view class="base-nav fr">
|
||||
<text>{{item.user.user_name_view}}</text>
|
||||
<text class="cr-ccc">评论于</text>
|
||||
<text class="cr-666">{{item.add_time_time}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="base-content oh">
|
||||
<view class="content cr-666">{{item.content}}</view>
|
||||
<view a:if="{{(item.msg || null) != null}}" class="spec">{{item.msg}}</view>
|
||||
<view a:if="{{item.is_reply == 1 && (item.reply || null) != null}}" class="reply br-t-dashed">
|
||||
<text class="cr-888">管理员回复:</text>
|
||||
<text class="reply-desc">{{item.reply}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view a:if="{{data_list.length == 0}}">
|
||||
<import src="/pages/common/nodata.axml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.axml" />
|
||||
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||
</scroll-view>
|
||||
157
public/appmini/old/alipay/pages/goods-comment/goods-comment.js
Normal file
157
public/appmini/old/alipay/pages/goods-comment/goods-comment.js
Normal file
@ -0,0 +1,157 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_bottom_line_status: false,
|
||||
data_list: [],
|
||||
data_page_total: 0,
|
||||
data_page: 1,
|
||||
goods_score: null,
|
||||
params: null,
|
||||
progress_class: ['progress-bar-danger', 'progress-bar-warning', 'progress-bar-secondary', '', 'progress-bar-success'],
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
//params['goods_id']=2;
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({ title: app.data.common_pages_title.goods_comment });
|
||||
},
|
||||
|
||||
// 初始化
|
||||
init() {
|
||||
// 获取数据
|
||||
this.goods_score();
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 获取商品评分
|
||||
goods_score() {
|
||||
my.request({
|
||||
url: app.get_request_url("goodsscore", "goods"),
|
||||
method: "POST",
|
||||
data: { goods_id: this.data.params.goods_id },
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
this.setData({
|
||||
goods_score: res.data.data || null,
|
||||
});
|
||||
} else {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
get_data_list(is_mandatory) {
|
||||
// 参数校验
|
||||
if ((this.data.params.goods_id || null) == null) {
|
||||
my.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
});
|
||||
} else {
|
||||
var self = this;
|
||||
|
||||
// 分页是否还有数据
|
||||
if ((is_mandatory || 0) == 0) {
|
||||
if (this.data.data_bottom_line_status == true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 加载loding
|
||||
my.showLoading({ title: "加载中..." });
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
|
||||
my.request({
|
||||
url: app.get_request_url("comment", "goods"),
|
||||
method: "POST",
|
||||
data: { goods_id: this.data.params.goods_id, page: this.data.data_page },
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
if (res.data.data.data.length > 0) {
|
||||
if (this.data.data_page <= 1) {
|
||||
var temp_data_list = res.data.data.data;
|
||||
} else {
|
||||
var temp_data_list = this.data.data_list;
|
||||
var temp_data = res.data.data.data;
|
||||
for (var i in temp_data) {
|
||||
temp_data_list.push(temp_data[i]);
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
data_list: temp_data_list,
|
||||
data_total: res.data.data.total,
|
||||
data_page_total: res.data.data.page_total,
|
||||
data_list_loding_status: 3,
|
||||
data_page: this.data.data_page + 1
|
||||
});
|
||||
|
||||
// 是否还有数据
|
||||
if (this.data.data_page > 1 && this.data.data_page > this.data.data_page_total) {
|
||||
this.setData({ data_bottom_line_status: true });
|
||||
} else {
|
||||
this.setData({ data_bottom_line_status: false });
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
});
|
||||
if (this.data.data_page <= 1) {
|
||||
this.setData({
|
||||
data_list: [],
|
||||
data_bottom_line_status: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0
|
||||
});
|
||||
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
|
||||
this.setData({
|
||||
data_list_loding_status: 2
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.setData({
|
||||
data_page: 1
|
||||
});
|
||||
this.get_data_list(1);
|
||||
},
|
||||
|
||||
// 滚动加载
|
||||
scroll_lower(e) {
|
||||
this.get_data_list();
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"pullRefresh": true
|
||||
}
|
||||
@ -39,8 +39,10 @@
|
||||
<text class="cr-main">{{goods.access_count}}</text>
|
||||
</view>
|
||||
<view class="fl tr">
|
||||
<text class="cr-888">累计评论</text>
|
||||
<text class="cr-main">{{goods.comments_count}}</text>
|
||||
<navigator url="/pages/goods-comment/goods-comment?goods_id={{goods.id}}" hover-class="none">
|
||||
<text class="cr-888">累计评论</text>
|
||||
<text class="cr-main">{{goods.comments_count}}</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -41,7 +41,7 @@ Page({
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({title: app.data.common_pages_title.goods_detail});
|
||||
my.setNavigationBar({title: (this.data.goods == null) ? app.data.common_pages_title.goods_detail : this.data.goods.title});
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
|
||||
@ -62,7 +62,7 @@ App({
|
||||
// 请求地址
|
||||
// request_url: "{{request_url}}",
|
||||
request_url: 'http://tp5-dev.com/',
|
||||
//request_url: 'https://test.shopxo.net/',
|
||||
request_url: 'https://test.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"pages": ["pages/goods-comment/goods-comment",
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/goods-category/goods-category",
|
||||
"pages/cart/cart",
|
||||
@ -9,6 +9,7 @@
|
||||
"pages/paytips/paytips",
|
||||
"pages/goods-search/goods-search",
|
||||
"pages/goods-detail/goods-detail",
|
||||
"pages/goods-comment/goods-comment",
|
||||
"pages/goods-attribute/goods-attribute",
|
||||
"pages/buy/buy",
|
||||
"pages/user-address/user-address",
|
||||
|
||||
@ -13,6 +13,6 @@
|
||||
<!-- 0 默认没有数据 -->
|
||||
<view wx:elif="{{status == 0}}" class="no-data-box tc">
|
||||
<image src="/images/empty.png" mode="widthFix" />
|
||||
<view class="no-data-tips">{{msg || '这里人迹罕至,什么都没有'}}</view>
|
||||
<view class="no-data-tips">{{msg || '没有相关数据'}}</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -12,7 +12,7 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
params['goods_id']=2;
|
||||
//params['goods_id']=2;
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
@ -154,15 +154,4 @@ Page({
|
||||
scroll_lower(e) {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 详情图片查看
|
||||
goods_detail_images_view_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if (value != null) {
|
||||
wx.previewImage({
|
||||
current: 0,
|
||||
urls: [value]
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@ -5,15 +5,18 @@
|
||||
<view class="value">{{goods_score.avg || '0.0'}}</view>
|
||||
</view>
|
||||
<view class="progress fr tc">
|
||||
<block wx:for="{{goods_score.rating}}" wx:key="key">
|
||||
<view class="progress-bar {{progress_class[index]}}" style="width: {{item.portion}}%;">{{item.name}}</view>
|
||||
<block wx:if="{{goods_score.avg > 0}}">
|
||||
<block wx:for="{{goods_score.rating}}" wx:key="key">
|
||||
<view class="progress-bar {{progress_class[index]}}" style="width: {{item.portion}}%;">{{item.name}}</view>
|
||||
</block>
|
||||
</block>
|
||||
<text wx:else class="cr-888">暂无评分</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 列表 -->
|
||||
<scroll-view scroll-y="{{true}}" class="scroll-box" bindscrolltolower="scroll_lower" lower-threshold="30">
|
||||
<view wx:for="{{data_list}}" wx:key="key" class="comment-item br-b spacing-mt">
|
||||
<view wx:for="{{data_list}}" wx:key="key" class="comment-item spacing-mt">
|
||||
<view class="oh nav">
|
||||
<image class="avatar dis-block fl" src="{{item.user.avatar || '/images/default-user.png'}}" mode="aspectFit"></image>
|
||||
<view class="base-nav fr">
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
/*
|
||||
* 评分
|
||||
*/
|
||||
.score-container {
|
||||
padding: 10rpx;
|
||||
}
|
||||
@ -12,15 +15,18 @@
|
||||
line-height: 60rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.progress {
|
||||
overflow: hidden;
|
||||
height: 40rpx;
|
||||
margin-top: 40rpx;
|
||||
background-color: #f5f5f5;
|
||||
margin-top: 35rpx;
|
||||
background-color: #eee;
|
||||
border-radius: 0;
|
||||
width: calc(100% - 200rpx);
|
||||
}
|
||||
.progress .cr-888 {
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.progress-bar {
|
||||
float: left;
|
||||
width: 0;
|
||||
@ -44,12 +50,18 @@
|
||||
background-color: #5eb95e;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 列表
|
||||
*/
|
||||
.scroll-box {
|
||||
height: calc(100vh - 125rpx);
|
||||
}
|
||||
.comment-item {
|
||||
padding: 0 10rpx 10rpx 10rpx;
|
||||
border-bottom:solid 1px #eee;
|
||||
}
|
||||
.comment-item .nav {
|
||||
background: #eee;
|
||||
background: #ebebeb;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
.comment-item .avatar {
|
||||
|
||||
@ -46,7 +46,7 @@ Page({
|
||||
},
|
||||
|
||||
onShow() {
|
||||
wx.setNavigationBarTitle({title: app.data.common_pages_title.goods_detail});
|
||||
wx.setNavigationBarTitle({title: (this.data.goods == null) ? app.data.common_pages_title.goods_detail : this.data.goods.title});
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
|
||||
@ -48,8 +48,10 @@
|
||||
<text class="cr-main">{{goods.access_count}}</text>
|
||||
</view>
|
||||
<view class="fl tr">
|
||||
<text class="cr-888">累计评论</text>
|
||||
<text class="cr-main">{{goods.comments_count}}</text>
|
||||
<navigator url="/pages/goods-comment/goods-comment?goods_id={{goods.id}}" hover-class="none">
|
||||
<text class="cr-888">累计评论</text>
|
||||
<text class="cr-main">{{goods.comments_count}}</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user