sharp-agezi 6 年 前
コミット
7f06ee7fd8

customized/pages/accounts/order.wxss → customized/pages/accounts/accounts.wxss


+ 32 - 2
customized/pages/address/add/add.js

@@ -121,12 +121,12 @@ Page({
     }
 
     wx.request({
-      url: host+'',
+      url: host +'/adressapi/insertadd',
       header: {
         'content-type': 'application/x-www-form-urlencoded'
       },
       data:{
-        userId: app.globalData.user_id, //'oovpNwjlsY6xx8ceCebFa1dOLd9E',  //app.globalData.user_id,
+        user_id: app.globalData.user_id, //'oovpNwjlsY6xx8ceCebFa1dOLd9E',  //app.globalData.user_id,
 			  consignee: that.data.name, //收货人
 			  province:that.data.region[0],
         city: that.data.region[1],
@@ -137,7 +137,37 @@ Page({
       },
       success(res){
         console.log(res,"地址保存")
+        wx.showToast({
+          title: '地址添加成功',
+          icon:'none',
+          success(){
+            setTimeout(()=>{
+              wx.navigateBack({
+                delta: 1
+              })
+            },1000)
+            
+          }
+        })
+        
       }
     })
+  },
+  getEditAddress(){ // 获取编辑的地址
+
+    let address = wx.getStorageSync('address'), 
+    name = address.consignee,
+    phone =address.phone,
+    region = [address.province,address.city,address.area],
+    detailAddress =address.adress,
+    switchChecked = address.switchChecked;
+    console.log(address)
+    this.setData({
+      name:name,
+      phone:phone,
+      region: region,
+      detailAddress: detailAddress,
+      switchChecked: switchChecked
+    })
   }
 })

+ 42 - 2
customized/pages/address/address.js

@@ -63,12 +63,12 @@ Page({
         'content-type': 'application/x-www-form-urlencoded'
       },
       data: {
-        userId: app.globalData.user_id,// 'oovpNwjlsY6xx8ceCebFa1dOLd9E'  //app.globalData.user_id,
+        user_id: app.globalData.user_id,// 'oovpNwjlsY6xx8ceCebFa1dOLd9E'  //app.globalData.user_id,
       },
       success(res) {
         console.log(res, "address")
         that.setData({
-          addressList:[...res.rows]
+          addressList:[...res.data.rows]
         })
       }
     })
@@ -77,5 +77,45 @@ Page({
     wx.navigateTo({
       url: '/customized/pages/address/add/add',
     })
+  },
+  delAddress(e){
+    let that = this, id = e.target.dataset.id;
+    wx.showModal({
+      title: '提示',
+      content: '是否确定删除地址?',
+      success(res){
+        if (res.confirm) {
+          console.log('用户点击确定')
+          wx.request({
+            url: host + '/adressapi/delete',
+            header: {
+              'content-type': 'application/x-www-form-urlencoded'
+            },
+            method:'get',
+            data:{
+              id: id 
+            },
+            success(res){
+              console.log(res,"删除");
+              wx.showToast({
+                title: '删除成功!',
+                icon:'none'
+              })
+              that.getaddress()
+            }
+
+          })
+        } else if (res.cancel) {
+          console.log('用户点击取消')
+        }
+      }
+    })
+    console.log(e.target.dataset.id)
+  },
+  editAddress(e){
+    wx.setStorageSync('address', e.target.dataset.item)
+    wx.navigateTo({
+      url: '/customized/pages/address/add/add',
+    })
   }
 })

+ 10 - 6
customized/pages/address/address.wxml

@@ -1,17 +1,21 @@
 <!-- 地址列表 -->
 <view class='address-box c-333'>
-  <view class='address-list bg-white mar-b20'>
+  <view class='address-list bg-white mar-b20' wx:for="{{addressList}}">
     <view class='mar-l20 mar-r20 pad-t20 pad-b20 f-s28'>
-      <view>王勇 15055166539</view>
-      <view>上海市 上海市 闵行区 虹漕路1467弄</view>
+      <view>{{item.consignee}} {{item.phone}}</view>
+      <view>{{item.province}} {{item.city}} {{item.area}} {{item.adress}}</view>
       <view class='address-icon f-box mar-t20'>
-        <view class='f-item f-box f-s24 f-align-items-center'>
+        <view class='f-item f-box f-s24 f-align-items-center' wx:if="{{item.adress_flag == '0'}}">
           <icon type="success" size="16" class='f-box f-align-items-center' color="orange" />
           <text class='icon-font'>默认地址</text>
         </view>
+        <view class='f-item f-box f-s24 f-align-items-center' wx:if="{{item.adress_flag == '1'}}">
+          <icon type="success" size="16" class='f-box f-align-items-center' color="#999" />
+          <text class='icon-font'>设为默认地址</text>
+        </view>
         <view>
-          <icon class='icon-bianji iconfont mar-r20' bindtap='edit'/>
-          <icon class='icon-tuanduicankaoxian- iconfont' bindtap='delete'/>
+          <icon class='icon-bianji iconfont mar-r20' data-item='{{item}}' bindtap='editAddress'/>
+          <icon class='icon-tuanduicankaoxian- iconfont' data-id='{{item.id}}' bindtap='delAddress'/>
         </view>
       
       </view>

+ 2 - 4
customized/pages/user/user.wxml

@@ -9,9 +9,8 @@
 </view>
 
 <!-- 我的订单 -->
-<view class='user-order '>
-  <view class="mar-t20 mar-b20 f-s32 mar-l20">我的订单</view>
-  <view class='bg-white'>
+<view class='user-order'>
+    <view class="mar-t20 pad-t20 pad-b20 mar-r20 f-s30 mar-l20 order-title">我的订单</view>
     <view class='f-box order-list f-justify-content-center mar-l20 mar-r20 f-s28'>
       <view class='f-item'>
         <icon class='iconfont icon-icon-test c-orange'></icon>
@@ -26,5 +25,4 @@
         <view>待收货</view>
       </view>
     </view>
-  </view>
 </view>

+ 14 - 2
customized/pages/user/user.wxss

@@ -1,11 +1,11 @@
 .user-header{
   width:100%;
-  height:360rpx;
+  height:320rpx;
 }
 .h-img{
   width:160rpx;
   height:160rpx;
-  border:4rpx solid #fff;
+  border:6rpx solid #fff;
   border-radius:50%;
   overflow: hidden;
   margin-top:50rpx;
@@ -17,9 +17,18 @@
 .order-list{
   text-align: center;
 }
+.user-order{
+  width:710rpx;
+  margin:0 auto;
+  background:#fff;
+  border-radius:20rpx;
+}
 .user-order .iconfont{
   font-size:48rpx;
 }
+.order-list{
+  padding:10rpx 0; 
+}
 .order-list .f-item{
   padding:16rpx 0;
   font-size:26rpx;
@@ -27,4 +36,7 @@
 }
 .order-list .f-item view{
   margin-top:10rpx;
+}
+.order-title{
+  border-bottom:2rpx solid #e0e0e0;
 }