Преглед изворни кода

✨ 对接反馈记录/首页/订单详情

谢创宏 пре 3 година
родитељ
комит
6d04ab8bb7


BIN
images/icon_03.png


BIN
images/icon_06.png


BIN
images/icon_07.png


+ 69 - 15
pages/feedback/feedback.js

@@ -66,19 +66,25 @@ Page({
66 66
       3: '一般',
67 67
       4: '满意',
68 68
       5: '非常好',
69
-    }
69
+    },
70
+    edit: "false"
70 71
   },
71 72
 
72 73
   /**
73 74
    * 生命周期函数--监听页面加载
74 75
    */
75 76
   onLoad: function (options) {
77
+    console.log(options)
76 78
     if(options.orderId) {
77 79
       this.setData({
78 80
         orderId: options.orderId,
79 81
         cover: options.cover,
80
-        name: options.name
82
+        name: options.name,
83
+        edit: options.edit || "false" 
81 84
       })
85
+      if(options.edit == "true") {
86
+        this.getfeedbackInfo(options.orderId)
87
+      }
82 88
     }
83 89
   },
84 90
 
@@ -251,20 +257,32 @@ Page({
251 257
   */
252 258
   onSubmit() {
253 259
     // api/feedback/add
254
-    let { orderId,value,raterList } = this.data;
260
+    let { orderId,value,raterList,edit } = this.data;
255 261
     console.log(this.data.imgs)
256
-    post('api/feedback/add',{
257
-      order_id: orderId,
258
-      content: value,
259
-      media_list: JSON.stringify(this.data.imgs),
260
-      score_whole: raterList[0].num,
261
-      score_effect: raterList[1].num,
262
-      score_price: raterList[2].num,
263
-      score_kind: raterList[3].num,
264
-      score_safe: raterList[4].num,
265
-    },(res) => {
266
-      console.log(res)
267
-    })
262
+    console.log(edit)
263
+    if(edit == "true") {
264
+      this.editFeedbackUpdate()
265
+    } else {
266
+      post('api/feedback/add',{
267
+        order_id: orderId,
268
+        content: value,
269
+        media_list: JSON.stringify(this.data.imgs),
270
+        score_whole: raterList[0].num,
271
+        score_effect: raterList[1].num,
272
+        score_price: raterList[2].num,
273
+        score_kind: raterList[3].num,
274
+        score_safe: raterList[4].num,
275
+      },(res) => {
276
+        console.log(res)
277
+        wx.showToast({
278
+          title: res.msg,
279
+          icon: 'none'
280
+        })
281
+        setTimeout(() => {
282
+          wx.navigateBack()
283
+        }, 1500);
284
+      })
285
+    }
268 286
   },
269 287
 
270 288
   /**
@@ -313,4 +331,40 @@ Page({
313 331
       })
314 332
     })
315 333
   },
334
+
335
+  /**
336
+   * 获取订单反馈详情
337
+   * api/feedback/info
338
+  */
339
+  getfeedbackInfo(id) {
340
+    get('api/feedback/info',{ id },(res) => {
341
+      this.setData({
342
+        value: res.data.content,
343
+        imgs: JSON.parse(res.data.media_list),
344
+        raterList: []
345
+      })
346
+    })
347
+  },
348
+
349
+  /**
350
+   * 编辑反馈记录
351
+   * api/feedback/update
352
+  */
353
+  editFeedbackUpdate() {
354
+    let { orderId,value,imgs } = this.data;
355
+    post('api/feedback/update',{
356
+      id: orderId,
357
+      content: value,
358
+      media_list: JSON.stringify(imgs)
359
+    },(res) => {
360
+      wx.showToast({
361
+        title: res.msg,
362
+        icon: 'none'
363
+      })
364
+      setTimeout(() => {
365
+        wx.navigateBack()
366
+      }, 1500);
367
+      console.log(res)
368
+    })
369
+  }
316 370
 })

+ 4 - 4
pages/feedback/feedback.wxml

