提交 7bf5bdd3 编写于 作者: I iotjin

add custom-tabbar

上级 b2a49cbf
......@@ -7,11 +7,14 @@
* GridView相关
* eChart分包导入,异步加载,多图表延时加载
* 自定义导航条,热门搜索和历史搜索框
* 时间日期选择器,月日周时分选择器,输入弹框
* 时间日期选择器、月日周时分选择器、字符串选择器、输入弹框
* 上下拉刷新、分组吸顶ListView
* 答题功能
* excel导入导出
* AES加密
* AES、SHA256
* 表格
* 侧滑筛选
* custom-tabbar(动态设置、不闪屏)
* wx.request 封装,云函数请求封装
* 封装一些组件(在JhTools文件夹)和工具类(在utils文件夹)
......
{
"pages": [
"pages/demoList/demoList",
"pages/tabbar/index",
"pages/one/one",
"pages/one/details",
"pages/three/three",
......@@ -71,6 +72,7 @@
"navigationBarTextStyle": "white"
},
"tabBar": {
"custom": false,
"color": "#cdcdcd",
"selectedColor": "#38BC9D",
"list": [{
......@@ -102,6 +104,7 @@
"wxe5f52902cf4de896"
],
"usingComponents": {
"custom-tabbar": "components/custom-tabbar/index",
"time-picker": "JhTools/time-picker/index",
"string-picker": "JhTools/string-picker/index",
"time-switch": "JhTools/time-switch/index",
......
// components/custom-tabbar/index.js
var app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
// tabbar 数组
list: {
type: Array,
value: []
},
},
data: {
selected: 0,
isShowTabbar: true,
color: "#7d7e80",
selectedColor: "#1989fa",
tabbars: [],
tabbars0: [{
isShowRedDot: true,
info: '',
text: '模块一',
iconPath: 'https://img.yzcdn.cn/vant/user-inactive.png',
selectedIconPath: 'https://img.yzcdn.cn/vant/user-active.png',
},
{
isShowRedDot: false,
info: '5',
text: '模块二',
iconPath: 'https://img.yzcdn.cn/vant/user-inactive.png',
selectedIconPath: 'https://img.yzcdn.cn/vant/user-active.png',
},
{
isShowRedDot: false,
info: '5',
text: '模块三',
iconPath: 'https://img.yzcdn.cn/vant/user-inactive.png',
selectedIconPath: 'https://img.yzcdn.cn/vant/user-active.png',
}
],
},
/**
* 组件的方法列表
*/
methods: {
onChangeTabbar(event) {
var index = event.detail
this.setData({
selected: index
});
this.triggerEvent('onChangeTabbar', this.data.selected);
}
},
lifetimes: {
detached: function () {},
attached: function () {
this.setData({
tabbars: this.properties.list
})
}
},
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
"van-tabbar": "@vant/weapp/tabbar/index",
"van-tabbar-item": "@vant/weapp/tabbar-item/index",
"page1": "./tabs/one",
"page2": "./tabs/two"
}
}
\ No newline at end of file
<!-- 页面展示 -->
<view hidden="{{selected == 0? false: true}}">
<page1 />
</view>
<view hidden="{{selected == 1? false: true}}">
<page2 />
</view>
<!-- 自定义 tabbar -->
<view hidden="{{tabbars.length<=0}}">
<van-tabbar active-color="{{selectedColor}}" inactive-color="{{color}}" active="{{ selected }}"
bind:change="onChangeTabbar" placeholder="true">
<block wx:for="{{tabbars}}" wx:key="index">
<block wx:if="{{item.info.length}}">
<van-tabbar-item info='{{item.info}}'>
<image slot="icon" src="{{ item.iconPath }}" mode="aspectFit" style="width: 25px; height: 25px;" />
<image slot="icon-active" src="{{ item.selectedIconPath }}" mode="aspectFit"
style="width: 25px; height: 25px;" />
<!-- {{item.text}} -->
<view class="text">{{item.text}}</view>
</van-tabbar-item>
</block>
<block wx:elif="{{item.isShowRedDot}}">
<van-tabbar-item dot>
<image slot="icon" src="{{ item.iconPath }}" mode="aspectFit" style="width: 25px; height: 25px;" />
<image slot="icon-active" src="{{ item.selectedIconPath }}" mode="aspectFit"
style="width: 25px; height: 25px;" />
<!-- {{item.text}} -->
<view class="text">{{item.text}}</view>
</van-tabbar-item>
</block>
<block wx:else>
<van-tabbar-item style="color:red;">
<image slot="icon" src="{{ item.iconPath }}" mode="aspectFit" style="width: 25px; height: 25px;" />
<image slot="icon-active" src="{{ item.selectedIconPath }}" mode="aspectFit"
style="width: 25px; height: 25px;" />
<!-- {{item.text}} -->
<view class="text">{{item.text}}</view>
</van-tabbar-item>
</block>
</block>
</van-tabbar>
</view>
\ No newline at end of file
.text {
margin-top: -4px;
font-size: 24rpx;
}
\ No newline at end of file
// pages/tabs/one.js
var app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
},
lifetimes: {
detached: function () {},
attached: function () {
var userType = app.userType
console.log('组件1111111');
}
},
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--pages/tabs/one.wxml-->
<text>pages/tabs/one.wxml</text>
\ No newline at end of file
/* pages/tabs/one.wxss */
\ No newline at end of file
// pages/tabs/two.js
var app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
},
lifetimes: {
detached: function () {},
attached: function () {
console.log('组件22222222');
}
},
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--pages/tabs/two.wxml-->
<text>pages/tabs/two.wxml</text>
/* pages/tabs/two.wxss */
\ No newline at end of file
......@@ -96,7 +96,8 @@ Page({
},
aesTest() {
const aesString = "---content---"
// const aesString = "---content---"
const aesString = "123124"
console.log("加密前:" + aesString)
var aesBuffer = AES.Encrypt(aesString)
console.log("加密后:" + aesBuffer)
......
// miniprogram/pages/tabbar/index.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
tabbars: [{
isShowRedDot: true,
info: '',
text: '模块一',
iconPath: 'https://img.yzcdn.cn/vant/user-inactive.png',
selectedIconPath: 'https://img.yzcdn.cn/vant/user-active.png',
},
{
isShowRedDot: false,
info: '5',
text: '模块二',
iconPath: 'https://img.yzcdn.cn/vant/user-inactive.png',
selectedIconPath: 'https://img.yzcdn.cn/vant/user-active.png',
},
{
isShowRedDot: false,
info: '',
text: '模块三',
iconPath: 'https://img.yzcdn.cn/vant/user-inactive.png',
selectedIconPath: 'https://img.yzcdn.cn/vant/user-active.png',
}
],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// var userType = app.userType
// console.log(userType);
},
onChangeTabbar(event) {
var index = event.detail
this.setData({
currentTabBar: index
});
if (index == 0) {}
if (index == 1) {}
if (index == 2) {}
}
})
/*
"tabBar": {
"custom": true,
"color": "#cdcdcd",
"selectedColor": "#4252DD",
"list": [{
"text": "首页",
"pagePath": "pages/one/one",
"iconPath": "images/tab/tab1.png",
"selectedIconPath": "images/tab/tab1_select.png"
},
{
"text": "我的",
"pagePath": "pages/two/two",
"iconPath": "images/tab/tab2.png",
"selectedIconPath": "images/tab/tab2_select.png"
}
]
},
*/
\ No newline at end of file
{
"usingComponents": {
"custom-tabbar": "../../components/custom-tabbar/index"
}
}
\ No newline at end of file
<custom-tabbar list="{{tabbars}}" bind:onChangeTabbar="onChangeTabbar"></custom-tabbar>
\ No newline at end of file
//通用工具类
module.exports = {
getSafeRandomNum: getSafeRandomNum,
getRandomNum: getRandomNum,
}
// 创建 min-max 之间的随机整数
function getSafeRandomNum(min, max) {
var seed = (new Date()).getTime();
seed = (seed * 9301 + 49297) % 233280;
var rand = seed / (233280.0);
var range = max - min;
return Math.floor(rand * (range + 1) + min);
}
// 创建 min-max 之间的随机整数
function getRandomNum(min, max) {
var range = max - min;
var rand = Math.random();
return Math.floor(rand * (range + 1) + min);
}
/* 使用
var CommonUtils = require('../../utils/commonUtils')
CommonUtils.getRandomNum()
*/
\ No newline at end of file
var CryptoJS = CryptoJS || function(u, p) {
var CryptoJS = CryptoJS || function (u, p) {
var d = {},
l = d.lib = {},
s = function() {},
s = function () {},
t = l.Base = {
extend: function(a) {
extend: function (a) {
s.prototype = this;
var c = new s;
a && c.mixIn(a);
c.hasOwnProperty("init") || (c.init = function() {
c.hasOwnProperty("init") || (c.init = function () {
c.$super.init.apply(this, arguments)
});
c.init.prototype = c;
c.$super = this;
return c
},
create: function() {
create: function () {
var a = this.extend();
a.init.apply(a, arguments);
return a
},
init: function() {},
mixIn: function(a) {
init: function () {},
mixIn: function (a) {
for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
a.hasOwnProperty("toString") && (this.toString = a.toString)
},
clone: function() {
clone: function () {
return this.init.prototype.extend(this)
}
},
r = l.WordArray = t.extend({
init: function(a, c) {
init: function (a, c) {
a = this.words = a || [];
this.sigBytes = c != p ? c : 4 * a.length
},
toString: function(a) {
toString: function (a) {
return (a || v).stringify(this)
},
concat: function(a) {
concat: function (a) {
var c = this.words,
e = a.words,
j = this.sigBytes;
......@@ -50,26 +50,26 @@ var CryptoJS = CryptoJS || function(u, p) {
this.sigBytes += a;
return this
},
clamp: function() {
clamp: function () {
var a = this.words,
c = this.sigBytes;
a[c >>> 2] &= 4294967295 <<
32 - 8 * (c % 4);
a.length = u.ceil(c / 4)
},
clone: function() {
clone: function () {
var a = t.clone.call(this);
a.words = this.words.slice(0);
return a
},
random: function(a) {
random: function (a) {
for (var c = [], e = 0; e < a; e += 4) c.push(4294967296 * u.random() | 0);
return new r.init(c, a)
}
}),
w = d.enc = {},
v = w.Hex = {
stringify: function(a) {
stringify: function (a) {
var c = a.words;
a = a.sigBytes;
for (var e = [], j = 0; j < a; j++) {
......@@ -79,47 +79,47 @@ var CryptoJS = CryptoJS || function(u, p) {
}
return e.join("")
},
parse: function(a) {
parse: function (a) {
for (var c = a.length, e = [], j = 0; j < c; j += 2) e[j >>> 3] |= parseInt(a.substr(j,
2), 16) << 24 - 4 * (j % 8);
return new r.init(e, c / 2)
}
},
b = w.Latin1 = {
stringify: function(a) {
stringify: function (a) {
var c = a.words;
a = a.sigBytes;
for (var e = [], j = 0; j < a; j++) e.push(String.fromCharCode(c[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
return e.join("")
},
parse: function(a) {
parse: function (a) {
for (var c = a.length, e = [], j = 0; j < c; j++) e[j >>> 2] |= (a.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
return new r.init(e, c)
}
},
x = w.Utf8 = {
stringify: function(a) {
stringify: function (a) {
try {
return decodeURIComponent(escape(b.stringify(a)))
} catch (c) {
throw Error("Malformed UTF-8 data");
}
},
parse: function(a) {
parse: function (a) {
return b.parse(unescape(encodeURIComponent(a)))
}
},
q = l.BufferedBlockAlgorithm = t.extend({
reset: function() {
reset: function () {
this._data = new r.init;
this._nDataBytes = 0
},
_append: function(a) {
_append: function (a) {
"string" == typeof a && (a = x.parse(a));
this._data.concat(a);
this._nDataBytes += a.sigBytes
},
_process: function(a) {
_process: function (a) {
var c = this._data,
e = c.words,
j = c.sigBytes,
......@@ -135,7 +135,7 @@ var CryptoJS = CryptoJS || function(u, p) {
}
return new r.init(q, j)
},
clone: function() {
clone: function () {
var a = t.clone.call(this);
a._data = this._data.clone();
return a
......@@ -144,31 +144,31 @@ var CryptoJS = CryptoJS || function(u, p) {
});
l.Hasher = q.extend({
cfg: t.extend(),
init: function(a) {
init: function (a) {
this.cfg = this.cfg.extend(a);
this.reset()
},
reset: function() {
reset: function () {
q.reset.call(this);
this._doReset()
},
update: function(a) {
update: function (a) {
this._append(a);
this._process();
return this
},
finalize: function(a) {
finalize: function (a) {
a && this._append(a);
return this._doFinalize()
},
blockSize: 16,
_createHelper: function(a) {
return function(b, e) {
_createHelper: function (a) {
return function (b, e) {
return (new a.init(e)).finalize(b)
}
},
_createHmacHelper: function(a) {
return function(b, e) {
_createHmacHelper: function (a) {
return function (b, e) {
return (new n.HMAC.init(a,
e)).finalize(b)
}
......@@ -177,11 +177,11 @@ var CryptoJS = CryptoJS || function(u, p) {
var n = d.algo = {};
return d
}(Math);
(function() {
(function () {
var u = CryptoJS,
p = u.lib.WordArray;
u.enc.Base64 = {
stringify: function(d) {
stringify: function (d) {
var l = d.words,
p = d.sigBytes,
t = this._map;
......@@ -193,7 +193,7 @@ var CryptoJS = CryptoJS || function(u, p) {
for (; d.length % 4;) d.push(l);
return d.join("")
},
parse: function(d) {
parse: function (d) {
var l = d.length,
s = this._map,
t = s.charAt(64);
......@@ -211,7 +211,7 @@ var CryptoJS = CryptoJS || function(u, p) {
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
})();
(function(u) {
(function (u) {
function p(b, n, a, c, e, j, k) {
b = b + (n & a | ~n & c) + e + k;
return (b << j | b >>> 32 - j) + n
......@@ -233,10 +233,10 @@ var CryptoJS = CryptoJS || function(u, p) {
}
for (var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) b[x] = 4294967296 * u.abs(u.sin(x + 1)) | 0;
r = r.MD5 = v.extend({
_doReset: function() {
_doReset: function () {
this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878])
},
_doProcessBlock: function(q, n) {
_doProcessBlock: function (q, n) {
for (var a = 0; 16 > a; a++) {
var c = n + a,
e = q[c];
......@@ -334,7 +334,7 @@ var CryptoJS = CryptoJS || function(u, p) {
a[2] = a[2] + g | 0;
a[3] = a[3] + h | 0
},
_doFinalize: function() {
_doFinalize: function () {