sunshine1130 4 年之前
父节点
当前提交
66e1c0a846

+ 6 - 6
api/comments.js

@@ -3,16 +3,16 @@ import request from '../utils/request.js'
 
 class comments extends request {
 
-    static async getCommentsByProduct(storeId, productId) {
-        const res = await this.getRequest(`${this.BASE_URL}Discuss/index?productId=${productId}&storeId=${storeId}`, this._defaultHeader)
+    static async getCommentsByProduct(page=1,pageSize=10,storeId, productId) {
+        const res = await this.getRequest(`${this.BASE_URL}Discuss/index?page=${page}&pageSize=${pageSize}&productId=${productId}&storeId=${storeId}`, this._defaultHeader)
         return res.data;
     }
-    static async getCommentsByStore(storeId) {
-        const res = await this.getRequest(`${this.BASE_URL}Discuss/index?storeId=${storeId}`, this._defaultHeader)
+    static async getCommentsByStore(page=1,pageSize=10,storeId) {
+        const res = await this.getRequest(`${this.BASE_URL}Discuss/index?page=${page}&pageSize=${pageSize}&storeId=${storeId}`, this._defaultHeader)
         return res.data;
     }
-    static async getPersonComments(myDiscuss=1) {
-        const res = await this.getRequest(`${this.BASE_URL}Discuss/index?myDiscuss=${myDiscuss}`, this._defaultHeader)
+    static async getPersonComments(page=1,pageSize=10,myDiscuss=1) {
+        const res = await this.getRequest(`${this.BASE_URL}Discuss/index?page=${page}&pageSize=${pageSize}&myDiscuss=${myDiscuss}`, this._defaultHeader)
         return res.data;
     }
 

+ 19 - 0
api/order.js

@@ -0,0 +1,19 @@
+import request from '../utils/request.js'
+
+class order extends request {
+
+    static async getOrderList(page = 1, pageSize = 10, orderStatus, writeOffStatus) {
+        const res = await this.getRequest(`${this.BASE_URL}Order/index?page=${page}&pageSize=${pageSize}&orderAtatus=${orderStatus}&writeOffStatus=${writeOffStatus}`)
+
+        return res.data
+    }
+    static async getAllOrderList(page = 1, pageSize = 10) {
+        const res = await this.getRequest(`${this.BASE_URL}Order/index?page=${page}&pageSize=${pageSize}`)
+
+        return res.data
+    }
+    
+
+}
+
+export default order

+ 3 - 3
api/product.js

@@ -1,6 +1,6 @@
 import request from '../utils/request.js'
 
-class product extends request{
+class product extends request {
 
     // static errorHandel(res) {
     //     console.log(res);
@@ -14,6 +14,6 @@ class product extends request{
         const res = await this.getRequest(`${this.BASE_URL}Product/read?id=${id}`)
         return res.data;
     }
-    
+
 }
-export default product
+export default product

+ 16 - 1
api/upload.js

@@ -13,12 +13,17 @@ class uploadImg extends request {
             }
 
         );
+        var imgUrls = [];
         Promise.all(uploads).then(res => {
             //图片上传完成
             // resolve(res)
             console.log(res)
             wx.hideLoading()
-            console.log("完成")
+            res.forEach(function (item) {
+                imgUrls.push(item.data.url)
+            })
+            return imgUrls;
+
         }).catch(err => {
             // reject(err)
             console.log(err)
@@ -30,5 +35,15 @@ class uploadImg extends request {
         })
 
     }
+    static async uploadAvatar(tempFilePaths) {
+        wx.showLoading({
+            title: '上传图片中...',
+            mask: true
+        });
+        const res = await request.upload(`${this.BASE_URL}Common/upload`, 'image', tempFilePaths)
+        console.log(res)
+        wx.hideLoading()
+        return res.data.url
+    }
 }
 export default uploadImg

+ 7 - 0
api/user.js

@@ -10,5 +10,12 @@ class store extends request{
         const res = await this.postRequest(`${this.BASE_URL}User/save`, data)
         return res.data;
     }
+    static async updateUserInfo(name,birthday,avatar){
+        const res = await this.getRequest(`${this.BASE_URL}User/editUser?name=${name}&birthday=${brithday}&avatar=${avatar}`)
+    }
+    static async getUserById(userId){
+        const res = await this.getRequest(`${this.BASE_URL}User/read?id=${userId}`)
+        return res.data
+    }
 }
 export default store

+ 67 - 130
pages/comments/comments.js

@@ -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
+            })
+        }
     },
 
     /**

+ 1 - 0
pages/comments/comments.wxml

@@ -1,3 +1,4 @@
 <!--pages/comments/comments.wxml-->
 <comments commentsList="{{commentsList}}"></comments>
+<view class="comments-end c-707070 f14" wx:if="{{loadingEnd}}">已经到底啦</view>
 

+ 6 - 1
pages/comments/comments.wxss

@@ -1 +1,6 @@
-/* pages/comments/comments.wxss */
+/* pages/comments/comments.wxss */
+.comments-end {
+    text-align: center;
+    padding: 10rpx;
+    background-color: #F7F7F7;
+}

