瀏覽代碼

fix:(用户订单页的评价,再来一单,预约页面数据接入)

sunshine1130 4 年之前
父節點
當前提交
c18c3324c0
共有 43 個文件被更改,包括 405 次插入390 次删除
  1. 14 6
      api/comments.js
  2. 5 1
      api/order.js
  3. 8 2
      api/store.js
  4. 4 26
      api/upload.js
  5. 2 2
      componets/comments/index.wxml
  6. 二進制
      images/commentsImg01.jpg
  7. 二進制
      images/commentsImg02.jpg
  8. 二進制
      images/commentsImg03.jpg
  9. 二進制
      images/headImg.jpg
  10. 0 0
      images/icons/right.png
  11. 二進制
      images/order-img01.jpg
  12. 二進制
      images/order-img02.jpg
  13. 二進制
      images/p1.jpg
  14. 二進制
      images/p2.jpg
  15. 二進制
      images/p3.jpg
  16. 二進制
      images/p4.jpg
  17. 二進制
      images/p5.jpg
  18. 二進制
      images/p6.jpg
  19. 二進制
      images/p7.jpg
  20. 二進制
      images/p8.jpg
  21. 二進制
      images/p9.jpg
  22. 二進制
      images/pos.png
  23. 二進制
      images/product01.jpg
  24. 二進制
      images/product02.jpg
  25. 二進制
      images/richText.png
  26. 二進制
      images/shop.jpg
  27. 二進制
      images/shopImg.jpg
  28. 48 213
      pages/appointment/appointment.js
  29. 10 3
      pages/appointment/appointment.scss
  30. 27 19
      pages/appointment/appointment.wxml
  31. 11 2
      pages/appointment/appointment.wxss
  32. 89 28
      pages/commentinfo/commentinfo.js
  33. 0 1
      pages/commentinfo/commentinfo.json
  34. 3 3
      pages/commentinfo/commentinfo.wxml
  35. 1 1
      pages/index/index.wxml
  36. 11 15
      pages/order/order.js
  37. 8 8
      pages/order/order.wxml
  38. 49 30
      pages/personorder/personorder.js
  39. 1 1
      pages/personorder/personorder.scss
  40. 14 5
      pages/personorder/personorder.wxml
  41. 0 1
      pages/personorder/personorder.wxss
  42. 14 11
      pages/product/product.js
  43. 86 12
      utils/date.js

+ 14 - 6
api/comments.js

@@ -3,18 +3,26 @@ import request from '../utils/request.js'
 
 class comments extends request {
 
-    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)
+    static async getCommentsByProduct(page = 1, pageSize = 10, storeId, productId) {
+        const res = await this.postRequest(`${this.BASE_URL}Discuss/index?page=${page}&pageSize=${pageSize}&productId=${productId}&storeId=${storeId}`, this._defaultHeader)
         return res.data;
     }
-    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)
+    static async getCommentsByStore(page = 1, pageSize = 10, storeId) {
+        const res = await this.postRequest(`${this.BASE_URL}Discuss/index?page=${page}&pageSize=${pageSize}&storeId=${storeId}`, this._defaultHeader)
         return res.data;
     }
-    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)
+    static async getPersonComments(page = 1, pageSize = 10, myDiscuss = 1) {
+        const res = await this.postRequest(`${this.BASE_URL}Discuss/index?page=${page}&pageSize=${pageSize}&myDiscuss=${myDiscuss}`, this._defaultHeader)
         return res.data;
     }
+    static async sendDiscuss(storeId, productId, orderId, productScore, storeScore, content, imgUrls) {
+        const res = await this.postRequest(`${this.BASE_URL}Discuss/save?storeId=${storeId}&productId=${productId}&orderId=${orderId}&productScore=${productScore}&storeScore=${storeScore}&content=${content}&imgUrls=${imgUrls}`, this._defaultHeader)
+        
+        return res.code;
+        
+
+
+    }
 
 
 }

+ 5 - 1
api/order.js

@@ -12,7 +12,11 @@ class order extends request {
 
         return res.data
     }
-    
+    static async getOrderById(id) {
+        const res = await this.getRequest(`${this.BASE_URL}Order/read?id=${id}`)
+        return res.data
+    }
+
 
 }
 

+ 8 - 2
api/store.js

@@ -1,6 +1,6 @@
 import request from '../utils/request.js'
 
-class store extends request{
+class store extends request {
 
     // static errorHandel(res) {
     //     console.log(res);
@@ -22,5 +22,11 @@ class store extends request{
         })
         return res.data;
     }
+    static async getStoreAppointTime(id) {
+        const res = await this.postRequest(`${this.BASE_URL}Store/appointmentTime?storeId=${id}`)
+        return res.data;
+    }
+
+
 }
-export default store
+export default store

+ 4 - 26
api/upload.js

@@ -7,32 +7,10 @@ class uploadImg extends request {
             title: '上传图片中...',
             mask: true
         });
