我的微信小程式第四個頁面【IE 盒模型、動態計算高度、margin-Top 慎用於子元素、scroll-view下拉重新整理,scroll-view上拉載入】
阿新 • • 發佈:2021-11-17
十年河東,十年河西,莫欺少年窮
學無止境,精益求精
描述1:box-sizing:border-box;/*IE盒模型內容寬度+padding+border==賦值的寬度{100%}*/
首先W3c的標準是:
IE 盒模型為:
IE 盒模型的CSS
.orderTitle{ height: 126rpx; width: 100%; display: flex; justify-content: space-around; align-items: center; padding: 0 22rpx 0 22rpx; box-sizing: border-box; /*IE 盒模型 內容寬度+padding+border == 賦值的寬度{100%}*/ background-color: #fff; }
描述三,動態計算
.scroll{ height: calc(100vh - 90rpx - 126rpx);/*動態計算高度 注意 減號要和數字之間有間隔 要帶單位哦 */ }
描述4:/*子盒子設定Magin-Top會作用於父盒子並把父盒子拉下來慎用*/
.userOrder{ width: 710rpx; height: auto; margin-top: 28rpx; /*子盒子設定 Magin-Top 會作用於父盒子並把父盒子拉下來 慎用*/ margin-left: 20rpx; background-color: #fff; padding: 0 32rpx 32rpx 32rpx; box-sizing: border-box; /*IE 盒模型 內容寬度+padding+border == 賦值的寬度{100%}*/ }
描述5:ES6陣列語法
saixuan() { //陣列的合併 var hebingAry = this.data.Users.concat(this.data.Users2); console.log("合併後的陣列長度為:" + hebingAry.length); //根據陣列屬性篩選--結果為陣列 var Useref=this.data.Users.filter(A => A.id==1); console.log(Useref); //find 也是篩選 結果為物件 只返回滿足條件的第一個 var fef=this.data.Users.find(A => A.id==1||A.id==2); console.log(fef); //find 也是篩選 結果為索引 只返回滿足條件的第一個 var inde=this.data.Users.findIndex(A => A.id==2||A.id==2); console.log(inde); console.log("..............................") //遍歷 forEach this.data.Users.forEach((e,i) => { e.name=e.name+"陳" }); console.log("......222222222222222222222222222222222222222222........................") //遍歷 Map var result = this.data.Users2.map((e,i) => { e.name=e.name+"陳" }); console.log(this.data.Users) console.log(this.data.Users2) },
效果圖如下:
程式碼如下:
wxml:
<!--pages/order/order.wxml--> <view class="bigview"> <view class="ordercate"> <view class="wwc {{wxIndex==1?'wwcactive':''}}" bindtap="wwcTap" data-index="1">已完成</view> <view class="wwc {{wxIndex==2?'wwcactive':''}}" bindtap="wwcTap" data-index="2">未完成</view> </view> <view class="orderTitle"> <view class="tlc {{tlcIndex==3?'tlcactive':''}}" bindtap="tlcTap" data-index="3">全部</view> <view class="tlc {{tlcIndex==4?'tlcactive':''}}" bindtap="tlcTap" data-index="4">門店</view> <view class="tlc {{tlcIndex==5?'tlcactive':''}}" bindtap="tlcTap" data-index="5">充電</view> <view class="tlc {{tlcIndex==6?'tlcactive':''}}" bindtap="tlcTap" data-index="6">換電</view> <view class="tlc {{tlcIndex==7?'tlcactive':''}}" bindtap="tlcTap" data-index="7">商城</view> </view> <scroll-view class="scroll" scroll-y="{{scor}}" bindscrolltolower="bindscrolltolower" bindrefresherrefresh="bindrefresherrefresh" refresher-enabled="{{true}}" refresher-triggered="{{IsOpen}}"> <view class="userOrder" wx:for="{{orderData}}" wx:for-item="item" wx:key="orderDetailId"> <view class="orderType">{{item.businessType}}訂單</view> <view class="Forderinfo"> <view class="orderinfoLeft">訂單編號:</view> <view class="orderinfo">{{item.orderNo}}</view> </view> <view class="Forderinfo"> <view class="orderinfoLeft">商品名稱:</view> <view class="orderinfo">{{item.goodsName}}</view> </view> <view class="Forderinfo"> <view class="orderinfoLeft">成交時間:</view> <view class="orderinfo">{{item.orderTime}}</view> </view> <view class="Forderinfo"> <view class="orderinfoLeft">成交金額:</view> <view class="orderinfo">{{item.orderPrice}}</view> </view> </view> </scroll-view> </view>View Code
JS
// pages/order/order.js var URL = "https://xxx.com/DEV/WuAnChangeApi"; const app = getApp(); Page({ /** * 頁面的初始資料 */ data: { Users: [{ id: 1, name: "chen" }, { id: 2, name: "chen2" }, { id: 3, name: "chen3" }, { id: 4, name: "chen4" }, { id: 5, name: "chen5" }], Users2: [{ id: 1, name: "張" }, { id: 2, name: "張2" }, { id: 3, name: "張3" }, { id: 4, name: "張4" }, { id: 5, name: "張5" }], wxIndex: 1, tlcIndex: 3, tabType: null, scor: true, orderData: [], pagination: {}, currentpageIndex: 1, IsOpen: false }, saixuan() { //陣列的合併 var hebingAry = this.data.Users.concat(this.data.Users2); console.log("合併後的陣列長度為:" + hebingAry.length); //根據陣列屬性篩選--結果為陣列 var Useref=this.data.Users.filter(A => A.id==1); console.log(Useref); //find 也是篩選 結果為物件 只返回滿足條件的第一個 var fef=this.data.Users.find(A => A.id==1||A.id==2); console.log(fef); //find 也是篩選 結果為索引 只返回滿足條件的第一個 var inde=this.data.Users.findIndex(A => A.id==2||A.id==2); console.log(inde); console.log("..............................") //遍歷 forEach this.data.Users.forEach((e,i) => { e.name=e.name+"陳" }); console.log("......222222222222222222222222222222222222222222........................") //遍歷 Map var result = this.data.Users2.map((e,i) => { e.name=e.name+"陳" }); console.log(this.data.Users) console.log(this.data.Users2) }, /** * 生命週期函式--監聽頁面載入 */ onLoad: function (options) { // wx.showLoading({ // title: '請稍後', // mask: true // }) this.saixuan(); this.GetOrder(); }, //上拉獲取資料 bindscrolltolower() { let that = this; that.setData({ currentpageIndex: that.data.pagination.pageNumber + 1, }) that.GetOrder(); }, //下來重新整理 bindrefresherrefresh() { console.log('觸發了') this.setData({ orderData: [], currentpageIndex: 1, pagination: {} }) this.GetOrder() }, wwcTap(e) { console.log(e) let index = e.currentTarget.dataset.index; this.setData({ wxIndex: index, tlcIndex: 3 }); }, tlcTap(e) { let that = this; console.log(e) let index = e.currentTarget.dataset.index; that.setData({ tlcIndex: index }); if (index == 3) { that.tabType = null; } if (index == 4) { that.tabType = "門店"; } if (index == 5) { that.tabType = "充電"; } if (index == 6) { that.tabType = "換電"; } if (index == 7) { that.tabType = "商城"; } }, async GetOrder() { let that = this; if (that.data.currentpageIndex > that.data.pagination.pageCount) { return; } let search = { isComplete: true, pageNumber: that.data.currentpageIndex, pageSize: 10, tabType: that.data.tabType } //method: method, var result = await app.request({ url: "/api/v1/OrderInfo/GetOrderList", data: search, method: "POST" }) console.log(result.data) var rdata = result.data.data; if (that.data.orderData) { rdata = that.data.orderData.concat(rdata); } that.setData({ orderData: rdata, pagination: result.data.pagination, IsOpen: false }) }, /** * 複製訂單編號 */ copy: function (e) { wx.setClipboardData({ data: e.currentTarget.dataset.num, success: function (res) { wx.getClipboardData({ success: (option) => { console.log(option.data) }, }) }, fail: function (err) { } }) }, })View Code
WXSS
/* pages/order/order.wxss */ .bigview{ background-color: #F4F8FB; height: 100vh; } .ordercate { height: 90rpx; width: 100%; display: flex; justify-content: space-around; align-items: center; background-color: #fff; } .wwc { width: 90rpx; height: 42rpx; font-size: 30rpx; font-weight: 600; } .wwcactive{ color: #0DD0D0; } .orderTitle{ height: 126rpx; width: 100%; display: flex; justify-content: space-around; align-items: center; padding: 0 22rpx 0 22rpx; box-sizing: border-box; /*IE 盒模型 內容寬度+padding+border == 賦值的寬度{100%}*/ background-color: #fff; } .tlc{ background-color: #F5F9FB; width: 132rpx; height: 64rpx; font-size: 28rpx; font-weight: 500; border:2rpx solid #F5F9FB; line-height: 64rpx; /* 垂直居中 */ text-align: center; /* 水平居中 */ border-radius: 10rpx; } .tlcactive{ background-color: #E5F9F9; color: #0DD0D0; } .scroll{ height: calc(100vh - 90rpx - 126rpx);/*動態計算高度 注意 減號要和數字之間有間隔 要帶單位哦 */ } .userOrder{ width: 710rpx; height: auto; margin-top: 28rpx; /*子盒子設定 Magin-Top 會作用於父盒子並把父盒子拉下來 慎用*/ margin-left: 20rpx; background-color: #fff; padding: 0 32rpx 32rpx 32rpx; box-sizing: border-box; /*IE 盒模型 內容寬度+padding+border == 賦值的寬度{100%}*/ } .orderType{ width: 100%; height: 112rpx; color: #1B1F2B; font-size: 32rpx; font-weight: 600; display: flex; align-items: center; border-bottom: 2rpx solid #ECEDF1; } .Forderinfo{ display: flex; justify-content: space-between; margin-top: 32rpx; } .orderinfoLeft{ color: #374353; font-size: 28rpx; font-weight: 500; width: 30%; } .orderinfo{ color: #374353; font-size: 28rpx; font-weight: 500; text-align: right; }View Code
@天才臥龍的部落格
付婷,你還那麼胖嗎?如果胖,就減肥肥吧。