-
首頁下拉加載數(shù)據(jù)
-
index.wxml
//引用封裝好的小數(shù)點(diǎn)保留2位的方法 <wxs module="filters" src="../../../filter/filter.wxs"></wxs> <view class="order-list"> <view class="navagator"> <!-- 標(biāo)簽欄 --> <view style="color:#797d82;"> <van-tabs> <van-tab title="全部"></van-tab> <van-tab title="待分享"></van-tab> <van-tab title="待付款"></van-tab> <van-tab title="待發(fā)貨"></van-tab> <van-tab title="待收貨"></van-tab> </van-tabs> </view> </view> <!-- 商品詳情 --> <view class="goodsDetail"> <view class="goodsBox" style="margin-top:30rpx;" wx:for="{{orderListArr}}" wx:key="{{index}}" bindtap="toDetail" data-orderId="{{item.orderId}}"> <van-card class="padd-15" wx:for="{{item.carts}}" wx:key="{{cartsItem.cartId}}" wx:for-item="cartsItem" num="{{cartsItem.buyNum}}" price="{{filters.toFix(cartsItem.price)}}" title="{{cartsItem.masterName}}" thumb="{{cartsItem.imgUrl}}" style="font-size: 30rpx;background-color: #fff;" /> <view slot="footer" style="height:80rpx" class="border-line"> <view style="height:26rpx;font-size:26rpx;padding-right:20rpx"> 共{{item.cartnumber}}件商品 <text style="padding-left:20rpx"></text> 實(shí)付¥ <text style="color:#C03131;font-size:30rpx">{{filters.toFix(item.totalPrice)}}</text> </view> </view> <view slot="footer" class="margin-top"> <text class="flr">{{item.payStatus == "0"?"已取消":"交易成功"}}</text> <view class="buttosize">{{item.payStatus == "0"?"重新購買":"評(píng)價(jià)"}}</view> </view> </view> </view> </view>
-
index.wxss
.van-card__price { color: #C03131 !important; } .padd-15 { padding: 30rpx 30rpx 0 30rpx; } .border-line { background-color: #fff; display: flex; justify-content: flex-end; line-height: 80rpx; height: 80rpx; border-bottom: 2rpx solid #ece9e9; border-top: 2rpx solid #ece9e9; z-index: 3 } .van-card[data-v-55a01f0e] { border-bottom: 2rpx solid #ECE9E9; } .van-card:not(:first-child) { margin-top: 0 } van-nav-bar .van-icon { color: #2e2f30; font-size: 44rpx } .order-list { height: 100%; background: #fff } .order-list .van-card { background: #fff } .order-list .navagator { position: fixed; width: 100%; top: 0; z-index: 9 } .van-card__header { background: #fff } .order-list .goodsDetail { margin-top: 45px; background: #fff } img { width: 140rpx; height: 140rpx } .van-card__thumb { width: 140rpx; height: 140rpx } .van-image__error, .van-image__img, .van-image__loading { width: 140rpx; height: 140rpx } .van-card__content { height: 140rpx } .van-card__header { min-height: 140rpx } .van-card__bottom { line-height: 40rpx; margin-top: 64rpx } .van-card { background: white } .flr { float: left; line-height: 90rpx; color: #bdc0c5 } .buttosize { font-size: 26rpx; width: 172rpx; height: 66rpx; display: flex; align-items: center; justify-content: center; border: 2rpx solid #2e2f30; box-sizing: border-box } .margin-top { height: 90rpx; align-items: center; background-color: #fff; display: flex; justify-content: space-between; margin-right: 10rpx; padding: 0 20rpx }
-
index.json
{ "usingComponents": { "w-swiper": "/components/w-swiper/w-swiper", "van-sticky": "../../../dist/sticky/index" }, "navigationBarTitleText": "首頁" }
-
index.js
//獲取應(yīng)用實(shí)例 // const filterFn = require("../../filter/filter.js"); const app = getApp() //Page Object Page({ data: { // 首頁頭部圖片 headSwiper: [], // 商品分類數(shù)組 categoryList: [], // 商品列表 productList: [], pageNum: 1, pullDownArr: [], // flag:true resing: [], dataBack: true }, sendId(event) { // console.log(event.currentTarget.dataset.link) var productId = event.currentTarget.dataset.link wx.navigateTo({ url: productId }); }, // 頁面展示相當(dāng)于 created() onShow: function () { // 獲取輪播圖數(shù)據(jù) this.getDataList() // 獲取商品分類數(shù)據(jù) this.categoryData() // 商品列表 this.productListData(this.data.pageNum) // this.goodList(1) }, // 獲取輪播圖數(shù)據(jù) getDataList() { let url = '/product/getBanners' app.$get(url).then(res => { // console.log(res,'sss') this.setData({ headSwiper: res.banners }) }).catch(err => { console.log(err) }) }, // 獲取商品分類數(shù)據(jù) categoryData() { let url = '/category/all' app.$get(url).then(res => { // console.log(res,'商品分類') this.setData({ categoryList: res.list }) }).catch(err => { console.log(err) }) }, // 獲取商品列表數(shù)據(jù) productListData(pageNum) { // console.log(2 + 1) let url = "/product/list?pageNum=" + pageNum app.$get(url).then(res => { wx.showLoading({ title: '拼命加載中', }) setTimeout(function () { wx.hideLoading() }, 2000) // 節(jié)流 判斷這個(gè)接口數(shù)組的長度 當(dāng)這個(gè)接口數(shù)組不為空的時(shí)候發(fā)送請(qǐng)求數(shù)據(jù) 问词,否則不發(fā)送 if (res.list.length) { console.log(res.list, '商品列表') //遍歷這個(gè)接口數(shù)組 let tempArr = res.list.map(item => { return { ...item, //把商品價(jià)格保留2位小數(shù) minPrice: (item.minPrice / 100).toFixed(2) } }) // 拼接productList let tempt = this.data.productList.concat(tempArr) // 保存數(shù)據(jù) this.setData({ // 然后把這個(gè)數(shù)組賦值給productList productList: tempt, resing: res.list, dataBack: true }) } }).catch(err => { console.log(err) }) }, // 事件處理函數(shù)的聲明(上拉刷新) // onPullDownRefresh: function () { // // 重新加載數(shù)據(jù) // this.setData({ pageNum: 0 }) // this.getData() // }, // 監(jiān)聽用戶上拉觸底事件(下拉加載) onReachBottom() { if (this.data.dataBack) { // 判斷數(shù)據(jù)長度是否為0 let pages = this.data.pageNum + 1 console.log(pages) this.productListData(pages) this.setData({ pageNum: pages, // 當(dāng)監(jiān)聽數(shù)據(jù)為假的時(shí)候不在發(fā)送請(qǐng)求 dataBack: false }) } } });
-
小程序?qū)崿F(xiàn)下拉加載
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
禁止轉(zhuǎn)載夺克,如需轉(zhuǎn)載請(qǐng)通過簡信或評(píng)論聯(lián)系作者拳亿。
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來玫霎,“玉大人凿滤,你說我怎么就攤上這事∈” “怎么了翁脆?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長鼻种。 經(jīng)常有香客問我反番,道長,這世上最難降的妖魔是什么叉钥? 我笑而不...
- 正文 為了忘掉前任罢缸,我火速辦了婚禮,結(jié)果婚禮上投队,老公的妹妹穿的比我還像新娘枫疆。我一直安慰自己,他們只是感情好敷鸦,可當(dāng)我...
- 文/花漫 我一把揭開白布息楔。 她就那樣靜靜地躺著寝贡,像睡著了一般。 火紅的嫁衣襯著肌膚如雪值依。 梳的紋絲不亂的頭發(fā)上圃泡,一...
- 文/蒼蘭香墨 我猛地睜開眼褒链,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼唁情!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起甫匹,我...
- 序言:老撾萬榮一對(duì)情侶失蹤甸鸟,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后兵迅,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體抢韭,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年恍箭,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了刻恭。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站构拳,受9級(jí)特大地震影響咆爽,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜置森,卻給世界環(huán)境...
- 文/蒙蒙 一斗埂、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧凫海,春花似錦蜜笤、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽沪伙。三九已至,卻和暖如春县好,著一層夾襖步出監(jiān)牢的瞬間围橡,已是汗流浹背。 一陣腳步聲響...
- 正文 我出身青樓晾咪,卻偏偏與公主長得像收擦,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子谍倦,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- <template> <!-- --> 序號(hào) 編號(hào) 時(shí)間 等級(jí) 照片 {{key+1}} ...
- 先看看效果 .wxml : <view class="container"> <!--左側(cè)欄--> <vie...
- [教程]微信小程序之試手豆瓣圖書API昼蛀,有demo有真相2016-10-13轉(zhuǎn)載作者:oopsguy 最近微信小程...
- 作者:葉小釵www.cnblogs.com/yexiaochai/p/9431816.html 接上文: 微信小程...
- 每天孩子們會(huì)有一節(jié)課的自由玩耍時(shí)間宴猾。 今天女生小可愛們跑來悄悄問我:“老師,你名字咋寫叼旋?” 我把工卡給她仇哆,讓她們自...