-        var uploads = [];
-        tempFilePaths.forEach((item, i) => {
-                uploads[i] = request.upload(`${this.BASE_URL}Common/upload`, 'image', item)
-            }
-
-        );
-        var imgUrls = [];
-        Promise.all(uploads).then(res => {
-            //图片上传完成
-            // resolve(res)
-            console.log(res)
-            wx.hideLoading()
-            res.forEach(function (item) {
-                imgUrls.push(item.data.url)
-            })
-            return imgUrls;
-
-        }).catch(err => {
-            // reject(err)
-            console.log(err)
-            wx.hideLoading()
-            wx.showToast({
-                title: '上传失败请重试',
-                icon: 'none'
-            })
-        })
+        const res = await request.upload(`${this.BASE_URL}Common/upload`, 'image', tempFilePaths)
+        wx.hideLoading()
+        return res.data.url
+       
 
     }
     static async uploadAvatar(tempFilePaths) {

+ 2 - 2
componets/comments/index.wxml

@@ -20,8 +20,8 @@
         <view class="comment-content padding5">
             <view class=" fw300 padding5">{{item.content}}</view>
             <view class="imgs">
-                <view class="comment-img " hidden="{{item.imgs.length<1}}" wx:for-index="index" wx:for="{{item.imgs}}" wx:key="imgurl">
-                        <image class="comm-img" src="{{item}}"  data-index="{{index}}"  data-active="{{fatherindex}}"  bindtap = "previewImg">
+                <view class="comment-img " wx:for-item="img" hidden="{{item.imgs.length<1}}" wx:for-index="index" wx:for="{{item.imgs}}" wx:key="imgurl">
+                        <image class="comm-img" wx:if="{{img}}" src="{{img}}"  data-index="{{index}}"  data-active="{{fatherindex}}"  bindtap = "previewImg">
                             
                         </image>
                 </view>

二進制
images/commentsImg01.jpg


二進制
images/commentsImg02.jpg


二進制
images/commentsImg03.jpg


二進制
images/headImg.jpg


images/right.png → images/icons/right.png


二進制
images/order-img01.jpg


二進制
images/order-img02.jpg


二進制
images/p1.jpg


二進制
images/p2.jpg


二進制
images/p3.jpg


二進制
images/p4.jpg


二進制
images/p5.jpg


二進制
images/p6.jpg


二進制
images/p7.jpg


二進制
images/p8.jpg


二進制
images/p9.jpg


二進制
images/pos.png


二進制
images/product01.jpg


二進制
images/product02.jpg


二進制
images/richText.png


二進制
images/shop.jpg


二進制
images/shopImg.jpg


+ 48 - 213
pages/appointment/appointment.js

@@ -1,6 +1,7 @@
 const app = getApp();
 import productApi from '../../api/product'
 import storeApi from '../../api/store'
+import createTimeApi from '../../utils/date'
 Page({
 
   /**
@@ -9,13 +10,19 @@ Page({
   data: {
     peopleNum: 1,
     activeTab: 0,
-    productInfo: {
-     
-    },
     shopInfo: {},
+    shopId: 0,
+    storeName:'',
+    productId: 0,
+    productImg: '',
+    productName: '',
+    price: 0,
     tabs: [],
     orderTime: "",
-    orderTimeHeight: 0
+    orderTimeHeight: 0,
+    days: [],
+
+
   },
 
   /**
@@ -24,20 +31,19 @@ Page({
   onLoad: async function (options) {
     var shopId = options.shopId;
     var productId = options.productId
-    var productInfo = await productApi.getProductById(productId);
-    var shopInfo = await storeApi.getStoreById(shopId);
+    var productImg = options.productImg;
+    var productName = options.productName;
+    var price = options.price;
+
     this.setData({
-      productInfo: productInfo.info,
-      shopInfo:shopInfo.info
+      shopId,
+      productId,
+      productImg,
+      productName,
+      price
     })
 
 
-    var tabs = await this.createTimeList(268);
-    this.setData({
-      tabs
-    });
-    this.getOrderHeight();
-    this.checkedTime()
   },
   checkAuth: async function () {
     console.log(this)
@@ -56,206 +62,26 @@ Page({
       activeTab: e.detail.index
     })
   },
-  //动态生成产品的父盒子高度
-  getOrderHeight: function () {
-    var activeTab = this.data.activeTab;
-    var orderTimeHeight = (this.data.tabs[activeTab].list.length) / 5 * 130;
+ 
+  createTimeList: async function () {
+    var storeId = this.data.shopId;
+    var price = this.data.price;
+    var shopInfo = await storeApi.getStoreById(storeId);
+    var openTime = shopInfo.info.openTime;
+    var closeTime = shopInfo.info.closeTime;
+    var date = await storeApi.getStoreAppointTime(storeId);
+    var days = date.date;
+    console.log(days) 
+    const tabs = createTimeApi.createTimeList(openTime, closeTime, days, price);
+    console.log(tabs)
     this.setData({
-      orderTimeHeight
-    })
-  },
-  createTimeList: async function (price) {
-    var titles = ["今天", "明天", "12-23", "12-24", "12-25", "12-26", "12-27"];
-    var day = ["12-21", "12-22", "12-23", "12-24", "12-25", "12-26", "12-27"];
-    const tabs = [];
-    let list = [{
-        id: "1",
-        time: "8:00",
-        price: price,
-
-      },
-      {
-        id: "2",
-        time: "8:30",
-        price: price,
-
-      },
-      {
-        id: "3",
-        time: "9:00",
-        price: price,
-
-      },
-      {
-        id: "4",
-        time: "9:30",
-        price: price,
-
-      },
-      {
-        id: "5",
-        time: "10:00",
-        price: price,
-
-      },
-      {
-        id: "6",
-        time: "10:30",
-        price: price,
-
-      },
-      {
-        id: "7",
-        time: "11:00",
-        price: price,
-
-      },
-      {
-        id: "8",
-        time: "11:30",
-        price: price,
-
-      }, {
-        id: "9",
-        time: "12:00",
-        price: price,
-
-      },
-      {
-        id: "10",
-        time: "12:30",
-        price: price,
-
-      },
-      {
-        id: "11",
-        time: "13:00",
-        price: price,
-
-      },
-      {
-        id: "12",
-        time: "13:30",
-        price: price,
-
-      },
-      {
-        id: "13",
-        time: "14:00",
-        price: price,
-
-      },
-      {
-        id: "14",
-        time: "14:30",
-        price: price,
-
-      },
-      {
-        id: "15",
-        time: "15:00",
-        price: price,
-
-      },
-      {
-        id: "16",
-        time: "15:30",
-        price: price,
-
-      }, {
-        id: "17",
-        time: "16:00",
-        price: price,
-
-      },
-      {
-        id: "18",
-        time: "16:30",
-        price: price,
-
-      },
-      {
-        id: "19",
-        time: "17:00",
-        price: price,
-
-      },
-      {
-        id: "20",
-        time: "17:30",
-        price: price,
-
-      },
-      {
-        id: "21",
-        time: "18:00",
-        price: price,
-
-      },
-      {
-        id: "22",
-        time: "18:30",
-        price: price,
-
-      },
-      {
-        id: "23",
-        time: "19:00",
-        price: price,
-
-      },
-      {
-        id: "24",
-        time: "19:30",
-        price: price,
-
-      },
-      {
-        id: "25",
-        time: "20:00",
-        price: price,
-
-      }
-    ];
-
-    titles.forEach(function (item, i, array) {
-      list.forEach(function (item, i, array) {
-        array[i].timeId = i;
-        array[i].inTime = true;
-        array[i].checked = false;
-      })
-
-      tabs.push({
-        title: titles[i],
-        day: day[i],
-        list
-      })
+      storeName:shopInfo.info.storeName,
+      days,
+      tabs
     })
-    // tabs[2].list.splice(7,7)
-    return tabs;
-
-
   },
 
-  //判断产品是否过时间
-  checkedTime: function (e) {
-    // 设置一小时内订单不能购买
-    var timeLimit = 1;
-    var nowTime = new Date(2020, 11, 21, 18, 29, 0);
-    var hour = nowTime.getHours();
-    var tabs = this.data.tabs[0];
-    var list = firstTabs.list;
-    // console.log(tabs[5].list)
-    list.forEach(function (item, i, array) {
-      var orderHour = item.time.split(":")[0];
-      if (parseInt(orderHour) <= parseInt(hour)) {
-        item.inTime = false;
-      }
-    })
-    this.setData({
-      tabs: nowTabs
-    })
-  },
+ 
 
   getOrderTime: function (e) {
     // var date = document.getElementById("orderDate");
@@ -266,7 +92,7 @@ Page({
     //选中时间的下标
     var index = e.currentTarget.dataset.i;
     //获取选中的日期
-    var date = this.data.tabs[i].day;
+    var date = this.data.days[i];
     var time = e.currentTarget.dataset.time;
     var oTime = date + '/' + time;
 
@@ -320,8 +146,9 @@ Page({
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow: function () {
+  onShow: async function () {
 
+    this.createTimeList();
   },
 
   /**
@@ -357,5 +184,13 @@ Page({
    */
   onShareAppMessage: function () {
 
-  }
+  },
+   //动态生成产品的父盒子高度
+ /*   getOrderHeight: function () {
+    var activeTab = this.data.activeTab;
+    var orderTimeHeight = (this.data.tabs[activeTab].list.length) / 5 * 130;
+    this.setData({
+      orderTimeHeight
+    })
+  }, */
 })

