2
0

5 Коммиты bcce88ab22 ... f157bc9fa5

Автор SHA1 Сообщение Дата
  ycm f157bc9fa5 11 2 лет назад
  ycm 57e3949eea Merge branch 'master' of http://git.nanodreamtech.com/dream/laundry 2 лет назад
  ycm edb0415325 1 2 лет назад
  ycm ed4d126d98 11 2 лет назад
  ycm e818e31b2c 11 2 лет назад

+ 41 - 30
pages/order/confirmOreder/confirmOreder.js

@@ -8,23 +8,7 @@ Page({
      */
     data: {
         isonline: 1,
-        currentList: [{
-            tit: '塑封包膜',
-            num: "30",
-            id: 1
-        }, {
-            tit: '绒面鞋补色',
-            num: "20",
-            id: 2
-        }, {
-            tit: '防水处理',
-            num: "20",
-            id: 3
-        }, {
-            tit: '防水处理',
-            num: "10",
-            id: 4
-        }],
+        currentList: [],
         mode: 1,
         checked: true,
         show1: false,
@@ -45,13 +29,8 @@ Page({
     },
     onLoad(opticon) {
         let order_no = opticon.order_no;
-        let currentList = this.data.currentList
-        currentList.map(item => {
-            item.active = false
-        })
         this.detail(order_no);
         this.setData({
-            currentList,
             order_no
         })
 
@@ -75,6 +54,12 @@ Page({
         }
     },
     goyhq(){
+        if(this.data.couponinfo){
+            this.setData({
+                total_price: parseFloat(parseFloat(this.data.total_price) + parseFloat(this.data.couponinfo.money)).toFixed(2)
+            })
+        }
+        console.log(this.data.total_price)
         wx.navigateTo({
           url: '../coupon/coupon?totalprice='+this.data.total_price+'&freight='+this.data.freight,
         })
@@ -120,7 +105,12 @@ Page({
                     mode:unit.type,
                     order_type:unit.type,
                     freight:unit.price,
-                    total_price:(total_price+price).toFixed(2)
+                    total_price:(total_price+price).toFixed(2),
+                    currentList: res.message.data.services
+                })
+                let currentList = that.data.currentList
+                currentList.map(item => {
+                    item.active = false
                 })
             }
 
@@ -149,17 +139,26 @@ Page({
         });
     },
     chios(e) {
+        let that = this
         let { item } = e.currentTarget.dataset
 
-        let currentList = this.data.currentList
+        let currentList = that.data.currentList
         currentList.map((it, index) => {
             if (item.id == it.id) {
-                it.active = !it.active
+                // it.active = !it.active
+                if(it.active){
+                    it.active = false
+                    that.setData({total_price: (parseFloat(that.data.total_price) + parseFloat((it.price.start_time && it.price.end_time)?it.price.sale_price*it.stock:it.price.price*it.stock)).toFixed(2)})
+                }else{
+                    it.active = true
+                    that.setData({total_price: (parseFloat(that.data.total_price) - parseFloat((it.price.start_time && it.price.end_time)?it.price.sale_price*it.stock:it.price.price*it.stock)).toFixed(2)})
+                }
             }
         })
-        this.setData({
+        that.setData({
             currentList
         })
+        // total_price
     },
     changeMode(e) {
         var id = e.currentTarget.dataset.id
@@ -167,13 +166,13 @@ Page({
         var unit=this.data.orderinfo.network.unit[key];
 
         
-        var total_price=parseFloat(this.data.orderinfo.total_price);
+        var total_price=parseFloat(this.data.total_price)
         var price=parseFloat(unit.price)
-        
+        console.log(total_price,price)
         this.setData({
             mode: id,
             freight:unit.price,
-            total_price:total_price+price
+            total_price:parseFloat(total_price+price).toFixed(2)
     
         })
     },
@@ -324,12 +323,24 @@ Page({
         if(that.data.couponinfo!=''&&that.data.couponinfo!=undefined){
             cid = that.data.couponinfo.pivot.id
         }
+        let services = []
+        that.data.currentList.forEach((item,index)=>{
+            if(item.active){
+                services.push({
+                    id: item.id,
+                    price: parseFloat((item.price.start_time && item.price.end_time)?item.price.sale_price*item.stock:item.price.price*item.stock).toFixed(2),
+                    price_id: item.price.id,
+                    stock: item.stock
+                })
+            }
+        })
         app.api.useApi(app.globalData.baseAppUrl + "api/orders", {
             order_no: that.data.order_no,
             order_type: that.data.mode,
             user_remark: that.data.remark,
             address_id:that.data.address_id,
-            coupon_id: cid
+            coupon_id: cid,
+            services: services
         }, "post").then(function (res) {
             console.log(res)
             if (res.code != 200) {

+ 5 - 4
pages/order/confirmOreder/confirmOreder.wxml

@@ -33,15 +33,16 @@
     </view>
 </view> 
 
-<!-- <view class="addService m-bottom-25">
+<view class="addService m-bottom-25">
     <view class="title">增值服务</view>
     <view class="content flex ">
         <view class="items  m-bottom-25 {{item.active ? 'active' : 'gray'}}" wx:for="{{currentList}}" wx:key="{{index}}" bindtap="chios" data-item="{{item}}">
-            <view class="name">{{item.tit}}</view>
-            <view class="num">¥{{item.num || 0}}/件</view>
+            <view class="name">{{item.title}}</view>
+            <view class="num">¥{{((item.price.start_time && item.price.end_time)?item.price.sale_price:item.price.price)}}/件</view>
+            <view class="num_pop">x{{item.stock}}</view>
         </view>
     </view>
-</view> -->
+</view>
 
 <view class="delivery  m-bottom-25">
     <view class=" flex ju-b">

+ 14 - 0
pages/order/confirmOreder/confirmOreder.wxss

@@ -103,11 +103,13 @@ page {
 }
 
 .addService .items {
+    position: relative;
     width: 210rpx;
     height: 92rpx;
     border-radius: 8rpx;
     line-height: 40rpx;
     margin-right: auto;
+    margin-bottom: 10rpx;
 }
 
 .addService .items.gray {
@@ -375,4 +377,16 @@ page {
 
 .red_price{
     color: #ff7300;
+}
+
+.num_pop{
+    position: absolute;
+    bottom: 0;
+    right: 0;
+    padding: 4rpx 5rpx 0 10rpx;
+    font-size: 20rpx;
+    background: #ff7300;
+    color: #fff;
+    color: #fff;
+    border-radius: 50rpx 0 0 0;
 }

+ 7 - 0
project.private.config.json

@@ -26,6 +26,13 @@
                     "query": "",
                     "launchMode": "default",
                     "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/order/confirmOreder/confirmOreder",
+                    "query": "order_no=ws20220506185141267630",
+                    "launchMode": "default",
+                    "scene": null
                 }
             ]
         }