@@ -30,21 +30,21 @@
30 30
               <image class="img-content" data-index="{{index}}" src="{{ item.url }}" alt="" bindtap="previewMedia"></image>
31 31
             </block>
32 32
           </view>
33
-          <image src="" class="delete-img" data-index="{{index}}" bindtap="onDeleteItem"></image>
33
+          <image src="/images/icon_03.png" class="delete-img" data-index="{{index}}" bindtap="onDeleteItem"></image>
34 34
         </view>
35 35
         
36 36
         <view class="item upload flex-column flex-center" wx:if="{{ imgs.length < 9 &&imgs[0].type != 'video' }}" bindtap="chooseVideo">
37
-          <image src=""></image>
37
+          <image src="/images/icon_06.png"></image>
38 38
           <text style="font-size: 28rpx;">添加视频</text>
39 39
         </view>
40 40
         <view class="item upload flex-column flex-center" wx:if="{{ imgs.length < 9}}" bindtap="chooseImage">
41
-          <image src=""></image>
41
+          <image src="/images/icon_07.png"></image>
42 42
           <text style="font-size: 28rpx;">添加图片</text>
43 43
         </view>
44 44
       </view>
45 45
     </view>
46 46
   </view>
47
-  <view class="detail border-radius rater">
47
+  <view class="detail border-radius rater" wx:if="{{ raterList.length > 0 }}">
48 48
     <view class="rater-text">
49 49
       <text style="font-family: PingFangSC-Medium, PingFang SC;font-weight: 500;">客户评价</text>
50 50
       <text style="font-size: 28rpx;color:#999;">(选填,且只有第一次填写生效)</text>

+ 1 - 1
pages/feedback/feedback.wxss

@@ -89,7 +89,7 @@
89 89
 .change-img .upload image {
90 90
   width: 48rpx;
91 91
   height: 48rpx;
92
-  background-color: #ccc;
92
+  /* background-color: #ccc; */
93 93
   margin-bottom: 6rpx;
94 94
 }
95 95
 

+ 44 - 11
pages/orderDetail/orderDetail.js

