luck 2 rokov pred
rodič
commit
c2b4d041c9

+ 223 - 58
pages/order/confirmOreder/confirmOreder.js

@@ -1,5 +1,6 @@
 // pages/order/confirmOreder/confirmOreder.js
-const app=getApp();
+const app = getApp();
+const addr = require('../../my/address/addSite/addSite.js');
 Page({
 
     /**
@@ -9,59 +10,101 @@ Page({
         currentList: [{
             tit: '塑封包膜',
             num: "30",
-            id:1
+            id: 1
         }, {
             tit: '绒面鞋补色',
             num: "20",
-            id:2
+            id: 2
         }, {
             tit: '防水处理',
             num: "20",
-            id:3
+            id: 3
         }, {
             tit: '防水处理',
             num: "10",
-            id:4
+            id: 4
         }],
-        mode:true,
-        checked:false,
-        show1:false,
-        show2:false,
-        code:""
+        mode: 1,
+        checked: false,
+        show1: false,
+        show2: false,
+        code: "",
+        order_no: "",
+        orderinfo: "",
+        address: "",
+        useraddr: "",
+        remark: "",
+        address_id:0,
 
     },
-    onLoad() {
+    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
+            currentList,
+            order_no
         })
+
     },
+    //详情
+    detail(order) {
+        var that = this;
+        app.api.useApi(app.globalData.baseAppUrl + "api/order_detail", {
+            order_no: order,
+        }, "get").then(function (res) {
+            if (res.code != 200) {
+                wx.showLoading({
+                    title: res.message.msg,
+                })
+                setTimeout(function () {
+                    wx.hideLoading({
+                        success: (res) => { },
+                    })
+                }, 2000);
+
+            } else {
+                that.setData({
+                    orderinfo: res.message.data,
+                    address: res.message.address.address,
+                    code: res.message.address.phone,
+                    name: res.message.address.username,
+                    address_id:res.message.address.id,
+                    useraddr: res.message.address,
+                })
+            }
 
-    changeClose1(e){
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
+    changeClose1(e) {
         this.setData({
-            show1:!this.data.show1
+            show1: !this.data.show1
         })
     },
 
-    changeClose2(e){
+    changeClose2(e) {
         this.setData({
-            show2:!this.data.show2
+            show2: !this.data.show2,
+            remark: this.data.remark
         })
+
     },
     onChange(event) {
         console.log(event);
         this.setData({
             checked: event.detail,
         });
-      },
-    chios(e){
-        let {item} = e.currentTarget.dataset
+    },
+    chios(e) {
+        let { item } = e.currentTarget.dataset
 
         let currentList = this.data.currentList
-        currentList.map((it,index)=>{
+        currentList.map((it, index) => {
             if (item.id == it.id) {
                 it.active = !it.active
             }
@@ -70,55 +113,177 @@ Page({
             currentList
         })
     },
-    changeMode(e){
-        let {mode} = e.currentTarget.dataset
+    changeMode(e) {
+        var id = e.target.dataset.id
+        console.log(id);
         this.setData({
-            mode
+            mode: id
         })
     },
-    goto(){
-        wx.navigateTo({
-            url:'/pages/my/cashier/cashier'
-        })
+
+    goto() {
+        if(!this.data.checked){
+            wx.showLoading({
+                title: '请阅读并同意洗护协议',
+            })
+            setTimeout(function () {
+                wx.hideLoading({
+                    success: (res) => { },
+                })
+            }, 1000);
+        }else{this.orderConfirm();}
+        
     },
-    getPhoneNumber (e){
+    getPhoneNumber(e) {
         app.login();
         console.log(e)
-        
-            var data={
-                'mds':wx.getStorageSync('seisson_key'),
-                'encryptedData':e.detail.encryptedData,
-                'errMsg':e.detail.errMsg,
-                'iv':e.detail.iv,
-                'appid':wx.getAppBaseInfo().host.appId,
-                'token':wx.getStorageSync('token')
-            }
-             wx.cloud.callFunction({
-              name: 'getPhoneNumber',
-              data:{
-                  'message':data
-              },
-              success:res=>{
-                  console.log(res)
-            var par=res.result.original;
-                  if(par.code==200){
-                    var phone=par.message.data.phone
-                    if(phone){
+
+        var data = {
+            'mds': wx.getStorageSync('seisson_key'),
+            'encryptedData': e.detail.encryptedData,
+            'errMsg': e.detail.errMsg,
+            'iv': e.detail.iv,
+            'appid': wx.getAppBaseInfo().host.appId,
+            'token': wx.getStorageSync('token')
+        }
+        wx.cloud.callFunction({
+            name: 'getPhoneNumber',
+            data: {
+                'message': data
+            },
+            success: res => {
+                console.log(res)
+                var par = res.result.original;
+                if (par.code == 200) {
+                    var phone = par.message.data.phone
+                    if (phone) {
                         this.setData({
                             code: phone,
-                          })     
+                        })
                     }
-                  }
+                }
             },
-              fail:err=>{
-                  console.log(err)
-              }
-            })
-      
-            // console.log("fetch cloudfunction success", cloudResult.result)
-          
+            fail: err => {
+                console.log(err)
+            }
+        })
+
+        // console.log("fetch cloudfunction success", cloudResult.result)
+
+
+
+
+    },
+    input1(e) {
+        console.log(e.detail);
+        this.setData({
+            name: e.detail.value
+        })
+    },
+    input2(e) {
+        this.setData({
+            code: e.detail.value
+        })
+    },
+    input3(e) {
+        this.setData({
+            address: e.detail.value
+        })
+    },
+    input4(e) {
+        this.setData({
+            remark: e.detail.value
+        })
+
+    },
+    addAddress() {
+        var that = this;
+        app.api.useApi(app.globalData.baseAppUrl + "api/address/create", {
+            username: that.data.name,
+            phone: that.data.code,
+            address: that.data.address,
+
+        }, "post").then(function (res) {
+            if (res.code != 200) {
+                wx.showLoading({
+                    title: res.message.msg,
+                })
+                setTimeout(function () {
+                    wx.hideLoading({
+                        success: (res) => { },
+                    })
+                }, 1000);
+            } else {
+                that.changeClose1();
+                that.setData({
+                    address_id: res.message.data.message.id,
+                })
+            }
+           
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
+    updateaddr(e) {
+        var that = this;
+        app.api.useApi(app.globalData.baseAppUrl + "api/address/update", {
+            username: that.data.name,
+            phone: that.data.code,
+            address: that.data.address,
+            id: e.target.dataset.id,
+        }, "post").then(function (res) {
+            if (res.original.code != 200) {
+                wx.showLoading({
+                    title: res.original.message.msg,
+                })
+            } else {
+                that.changeClose1();
+                // wx.navigateTo({
+                //     url: '/pages/my/address/address',
+                // })
+            }
+            setTimeout(function () {
+                wx.hideLoading({
+                    success: (res) => { },
+                })
+            }, 2000);
+
+
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
+    orderConfirm() {
+        var that=this;
+        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
+        }, "post").then(function (res) {
+            if (res.original.code != 200) {
+                wx.showLoading({
+                    title: res.original.message.msg,
+                })
+                setTimeout(function () {
+                    wx.hideLoading({
+                        success: (res) => { },
+                    })
+                }, 1000);
+
+            } else {
+
+                wx.navigateTo({
+                    url: '/pages/my/cashier/cashier'
+                })
+            }
+
+
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
 
 
 
-      }
 })

+ 25 - 24
pages/order/confirmOreder/confirmOreder.wxml

@@ -3,37 +3,37 @@
     <image src="/image/icon/spot.png" class="icon"></image>
 
     <view class="message ">
-        <view class="tit">中央美术学院9号楼洗衣房代收点</view>
-        <view class="time">9:00-21:00开放·支持上门</view>
+        <view class="tit">{{orderinfo.network.name}}</view>
+        <view class="time">{{orderinfo.network.unit[0].svctm}}开放·{{orderinfo.network.unit[0].type_name}}·{{orderinfo.network.unit[1].type_name}}·{{orderinfo.network.unit[2].type_name}}</view>
     </view>
 </view>
 
 <view class="messageBox m-bottom-25">
     <view class="top b-bottom">
-        <view class="item flex ju-b m-bottom-20 " wx:for="{{2}}">
+        <view class="item flex ju-b m-bottom-20 " wx:for="{{orderinfo.order_info}}" wx:key="{{index}}">
             <view class="le flex">
-                <image src="/image/icon/peijian.png" class="icon m-right-15"></image>
-                <text class="name">薄上衣(春夏装)</text>
+                <image src="{{item.good.thumb?item.good.thumb:'/image/icon/peijian.png'}}" class="icon m-right-15"></image>
+                <text class="name">{{item.good.title}}</text>
             </view>
             <view class="lr flex ju-b">
-                <view class="num">x <text>1</text></view>
-                <view class="price">¥<text>29</text></view>
+                <view class="num">x <text>{{item.stock}}</text></view>
+                <view class="price">¥<text>{{item.total_price}}</text></view>
             </view>
         </view>
     </view>
 
 
-    <view class="footer flex ju-b">
+    <!-- <view class="footer flex ju-b">
         <view class="le">优惠券</view>
         <view class="lr flex">
             <text class="m-right-15">暂无优惠券可用</text>
             <van-icon name="arrow" color="#C7C7CC" />
 
         </view>
-    </view>
-</view>
+    </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}}">
@@ -41,14 +41,15 @@
             <view class="num">¥{{item.num || 0}}/件</view>
         </view>
     </view>
-</view>
+</view> -->
 
 <view class="delivery  m-bottom-25">
     <view class=" flex ju-b">
         <text class="title">配送</text>
         <view class="btnBox flex ju-b">
-            <view class="btn {{mode ? 'active' : ''}}" bindtap="changeMode" data-mode="{{true}}">代收点</view>
-            <view class="btn {{mode ? '' : 'active'}}" bindtap="changeMode" data-mode="{{false}}">上门取送</view>
+            <view class="btn {{mode==1 ? 'active' : ''}}" bindtap="changeMode" data-id="1">代收点</view>
+            <view class="btn {{mode==3? 'active' : ''}}" bindtap="changeMode" data-id="3">上门取送</view>
+            <view class="btn {{mode==2? 'active' : ''}}" bindtap="changeMode" data-id="2">到柜存取</view>
         </view>
     </view>
 
@@ -59,7 +60,7 @@
         </view>
         <view class="lr flex ju-e">
             <text>运费</text>
-            <text class="code">¥<text class="num">0</text></text>
+            <text class="code">¥<text class="num">{{orderinfo.freight}}</text></text>
         </view>
     </view>
 
@@ -72,7 +73,7 @@
         </view>
 
         <view class="content m-top-20">
-            请填写联系信息,以便送回时联系您
+          {{name}}-{{code}}<view>{{address}}</view>
         </view>
     </view>
 </view>
@@ -81,7 +82,7 @@
 <view class="footer flex ju-b">
     <view class="le">清洗备注</view>
     <view class="lr flex" bindtap="changeClose2">
-        <text class="m-right-15">例:蓝色短袖袖口有污渍请着重清洗</text>
+        <text class="m-right-15">{{remark?remark:'例:蓝色短袖袖口有污渍请着重清洗'}}</text>
         <van-icon name="arrow" color="#C7C7CC" />
 
     </view>
@@ -95,7 +96,7 @@
 
 <view class="footerNav flex ju-b">
     <view class="le">
-        <text>¥<text class="num">30</text></text>
+        <text>¥<text class="num">{{orderinfo.total_price}}</text></text>
 
         <view class="tips">价格以实际收到为准</view>
     </view>
@@ -112,21 +113,21 @@
 
         <view class="content">
             <view class="inputBox flex b-bottom">
-                <text>姓名</text><input type="text" placeholder="请填写您的姓名" />
+                <text>姓名</text><input type="text" bind:input="input1" clearable label="姓名" value='{{name}}' placeholder="请填写您的姓名" />
             </view>
 
             <view class="inputBox flex b-bottom">
-                <text>手机</text><input type="text" placeholder="请填写您的手机号" value="{{code}}" />
+                <text>手机</text><input style="width: 50%;" type="text" bind:input="input2" clearable label="手机" placeholder="请填写您的手机号" value="{{code}}" />
                 <button open-type="getPhoneNumber"  bindgetphonenumber="getPhoneNumber" style="color: green;">获取微信手机号</button>
             </view>
 
             <view class="inputBox flex b-bottom">
-                <text>地址</text><input type="text" placeholder="填写宿舍楼名称、宿舍号信息" />
+                <text>地址</text><input type="text" bind:input="input3" clearable label="地址" value='{{address}}' placeholder="填写宿舍楼名称、宿舍号信息" />
             </view>
         </view>
 
 
-        <view class="btn btn-sky">
+        <view class="btn btn-sky" bindtap="{{useraddr.id?'updateaddr':'addsave'}}" data-id="{{useraddr.id}}">
             保存并使用
         </view>
     </view>
@@ -139,9 +140,9 @@
         </view>
 
         <view class="content">
-            <textarea placeholder="例:蓝色短袖袖口有污渍请着重清洗" class="bg" placeholder-class="placeholder"></textarea>
+            <textarea placeholder="例:蓝色短袖袖口有污渍请着重清洗" class="bg" bindblur="input4" placeholder-class="placeholder">{{remark}}</textarea>
         </view>
-        <view class="btn btn-sky">
+        <view class="btn btn-sky" bindtap="changeClose2">
             确定
         </view>
     </view>

+ 4 - 4
pages/order/confirmOreder/confirmOreder.wxss

@@ -144,7 +144,7 @@ page {
 }
 
 .delivery .btnBox {
-    width: 296rpx;
+    width: 415rpx;
     height: 66rpx;
     background: #F1F1F1;
     border-radius: 32rpx;
@@ -168,7 +168,7 @@ page {
 }
 
 .delivery .center .le {
-    width: 74%;
+    width: 68%;
 }
 
 .delivery .center .address {
@@ -185,7 +185,7 @@ page {
     font-size: 28rpx;
     color: #191C27;
     border-left: 1px solid #E4E4E4;
-    width: 20%;
+    width: 30%;
 }
 
 .delivery .center .lr .code {
@@ -286,7 +286,7 @@ page {
 
 .pupBox .content .inputBox input {
     font-size: 28rpx;
-    width: 52%;
+    width: 100%;
 }
 
 .pupBox .btn {

+ 27 - 2
pages/order/placeOrder/placeOrder.js

@@ -210,9 +210,34 @@ Page({
 
     },
     getOrder() {
-        wx.navigateTo({
-            url: '/pages/order/confirmOreder/confirmOreder',
+        var nid = this.data.worke.id;
+        app.api.useApi(app.globalData.baseAppUrl + "api/makeorder", {
+            network_id: nid,
+        }, "post").then(function (res) {
+            console.log(res);
+            if (res.code != 200) {
+                wx.showLoading({
+                    title: res.message.msg,
+                })
+                wx.setTimeout(() => {
+                    wx.hideLoading();
+                }, 1000);
+            } else {
+                var order_no = res.message.data.order_no;
+                wx.navigateTo({
+                    url: '/pages/order/confirmOreder/confirmOreder?order_no='+order_no,
+                })
+            }
+
+           
+
+        }).catch(function (err) {
+            console.log(222);
         })
+
+
+
+      
     },
     carPlus(e) {
         let items = e.currentTarget.dataset.item, list = this.data.carList

+ 0 - 1
pages/order/placeOrder/placeOrder.wxml

@@ -133,7 +133,6 @@
         <view class="box">
 
             <scroll-view scroll-y>
-
                 <view class="items flex b-bottom" wx:for="{{carList}}" wx:key="{{index}}">
                     <view class="le">
                         <image src="/image/order/houwaitao.png" class="picture"></image>

+ 18 - 0
project.private.config.json

@@ -95,6 +95,24 @@
           "pathName": "pages/order/serviceDetails/serviceDetails",
           "query": "goods_id=1&title=%E5%A4%96%E9%83%A8%E6%B5%8B%E8%AF%95%E7%BD%91%E7%82%B9%20%20&address=22%20&worke_id=1",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/order/placeOrder/placeOrder",
+          "query": "parmise=%7B%22id%22%3A1%2C%22institution_id%22%3A1%2C%22name%22%3A%22%E6%B5%8B%E8%AF%95%E7%BD%91%E7%82%B9%20%22%2C%22title%22%3A%22%E5%A4%96%E9%83%A8%E6%B5%8B%E8%AF%95%E7%BD%91%E7%82%B9%20%20%22%2C%22province_id%22%3A110000%2C%22city_id%22%3A110100%2C%22area_id%22%3A110101%2C%22address%22%3A%2222%20%22%2C%22signing_status%22%3A1%2C%22business_status%22%3A1%2C%22lng%22%3A%22114.320249%20%22%2C%22lat%22%3A%2230.448342%22%2C%22type%22%3A%220%22%2C%22contact%22%3A%22%20%22%2C%22type_info%22%3A%22%22%2C%22created_at%22%3Anull%2C%22updated_at%22%3Anull%2C%22distance%22%3A12337.04%2C%22unit%22%3A%5B%7B%22id%22%3A1%2C%22type%22%3A1%2C%22price%22%3A%220.00%22%2C%22phone%22%3A%2218064109218%20%22%2C%22svctm%22%3A%22%E5%91%A8%E4%B8%80%E8%87%B3%E5%91%A8%E4%BA%94%2018-20%3A00%2C22%3A00-23%3A00%22%2C%22type_name%22%3A%22%E4%BB%A3%E6%94%B6%E7%82%B9%22%7D%2C%7B%22id%22%3A2%2C%22type%22%3A2%2C%22price%22%3A%220.00%22%2C%22phone%22%3A%2218064109218%20%22%2C%22svctm%22%3A%22%E5%91%A8%E4%B8%80%E8%87%B3%E5%91%A8%E4%BA%94%2018-20%3A00%2C22%3A00-23%3A00%20%22%2C%22type_name%22%3A%22%E5%AD%98%E5%8F%96%E6%9F%9C%22%7D%2C%7B%22id%22%3A3%2C%22type%22%3A3%2C%22price%22%3A%2210.00%22%2C%22phone%22%3A%2218064109218%20%22%2C%22svctm%22%3A%22%E5%91%A8%E4%B8%80%E8%87%B3%E5%91%A8%E4%BA%94%2018-20%3A00%2C22%3A00-23%3A00%20%20%22%2C%22type_name%22%3A%22%E4%B8%8A%E9%97%A8%E5%8F%96%E9%80%81%22%7D%5D%7D",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/order/confirmOreder/confirmOreder",
+          "query": "order_no=ws20220224110319214623",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/order/confirmOreder/confirmOreder",
+          "query": "order_no=ws20220224154137393425",
+          "scene": null
         }
       ]
     }