From 1327251981b0aa5bcc8857125da31df0dbc00aee Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Fri, 12 Jul 2019 00:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/appmini/old/alipay/app.js | 22 +++ public/appmini/old/alipay/app.json | 1 + .../old/alipay/pages/common/nodata.axml | 2 +- .../pages/goods-comment/goods-comment.acss | 98 +++++++++++ .../pages/goods-comment/goods-comment.axml | 45 +++++ .../pages/goods-comment/goods-comment.js | 157 ++++++++++++++++++ .../pages/goods-comment/goods-comment.json | 3 + .../pages/goods-detail/goods-detail.axml | 6 +- .../alipay/pages/goods-detail/goods-detail.js | 2 +- public/appmini/old/weixin/app.js | 2 +- public/appmini/old/weixin/app.json | 3 +- .../old/weixin/pages/common/nodata.wxml | 2 +- .../pages/goods-comment/goods-comment.js | 13 +- .../pages/goods-comment/goods-comment.json | 2 +- .../pages/goods-comment/goods-comment.wxml | 9 +- .../pages/goods-comment/goods-comment.wxss | 22 ++- .../weixin/pages/goods-detail/goods-detail.js | 2 +- .../pages/goods-detail/goods-detail.wxml | 6 +- 18 files changed, 366 insertions(+), 31 deletions(-) create mode 100644 public/appmini/old/alipay/pages/goods-comment/goods-comment.acss create mode 100644 public/appmini/old/alipay/pages/goods-comment/goods-comment.axml create mode 100644 public/appmini/old/alipay/pages/goods-comment/goods-comment.js create mode 100644 public/appmini/old/alipay/pages/goods-comment/goods-comment.json diff --git a/public/appmini/old/alipay/app.js b/public/appmini/old/alipay/app.js index 0741d5d79..9e065b6f5 100644 --- a/public/appmini/old/alipay/app.js +++ b/public/appmini/old/alipay/app.js @@ -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 + }); + } + }, + }); diff --git a/public/appmini/old/alipay/app.json b/public/appmini/old/alipay/app.json index 418bb49ab..140b2ec29 100644 --- a/public/appmini/old/alipay/app.json +++ b/public/appmini/old/alipay/app.json @@ -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", diff --git a/public/appmini/old/alipay/pages/common/nodata.axml b/public/appmini/old/alipay/pages/common/nodata.axml index a4f8a0fce..82d676bb2 100755 --- a/public/appmini/old/alipay/pages/common/nodata.axml +++ b/public/appmini/old/alipay/pages/common/nodata.axml @@ -13,6 +13,6 @@ - {{msg || '这里人迹罕至,什么都没有'}} + {{msg || '没有相关数据'}} \ No newline at end of file diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss b/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss new file mode 100644 index 000000000..912526fbe --- /dev/null +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss @@ -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; +} \ No newline at end of file diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml b/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml new file mode 100644 index 000000000..fadbd77e9 --- /dev/null +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml @@ -0,0 +1,45 @@ + + + + 动态评分 + {{goods_score.avg || '0.0'}} + + + + + {{item.name}} + + + 暂无评分 + + + + + + + + + + {{item.user.user_name_view}} + 评论于 + {{item.add_time_time}} + + + + {{item.content}} + {{item.msg}} + + 管理员回复: + {{item.reply}} + + + + + + + + + + + + \ No newline at end of file diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.js b/public/appmini/old/alipay/pages/goods-comment/goods-comment.js new file mode 100644 index 000000000..5be60751d --- /dev/null +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.js @@ -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(); + }, +}); diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.json b/public/appmini/old/alipay/pages/goods-comment/goods-comment.json new file mode 100644 index 000000000..ed3a57db1 --- /dev/null +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.json @@ -0,0 +1,3 @@ +{ + "pullRefresh": true +} \ No newline at end of file diff --git a/public/appmini/old/alipay/pages/goods-detail/goods-detail.axml b/public/appmini/old/alipay/pages/goods-detail/goods-detail.axml index 0450ab0a4..27fd425e0 100644 --- a/public/appmini/old/alipay/pages/goods-detail/goods-detail.axml +++ b/public/appmini/old/alipay/pages/goods-detail/goods-detail.axml @@ -39,8 +39,10 @@ {{goods.access_count}} - 累计评论 - {{goods.comments_count}} + + 累计评论 + {{goods.comments_count}} + diff --git a/public/appmini/old/alipay/pages/goods-detail/goods-detail.js b/public/appmini/old/alipay/pages/goods-detail/goods-detail.js index febd307a7..2cf4681a9 100644 --- a/public/appmini/old/alipay/pages/goods-detail/goods-detail.js +++ b/public/appmini/old/alipay/pages/goods-detail/goods-detail.js @@ -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}); }, // 获取数据列表 diff --git a/public/appmini/old/weixin/app.js b/public/appmini/old/weixin/app.js index d9d1f1086..c7025162a 100755 --- a/public/appmini/old/weixin/app.js +++ b/public/appmini/old/weixin/app.js @@ -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}}", diff --git a/public/appmini/old/weixin/app.json b/public/appmini/old/weixin/app.json index 71fe18ad8..f325a2101 100755 --- a/public/appmini/old/weixin/app.json +++ b/public/appmini/old/weixin/app.json @@ -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", diff --git a/public/appmini/old/weixin/pages/common/nodata.wxml b/public/appmini/old/weixin/pages/common/nodata.wxml index 6dbc17a21..2aa73d38b 100755 --- a/public/appmini/old/weixin/pages/common/nodata.wxml +++ b/public/appmini/old/weixin/pages/common/nodata.wxml @@ -13,6 +13,6 @@ - {{msg || '这里人迹罕至,什么都没有'}} + {{msg || '没有相关数据'}} \ No newline at end of file diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.js b/public/appmini/old/weixin/pages/goods-comment/goods-comment.js index 5ce3292b6..cd5221d0c 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.js +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.js @@ -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] - }); - } - }, }); diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.json b/public/appmini/old/weixin/pages/goods-comment/goods-comment.json index 8835af069..331ad4f3d 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.json +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.json @@ -1,3 +1,3 @@ { - "usingComponents": {} + "enablePullDownRefresh": true } \ No newline at end of file diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml index b5edef4ed..cab4d853a 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml @@ -5,15 +5,18 @@ {{goods_score.avg || '0.0'}} - - {{item.name}} + + + {{item.name}} + + 暂无评分 - + diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss index ed381922b..912526fbe 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss @@ -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 { diff --git a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js index 4174dcfeb..bde266ed1 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js @@ -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}); }, // 获取数据列表 diff --git a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml index 47aa17b69..f356259cf 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml @@ -48,8 +48,10 @@ {{goods.access_count}} - 累计评论 - {{goods.comments_count}} + + 累计评论 + {{goods.comments_count}} + -- GitLab