sharp-agezi %!s(int64=6) %!d(string=hai) anos
pai
achega
15f1abd324

+ 2 - 1
app.json

@@ -103,7 +103,8 @@
         "pages/accounts/accounts",
         "pages/address/address",
         "pages/user/user",
-        "pages/address/add/add"
+        "pages/address/add/add",
+        "pages/order/order"
       ]
     }
   ],

+ 30 - 1
customized/pages/accounts/accounts.js

@@ -9,15 +9,44 @@ Page({
   data: {
     goodsList:[],
     host: app.globalData.servsers,
-    amount:''
+    amount:'',
+    address:{},// 地址为空
   },
 
+  onLoad(){
+    let that =this;
+    wx.request({
+      url: host + '/adressapi/getdefaustAdress',
+      method:'get',
+      data:{
+        user_id: app.globalData.user_id
+      },
+      header: {
+        'content-type': 'application/x-www-form-urlencoded'
+      },
+      success(res){
+        console.log(res,"获取默认地址")
+        that.setData({
+          address: res.data
+        })
+      }
+
+
+    })
+  },
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
     let goodsList=[],that=this;
+    let address = wx.getStorageSync('accountAddress');
+    console.log(address,"addressaddress")
+    if (address){
+      that.setData({
+        address: address
+      })
+    }
     goodsList = [...wx.getStorageSync('goodsList')];
     that.setData({
       goodsList: goodsList,

+ 7 - 4
customized/pages/accounts/accounts.wxml

@@ -1,10 +1,13 @@
 <!-- 地址 -->
 <view class='address-box bg-white c-333'>
-  <view class='mar-l20 mar-r20 f-box' bindtap='addressBtn'>
+  <view class='mar-l20 mar-r20 pad-t20 pad-b20 f-box' bindtap='addressBtn'>
     <icon class='iconfont icon-dizhi mar-r20 f-box f-align-items-center c-orange' style='font-size:50rpx;'></icon>
-    <view class='address-infor f-item'>
-      <view class='f-box f-s30'><text>阿哥子</text><text>18888888888</text></view>
-      <view class='mar-t20 f-s30'>上海市 闵行区 虹漕路88号</view>
+    <view class='address-infor f-item' wx:if="{{address.consignee}}">
+      <view class='f-box f-s30'><text>{{address.consignee}}</text><text>{{address.phone}}</text></view>
+      <view class='mar-t20 f-s30'>{{address.province}} {{address.city}} {{address.area}} {{address.adress}}</view>
+    </view>
+    <view class='address-infor f-item f-box f-justify-content-center f-align-items-center f-s28 pad-t20 pad-b20' wx:else>
+      您还没有收货地址
     </view>
     <view class='arrow'></view>
   </view>

+ 41 - 20
customized/pages/address/add/add.js

@@ -11,14 +11,22 @@ Page({
     phone:'',
     region: ['上海市', '上海市', '黄浦区'],
     detailAddress:'',
+    id:null,
     switchChecked:false, //是否默认
+    type:'add',
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    console.log(options,"options")
+    if (options.type ==='edit'){ // 表示编辑
+      this.setData({
+        type:'edit'
+      })
+      this.getEditAddress(this)
+    }
   },
 
   /**
@@ -32,7 +40,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-
+    
   },
 
   /**
@@ -119,26 +127,37 @@ Page({
       });
       return
     }
-
+    let data ={
+      consignee: that.data.name, //收货人
+      province: that.data.region[0],
+      city: that.data.region[1],
+      area: that.data.region[2],
+      adress: that.data.detailAddress,
+      phone: that.data.phone,
+      adress_flag: that.data.switchChecked ? 0 : 1  // 是否默认 0是 1 否
+    },
+      url = host + '/adressapi/insertadd',
+      title = "地址添加成功";
+      if(that.data.type == 'edit'){
+        data['action_account'] = null;
+        data['id'] = that.data.id;
+        url = host + '/adressapi/update';
+        title = "地址编辑成功";
+      } else {
+        data['user_id'] =app.globalData.user_id;
+        url = host + '/adressapi/insertadd';
+        title = "地址添加成功";
+      }
     wx.request({
-      url: host +'/adressapi/insertadd',
+      url: url,
       header: {
         'content-type': 'application/x-www-form-urlencoded'
       },
-      data:{
-        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],
-        area: that.data.region[2],
-			  adress:that.data.detailAddress,
-			  phone:that.data.phone,
-        adress_flag: that.data.switchChecked ? 0 : 1  // 是否默认 0是 1 否
-      },
+      data: data,
       success(res){
         console.log(res,"地址保存")
         wx.showToast({
-          title: '地址添加成功',
+          title: title,
           icon:'none',
           success(){
             setTimeout(()=>{
@@ -153,21 +172,23 @@ Page({
       }
     })
   },
-  getEditAddress(){ // 获取编辑的地址
-
+  getEditAddress(that){ // 获取编辑的地址
+    
     let address = wx.getStorageSync('address'), 
     name = address.consignee,
     phone =address.phone,
     region = [address.province,address.city,address.area],
     detailAddress =address.adress,
-    switchChecked = address.switchChecked;
+    switchChecked = address.adress_flag == '0'? true : false ,
+    id = address.id;
     console.log(address)
-    this.setData({
+    that.setData({
       name:name,
       phone:phone,
       region: region,
       detailAddress: detailAddress,
-      switchChecked: switchChecked
+      switchChecked: switchChecked,
+      id: id
     })
   }
 })

+ 17 - 1
customized/pages/address/address.js

@@ -56,6 +56,9 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   getaddress() {
+    wx.showLoading({
+      title: '加载中',
+    })
     let that = this;
     wx.request({
       url: host + '/adressapi/adressview',
@@ -70,6 +73,9 @@ Page({
         that.setData({
           addressList:[...res.data.rows]
         })
+      },
+      complete(){
+        wx.hideLoading()
       }
     })
   },
@@ -115,7 +121,17 @@ Page({
   editAddress(e){
     wx.setStorageSync('address', e.target.dataset.item)
     wx.navigateTo({
-      url: '/customized/pages/address/add/add',
+      url: '/customized/pages/address/add/add?type=edit',
+    })
+  },
+  selectAddress(e){ // 选中地址
+    console.log(e)
+    wx.setStorageSync('accountAddress', e.currentTarget.dataset.item)
+    wx.navigateBack({
+      delta: 1
     })
+    // wx.navigateTo({
+    //   url: '/customized/pages/accounts/accounts?type=selectAddress',
+    // })
   }
 })

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

@@ -2,16 +2,18 @@
 <view class='address-box c-333'>
   <view class='address-list bg-white mar-b20' wx:for="{{addressList}}">
     <view class='mar-l20 mar-r20 pad-t20 pad-b20 f-s28'>
-      <view>{{item.consignee}} {{item.phone}}</view>
-      <view>{{item.province}} {{item.city}} {{item.area}} {{item.adress}}</view>
+      <view data-item='{{item}}' bindtap='selectAddress'>
+        <view>{{item.consignee}} {{item.phone}}</view>
+        <view>{{item.province}} {{item.city}} {{item.area}} {{item.adress}}</view>
+      </view>
       <view class='address-icon f-box mar-t20'>
         <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>
+          <!-- <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' data-item='{{item}}' bindtap='editAddress'/>

+ 2 - 2
customized/pages/index/index.wxml

@@ -1,5 +1,5 @@
 <view class="auto">
-  <view class="f-box mar-t20 custom-list">
+  <view class="f-box mar-t20 custom-list" bindtap='customized'>
     <view class='cust-img mar-r20 mar-l20 f-box f-align-items-center'>
       <image src="/customized/images/customized/cup_black_small.png" mode="aspectFit"></image>
     </view>
@@ -9,7 +9,7 @@
       <view class="mar-t20 f-s30 c-orange">¥45.00</view>
      
      <view class='f-box mar-t20 f-s32 f-align-items-center'>
-       <navigator bindtap='customized' class='cust-btn f-item f-s32 c-green'>定制</navigator>
+       <navigator class='cust-btn f-item f-s32 c-green'>定制</navigator>
        <view class='tu-icon f-box f-align-items-center'>
         <image src='/customized/images/customized/tu_icon.png' mode="aspectFit"></image>
       </view>

+ 66 - 0
customized/pages/order/order.js

@@ -0,0 +1,66 @@
+// customized/pages/order/order.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 5 - 0
customized/pages/order/order.json

@@ -0,0 +1,5 @@
+{
+ "usingComponents": {
+  "data-none": "/components/data-none/data-none"
+  }
+}

+ 22 - 0
customized/pages/order/order.wxml

@@ -0,0 +1,22 @@
+<view class='order-box bg-white c-333'>
+  <view class='order-list mar-b20'>
+    <view class='mar-r20 mar-l20'>
+      <text class='f-s30'>奶钢 杯子 300ml</text>
+      <view  class='f-box f-align-items-center f-s28 mar-t20 mar-b20'>
+        <text class='f-item f-s30 c-orange'>¥18.80</text>
+        <view> × 1</view>
+      </view>
+    </view>      
+      <!-- 图片list -->
+    <view class='f-box goods-img-list' >
+      <image src='https://dlz.info666.com//temp/101b865a-44b5-4e87-8181-2ee7d366b502.png' mode="aspectFit"></image>
+    </view>
+    <!-- 操作按钮 -->
+    <view class='f-box f-justify-content-end pad-t20 pad-b20 f-s30'>
+      <view class='order-btn bg-orange'>立即付款</view>
+      <view class='order-btn bg-orange'>查看物流</view>
+      <view class='order-btn bg-green'>确认收货</view>
+    </view>
+  </view>
+</view>
+<data-none></data-none>

+ 18 - 0
customized/pages/order/order.wxss

@@ -0,0 +1,18 @@
+.goods-img-list image{
+  width:140rpx;
+  height:140rpx;
+  margin:5rpx;
+}
+.order-list{
+  padding:20rpx;
+  border-bottom:2rpx solid #e0e0e0;
+}
+.order-btn{
+  width:180rpx;
+  text-align: center;
+  margin-left:20rpx;
+  line-height:70rpx;
+  height:70rpx;
+  border-radius:6rpx;
+  color:#fff;
+}

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

@@ -18,10 +18,9 @@
   text-align: center;
 }
 .user-order{
-  width:710rpx;
+  width:750rpx;
   margin:0 auto;
   background:#fff;
-  border-radius:20rpx;
 }
 .user-order .iconfont{
   font-size:48rpx;

+ 15 - 1
project.config.json

@@ -28,7 +28,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 10,
+			"current": 12,
 			"list": [
 				{
 					"id": 0,
@@ -101,6 +101,20 @@
 					"pathName": "customized/pages/address/add/add",
 					"query": "",
 					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "accounts",
+					"pathName": "customized/pages/order/order",
+					"query": "",
+					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "order",
+					"pathName": "customized/pages/order/order",
+					"query": "",
+					"scene": null
 				}
 			]
 		}