Jelajahi Sumber

添加地址

yann 5 bulan lalu
induk
melakukan
9e5aa49901

+ 2 - 1
components/addCartModel/addCartModel.js

@@ -83,8 +83,9 @@ Component({
             prod.quantity = this.data.quantity;
             prod.price = prodAttrPrice.price;
             wx.navigateTo({
-              url: '/pages/order/confirmOrder/confirmOrder?prods='+encodeURIComponent(JSON.stringify([prod])),
+                url: '/pages/order/confirmOrder/confirmOrder?prods='+encodeURIComponent(JSON.stringify([prod])),
             })
+            this.triggerEvent('close');
             return;
         }
         const cartItem = {

+ 1 - 1
components/existProduct-list/existProduct-list.wxml

@@ -5,7 +5,7 @@
                     <image src="/images/index/category-item.png" mode="aspectFill"></image>
                     <view class="info">
                         <text>{{item.prodName}}</text>
-                        <text>{{item.prodAttrName}}</text>
+                        <text>{{item.prodAttrName || item.attrName}}</text>
                         <text>¥{{item.price}}</text>
                     </view>
                     <view class="count">

+ 5 - 0
components/product-list/product-list.js

@@ -65,6 +65,11 @@ Component({
             }
             API.getProdsList(data).then(res=>{
                 if(res){
+                    res.mercProdList.forEach(item=>{
+                        if(!item.price && item.prodAttrList){
+                            item.price = item.prodAttrList[0].prodAttrPrice.price;
+                        }
+                    })
                     this.setData({
                         goodsList:this.data.pageNum === 1?res.mercProdList:[...this.data.goodsList,...res.mercProdList]
                     })

+ 1 - 1
components/product-list/product-list.wxml

@@ -7,7 +7,7 @@
             </view>
             <view class="goods-info">
                 <text class="goods-name">{{item.prodName}}</text>
-                <text class="goods-price" wx:if="{{position !== 'presale'}}">¥{{item.prodPicList[0].price}}</text>
+                <text class="goods-price" wx:if="{{position !== 'presale'}}">¥{{item.price}}</text>
             </view>
             <view class="goods-action" wx:if="{{position !== 'presale'}}">
                 <view class="favorite">

+ 7 - 0
pages/cart/cart.js

@@ -130,6 +130,13 @@ Page({
             isManage:!this.data.isManage
         })
     },
+    // 确认下单
+    confirmOrder(){
+        let prods = this.data.cartList.filter(item=>item.checkFlag === "1");
+        wx.navigateTo({
+            url: '/pages/order/confirmOrder/confirmOrder?prods='+encodeURIComponent(JSON.stringify(prods)),
+        })
+    },
     onLoad(){
     },
     onShow(){

+ 1 - 1
pages/cart/cart.wxml

@@ -44,7 +44,7 @@
             <checkbox value="all" checked="{{isAllChecked}}" bindtap="toggleAll">全 选</checkbox>
         </label>
         <text wx:if="{{!isManage}}">合计:¥{{totalPrice}}</text>
-        <text wx:if="{{!isManage}}">确认下单</text>
+        <text wx:if="{{!isManage}}" bindtap="confirmOrder">确认下单</text>
         <view class="delete" wx:if="{{isManage}}" catchtap="deleteProd">删 除</view>
     </view>
 </view>

+ 79 - 0
pages/my/addAddress/addAddress.js

@@ -0,0 +1,79 @@
+// pages/my/addAddress/addAddress.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    form:{
+        checked:false
+    }
+  },
+  // 监听input的输入
+  inputChange(e){
+    let key = e.currentTarget.dataset.key;
+    let value = e.detail.value;
+    let obj = {};
+    obj[key] = value;
+    this.setData({
+        form:{
+            ...obj
+        }
+    })
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 4 - 0
pages/my/addAddress/addAddress.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText":"新增收获地址"
+}

+ 24 - 0
pages/my/addAddress/addAddress.wxml

@@ -0,0 +1,24 @@
+<!--pages/my/addAddress/addAddress.wxml-->
+<view>
+    <form catchsubmit="formSubmit">
+        <label class="radio">
+            <radio value="r1" checked="{{form.checked}}"/>设置为默认地址
+        </label>
+        <view class="info">
+           <text class="name">收件人</text>
+           <input type="text" class="input" data-key="name" bindinput="inputChange"/>
+        </view>
+        <view class="info">
+           <text class="name">手机号</text>
+           <input type="text" data-key="phone" class="input" bindinput="inputChange"/>
+        </view>
+        <view class="info">
+           <text class="name">所在地区</text>
+           <input type="text" data-key="region" class="input" bindinput="inputChange"/>
+        </view>
+        <view class="info">
+           <text class="name">详细地址</text>
+           <input type="text" data-key="address" class="input" bindinput="inputChange"/>
+        </view>
+    </form>
+</view>

+ 20 - 0
pages/my/addAddress/addAddress.wxss

@@ -0,0 +1,20 @@
+/* pages/my/addAddress/addAddress.wxss */
+.radio{
+    display: block;
+    text-align: right;
+    margin: 30rpx 20rpx 50rpx 0;
+}
+.info{
+    width: 85%;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin: 30rpx auto;
+}
+.info .input{
+    width: 450rpx;
+    height: 100rpx;
+    background: #F2F2F2;
+    border-radius: 10rpx;
+    padding-left: 20rpx;
+}

+ 75 - 0
pages/my/addressManage/addressManage.js

@@ -0,0 +1,75 @@
+import { API } from "../../../service/api"
+
+// pages/my/addressManage/addressManage.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    addressList:[]
+  },
+  // 获取地址列表
+  getAddressList(){
+      API.getAddressList().then(res=>{
+          this.setData({
+              addressList:res.userAddressList
+          })
+      })
+  },  
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.getAddressList();
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 4 - 0
pages/my/addressManage/addressManage.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText":"地址管理"
+}

+ 20 - 0
pages/my/addressManage/addressManage.wxml

@@ -0,0 +1,20 @@
+<!--pages/my/addressManage/addressManage.wxml-->
+<view>
+   <view class="header">
+      <text>常用地址</text>
+      <text>+新增</text>
+   </view>
+   <view class="addressList">
+    <view class="itemAddress" wx:for="{{addressList}}" wx:key="id">
+        <checkbox checked="{{item.checked}}"/>
+        <view class="content">
+            <view>
+              <text>{{item.name}}</text>
+              <text>{{item.phone}}</text>
+            </view>
+            <text class="address">{{item.address}}</text>
+        </view>
+        <text>删除</text>
+    </view>
+   </view>
+</view>

+ 22 - 0
pages/my/addressManage/addressManage.wxss

@@ -0,0 +1,22 @@
+/* pages/my/addressManage/addressManage.wxss */
+.header{
+    line-height: 100rpx;
+    display: flex;
+    justify-content: space-between;
+    background: #F9F9F9;
+}
+.header text:nth-child(1){
+    margin-left:20rpx;
+}
+.header text:nth-child(2){
+    margin-right: 20rpx;
+}
+.itemAddress{
+    width: 90%;
+    margin: auto;
+    border-bottom: 2rpx solid #bbbaba;
+    padding: 50rpx 20rpx;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+}

+ 0 - 1
pages/my/my.js

@@ -1 +0,0 @@
-Page({})

+ 0 - 4
pages/my/my.json

@@ -1,4 +0,0 @@
-{
-  "navigationStyle": "custom",
-  "usingComponents": {}
-}

+ 0 - 3
pages/my/my.wxml

@@ -1,3 +0,0 @@
-<view>
-  my
-</view>

+ 0 - 0
pages/my/my.wxss


+ 66 - 0
pages/my/personalCenter/personalCenter.js

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

+ 3 - 0
pages/my/personalCenter/personalCenter.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 2 - 0
pages/my/personalCenter/personalCenter.wxml

@@ -0,0 +1,2 @@
+<!--pages/my/personalCenter/personalCenter.wxml-->
+<text>pages/my/personalCenter/personalCenter.wxml</text>

+ 1 - 0
pages/my/personalCenter/personalCenter.wxss

@@ -0,0 +1 @@
+/* pages/my/personalCenter/personalCenter.wxss */

+ 4 - 0
service/api.js

@@ -265,5 +265,9 @@ export const API = {
     // 减少商品数量
     subCartProdCount: function(playload){
         return http.post("/api/store/carts/subCnt",playload)
+    },
+    // 获取地址列表
+    getAddressList: function(){
+        return http.post("/api/store/user-profile/address-list",{})
     }
 }