+ 10 - 3
pages/appointment/appointment.scss

@@ -1,7 +1,13 @@
 .container {
-
+    width: 100%;
+    height: 100%;
     background-color: #F7F7F7;
-    max-height: 699px;
+    .product-img{
+        width: 100%;
+        >image{
+            width: 100%;
+        }
+    }
     .product-title,
     .shop-name {
         width: 100%;
@@ -48,12 +54,13 @@
     .order-time{
         background-color: #fff;
         margin-bottom: 20rpx;
+        padding-bottom: 20rpx;
         display: flex;
         justify-content: flex-start;
         position: relative;
         .weui-tabs {
             width: 100%;
-            height: 800rpx;
+            
             .weui-tabs-bar__wrp {
                 .weui-tabs-bar__content {
                     height: 95rpx;

+ 27 - 19
pages/appointment/appointment.wxml

@@ -1,6 +1,9 @@
 <view class="container">
-    <view class="product-title card f17">{{productInfo.productName}}</view>
-    <view class="shop-name card f17">门店·{{shopInfo.storeName}}</view>
+    <view class="product-img">
+        <image src="{{productImg}}"></image>
+    </view>
+    <view class="product-title card f17">{{productName}}</view>
+    <!-- <view class="shop-name card f17">门店·{{storeName}}</view> -->
     <view class="people-num card">
         <view class="title">选择人数</view>
         <view class="num-box">
@@ -18,31 +21,36 @@
         </view>
     </view>
     <view class="order-time card">
-        <mp-tabs tabs="{{tabs}}" style="width: 100%;" data-active="{{activeTab}}" activeTab="{{activeTab}}" swiperClass="weui-tabs-swiper" bindtabclick="onTabClick"
-        bindchange="onSlideChangeEnd" activeClass="tab-bar-title__selected" tabActiveTextColor="#E32490" swiperHeight="{{(tabs[activeTab].list.length)/5*140}}">
-        <block wx:for="{{tabs}}" wx:key="title">
+        <mp-tabs tabs="{{tabs}}" style="width: 100%;" data-active="{{activeTab}}" activeTab="{{activeTab}}"
+            swiperClass="weui-tabs-swiper" bindtabclick="onTabClick" bindchange="onSlideChangeEnd"
+            activeClass="tab-bar-title__selected" tabActiveTextColor="#E32490"
+            swiperHeight="{{(tabs[activeTab].list.length)/5*140}}">
+            <block wx:for="{{tabs}}" wx:key="title">
 
-            <view class="tab-content" data-set="{{item}}" slot="tab-content-{{index}}" bind:tap="handleClick" style="height: {{orderTimeHeight}}rpx;">
-                <view  class="orders" style="height: {{orderTimeHeight}}rpx;overflow-y: auto;">
-                    <block wx:for="{{tabs[index].list}}"wx:for-index="index" wx:key="id">
-                        
-                       <view class="time-info {{item.checked&&item.inTime?'select-time':''}}  {{item.inTime?'':'out-time'}}"  data-time="{{item.time}}"  data-i="{{index}}"  bindtap = "getOrderTime" >
-                           <view class="time fw300" >{{item.time}}</view>
-                           <view class="price fw300" >¥{{productInfo.currentPrice}}</view>
-                       </view>
-                    </block>
+                <view class="tab-content" data-set="{{item}}" slot="tab-content-{{index}}" bind:tap="handleClick"
+                    style="height: {{(tabs[activeTab].list.length)/5*140}}rpx;">
+                    <view class="orders" style="height: {{(tabs[activeTab].list.length)/5*140}}rpx;overflow-y: auto;">
+                        <block wx:for="{{tabs[activeTab].list}}" wx:for-index="index" wx:key="id">
+                           
+                            <view
+                                class="time-info {{item.checked&&item.inTime?'select-time':''}}  {{item.inTime?'':'out-time'}}"
+                                data-time="{{item.time}}" data-i="{{index}}" bindtap="getOrderTime">
+                                <view class="time fw300">{{item.time}}</view>
+                                <view class="price fw300">¥{{item.price}}</view>
+                            </view>
+                        </block>
 
+                    </view>
                 </view>
-            </view>
-        </block>
-    </mp-tabs>
+            </block>
+        </mp-tabs>
 
     </view>
     <navigator class="appointment card" url="" hover-class="appointment-hover" open-type="navigate">
-        <view class="btn" bindtap = "checkAuth">
+        <view class="btn" bindtap="checkAuth">
             确认预约
         </view>
     </navigator>
 
-    
+
 </view>

+ 11 - 2
pages/appointment/appointment.wxss

@@ -1,6 +1,15 @@
 .container {
+  width: 100%;
+  height: 100%;
   background-color: #F7F7F7;
-  max-height: 699px;
+}
+
+.container .product-img {
+  width: 100%;
+}
+
+.container .product-img > image {
+  width: 100%;
 }
 
 .container .product-title,
@@ -53,6 +62,7 @@
 .container .order-time {
   background-color: #fff;
   margin-bottom: 20rpx;
+  padding-bottom: 20rpx;
   display: flex;
   justify-content: flex-start;
   position: relative;
@@ -60,7 +70,6 @@
 
 .container .order-time .weui-tabs {
   width: 100%;
-  height: 800rpx;
 }
 
 .container .order-time .weui-tabs .weui-tabs-bar__wrp .weui-tabs-bar__content {

+ 89 - 28
pages/commentinfo/commentinfo.js

@@ -1,5 +1,6 @@
 // pages/commentinfo/commentinfo.js
 
+import commentsApi from '../../api/comments';
 import uploadApi from '../../api/upload'
 Page({
 
@@ -11,14 +12,21 @@ Page({
     productStars: 5,
     textWidth: 0,
     wordsNum: 0,
-    limitNum: 100,
+    limitNum: 70,
     outLimit: false,
     commentText: "",
     imgs: [],
+    orderId: 0,
+    productId: 0,
+    shopId: 0,
+    imgurls: [],
+
+
+
   },
 
   // 上传图片
-  chooseImg: function (e) {
+  chooseImg: async function (e) {
     var that = this;
     var imgs = this.data.imgs;
     if (imgs.length >= 9) {
@@ -36,10 +44,11 @@ Page({
       // count: 1, // 默认9
       sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
       sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
-      success: function (res) {
+      success: async function (res) {
         // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
-        var tempFilePaths = res.tempFilePaths;
-        var imgs = that.data.imgs;
+        let tempFilePaths = res.tempFilePaths;
+        console.log(tempFilePaths)
+        let imgs = that.data.imgs;
         // console.log(tempFilePaths + '----');
         for (var i = 0; i < tempFilePaths.length; i++) {
           if (imgs.length >= 9) {
@@ -48,14 +57,14 @@ Page({
             });
             return false;
           } else {
-            imgs.push(tempFilePaths[i]);
+            var imgUrl = await uploadApi.uploadCommentImgs(tempFilePaths[i]);
+            imgs.push(imgUrl);
           }
         }
-        uploadApi.uploadCommentImgs(tempFilePaths)
-        
         that.setData({
-          imgs: imgs
-        });
+          imgs
+        })
+
       }
     });
   },
@@ -81,14 +90,58 @@ Page({
       urls: imgs
     })
   },
-  sendComment: function (e) {
+  sendComment: async function (e) {
+    let self = this;
+    let wordsNum = this.data.wordsNum;
+    let limitNum = this.data.limitNum;
+    let content = this.data.commentText;
+    let imgs = this.data.imgs;
+    if (wordsNum > limitNum) {
+      wx.showModal({
+        title: '字数超出限制!',
+        content: '请按规定的字数评价。',
+        showCancel: false,
+        confirmText: "确定"
+      })
+      return;
+    }
+    if (wordsNum == 0) {
+      wx.showModal({
+        title: '请填写评论',
+        content: '请谈谈你对产品的评价吧',
+        showCancel: false,
+        confirmText: "确定"
+      })
+      return;
+    }
+    let storeScore = this.data.shopStars;
+    let productScore = this.data.productStars;
+    let imgUrls = imgs.join(',');
+    let storeId = this.data.shopId;
+    let productId = this.data.productId;
+    let orderId = this.data.orderId;
+
+    let code = await commentsApi.sendDiscuss(storeId, productId, orderId, productScore, storeScore, content, imgUrls);
+    if (code == 1) {
+      wx.showModal({
+        title: '评论成功!',
+        content: '评论可以在我的评论中查看',
+        showCancel: false,
+        confirmText: "确定",
+        success(res) {
+          wx.switchTab({
+            url: '../personorder/personorder',
+          })
+        }
+      })
 
-    wx.showModal({
-      title: '评论成功!',
-      content: '评论可以在我的评论中查看',
-      showCancel: false,
-      confirmText: "确定"
-    })
+    } else {
+      wx.showModal({
+        title: '评论失败!',
+        showCancel: false,
+        confirmText: "确定"
+      })
+    }
 
 
   },
@@ -110,22 +163,21 @@ Page({
 
   //根据当前的评论字数更改字数的num
   changeComment: function (e) {
-    // console.log(e.detail)
-    // console.log(e.detail.value.length)
-    var length = e.detail.value.length;
+
+    var length = e.detail.cursor;
+    var content = e.detail.value;
     if (length > this.data.limitNum) {
       this.setData({
-        outLimit: true
+        wordsNum: length,
+        outLimit: true,
+        commentText: content
       })
+      return;
     }
     this.setData({
-      wordsNum: e.detail.value.length
-    })
-  },
-  //填写评论文字内容
-  setCommenText: function (e) {
-    this.setData({
-      commentText: e.detail.value
+      wordsNum: length,
+      outLimit: false,
+      commentText: content
     })
   },
   /**
@@ -136,6 +188,15 @@ Page({
     this.setData({
       textWidth
     })
+    console.log(options)
+    var orderId = options.id;
+    var shopId = options.shopId;
+    var productId = options.productId;
+    this.setData({
+      orderId,
+      productId,
+      shopId
+    })
 
   },
 

+ 0 - 1
pages/commentinfo/commentinfo.json

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

+ 3 - 3
pages/commentinfo/commentinfo.wxml

@@ -51,7 +51,7 @@
     <view class="comment-text">
         <view class="words f14">
 
-            <textarea bindblur="setCommenText" style="height: 200rpx;width: {{textWidth}}rpx;" auto-focus="true"
+            <textarea style="height: 200rpx;width: {{textWidth}}rpx;" auto-focus="true"
                 class="comm-text" placeholder="对产品跟服务满意吗?(评论限制{{limitNum}}字以内)" bindinput="changeComment" />
             <view class="words-num">
                     <view class="word {{outLimit?'red':''}}">
@@ -66,7 +66,7 @@
     <view class="comment-img card">
         <view class="weui-uploader">
             <view class="img-v weui-uploader__bd">
-              <view class='pic' wx:for="{{imgs}}" wx:for-item="item" wx:key="*this">
+              <view class='pic' wx:for="{{imgs}}" wx:for-item="item" wx:key="*this" wx:for-index="index">
                   <image class='weui-uploader__img '
                           src="{{item}}"
                           data-index="{{index}}" mode="aspectFill" bindtap="previewImg">
@@ -87,7 +87,7 @@
             </view>
             
         </view>
-        <!-- <button class="upload-img-btn" bindtap="chooseImg" type='primary'>拍照  / 上传</button> -->
+        
     </view>
     
     <view class="comment-btn f18" bindtap = "sendComment">发布评论</view>

+ 1 - 1
pages/index/index.wxml

@@ -8,7 +8,7 @@
         </view>
         <navigator class="c-202020 f15" url="../shop/shop" hover-class="none" open-type="navigate">
           查看全部
-          <image class="" src="../../images/right.png" style="width: 25rpx;height: 25rpx;">
+          <image class="" src="../../images/icons/right.png" style="width: 25rpx;height: 25rpx;">
           </image>
         </navigator>
       </view>

+ 11 - 15
pages/order/order.js

@@ -1,7 +1,7 @@
 import {
   drawById
 } from "../../utils/qrcode"
-
+import orderApi from '../../api/order'
 // pages/order/order.js
 Page({
 
@@ -9,28 +9,24 @@ Page({
    * 页面的初始数据
    */
   data: {
-    order: {
-      orderId: 202020058792,
-      title: "葛优躺(北京躺)电影足疗",
-      price: 298,
-      orderTime: "12-12 17:00~18:00",
-
-    },
-    shop: {
-      name: "大华店",
-      address: "上海市徐汇区漕溪北路88号",
-      tel: "021-1234567"
-    }
+    order: {}
 
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
+  onLoad: async function (options) {
+
+    var orderId = options.id;
+    let order = await orderApi.getOrderById(orderId);
+    this.setData({
+      order: order.info
+    })
     drawById.call(wx, "qrCode", {
-      text: this.data.order.orderId, // 二维码内容
+      text: order.info.writeOffCode, // 二维码内容
     })
+
   },
 
   createQrcode: function () {

+ 8 - 8
pages/order/order.wxml

@@ -11,40 +11,40 @@
     </view>
     <view class="order card">
         <view class="order-img">
-            <image class="" src="../../images/order-img01.jpg">
+            <image class="" src="{{order.productImg}}">
 
             </image>
         </view>
         <view class="order-info">
 
-            <view class="order-id f13 c-707070">{{order.orderId}}</view>
+            <view class="order-id f13 c-707070">{{order.orderSn}}</view>
             <view class="order-title c-202020">
-                {{order.title}}
+                {{order.productName}}
 
             </view>
-            <view class="order-price f18">¥{{order.price}}</view>
+            <view class="order-price f18">¥{{order.orderMoney}}</view>
 
             <view class="order-date f13 c-707070">
                 <mp-icon icon="time" size="18" class="icon" color="#707070"></mp-icon>
-                {{order.orderTime}}
+                {{order.appointmentTime}}
             </view>
 
         </view>
     </view>
     <view class="shop-info card">
         <view class="shop f17">
-            {{ shop.name}}
+            {{ order.storeName}}
         </view>
         <view class="address f14 c-707070 ">
             <image src="../../images/icons/location.png"></image>
-            {{shop.address}}
+            {{order.address}}
         </view>
         <view class="f17 shop">
             场馆电话
         </view>
         <view class="tel f14 c-707070 ">
             <image src="../../images/icons/tel.png"></image>
-            {{shop.tel}}
+            {{order.mobile}}
         </view>
     </view>
 </view>

+ 49 - 30
pages/personorder/personorder.js

@@ -1,8 +1,6 @@
 // pages/personorder/personorder.js
 const app = getApp()
 import orderApi from '../../api/order'
-import storeApi from '../../api/store'
-import productApi from '../../api/product'
 Page({
 
   /**
@@ -57,7 +55,8 @@ Page({
   getOrderList: async function (params) {
     var pageNo = this.data.pageNo;
     var orderList = await orderApi.getAllOrderList(pageNo, 3);
-    var list = await this.handelOrderList(orderList.list);
+    var list = orderList.list;
+    console.log(list)
     //代消费订单
     var writeOffOrderList = [];
     //待评价订单
@@ -68,12 +67,21 @@ Page({
       if (item.status == 2 && item.writeOffStatus == 1) {
         writeOffOrderList.push(item)
       }
-      if (item.status == 2 && item.writeOffStatus == 2) {
+      if (item.status == 2 && item.writeOffStatus == 2 && item.discussId != '') {
         finishOrderList.push(item)
       }
+      if (item.status == 2 && item.writeOffStatus == 2 && item.discussId == '') {
+        commentOffOrderList.push(item)
+      }
     })
     var tabs = this.data.tabs;
     tabs[0].list = list;
+    tabs[1].list = writeOffOrderList;
+    tabs[2].list = commentOffOrderList;
+    tabs[3].list = finishOrderList;
+    this.setData({
+      tabs
+    })
 
   },
 
@@ -83,9 +91,8 @@ Page({
     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;
+    tabs[0].list = orderList.list;
     this.setData({
       tabs
     })
@@ -97,9 +104,8 @@ Page({
     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;
+    tabs[1].list = orderList.list;
     this.setData({
       tabs
     })
@@ -111,9 +117,8 @@ Page({
     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;
+    tabs[2].list = orderList.list;
     this.setData({
       tabs
     })
@@ -121,14 +126,13 @@ Page({
   },
 
   // 获取已经完成的列表
-  getfinishOrderList: async function (params) {
+  getfinishOrderList: 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[3].list = list;
+    tabs[3].list = orderList.list;
     this.setData({
       tabs
     })
@@ -152,33 +156,34 @@ Page({
 
   },
 
-
-
-
-  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;
+  showOrderInfo: async function (e) {
+    console.log(e.currentTarget)
+    var orderId = e.currentTarget.dataset.orderid;
+    var status = e.currentTarget.dataset.status;
+    var writeStatus = e.currentTarget.dataset.writestatus;
+    wx.navigateTo({
+      url: '/pages/order/order?id=' + orderId,
     })
-    return list
+    /*  if(status==2&&writeStatus==1){
+       wx.navigateTo({
+         url: 'pages/order/order?orderId='+orderId,
+       })
+       return
+     } */
 
   },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: async function () {
-    await this.getOrderList()
+  onReady: function () {
+
   },
 
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow: function () {
-
+  onShow: async function () {
+    await this.getOrderList()
   },
 
   /**
@@ -216,9 +221,23 @@ Page({
 
   },
   gotoComment: function (e) {
+    var orderId = e.currentTarget.dataset.orderid;
+    var shopId = e.currentTarget.dataset.shopid;
+    var productId = e.currentTarget.dataset.productid;
 
     wx.navigateTo({
-      url: '../commentinfo/commentinfo',
+      url: '../commentinfo/commentinfo?id=' + orderId + '&shopId=' + shopId + '&productId=' + productId,
+    })
+  },
+  // 再来一单
+  buyAgain: function (e) {
+    var shopId = e.currentTarget.dataset.shopid;
+    var productId = e.currentTarget.dataset.productid;
+    var productImg = e.currentTarget.dataset.productimg;
+    var productName = e.currentTarget.dataset.productname;
+    var price = e.currentTarget.dataset.price;
+    wx.navigateTo({
+      url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&productImg=' + productImg + '&productName=' + productName + '&price=' + price,
     })
   }
 })

+ 1 - 1
pages/personorder/personorder.scss

@@ -93,7 +93,7 @@
             .operate-btn{
                 display: flex;
                 justify-content: flex-end;
-                height: 100rpx;
+                
                 .btn{
                     width: 150rpx;
                     height: 60rpx;

+ 14 - 5
pages/personorder/personorder.wxml

@@ -1,14 +1,16 @@
 <!--pages/personorder/personorder.wxml-->
 <view class="container">
     <mp-tabs tabs="{{tabs}}" activeTab="{{activeTab}}" swiperClass="weui-tabs-swiper" bindtabclick="onTabClick"
-        bindchange="onChange" activeClass="tab-bar-title__selected" tabActiveTextColor="#E32490" swiperHeight="{{(tabs[activeTab].list.length)*420}}">
+        bindchange="onChange" activeClass="tab-bar-title__selected" tabActiveTextColor="#E32490"
+        swiperHeight="{{(tabs[activeTab].list.length)*420}}">
         <block wx:for="{{tabs}}" wx:key="title">
 
             <view class="tab-content" data-set="{{item}}" slot="tab-content-{{index}}" bind:tap="handleClick">
                 <view style="overflow-y: auto;height:{{orderHeight}}rpx" class="orders">
                     <block wx:for="{{tabs[index].list}}" wx:key="id">
                         <view class="orderinfo card">
-                            <view class="order-item">
+                            <view class="order-item" bindtap="showOrderInfo" data-orderid="{{item.id}}"
+                                data-status="{{item.status}}" data-writestatus="{{item.writeOffStatus}}">
                                 <view class="order-img">
                                     <image class="" src="{{item.productImg}}">
 
@@ -32,7 +34,7 @@
                                                 color="#707070"></mp-icon>
                                             {{item.address}}
                                         </view>
-                                        <view class="distance f13 ">{{item.distance}}</view>
+                                        <!-- <view class="distance f13 ">{{item.distance}}</view> -->
                                     </view>
 
 
@@ -40,8 +42,15 @@
                                 </view>
                             </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.status==1}}" data-orderId="{{}}" bindtap = "gotoComment">评价</view>
+                                <view class="buy-again btn f14" data-shopid="{{item.storeId}}"
+                                    data-productid="{{item.productId}}" data-productimg="{{item.productImg}}"
+                                    data-productname="{{item.productName}}" data-price="{{item.orderMoney}}"
+                                    catchtap="buyAgain" wx:if="{{item.status==2&&item.writeOffStatus==2}}">再来一单
+                                </view>
+                                <view class="comment btn f14"
+                                    wx:if="{{item.status==2&&item.writeOffStatus==2&&item.discussId==''}}"
+                                    data-orderid="{{item.id}}" data-shopid="{{item.storeId}}"
+                                    data-productid="{{item.productId}}" bindtap="gotoComment">评价</view>
                                 <view class="pay btn f14" wx:if="{{item.orderStatus==1}}">付款</view>
                             </view>
                         </view>

+ 0 - 1
pages/personorder/personorder.wxss

@@ -89,7 +89,6 @@
 .container .orders .orderinfo .operate-btn {
   display: flex;
   justify-content: flex-end;
-  height: 100rpx;
 }
 
 .container .orders .orderinfo .operate-btn .btn {

+ 14 - 11
pages/product/product.js

@@ -7,12 +7,12 @@ Page({
      * 页面的初始数据
      */
     data: {
-     
+
         shopId: 0,
         productId: 0,
         product: {},
-        commentsList:[],
-        commentsNum:0
+        commentsList: [],
+        commentsNum: 0
 
     },
 
@@ -26,7 +26,7 @@ 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 comments = await commentsApi.getCommentsByProduct(1, 10, shopId, productId);
         //对返回的评论列表进行处理
         var list = this.standardCommentsList(comments.list);
         console.log(list)
@@ -35,11 +35,11 @@ Page({
             productId,
             product: product.info,
             commentsList: list,
-            commentsNum:comments.count
+            commentsNum: comments.count
         })
-        
-       
-      
+
+
+
     },
     standardCommentsList: function (list) {
         list.forEach(function (item, i, array) {
@@ -104,14 +104,17 @@ Page({
         var shopId = this.data.shopId;
         var productId = this.data.productId;
         wx.navigateTo({
-          url: '../comments/comments?title=全部评论&commentstype=all&shopId='+shopId+'&productId='+productId,
+            url: '../comments/comments?title=全部评论&commentstype=all&shopId=' + shopId + '&productId=' + productId,
         })
     },
-    gotoAppointment:function (e) {
+    gotoAppointment: function (e) {
         var shopId = this.data.shopId;
         var productId = this.data.productId;
+        var productImg = this.data.product.productImg;
+        var productName = this.data.product.productName;
+        var price = this.data.product.currentPrice;
         wx.navigateTo({
-          url: '../appointment/appointment?shopId='+shopId+'&productId='+productId,
+            url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&productImg=' + productImg + '&productName=' + productName + '&price=' + price,
         })
     }
 })

+ 86 - 12
utils/date.js

@@ -1,12 +1,86 @@
- function addDays(date, days,seperator='-') {
-    let oDate = new Date(date).valueOf();
-    let nDate = oDate + days * 24 * 3600 * 1000;
-    nDate = new Date(nDate);
-    let y = nDate.getFullYear().toString().padStart(2, 0);
-    let m = (nDate.getMonth() + 1).toString().padStart(2, 0);
-    let d = nDate.getDate().toString().padStart(2, 0);
-    return `${y}${seperator}${m}${seperator}${d}`
-  }
-
-
- 
+ //生成某个时间段内每半小时为间隔的时间数组
+ function createHourList(openTime, closeTime, price) {
+
+   let openHour = parseInt(openTime.split(':')[0]);
+   let openMin = parseInt(openTime.split(':')[1]);
+   let closeHour = parseInt(closeTime.split(':')[0]);
+   let closeMin = parseInt(closeTime.split(':')[1]);
+   let openDate = new Date().setHours(openHour, openMin);
+   let closeDate = new Date().setHours(closeHour, closeMin);
+   var dateList = [];
+   while (closeDate >= openDate) {
+     var hour = new Date(closeDate).getHours() < 10 ? '0' + new Date(closeDate).getHours() : new Date(closeDate).getHours();
+     var minute = new Date(closeDate).getMinutes() < 30 ? '00' : '30';
+     dateList.unshift({
+       time: hour + ':' + minute,
+       price: price
+     });
+     closeDate -= 30 * 60 * 1000
+   }
+   dateList.pop()
+   return dateList;
+ }
+ //判断产品是否过时间
+ function checkedTime(list) {
+   // 设置一小时内订单不能购买
+   var timeLimit = 1;
+   var nowTime = new Date('2020-12-27 14:02:00');
+   var hour = nowTime.getHours();
+   var checkList = [];
+   // console.log(tabs[5].list)
+   list.forEach(function (item, i, array) {
+     var orderHour = parseInt(item.time.split(":")[0]);
+     var orderMin = parseInt(item.time.split(':')[1]);
+     if (orderHour < parseInt(hour)) {
+       item.inTime = false;
+     }
+     if (orderHour == parseInt(hour) && orderMin < 30) {
+       item.inTime = false;
+     }
+     checkList.push(item)
+   })
+   return checkList;
+ }
+//生成预约界面的时间列表
+ function createTimeList(openTime, closeTime, days, price) {
+   let tabs = []
+   days.forEach((item, i, array) => {
+     tabs.push({
+       title: item,
+       list: []
+     });
+   })
+   console.log('----------------')
+   tabs[0].title = "今天";
+   tabs[1].title = "明天";
+   tabs.forEach((item, index, array) => {
+     let timeList = createHourList(openTime, closeTime, price);
+     let list = item.list
+     timeList.forEach((time, i, array) => {
+       list.push(time)
+     })
+
+   })
+   console.log(tabs)
+   tabs.forEach((item, index, array) => {
+     item.list.forEach((listitem, i, listArray) => {
+       //时间id
+       listitem.timeId = i
+       //是否处于可用时间内
+       listitem.inTime = true;
+       //是否被选中
+       listitem.checked = false;
+     })
+   })
+   var nowTimeList = checkedTime(tabs[0].list);
+   tabs[0].list = nowTimeList;
+
+   return tabs;
+
+ }
+
+
+ module.exports = {
+   createTimeList: createTimeList,
+
+ }