sharp-agezi 6 年 前
コミット
cf91f34af8

+ 2 - 1
app.json

@@ -98,7 +98,8 @@
         "pages/made/madeFont/madeFont",
         "pages/made/comb/comb",
         "pages/canvas/canvas",
-        "pages/made/car/car"
+        "pages/car/car",
+        "pages/order/order"
       ]
     }
   ],

+ 48 - 43
customized/pages/made/car/car.js

@@ -11,6 +11,7 @@ Page({
     host: app.globalData.servsers,
     amount:0, //总价
     checkAll:false, // 全选
+    checkStatic:false, //默认一个都没有选择
   },
 
   /**
@@ -24,52 +25,17 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
     let that = this;
     that.getCarlist(that)
-    
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
-
   },
 
   /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 用户点击右上角分享
+   * 生命周期函数--监听页面显示
    */
-  onShareAppMessage: function () {
-
-  },
+  // onShow: function () {
+    
+    
+  // },
   subtraction(e){ // 减少
   let that = this;
     console.log(e)
@@ -106,6 +72,22 @@ Page({
     that.totalPrice(that)
 
   },
+  checkboxChangeAll(e){ // 全选
+  console.log(e)
+    let that = this, checkAll= that.data.checkAll , carList=that.data.carList;
+    if (e.detail.value[0]) { 
+      checkAll = true; // 表示选中
+    } else {
+      checkAll = false;
+    }
+    carList.forEach(res => {
+      res.checked = checkAll;
+    })
+    that.setData({
+      carList:carList
+    })
+    that.totalPrice(that)
+  },
   getCarlist(that){
     wx.request({
       url: host +'/queryShopCar',
@@ -132,11 +114,33 @@ Page({
       }
     })
   },
+  carSubmit(){ // 提交订单
+    let that = this, carList=[];
+    if (that.data.checkStatic){
+      that.data.carList.forEach(el=>{
+        if(el.checked){
+          carList.push(el)
+        }
+      })
+      wx.setStorageSync('goodsList', carList);
+      wx.setStorageSync('amount', that.data.amount);
+      wx.navigateTo({
+        url: '/customized/pages/order/order',
+      })
+    } else {
+      wx.showToast({
+        title: '您还没有选择商品',
+        icon:'none'
+      })
+    }
+  },
   totalPrice(that){
-    let amount = 0,checkAll = true;
+    let amount = 0, checkAll = true, checkStatic= false;
     that.data.carList.forEach(res=>{
       if(res.checked){
-        amount += res.customgoodsPriceNow * res.customGoodsNum
+        amount += res.customgoodsPriceNow * res.customGoodsNum;
+        checkStatic = true
+       
       }
       if (!res.checked) {
         checkAll = false
@@ -144,7 +148,8 @@ Page({
     })
     that.setData({
       amount:amount.toFixed(2),
-      checkAll: checkAll
+      checkAll: checkAll,
+      checkStatic: checkStatic
     })
   }
 })

customized/pages/made/car/car.json → customized/pages/car/car.json


+ 41 - 0
customized/pages/car/car.wxml

@@ -0,0 +1,41 @@
+<view>
+  <!-- 购物车列表 -->
+  <view class='car-box '>
+    <view  class='car-list  bg-white' wx:for="{{carList}}" wx:for-index="idx">
+      <view class='f-box car-auto'>
+          <checkbox-group class="car-checkbox f-box f-align-items-center" bindchange="checkboxChange" data-index="{{idx}}">
+            <label class="checkbox">
+              <checkbox value='{{item.shopCarId}}' checked='{{item.checked}}' />
+            </label>
+          </checkbox-group>
+          <view class='f-item'>
+            <text class='f-s30'>{{item.customGoodsName}}</text>
+            <view  class='f-box f-align-items-center' style='margin:20rpx 0;'>
+              <text class='f-item f-s28'>¥{{item.customgoodsPriceNow}}</text>
+              <view class='car-numBtn f-box'>
+                <view bindtap='subtraction' data-index="{{idx}}">-</view>
+                <input disabled="true" value="{{item.customGoodsNum}}"/>
+                <view bindtap='add' data-index="{{idx}}">+</view>
+              </view>
+            </view>
+            <!-- 图片list -->
+            <view class='f-box car-img-list' wx:for='{{item.imgArray}}' wx:for-item="itemSrc">
+              <image src='{{host}}{{itemSrc}}' mode="aspectFit"></image>
+            </view>
+          </view>
+        </view>
+      </view>
+    </view>
+</view>
+
+<view class='footer bg-white'>
+  <view  class='car-footer'>
+    <view  class='f-box'>
+        <checkbox-group class="f-s30 f-box f-align-items-center mar-l20" bindchange="checkboxChangeAll">
+          <label class="checkbox" ><checkbox value="1" checked='{{checkAll}}'/>全选</label>
+        </checkbox-group>
+      <view class='f-item f-s30 mar-l20 f-box mar-r20 f-justify-content-end'>金额:¥{{amount}}</view>
+      <view class='f-s32 f-item car-btn bg-orange c-white' bindtap='carSubmit'>提交订单</view>
+    </view>
+  </view>
+</view>

customized/pages/made/car/car.wxss → customized/pages/car/car.wxss


+ 0 - 41
customized/pages/made/car/car.wxml

@@ -1,41 +0,0 @@
-<view>
-  <!-- 购物车列表 -->
-  <view class='car-box '>
-    <view  class='car-list  bg-white' wx:for="{{carList}}" wx:for-index="idx">
-    <view class='f-box car-auto'>
-        <checkbox-group class="car-checkbox f-box f-align-items-center" bindchange="checkboxChange" data-index="{{idx}}">
-          <label class="checkbox">
-            <checkbox value='{{item.shopCarId}}' checked='{{item.checked}}' />
-          </label>
-        </checkbox-group>
-        <view class='f-item'>
-          <text class='f-s30'>{{item.customGoodsName}}</text>
-          <view  class='f-box f-align-items-center' style='margin:20rpx 0;'>
-            <text class='f-item f-s28'>¥{{item.customgoodsPriceNow}}</text>
-            <view class='car-numBtn f-box'>
-              <view bindtap='subtraction' data-index="{{idx}}">-</view>
-              <input disabled="true" value="{{item.customGoodsNum}}"/>
-              <view bindtap='add' data-index="{{idx}}">+</view>
-            </view>
-          </view>
-          <!-- 图片list -->
-          <view class='f-box car-img-list' wx:for='{{item.imgArray}}' wx:for-item="itemSrc">
-            <image src='{{host}}{{itemSrc}}' mode="aspectFit"></image>
-          </view>
-        </view>
-      </view>
-    </view>
-  </view>
-</view>
-
-<view class='footer bg-white'>
-  <view  class='car-footer'>
-    <view  class='f-box'>
-        <checkbox-group class="f-s30 f-box f-align-items-center mar-l20">
-          <label class="checkbox"><checkbox checked='{{checkAll}}'/>全选</label>
-        </checkbox-group>
-      <view class='f-item f-s30 mar-l20 f-box mar-r20 f-justify-content-end'>金额:¥{{amount}}</view>
-      <view class='f-s32 f-item car-btn bg-orange c-white'>提交订单</view>
-    </view>
-  </view>
-</view>

+ 1 - 1
customized/pages/made/comb/comb.js

@@ -348,7 +348,7 @@ Page({
               if (res.confirm) {
                 console.log('用户点击确定')
                 wx.redirectTo({
-                  url: '/customized/pages/made/car/car',
+                  url: '/customized/pages/car/car',
                 })
               } else if (res.cancel) {
                 console.log('用户点击取消')

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

@@ -0,0 +1,60 @@
+let app = getApp();
+let host = app.globalData.servsers; // 请求的url
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    goodsList:[],
+    host: app.globalData.servsers,
+  },
+
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    let goodsList=[],that=this;
+    goodsList = [...wx.getStorageSync('goodsList')];
+    that.setData({
+      goodsList: goodsList
+    })
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

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

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

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

@@ -0,0 +1,44 @@
+<!-- 地址 -->
+<view class='address-box bg-white'>
+  <view class='mar-l20 mar-r20 f-box'>
+    <view class='address-infor f-item'>
+      <view class='f-box f-s30'><text>阿哥子</text><text>15055166539</text></view>
+      <view class='mar-t20 f-s30'>
+        上海市 闵行区 虹漕路88号
+      </view>
+    </view>
+    <view class='arrow'></view>
+  </view>
+</view>
+<!-- 订单 -->
+<view class='goodsList-box mar-t20 bg-white'>
+  <view  class='goods-list' wx:for="{{goodsList}}">
+      <view class='mar-r20 mar-l20'>
+        <text class='f-s30'>{{item.customGoodsName}}</text>
+        <view  class='f-box f-align-items-center f-s28' style='margin:20rpx 0;'>
+          <text class='f-item'>¥{{item.customgoodsPriceNow}}</text>
+          <view> × {{item.customGoodsNum}}</view>
+        </view>
+      </view>      
+      <!-- 图片list -->
+      <view class='f-box goods-img-list' wx:for='{{item.imgArray}}' wx:for-item="itemSrc">
+        <image src='{{host}}{{itemSrc}}' mode="aspectFit"></image>
+      </view>
+  </view>
+</view>
+
+<!-- 其他内容,邮费/备注等 -->
+<view class='other-box bg-white mar-t20'>
+  <view class='mar-l20 mar-r20 f-s28'>
+    <view class='other-list f-box'>
+        <view class="f-item">运费</view>
+        <view>包邮</view>
+      </view>
+      <view class='other-list'>
+        <view class='mar-b20'>备注</view>
+        <input placeholder='备注内容~'></input>
+      </view>
+      
+  </view>
+    
+</view>

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

@@ -0,0 +1,30 @@
+.address-box{
+  position: relative;
+}
+.arrow{
+width: 18rpx;
+height: 18rpx;
+border-top: 1px solid #999;
+border-right: 1px solid #999;
+position: absolute;
+top:50%;
+right: 50rpx;
+transform: rotate(45deg);
+margin-top:-9rpx;
+}
+.address-infor{
+  padding:20rpx 0;
+}
+
+.goods-img-list image{
+  width:140rpx;
+  height:140rpx;
+  margin:5rpx;
+}
+.goods-list{
+  padding:20rpx;
+  border-bottom:2rpx solid #e0e0e0;
+}
+.other-list{
+  padding:20rpx 0;
+}

+ 6 - 5
project.config.json

@@ -61,15 +61,16 @@
 					"query": ""
 				},
 				{
-					"id": -1,
-					"name": "canvas",
-					"pathName": "customized/pages/canvas/canvas",
-					"query": ""
+					"id": 5,
+					"name": "order",
+					"pathName": "customized/pages/order/order",
+					"query": "",
+					"scene": null
 				},
 				{
 					"id": 6,
 					"name": "car",
-					"pathName": "customized/pages/made/car/car",
+					"pathName": "customized/pages/car/car",
 					"query": "",
 					"scene": null
 				}