Explorar el Código

地址、下单

luck hace 2 años
padre
commit
d08a124568

+ 1 - 0
app.js

@@ -116,6 +116,7 @@ App({
                   wx.setStorageSync('uid', res.message.user_id);
                   wx.setStorageSync('exp_time', res.message.exp_time);
                   wx.setStorageSync('seisson_key', res.message.session_key);
+                  wx.setStorageSync('phone', res.message.phone);
                   wx.setStorageSync('nid', res.message.network_id);//当前网点选择id
                   resolve(res);
                 }

+ 105 - 5
pages/my/address/addSite/addSite.js

@@ -1,4 +1,5 @@
 // pages/my/address/addSite/addSite.js
+const app = getApp();
 Page({
 
     /**
@@ -15,8 +16,8 @@ Page({
         name: '',
         phone: '',
         address: '',
-
-        checked4: false
+        checked4: false,
+        id:""
 
     },
 
@@ -24,11 +25,28 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        var type = options.parmise == 'add' ? true : false;
+        console.log(options.parmise);
+        if(!type){
+        var parmise = JSON.parse(options.parmise)
+       
         this.setData({
-            type: options.parmise == '添加' ? true : false
+            type: type,
+            resultInfo: {
+                name: parmise.username,
+                phone: parmise.phone,
+                address: parmise.address,
+                checked4: parmise.is_default == 1 ? true : false
+            },
+            name: parmise.username,
+            phone: parmise.phone,
+            address: parmise.address,
+            checked4: parmise.is_default == 1 ? true : false,
+            id:parmise.id,
         })
-        console.log(options);
-
+    }else{
+        this.setData({type: type})
+    }
         if (this.data.type) {
             wx.setNavigationBarTitle({
                 title: '添加新地址',
@@ -95,6 +113,88 @@ Page({
         console.log(this.data.checked1, this.data.checked2, this.data.checked3);
     },
 
+    addAddress() {
+        var that = this;
+        app.api.useApi(app.globalData.baseAppUrl + "api/address/create", {
+            username: that.data.resultInfo.name,
+            phone: that.data.resultInfo.phone,
+            address: that.data.resultInfo.address,
+            is_default: that.data.resultInfo.checked
+
+        }, "post").then(function (res) {
+            if (res.original.code != 200) {
+                wx.showLoading({
+                    title: res.original.message.msg,
+                })
+            } else {
+                wx.navigateTo({
+                    url: '/pages/my/address/address',
+                })
+            }
+            setTimeout(function () {
+                wx.hideLoading({
+                    success: (res) => { },
+                })
+            }, 2000);
+
+
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
+    del(e) {
+        console.log(e);
+        app.api.useApi(app.globalData.baseAppUrl + "api/address/del", {
+            id:e.target.dataset.id,
+        }, "post").then(function (res) {
+            if (res.original.code != 200) {
+                wx.showLoading({
+                    title: res.original.message.msg,
+                })
+            } else {
+                wx.navigateTo({
+                    url: '/pages/my/address/address',
+                })
+            }
+            setTimeout(function () {
+                wx.hideLoading({
+                    success: (res) => { },
+                })
+            }, 2000);
+
 
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
+    updateaddr(e){
+        var that = this;
+        app.api.useApi(app.globalData.baseAppUrl + "api/address/update", {
+            username: that.data.resultInfo.name,
+            phone: that.data.resultInfo.phone,
+            address: that.data.resultInfo.address,
+            is_default: that.data.resultInfo.checked,
+            id:e.target.dataset.id,
 
+        }, "post").then(function (res) {
+            if (res.original.code != 200) {
+                wx.showLoading({
+                    title: res.original.message.msg,
+                })
+            } else {
+                wx.navigateTo({
+                    url: '/pages/my/address/address',
+                })
+            }
+            setTimeout(function () {
+                wx.hideLoading({
+                    success: (res) => { },
+                })
+            }, 2000);
+
+
+        }).catch(function (err) {
+            console.log(222);
+        })
+    }
 })

+ 7 - 7
pages/my/address/addSite/addSite.wxml

@@ -1,8 +1,8 @@
 <!--pages/my/address/addSite/addSite.wxml-->
 <view class="form">
-    <van-field bind:input="input1" clearable label="姓名" placeholder="请填写您的姓名" />
-    <van-field bind:input="input2" clearable label="手机" placeholder="请填写您的手机号码" />
-    <van-field bind:input="input3" clearable label="地址" placeholder="填写宿舍楼名称、宿舍号信息" />
+    <van-field bind:input="input1" clearable label="姓名" value='{{name}}' placeholder="请填写您的姓名" />
+    <van-field bind:input="input2" clearable label="手机" value='{{phone}}' placeholder="请填写您的手机号码" />
+    <van-field bind:input="input3" clearable label="地址" value='{{address}}' placeholder="填写宿舍楼名称、宿舍号信息" />
 </view>
 
 <view class="bg"></view>
@@ -12,14 +12,14 @@
         <view class="tit">设为默认地址</view>
         <view class="tips">将该地址作为每次下单时默认选择的地址</view>
     </view>
-    <van-switch checked="{{ checked4 }}" size="20px" bind:change="onChange" />
+    <van-switch checked="{{ checked4 }}" size="20px" bind:change="onChange"  />
 </view>
 <view class="footer" wx:if="{{type}}">
-    <view class="footerBtn skyBlue" wx:if="{{checked1 && checked2 && checked3}}">保存并使用</view>
+    <view class="footerBtn skyBlue" wx:if="{{checked1 && checked2 && checked3}}" bindtap="addAddress">保存并使用</view>
     <view class="footerBtn " wx:else>保存并使用</view>
 </view>
 
 <view class="footer flex ju-c" wx:else>
-    <view class="footerBtn border">删除</view>
-    <view class="footerBtn footerBtn2 skyBlue" >保存并使用</view>
+    <view class="footerBtn border" bindtap="del" data-id="{{id}}">删除</view>
+    <view class="footerBtn footerBtn2 skyBlue" bindtap="updateaddr" data-id="{{id}}">保存并使用</view>
 </view>

+ 21 - 8
pages/my/address/address.js

@@ -6,10 +6,10 @@ Page({
      * 页面的初始数据
      */
     data: {
-        addressList:[{}]
+        addressList:[]
     },
     onLoad:function(){
-
+        this.address()
     },
     addSite(e){
         let {parmise} = e.currentTarget.dataset
@@ -18,23 +18,36 @@ Page({
           url: './addSite/addSite?parmise='+parmise,
         })
     },
-
+    editSite(e){
+        let {parmise} = e.currentTarget.dataset
+        console.log(parmise);
+        wx.navigateTo({
+          url: './addSite/addSite?parmise='+JSON.stringify(parmise),
+        })
+    },
     //获取地址列表
     address(){
-        app.api.useApi(app.globalData.baseAppUrl + "api/network/desc", {
+        var that=this;
+        app.api.useApi(app.globalData.baseAppUrl + "api/address/index", {
             network_id: 1,
         }, "get").then(function (res) {
-            if (res.code != 200) {
+            
+            if (res.original.code != 200) {
                 wx.showLoading({
-                    title: '地址加载失败' + res.status,
+                    title:res.original.message.msg,
                 })
             } else {
+              
                 that.setData({
-                    worke: res.message.data
+                    addressList: res.original.message.data.data
                 })
             }
 
-            wx.hideLoading();
+            setTimeout(function () {
+                wx.hideLoading({
+                  success: (res) => {},
+                })
+               }, 2000);
 
         }).catch(function (err) {
             console.log(222);

+ 7 - 6
pages/my/address/address.wxml

@@ -3,21 +3,22 @@
     <view class="itemBoxs flex ju-b b-bottom" wx:for="{{addressList}}" wx:key="{{index}}" >
         <view class="le">
             <view class="address t-text-ellipsis2">
-                中央美术学院北门9号楼303宿舍的撒即可打开手
+                {{item.address}}
             </view>
             <view class="message flex">
-                <text class="name">张君雅</text>
-                <text class="phone">13016098761</text>
-                <view class="default">默认</view>
+                <text class="name">{{item.username}}</text>
+                <text class="phone">{{item.phone}}</text>
+                <view class="default" wx:if="{{item.is_default==1}}">默认</view>
             </view>
         </view>
-        <image class="lr" src="/image/icon/edit.png" bindtap="addSite" data-parmise="编辑"></image>
+
+        <image class="lr" src="/image/icon/edit.png" bindtap="editSite" data-parmise="{{item}}"></image>
     </view>
 </view>
 <view style="margin-top: 150px;">
     <van-empty class="custom-image" image="/image/address/no-address.png" description="暂无地址,去添加一个吧!" />
 </view>
 
-<view class="footerBtn" bindtap="addSite" data-parmise="添加">
+<view class="footerBtn" bindtap="addSite" data-parmise="add">
     <van-icon name="plus" />添加新地址
 </view>

+ 36 - 43
pages/order/placeOrder/placeOrder.js

@@ -1,4 +1,5 @@
 // pages/order/placeOrder/placeOrder.js
+const app=getApp();
 Page({
 
     /**
@@ -6,35 +7,7 @@ Page({
      */
     data: {
         activeKey: 0,
-        navList: [
-            {
-                tit: "活动"
-            },
-            {
-                tit: "套餐"
-            },
-            {
-                tit: "洗衣"
-            },
-            {
-                tit: "洗鞋"
-            },
-            {
-                tit: "其他"
-            },
-            {
-                tit: "其他"
-            },
-            {
-                tit: "其他"
-            },
-            {
-                tit: "其他"
-            },
-            {
-                tit: "其他"
-            },
-        ],
+        navList: [],
         height: '',
         show: false,
         detailsShow: false,
@@ -43,27 +16,24 @@ Page({
         ],
         carNum: 0,
         carPrice: '',
-        shoppingList: [
-            {
-                num: 0,
-                id: 0,
-                price: 20
-
-            },
-            {
-                num: 0,
-                id: 1,
-                price: 39
-            }
-        ]
+        shoppingList: [],
+        worke:"",
+        status:""
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        
+        var worke=JSON.parse(options.parmise)
+        this.setData({
+            worke:worke,
+            status: app.globalData.status
+        })
         this.getHeight()
         this.getCarAll()
+        this.leftList()
     },
 
     shoppingMinus(e) {
@@ -237,7 +207,6 @@ Page({
         })
     },
     getHeight() {
-
         var clientHeight;
         wx.getSystemInfo({
             success: (res) => {
@@ -276,7 +245,31 @@ Page({
             show: !this.data.show
         })
     },
+    leftList: function () {
+        var that = this;
+        var nid = this.data.worke.id;
+    
+        app.api.useApi(app.globalData.baseAppUrl + "api/good", {
+            network_id: nid,
+        }, "get").then(function (res) {
+            console.log(res);
+            if (res.code != 200) {
+                wx.showLoading({
+                    title:  res.message.status,
+                })
+            } else {
+                that.setData({
+                    navList: res.message.data,
+                    shoppingList:res.message.data[0].good
+                })
+            }
 
+            wx.hideLoading();
+
+        }).catch(function (err) {
+            console.log(222);
+        })
+    },
 
 
 })

+ 9 - 9
pages/order/placeOrder/placeOrder.wxml

@@ -1,17 +1,17 @@
 <view class="topBox" id="topBox">
     <view class="title flex" bindtap="addressDetail">
-        <text>中央美术学院9号楼洗衣房1号柜</text>
+        <text>{{worke.title}}</text>
         <van-icon name="arrow" size="15" color="#191C27" />
     </view>
 
     <view class="footer flex ju-b">
         <view class="le">
             <view class="address">
-                <text>洪山区茅店山西路4号创星汇科技…</text>
-                <text>|距离40m</text>
+                <text>{{worke.address}}</text>
+                <text>|距离{{worke.distance}}km</text>
             </view>
             <view class="tips">
-                <text class="tag">已满柜</text>
+                <text class="tag">{{status[worke.signing_status]}}</text>
                 <text>24h开放·支持上门</text>
             </view>
         </view>
@@ -45,7 +45,7 @@
     <view class="slidebar">
         <scroll-view scroll-y>
             <view class="sliderItem b-bottom {{activeKey == index?'active':''}}" wx:for="{{navList}}" wx:key="*this" bindtap="changeActive" data-activeKey="{{index}}">
-                {{item.tit}}
+                {{item.title}}
             </view>
         </scroll-view>
     </view>
@@ -60,16 +60,16 @@
             <view class="box">
                 <view class="items flex b-bottom" wx:for="{{shoppingList}}" wx:key="{{item.id}}">
                     <view class="le">
-                        <image src="/image/order/houwaitao.png" class="picture"></image>
+                        <image src="{{item.thumb?item.thumb:'/image/order/houwaitao.png'}}" class="picture"></image>
 
                     </view>
                     <view class="lr">
                         <view class="message flex ju-b">
-                            <view class="tit">薄上衣(春夏装)</view>
+                            <view class="tit">{{item.title}}</view>
                             <view class="num flex ju-b">
                                 <view>
-                                    <text class="price">¥<text class="number">{{item.price}}</text></text>
-                                    <text class="oldPrice">¥9</text>
+                                    <text class="price">¥<text class="number">{{item.price.sale_price}}</text></text>
+                                    <text class="oldPrice">¥{{item.price.price}}</text>
                                 </view>
 
                                 <view class="btn-sky btn flex ju-c" wx:if="{{item.num == 0}}" bindtap="shoppingPlus" data-item="{{item}}">

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

@@ -19,6 +19,7 @@
 .topBox .footer .le {
     border-right: 1rpx solid #E4E4E4;
     padding-right: 40rpx;
+    width: 80%;
 }
 
 .topBox .footer .address {

+ 3 - 1
pages/tabber/home/index.js

@@ -85,8 +85,10 @@ Page({
         if (this.data.islocation) {
             this.getLocation()
         }
+        var parmise=this.data.worke;
+
         wx.navigateTo({
-            url: '/pages/order/placeOrder/placeOrder',
+            url: '/pages/order/placeOrder/placeOrder?parmise='+JSON.stringify(parmise),
         })
     },
 

+ 1 - 1
pages/tabber/home/index.wxml

@@ -12,7 +12,7 @@
             <image src="/image/home/pic.png" class="pic"></image>
             <view class="content">
                 <view class="tit">{{worke.title}}</view>
-                <view class="message">离您最近|距离{{worke.distance}}米</view>
+                <view class="message">离您最近|距离{{worke.distance}}米</view>
                 <view class="tags">{{status[worke.signing_status]}}</view>
             </view>
         </view>

+ 4 - 0
pages/tabber/my/index.js

@@ -46,9 +46,13 @@ Page({
      */
     onLoad: function (options) {
         this.getBtnInfo()
+        this.setData({
+            code:wx.getStorageSync('phone'),
+        })
         if (this.data.active == true) {
             this.data.menuList.shift()
             this.setData({
+                code:wx.getStorageSync('phone'),
                 menuList:this.data.menuList
             })
 

+ 6 - 0
project.private.config.json

@@ -71,6 +71,12 @@
           "pathName": "pages/my/cashier/cashier",
           "query": "",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/my/address/addSite/addSite",
+          "query": "parmise=%E6%B7%BB%E5%8A%A0",
+          "scene": null
         }
       ]
     }