|
@@ -7,154 +7,65 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- commentsList: [{
|
|
|
- id: 1,
|
|
|
- headImg: "../../images/headImg.jpg",
|
|
|
- product: "葛优躺(北京躺)电影足疗",
|
|
|
- assessDate: "2020-02-02",
|
|
|
- stars: 5,
|
|
|
- comments: {
|
|
|
- content: "3号技师特别好~~~赞一个,下次还来。",
|
|
|
- imgs: [{
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845363&di=e7d98132fabd3cff8c6af84706dabbd3&imgtype=0&src=http%3A%2F%2Fdpic.tiankong.com%2F13%2Fsi%2FQJ6552879374.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=51f1ef89c02857c1187ba1abb7d0afb4&imgtype=0&src=http%3A%2F%2Fpicnew11.photophoto.cn%2F20170225%2Fzhongyiyangshengjiamubiao-zhongyituinaanmo-24406997_1.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- ]
|
|
|
- }
|
|
|
- }, {
|
|
|
- id: 2,
|
|
|
- headImg: "../../images/headImg.jpg",
|
|
|
- product: "葛优躺(北京躺)电影足疗",
|
|
|
- assessDate: "2020-02-02",
|
|
|
- stars: 5,
|
|
|
- comments: {
|
|
|
- content: "3号技师特别好~~~赞一个,下次还来。",
|
|
|
- imgs: [{
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
-
|
|
|
- ]
|
|
|
- }
|
|
|
- }, {
|
|
|
- id: 3,
|
|
|
- headImg: "../../images/headImg.jpg",
|
|
|
- product: "葛优躺(北京躺)电影足疗",
|
|
|
- assessDate: "2020-02-02",
|
|
|
- stars: 4,
|
|
|
- comments: {
|
|
|
- content: "3号技师特别好~~~赞一个,下次还来。",
|
|
|
- imgs: []
|
|
|
- }
|
|
|
- }, {
|
|
|
- id: 4,
|
|
|
- headImg: "../../images/headImg.jpg",
|
|
|
- product: "葛优躺(北京躺)电影足疗",
|
|
|
- assessDate: "2020-02-02",
|
|
|
- stars: 5,
|
|
|
- comments: {
|
|
|
- content: "3号技师特别好~~~赞一个,下次还来。",
|
|
|
- imgs: [{
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
-
|
|
|
- ]
|
|
|
- }
|
|
|
- }, {
|
|
|
- id: 5,
|
|
|
- headImg: "../../images/headImg.jpg",
|
|
|
- product: "葛优躺(北京躺)电影足疗",
|
|
|
- assessDate: "2020-02-02",
|
|
|
- stars: 5,
|
|
|
- comments: {
|
|
|
- content: "3号技师特别好~~~赞一个,下次还来。",
|
|
|
- imgs: [{
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- {
|
|
|
- imgurl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1608485845364&di=f3d84d43be664894c7a7666198a98055&imgtype=0&src=http%3A%2F%2Fpic9.nipic.com%2F20100827%2F3079353_153325059762_2.jpg"
|
|
|
- },
|
|
|
- ]
|
|
|
- }
|
|
|
- }],
|
|
|
- shopId: '',
|
|
|
- productId: ''
|
|
|
-
|
|
|
+ commentsList: [],
|
|
|
+ shopId: 0,
|
|
|
+ productId: 0,
|
|
|
+ commentsType: '',
|
|
|
+ pageNo: 1,
|
|
|
+ pageSum: '',
|
|
|
+ loadingEnd: false,
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: async function (options) {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: options.title
|
|
|
})
|
|
|
if (options.commentstype == 'my') {
|
|
|
|
|
|
- var comments = await commentsApi.getPersonComments(1);
|
|
|
- var list = this.standardCommentsList(comments.list);
|
|
|
- this.setData({
|
|
|
- commentsList: list
|
|
|
- })
|
|
|
+ await this.getMyCommentsList();
|
|
|
|
|
|
}
|
|
|
if (options.commentstype == 'all') {
|
|
|
var shopId = options.shopId;
|
|
|
var productId = options.productId;
|
|
|
- var comments = await commentsApi.getCommentsByProduct(shopId, productId);
|
|
|
- //对返回的评论列表进行处理
|
|
|
- var list = this.standardCommentsList(comments.list);
|
|
|
- this.setData({
|
|
|
- commentsList: list,
|
|
|
- shopId,
|
|
|
- productId
|
|
|
- })
|
|
|
-
|
|
|
+ await this.getAllCommentsList(shopId,productId)
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ // 获取产品的全部评论
|
|
|
+ getAllCommentsList: async function (shopId, productId) {
|
|
|
+ var page = this.data.pageNo;
|
|
|
+ var comments = await commentsApi.getCommentsByProduct(page, 10, shopId, productId);
|
|
|
+ //对返回的评论列表进行处理
|
|
|
+ var commList = this.standardCommentsList(comments.list);
|
|
|
+ var commentsList = this.data.commentsList;
|
|
|
+ var list = commentsList.concat(commList)
|
|
|
+ this.setData({
|
|
|
+ commentsList: list,
|
|
|
+ shopId,
|
|
|
+ productId,
|
|
|
+ commentsType: 'all',
|
|
|
+ pageSum: comments.pageCount,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //获取我的全部评论
|
|
|
+ getMyCommentsList: async function () {
|
|
|
+ var page = this.data.pageNo;
|
|
|
+ var comments = await commentsApi.getPersonComments(page, 10, 1);
|
|
|
+ var commList = this.standardCommentsList(comments.list);
|
|
|
+ var commentsList = this.data.commentsList;
|
|
|
+ var list = commentsList.concat(commList)
|
|
|
+ this.setData({
|
|
|
+ commentsList: list,
|
|
|
+ commentsType: 'my',
|
|
|
+ commentsNum: comments.count
|
|
|
+ })
|
|
|
+ },
|
|
|
standardCommentsList: function (list) {
|
|
|
list.forEach(function (item, i, array) {
|
|
|
let urls = item.imgUrls;
|
|
@@ -204,7 +115,33 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
- console.log('bottom')
|
|
|
+ var self = this;
|
|
|
+ var commentsType = this.data.commentsType;
|
|
|
+ var pageNo = this.data.pageNo;
|
|
|
+ pageNo += 1;
|
|
|
+ this.setData({
|
|
|
+ pageNo
|
|
|
+ })
|
|
|
+ if (commentsType == 'my') {
|
|
|
+ if(self.data.pageNo <= self.data.pageSum){
|
|
|
+ this.getMyCommentsList()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.setData({
|
|
|
+ loadingEnd: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(commentsType=='all'){
|
|
|
+ var shopId = self.data.shopId;
|
|
|
+ var productId = self.data.productId;
|
|
|
+ if(self.data.pageNo <= self.data.pageSum){
|
|
|
+ this.getAllCommentsList(shopId,productId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.setData({
|
|
|
+ loadingEnd: true
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|