+ 2 - 7
pages/person/person.js

@@ -24,7 +24,6 @@ Page({
       })
     }
   },
-
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
@@ -35,11 +34,7 @@ Page({
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow: async function () {
-
-
-
-  },
+  onShow: async function () {},
 
   /**
    * 生命周期函数--监听页面隐藏
@@ -91,7 +86,7 @@ Page({
       hasMobile: hasMobile,
     })
   },
-  gotoComment:async function (e) {
+  gotoComment: async function (e) {
     console.log(this)
     const isAuth = await app.isAuth()
     if (!isAuth) {

+ 22 - 13
pages/personinfo/personinfo.js

@@ -1,4 +1,7 @@
 // pages/personinfo/personinfo.js
+import userApi from '../../api/user'
+const app = getApp();
+
 Page({
 
   /**
@@ -8,21 +11,31 @@ Page({
     endDate: "",
     birth: "1993-12-12",
     sex: 0,
-    array: ["男", "女"],
-    tel: "18822224444",
-    userName: "伊布",
-    imgUrl:"../../images/headImg.jpg"
+    array: ["未知", "男", "女"],
+    userName: "",
+    imgUrl: "",
+    userInfo: {}
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
+  onLoad: async function (options) {
     var d = new Date();
     var endDate = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
     this.setData({
       endDate
     })
+    let userInfo = await app.getWxUserInfo();
+    let userId = userInfo.userId;
+    let user = await userApi.getUserById(userId);
+    console.log(user)
+    this.setData({
+      sex: userInfo.gender,
+      imgUrl: user.info.avatar,
+      userName: user.info.name,
+    })
+
   },
 
   changeUserName: function (e) {
@@ -30,11 +43,6 @@ Page({
       userName: e.detail.value
     })
   },
-  changeTel: function (e) {
-    this.setData({
-      tel: e.detail.value
-    })
-  },
   changeBirth: function (e) {
     this.setData({
       birth: e.detail.value
@@ -62,7 +70,7 @@ Page({
       }
     })
   },
-
+  updatePersonInfo: async function () {},
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
@@ -81,14 +89,15 @@ Page({
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {
-
+    
   },
 
   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {
-
+    console.log('隐藏啦')
+    console.log(this.data)
   },
 
   /**

+ 3 - 3
pages/personinfo/personinfo.wxml

@@ -32,7 +32,7 @@
         <view class="title">生日</view>
         <view class="info">
             <picker mode="date" value="{{date}}" start="1970-01-01" end="{{endDate}}" bindchange="changeBirth">
-                {{birth}}
+                {{userInfo.birthday?userInfo.birthday:'1970-01-01'}}
             </picker>
         </view>
         <image class="icon" src="../../images/icons/next-gray.png">
@@ -40,7 +40,7 @@
         </image>
 
     </view>
-    <view class="tel">
+    <!-- <view class="tel">
         <view class="title">手机</view>
         <view class="info">
             <input type="text" value="{{tel}}" bindblur = "changeTel"/>
@@ -48,5 +48,5 @@
         <image class="icon" src="../../images/icons/next-gray.png">
 
         </image>
-    </view>
+    </view> -->
 </view>

+ 123 - 80
pages/personorder/personorder.js

@@ -1,5 +1,8 @@
 // pages/personorder/personorder.js
 const app = getApp()
+import orderApi from '../../api/order'
+import storeApi from '../../api/store'
+import productApi from '../../api/product'
 Page({
 
   /**
@@ -8,7 +11,23 @@ Page({
   data: {
     activeTab: 0,
     orderHeight: 0,
-    tabs:[]
+    tabs: [],
+    orderList: [],
+    pageNo: 1,
+    loadingEnd: false,
+    tabs: [{
+        title: '全部'
+      },
+      {
+        title: '代消费'
+      },
+      {
+        title: '待评价'
+      },
+      {
+        title: '已完成'
+      },
+    ]
   },
 
   /**
@@ -17,16 +36,15 @@ Page({
   onLoad: async function () {
     console.log(this)
     const isAuth = await app.isAuth()
-    if (!isAuth){
+    if (!isAuth) {
       wx.redirectTo({
-      url: '/pages/prompt/prompt?page='+this.route,
+        url: '/pages/prompt/prompt?page=' + this.route,
       })
     }
-    var tabs = await this.getOrderList();
-    this.setData({
-      tabs
-    });
-    this.getOrderHeight()
+
+
+    this.getOrderHeight();
+
   },
   //动态生成产品的父盒子高度
   getOrderHeight: function () {
@@ -36,77 +54,85 @@ Page({
       orderHeight
     })
   },
-
-  getOrderList: async function () {
-    const self = this
-    var titles = ["全部", "代消费", "待评价", "已完成"];
-    const tabs = [];
-    // 订单的三个状态,0是未付款,是未完成订单,1是未评价,待评价订单,2是已评价的完成订单
-    var list = [{
-        id: "1",
-        orderId: "20200625118",
-        orderStatus:1,
-        title: "中式古法推拿",
-        price: "1299",
-        orderTime: "8-26 16:26",
-        shopAddress: "上海市普陀区中江路3600号",
-        distance: ">6km",
-        imgurl: "../../images/order-img01.jpg"
-      },
-      {
-        id: "2",
-        orderId: "20200625118",
-        orderStatus:0,
-        title: "中式古法推拿",
-        price: "1299",
-        orderTime: "8-26 16:26",
-        shopAddress: "上海市普陀区中江路3600号",
-        distance: ">6km",
-        imgurl: "../../images/order-img02.jpg"
-      },
-      {
-        id: "3",
-        orderId: "20200625118",
-        orderStatus:2,
-        title: "中式古法推拿",
-        price: "1299",
-        orderTime: "8-26 16:26",
-        shopAddress: "上海市普陀区中江路3600号",
-        distance: ">6km",
-        imgurl: "../../images/order-img01.jpg"
-      },
-      {
-        id: "4",
-        orderId: "20200625118",
-        orderStatus:1,
-        title: "中式古法推拿",
-        price: "1299",
-        orderTime: "8-26 16:26",
-        shopAddress: "上海市普陀区中江路3600号",
-        distance: ">6km",
-        imgurl: "../../images/order-img02.jpg"
+  getOrderList: async function (params) {
+    var pageNo = this.data.pageNo;
+    var orderList = await orderApi.getAllOrderList(pageNo, 3);
+    var list = await this.handelOrderList(orderList.list);
+    //代消费订单
+    var writeOffOrderList = [];
+    //待评价订单
+    var commentOffOrderList = [];
+    //已完成订单
+    var finishOrderList = [];
+    list.forEach(function (item, u, array) {
+      if (item.status == 2 && item.writeOffStatus == 1) {
+        writeOffOrderList.push(item)
+      }
+      if (item.status == 2 && item.writeOffStatus == 2) {
+        finishOrderList.push(item)
       }
-    ];
+    })
+    var tabs = this.data.tabs;
+    tabs[0].list = list;
 
-    for (let i = 0; i < titles.length; i++) {
-      let title = titles[i];
-      tabs.push({
-        title,
-        list
-      })
-    }
-    tabs[2].list = [{
-      id: "1",
-      orderId: "20200625118",
-      title: "中式古法推拿",
-      price: "1299",
-      orderTime: "8-26 16:26",
-      shopAddress: "上海市普陀区中江路3600号",
-      distance: ">6km",
-      imgurl: "../../images/order-img02.jpg"
-    }];
-    return tabs;
+  },
+
+  // 获取全部列表
+  getAllOrderList: async function () {
+    const self = this
+    var pageNo = this.data.pageNo;
+    // 获取全部订单
+    var orderList = await orderApi.getAllOrderList(pageNo, 4);
+    var list = await this.handelOrderList(orderList.list);
+    var tabs = this.data.tabs;
+    tabs[0].list = list;
+    this.setData({
+      tabs
+    })
+    // return list;
+  },
+  // 获取代消费列表
+  getwriteOffOrderList: async function () {
+    const self = this
+    var pageNo = this.data.pageNo;
+    // 获取代消费订单
+    var orderList = await orderApi.getOrderList(pageNo, 4, 2, 1);
+    var list = await this.handelOrderList(orderList.list);
+    var tabs = this.data.tabs;
+    tabs[1].list = list;
+    this.setData({
+      tabs
+    })
+    // return list;
+  },
+  // 获取待评价列表
+  getcommentOffOrderList: async function () {
+    const self = this
+    var pageNo = this.data.pageNo;
+    // 获取代消费订单
+    var orderList = await orderApi.getOrderList(pageNo, 4, 2, 1);
+    var list = await this.handelOrderList(orderList.list);
+    var tabs = this.data.tabs;
+    tabs[2].list = list;
+    this.setData({
+      tabs
+    })
+    // return list;
+  },
 
+  // 获取已经完成的列表
+  getfinishOrderList: async function (params) {
+    const self = this
+    var pageNo = this.data.pageNo;
+    // 获取代消费订单
+    var orderList = await orderApi.getOrderList(pageNo, 4, 2, 1);
+    var list = await this.handelOrderList(orderList.list);
+    var tabs = this.data.tabs;
+    tabs[3].list = list;
+    this.setData({
+      tabs
+    })
+    // return list;
   },
   onTabClick(e) {
     const index = e.detail.index
@@ -123,13 +149,29 @@ Page({
     })
   },
   handleClick(e) {
-   
+
+  },
+
+
+
+
+  handelOrderList: async function (list) {
+
+    list.forEach(async function (item, i, array) {
+      let store = await storeApi.getStoreById(item.storeId);
+      let product = await productApi.getProductById(item.productId);
+      item.address = store.info.address;
+      item.productName = product.info.productName;
+      item.productImg = product.info.productImg;
+    })
+    return list
+
   },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-
+  onReady: async function () {
+    await this.getOrderList()
   },
 
   /**
@@ -173,7 +215,8 @@ Page({
   onShareAppMessage: function () {
 
   },
-  gotoComment:function (e) {
+  gotoComment: function (e) {
+
     wx.navigateTo({
       url: '../commentinfo/commentinfo',
     })

+ 0 - 1
pages/personorder/personorder.json

@@ -1,5 +1,4 @@
 {
-  "disableScroll": true,
   "usingComponents": {
     "mp-icon": "weui-miniprogram/icon/icon",
     "mp-tabs": "/componets/tabs/index"

+ 8 - 8
pages/personorder/personorder.wxml

@@ -10,27 +10,27 @@
                         <view class="orderinfo card">
                             <view class="order-item">
                                 <view class="order-img">
-                                    <image class="" src="{{item.imgurl}}">
+                                    <image class="" src="{{item.productImg}}">
 
                                     </image>
                                 </view>
                                 <view class="order-desc">
-                                    <view class="order-id f13 c-707070">{{item.orderId}}</view>
+                                    <view class="order-id f13 c-707070">{{item.orderSn}}</view>
                                     <view class="order-title c-202020">
-                                        <view class="title">{{item.title}}</view>
+                                        <view class="title">{{item.productName}}</view>
 
                                     </view>
-                                    <view class="order-price f18">¥{{item.price}}</view>
+                                    <view class="order-price f18">¥{{item.orderMoney}}</view>
 
                                     <view class="order-date f13 c-707070">
                                         <mp-icon icon="time" size="18" class="icon" color="#707070"></mp-icon>
-                                        {{item.orderTime}}
+                                        {{item.appointmentTime}}
                                     </view>
                                     <view class="order-shop-address">
                                         <view class="address f13 c-707070">
                                             <mp-icon icon="location" size="18" class="icon" type="filled"
                                                 color="#707070"></mp-icon>
-                                            {{item.shopAddress}}
+                                            {{item.address}}
                                         </view>
                                         <view class="distance f13 ">{{item.distance}}</view>
                                     </view>
@@ -41,8 +41,8 @@
                             </view>
                             <view class="operate-btn">
                                 <view class="buy-again btn f14" wx:if="{{item.orderStatus !==0}}">再来一单</view>
-                                <view class="comment btn f14" wx:if="{{item.orderStatus==1}}"  bindtap = "gotoComment">评价</view>
-                                <view class="pay btn f14" wx:if="{{item.orderStatus==0}}">付款</view>
+                                <view class="comment btn f14" wx:if="{{item.status==1}}" data-orderId="{{}}" bindtap = "gotoComment">评价</view>
+                                <view class="pay btn f14" wx:if="{{item.orderStatus==1}}">付款</view>
                             </view>
                         </view>
                     </block>

+ 25 - 127
pages/product/product.js

@@ -1,20 +1,18 @@
 // pages/productinfo/productinfo.js
 import productApi from '../../api/product'
-
+import commentsApi from '../../api/comments'
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-        productinfo: {
-            title: "葛优躺(北京躺)电影足疗",
-            price: "666",
-            commentsList: []
-        },
+     
         shopId: 0,
         productId: 0,
-        product: {}
+        product: {},
+        commentsList:[],
+        commentsNum:0
 
     },
 
@@ -28,130 +26,30 @@ Page({
         var shopId = options.shopId;
         var productId = options.productId;
         var product = await productApi.getProductById(productId);
+        var comments = await commentsApi.getCommentsByProduct(1,10,shopId, productId);
+        //对返回的评论列表进行处理
+        var list = this.standardCommentsList(comments.list);
+        console.log(list)
         this.setData({
             shopId,
             productId,
-            product: product.info
+            product: product.info,
+            commentsList: list,
+            commentsNum:comments.count
         })
-
-        /*    var list = [{
-             id: 1,
-             headImg: "../../images/headImg.jpg",
-             product: "葛优躺(北京躺)电影足疗",
-             assessDate: "2020-02-02",
-             stars: 5,
-             comments: {
-                 content: "3号技师特别好~~~赞一个,下次还来。",
-                 imgs: [{
-                         imgurl: "../../images/commentsImg01.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg02.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg03.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg03.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg02.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg01.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg02.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg01.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg03.jpg"
-                     },
-                 ]
-             }
-         }, {
-             id: 2,
-             headImg: "../../images/headImg.jpg",
-             product: "葛优躺(北京躺)电影足疗",
-             assessDate: "2020-02-02",
-             stars: 5,
-             comments: {
-                 content: "3号技师特别好~~~赞一个,下次还来。",
-                 imgs: [{
-                         imgurl: "../../images/commentsImg01.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: "../../images/commentsImg01.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg02.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg01.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg03.jpg"
-                     },
-
-                 ]
-             }
-         }, {
-             id: 5,
-             headImg: "../../images/headImg.jpg",
-             product: "葛优躺(北京躺)电影足疗",
-             assessDate: "2020-02-02",
-             stars: 5,
-             comments: {
-                 content: "3号技师特别好~~~赞一个,下次还来。",
-                 imgs: [{
-                         imgurl: "../../images/commentsImg01.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg02.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg03.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg02.jpg"
-                     },
-                     {
-                         imgurl: "../../images/commentsImg01.jpg"
-                     },
-
-                 ]
-             }
-         }];
-
-         
-         this.setData({
-             // id: options.id,
-             commentsList: list,
-         })
-         */
+        
+       
+      
+    },
+    standardCommentsList: function (list) {
+        list.forEach(function (item, i, array) {
+            let urls = item.imgUrls;
+            let imgs = urls.split(',');
+            item.imgs = imgs;
+            let time = item.createTime.trim().split(" ")[0];
+            item.commentTime = time
+        })
+        return list;
     },
 
     /**

+ 4 - 5
pages/product/product.wxml

@@ -17,9 +17,8 @@
 
                 网友点评
             </view>
-            <view class="all-comments f15 .c-707070"  bindtap = "gotoAllComments"
-                >
-                全部{{commentsList.length}}条
+            <view class="all-comments f15 .c-707070" bindtap="gotoAllComments">
+                全部{{commentsNum}}条
                 <mp-icon icon="arrow" size="12" class="comments-icon" color="#707070"></mp-icon>
             </view>
         </view>
@@ -28,8 +27,8 @@
     </view>
     <!-- 预约 -->
     <!-- <navigator class="appointment card" url="../appointment/appointment?price={{productinfo.price}}" hover-class="appointment-hover" open-type="navigate"> -->
-    <view class="appointment card"  hover-class="appointment-hover" >
-        <view class="btn" bindtap = "gotoAppointment">
+    <view class="appointment card" hover-class="appointment-hover">
+        <view class="btn" bindtap="gotoAppointment">
             立即预约
         </view>
     </view>

+ 15 - 9
pages/shop/shop.js

@@ -1,25 +1,31 @@
 // pages/shoplist/shoplist.js
-import { default as storeApi} from "../../api/store"
+import {
+  default as storeApi
+} from "../../api/store"
+import commentsApi from '../../api/comments'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-shopList:[]
+    shopList: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad:async function (options) {
-   var rs = await storeApi.getStoreList(1,5);
-   console.log(rs)
-   this.setData({
-    shopList:rs.list
-   })
+  onLoad: async function (options) {
+    
+    var rs = await storeApi.getStoreList(1, 5);
+  
+    console.log(rs)
+    this.setData({
+      shopList: rs.list,
+      
+    })
   },
-
+ 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 52 - 187
pages/shopinfo/shopinfo.js

@@ -1,6 +1,7 @@
 // pages/shopinfo/shopinfo.js
 import storeApi from '../../api/store'
 import productApi from '../../api/product'
+import commentsApi from '../../api/comments'
 Page({
 
     /**
@@ -8,73 +9,15 @@ Page({
      */
     data: {
 
-        shopInfo: {
-            shopImg: "../../images/shopImg.jpg",
-            shopName: "大华店",
-            stars: 5,
-            shopAddress: "上海市宝山区域大华虎城A座10L",
-            shopTel: "0556-7158735",
-            products: [{
-                    imgurl: "../../images/p1.jpg",
-                    title: "电影足疗60分钟",
-                    oldPrice: "298",
-                    newPrice: "198",
-                    discount: "6.7"
-                },
-                {
-                    imgurl: "../../images/p2.jpg",
-                    title: "中式古法推拿套餐",
-                    oldPrice: "298",
-                    newPrice: "258",
-                    discount: "8.7"
-                }, {
-                    imgurl: "../../images/p3.jpg",
-                    title: "小时代电影足疗90分钟",
-                    oldPrice: "368",
-                    newPrice: "258",
-                    discount: "7.0"
-                }, {
-                    imgurl: "../../images/p4.jpg",
-                    title: "小时代PLUS电影足疗120分钟",
-                    oldPrice: "498",
-                    newPrice: "338",
-                    discount: "6.8"
-                }, {
-                    imgurl: "../../images/p5.jpg",
-                    title: "采耳加钟",
-                    oldPrice: "298",
-                    newPrice: "198",
-                    discount: "6.7"
-                }, {
-                    imgurl: "../../images/p6.jpg",
-                    title: "第六感精油SPA90分钟",
-                    oldPrice: "598",
-                    newPrice: "398",
-                    discount: "6.7"
-                }, {
-                    imgurl: "../../images/p7.jpg",
-                    title: "温阳臀疗/肾疗",
-                    oldPrice: "880",
-                    newPrice: "668",
-                    discount: "7.6"
-                }, {
-                    imgurl: "../../images/p8.jpg",
-                    title: "电全身淋巴排毒(含腹股沟)",
-                    oldPrice: "880",
-                    newPrice: "768",
-                    discount: "8.8"
-                }, {
-                    imgurl: "../../images/p9.jpg",
-                    title: "神秘多巴胺组合套餐",
-                    oldPrice: "1688",
-                    newPrice: "1288",
-                    discount: "7.7"
-                },
-            ],
-            shopDesc: "本店所有商品照片为专业摄影师拍摄,后期起精心修制及色彩调整,尽量与实际商品保持一致,但由于拍摄时的用光、角度、显示器色彩偏差、个人对颜色的认知等方面的差异,导致实物可能会与照片存在一些色差,最终颜色以实际商品为准。"
-        },
+        shopInfo: {},
         commentsList: [],
-        productList: []
+        productList: [],
+        shopId: 0,
+        pageNo: 1,
+        pageSum: '',
+        loadingEnd: false,
+        commentsNum: 0
+
     },
 
     /**
@@ -82,130 +25,37 @@ Page({
      */
     onLoad: async function (options) {
 
-        var list = [{
-            id: 1,
-            headImg: "../../images/headImg.jpg",
-            product: "葛优躺(北京躺)电影足疗",
-            assessDate: "2020-02-02",
-            stars: 5,
-            comments: {
-                content: "3号技师特别好~~~赞一个,下次还来。",
-                imgs: [{
-                        imgurl: "../../images/commentsImg01.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg02.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg03.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg03.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg02.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg01.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg02.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg01.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg03.jpg"
-                    },
-                ]
-            }
-        }, {
-            id: 2,
-            headImg: "../../images/headImg.jpg",
-            product: "葛优躺(北京躺)电影足疗",
-            assessDate: "2020-02-02",
-            stars: 5,
-            comments: {
-                content: "3号技师特别好~~~赞一个,下次还来。",
-                imgs: [{
-                        imgurl: "../../images/commentsImg01.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: "../../images/commentsImg01.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg02.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg01.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg03.jpg"
-                    },
-
-                ]
-            }
-        }, {
-            id: 5,
-            headImg: "../../images/headImg.jpg",
-            product: "葛优躺(北京躺)电影足疗",
-            assessDate: "2020-02-02",
-            stars: 5,
-            comments: {
-                content: "3号技师特别好~~~赞一个,下次还来。",
-                imgs: [{
-                        imgurl: "../../images/commentsImg01.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg02.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg03.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg02.jpg"
-                    },
-                    {
-                        imgurl: "../../images/commentsImg01.jpg"
-                    },
-
-                ]
-            }
-        }];
-        await this.getShopInfo(options.id);
+        this.setData({
+            shopId: options.id
+        })
+        await this.getShopInfo();
+        await this.getCommentsList()
 
-        // this.setData({
-        //     productList
-        // });
-        /*  this.setData({
-            shopId:options.id,
-            productList,
+    },
+    getCommentsList: async function () {
+        var page = this.data.pageNo;
+        var shopId = this.data.shopId;
+        var comments = await commentsApi.getCommentsByStore(page, 2, shopId);
+        //对返回的评论列表进行处理
+        var commList = this.standardCommentsList(comments.list);
+        var commentsList = this.data.commentsList;
+        var list = commentsList.concat(commList)
+        this.setData({
             commentsList: list,
+            pageSum: comments.pageCount,
+            commentsNum: comments.count
         })
- */
     },
-
+    standardCommentsList: function (list) {
+        list.forEach(function (item, i, array) {
+            let urls = item.imgUrls;
+            let imgs = urls.split(',');
+            item.imgs = imgs;
+            let time = item.createTime.trim().split(" ")[0];
+            item.commentTime = time
+        })
+        return list;
+    },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
@@ -246,6 +96,20 @@ Page({
      */
     onReachBottom: function () {
 
+        var self = this;
+        var pageNo = self.data.pageNo;
+        pageNo += 1;
+
+        self.setData({
+            pageNo
+        })
+        if (self.data.pageNo <= self.data.pageSum) {
+            self.getCommentsList()
+            return
+        }
+        self.setData({
+            loadingEnd: true
+        })
     },
 
     /**
@@ -254,8 +118,9 @@ Page({
     onShareAppMessage: function () {
 
     },
-    getShopInfo: async function (shopId) {
+    getShopInfo: async function () {
         const self = this;
+        var shopId = self.data.shopId;
         const productList = await productApi.getProductList(1, 100);
         const shopInfo = await storeApi.getStoreById(shopId);
         console.log(productList)

+ 4 - 14
pages/shopinfo/shopinfo.scss

@@ -116,24 +116,14 @@
 
     .comments {
         margin-bottom: 10rpx;
-
-        .all-comments {
-            position: relative;
-
-            .comments-icon {
-                position: absolute;
-                top: -1rpx;
-                left: 380rpx;
-            }
+        >.comments-end {
+            text-align: center;
+            padding: 10rpx;
+            background-color: #F7F7F7;
         }
     }
 }
 
-.all-comments {
-    height: 100rpx;
-    line-height: 100rpx;
-    padding-left: 150rpx;
-}
 
 .padding40 {
     padding-left: 40rpx;

+ 5 - 2
pages/shopinfo/shopinfo.wxml

@@ -73,9 +73,12 @@
    </view>
    <view class="comments card">
       <view class="shop-title f17 fw600">
-         全部评论({{commentsList.length}})
+         全部评论({{commentsNum}})
+      </view>
+      <comments commentsList="{{commentsList}}"></comments>
+      <view class="comments-end c-707070 f14" wx:if="{{loadingEnd}}">
+         已经到底啦
       </view>
-      <comments commentsList="{{[commentsList[0],commentsList[1],commentsList[1]]}}"></comments>
    </view>
 
 </view>

+ 4 - 14
pages/shopinfo/shopinfo.wxss

@@ -108,20 +108,10 @@
   margin-bottom: 10rpx;
 }
 
-.container .comments .all-comments {
-  position: relative;
-}
-
-.container .comments .all-comments .comments-icon {
-  position: absolute;
-  top: -1rpx;
-  left: 380rpx;
-}
-
-.all-comments {
-  height: 100rpx;
-  line-height: 100rpx;
-  padding-left: 150rpx;
+.container .comments > .comments-end {
+  text-align: center;
+  padding: 10rpx;
+  background-color: #F7F7F7;
 }
 
 .padding40 {