@@ -29,6 +29,7 @@ Page({
29 29
     page: 1,
30 30
     index: 0,
31 31
     visible: false,
32
+    currentItem: {}
32 33
   },
33 34
 
34 35
   /**
@@ -40,7 +41,6 @@ Page({
40 41
       id: options.orderId
41 42
     },() => {
42 43
       this.getOrderInfo()
43
-      this.getFeedbackList()
44 44
     })
45 45
   },
46 46
 
@@ -55,14 +55,16 @@ Page({
55 55
    * 生命周期函数--监听页面显示
56 56
    */
57 57
   onShow: function () {
58
-
58
+    this.getFeedbackList(1)
59 59
   },
60 60
 
61 61
   /**
62 62
    * 生命周期函数--监听页面隐藏
63 63
    */
64 64
   onHide: function () {
65
-
65
+    this.setData({
66
+      visible: false
67
+    })
66 68
   },
67 69
 
68 70
   /**
@@ -110,9 +112,11 @@ Page({
110 112
   /**
111 113
    * 打开弹框
112 114
    */
113
-  onEditItem() {
115
+  onEditItem(e) {
116
+    console.log(e)
114 117
     this.setData({
115
-      visible: true
118
+      visible: true,
119
+      currentItem: e.currentTarget.dataset.item
116 120
     })
117 121
   },
118 122
 
@@ -126,12 +130,34 @@ Page({
126 130
   },
127 131
 
128 132
   /**
129
-   * 图片预览
130
-   */
131
-  previewImage(e) {
132
-    wx.previewImage({
133
-      current: e.currentTarget.dataset.index,
134
-      urls: this.data.urls
133
+   * 预览图片和视频
134
+  */
135
+  previewMedia(e) {
136
+    let { idx,index } = e.currentTarget.dataset;
137
+    let arr = this.data.list[idx].media_list
138
+    let current = index
139
+    wx.previewMedia({
140
+      sources: arr,
141
+      current
142
+    })
143
+  },
144
+
145
+  /**
146
+   * 删除反馈记录
147
+   * api/feedback/delete
148
+  */
149
+  onDelete(e) {
150
+    post('api/feedback/delete',{
151
+      id: this.data.currentItem.id
152
+    },(res) => {
153
+      wx.showToast({
154
+        title: res.msg,
155
+        icon: 'none'
156
+      })
157
+      this.setData({
158
+        visible: false     
159
+      })
160
+      this.getFeedbackList(1)
135 161
     })
136 162
   },
137 163
 
@@ -160,6 +186,13 @@ Page({
160 186
       page: _page || page,
161 187
       limit: 10
162 188
     },(res) => {
189
+      if (_page == 1 || page == 1) {
190
+        list = []
191
+        this.data.page = 1
192
+      }
193
+      res.data.list.forEach((item,index) => {
194
+        item.media_list = JSON.parse(item.media_list)
195
+      })
163 196
       list.push(...res.data.list)
164 197
       this.setData({ list,total: res.data.total, })
165 198
       console.log(res)

+ 29 - 13
pages/orderDetail/orderDetail.wxml

@@ -33,9 +33,9 @@
33 33
         <text>预约费用:</text>
34 34
         <text style="color: #333333;">¥{{ detailData.order_price }}</text>
35 35
       </view>
36
-      <view class="flex-justify-space-between">
36
+      <view class="flex-justify-space-between" wx:if="{{ detailData.discount_type == 2 }}">
37 37
         <text>优惠券:</text>
38
-        <text style="color: #333333;">-¥888.88</text>
38
+        <text style="color: #333333;">-¥{{ detailData.discount }}</text>
39 39
       </view>
40 40
       <view class="flex-justify-space-between" wx:if="{{ detailData.discount_type == 2 }}">
41 41
         <text>优惠券类型:</text>
@@ -62,32 +62,48 @@
62 62
         <view class="btn flex-center">新增反馈</view>
63 63
       </navigator>
64 64
     </view>
65
-    <view class="item flex-column" wx:for="{{list}}" wx:key="index">
65
+    <view class="item flex-column" wx:for="{{list}}" wx:for-index="idx" wx:key="index">
66 66
       <view class="user-info flex-align-center">
67
-        <image></image>
67
+        <image src="{{ item.avatar_url }}"></image>
68 68
         <view class="info flex-column flex1">
69
-          <text style="font-size: 28rpx;margin-bottom: 6rpx;">查理兹·塞隆…</text>
70
-          <text style="font-size: 20rpx;color: #999;">下午  3:45</text>
69
+          <text style="font-size: 28rpx;margin-bottom: 6rpx;">{{ item.nickname }}</text>
70
+          <text style="font-size: 20rpx;color: #999;">{{ item.create_time }}</text>
71 71
         </view>
72
-        <view class="more flex-align-center flex-justify-space-between" bindtap="onEditItem">
72
+        <view class="more flex-align-center flex-justify-space-between" data-item="{{ item }}" bindtap="onEditItem" wx:if="{{ item.allow_edit == 1 }}">
73 73
           <text></text>
74 74
           <text></text>
75 75
           <text></text>
76 76
         </view>
77 77
         <!-- <view class="more">···</view> -->
78 78
       </view>
79
-      <text style="font-size: 28rpx;color: #666;">当前皮肤毛孔出现堵塞,抓哟集中在T区,主要问题在于自身油脂分泌过多。</text>
80
-      <view class="box">
81
-        <image src="{{item}}" data-index="{{item}}" bindtap="previewImage" wx:for="{{urls}}" wx:key="index"></image>
79
+      <text style="font-size: 28rpx;color: #666;margin-bottom: 30rpx;">{{ item.content }}</text>
80
+      <view class="box" wx:if="{{ item.media_list && item.media_list.length > 0 }}">
81
+        <view class="item-media" wx:for="{{ item.media_list }}" wx:key="index">
82
+          <block wx:if="{{ item.type == 'video' }}">
83
+            <!-- <video src="{{ item.url }}"></video> -->
84
+            <!-- <text>视频播放</text> -->
85
+            <view class="flex-center" style="font-size: 28rpx;width: 100%;height: 100%;background-color: #ccc;" data-idx="{{ idx }}" data-index="{{index}}" bindtap="previewMedia">
86
+              <!-- 这个是视频 -->
87
+              <image class="icon-01" src="/images/icon_01.png"></image>
88
+              <!-- <text style="position: absolute;">这个是视频</text> -->
89
+              <image class="img-content" data-index="{{index}}" src="{{ item.thumb }}" alt=""></image>
90
+            </view>
91
+          </block>
92
+          <block wx:if="{{ item.type == 'image' }}">
93
+            <image class="img-content" data-idx="{{ idx }}" data-index="{{index}}" src="{{ item.url }}" alt="" bindtap="previewMedia"></image>
94
+          </block>
95
+        </view>
96
+        
97
+        <!-- <image src="{{item.url}}" data-index="{{item}}" bindtap="previewImage" wx:for="{{item.media_list}}" wx:key="index"></image> -->
82 98
       </view>
83 99
     </view>
84 100
   </view>
85
-  <view class="no-more-data">已经到底啦~~</view>
101
+  <view class="no-more-data" style="display: {{list.length > 0 && list.length >= total ? 'block' : 'none'}};">已经到底啦~~</view>
86 102
 </view>
87 103
 
88 104
 <wux-popup class="popup-radius" position="bottom" catchtouchmove="isShow" visible="{{ visible }}" bind:close="onPopupState">
89
-  <view class="btn-item flex-center" style="color: #FF77B0;">删除</view>
90
-  <navigator url="/pages/feedback/feedback" hover-class="none">
105
+  <view class="btn-item flex-center" style="color: #FF77B0;" bindtap="onDelete">删除</view>
106
+  <navigator url="/pages/feedback/feedback?orderId={{ currentItem.id }}&cover={{ detailData.cover_url }}&name={{ detailData.project_name }}&edit=true" hover-class="none">
91 107
     <view class="btn-item flex-center">编辑</view>
92 108
   </navigator>
93 109
   <view class="btn-item flex-center" style="color: #999999;" bindtap="onPopupState">取消</view>

+ 20 - 4
pages/orderDetail/orderDetail.wxss

@@ -97,7 +97,7 @@
97 97
   width: 64rpx;
98 98
   height: 64rpx;
99 99
   border-radius: 50%;
100
-  background-color: red;
100
+  /* background-color: red; */
101 101
   margin-right: 14rpx;
102 102
 }
103 103
 
@@ -119,14 +119,30 @@
119 119
   display: grid;
120 120
   grid-gap: 20rpx 22rpx;
121 121
   grid-template-columns: repeat(3, 1fr);
122
-  padding: 30rpx 0;
122
+  padding: 0rpx 0 30rpx;
123 123
 }
124 124
 
125
-.list .box image {
125
+.list .box .item-media {
126 126
   width: 198rpx;
127 127
   height: 198rpx;
128
+  border-radius: 16px;
129
+  box-sizing: border-box;
130
+  overflow: hidden;
131
+  position: relative;
132
+}
133
+
134
+.list .box image {
135
+  width: 100%;
136
+  height: 100%;
128 137
   border-radius: 16rpx;
129
-  background-color: red;
138
+  /* background-color: red; */
139
+}
140
+
141
+
142
+.list .box .icon-01 {
143
+  width: 64rpx;
144
+  height: 64rpx;
145
+  position: absolute;
130 146
 }
131 147
 
132 148
 .btn-item {

+ 1 - 1
utils/http.js

@@ -48,7 +48,7 @@ function http(url,method,params, success, fail) {
48 48
           title: data.msg,
49 49
           icon: 'none'
50 50
         })
51
-        login()
51
+        // login()
52 52
       }
53 53
     },
54 54
     fail() {