|
本篇為大家介紹為何我們在最后做交互的時候,并沒有使用上一篇講的選項卡的效果。
大家注意看,在我點擊跳轉后,首先能看到的是切換選項卡的一個運動過程,然后才給用戶展示出被跳轉的頁面,開始看起來挺炫酷的,但我們覺得這不是一個好的用戶體驗。因為隨著使用次數(shù)的增加,會讓用戶感覺到這個功能不能馬上展示出他想要的頁面,還會有一種審美疲勞的感覺。
同時大家也都知道,微信小程序大小只限定在2M以內(nèi),而這種寫法會增加不少的代碼量,所以盡量的精簡代碼。
這大概也是大多數(shù)類似的小程序沒有該功能的原因吧?。儗俦救讼共拢?/p>
既然沒有了這個效果,那我們?nèi)绾螌崿F(xiàn)切換選項卡的功能呢?
思路:在“個人中心”點擊跳轉時需要傳遞一個 id (index),然后在“全部訂單”頁面接收,用該 id (index)使被選中 tab 高亮,同時把用該 id(index)交互過來的數(shù)據(jù)渲染在頁面中。
在“全部訂單”頁面點擊 tab 切換頁面時,同理使用該 tab 攜帶的 id (index)進行交互,把交互過來的數(shù)據(jù)渲染在頁面中。
wxml代碼,是不是比上一篇的精簡很多呢?
-
-
-
scroll-x="true" bindscroll="scroll" class="scroll-view_H list-liu">
-
class="scroll-view-item_H swiper-tab-list {{currentTab==0?'on':''}}" bindtap="swichNav" hover-class="eee" id="1">全部
-
class="scroll-view-item_H swiper-tab-list {{currentTab==1?'on':''}}" bindtap="swichNav" hover-class="eee" id="2">待付款
-
class="scroll-view-item_H swiper-tab-list {{currentTab==2?'on':''}}" bindtap="swichNav" hover-class="eee" id="3">待發(fā)貨
-
class="scroll-view-item_H swiper-tab-list {{currentTab==3?'on':''}}" bindtap="swichNav" hover-class="eee" id="4">已發(fā)貨
-
class="scroll-view-item_H swiper-tab-list {{currentTab==4?'on':''}}" bindtap="swichNav" hover-class="eee" id="5">已完成
-
-
-
-
-
scroll-y="{{true}}" style="height: {{clientHeight?clientHeight+'px':'auto'}}">
-
class="kong">
-
-
class="list" wx:for="{{carts}}" wx:key="*this">
-
-
class="pic">
-
src="{{item.product_photo_path}}">
-
-
-
url="../detail/detail" class="con" id="{{item.er[0].ordernoId}}" bindtap="navigatorToDetail">
-
-
class="type1">{{item.product_name}}
-
class="type2">{{item.product_content}}
-
-
-
-
class="price">
-
class="price1">¥{{item.product_price}}
-
class="number">×{{item.product_count}}
-
src="../../img/del.png" bindtap="deleteThis" id="{{item.er[0].ordernoId}}" >
-
-
-
本篇結束,感謝大家觀摩!
|