Coder Social home page Coder Social logo

wxtabs's Introduction

wxTabs

tabs for wechat app

特点:

各页面状态(空白,错误,加载中)已自动处理

页面下拉刷新和上拉加载更多的方法已实现,并封装在tabUtil中,无需在page中书写.

tab之间的切换逻辑已处理.

使用时需要做的:

拷贝

netUtil.js拷贝到utils目录下

lib文件夹拷贝到根目录下

修改

针对具体项目微调netUtil里的一些字段,比如将用于分批加载的pagesize和pageIndex改成自己网络请求里的相应字段.

tab颜色和最小宽度,以及高度可在tabs.wxss里修改.

使用(参考pages\index)

写每个页面的wxml和wxss,模板化,并在具体页面导入

<!--tab标题-->
  <import src="../../lib/tab/tabs.wxml"/>
  <view  style="width: 100%">
    <template is="tabs" data="{{...tabInfo}}" />
  </view>

  <!--tab下方的listview-->

  <import src="../../lib/listview/albumlv.wxml"/>
  <block wx:for-items="{{tabInfo.tabStrs}}" wx:for-item="str" wx:for-index="i" wx:key="unique">

    <view  wx:if="{{tabInfo.tabIndex == i}}" style="width: 100%;height: 60%">
      <template is="albumlv" data="{{...tabDatas[i]}}" />
    </view>
  </block>

引入js:

var netUtil=require("../../utils/netUtil.js");
var tabUtil=require("../../lib/tab/tabUtil.js");
var lvUtil=require("../../lib/tab/lvUtil.js");

调用:

 var tabStrs = [' ',' ','推荐','学业成绩','行为问题','亲子关系','人际关系','情绪困扰'];

    tabUtil.initTab(that,tabStrs,2,function(i){
      var params = {};
      params.type=1;
      params.labelIds ="1,2,3,4,5";
      params.sourceType=0;
      params.priceType=0;
      params.categoryIds = i-2;
      params.pageIndex = 1;
      params.pageSize = 20;
      var lvBean = lvUtil.initLv(that,API.Lesson.SEARCH,params,i,'',{
        getListFromNetData:function(netData){
          return netData;
        },
        handleItemInfo:function(item){
          // utils.showVoiceItemPriceText(item);
        }
      });
      return lvBean;
    });

wxtabs's People

Contributors

hss01248 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.