Commit 103a881b authored by yiruiwen's avatar yiruiwen

Merge branch 'yiruiwen'

parents b2bf9e0a e3c5744e
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
desc: 'Collection of many commonly used pages and layouts, reducing the repetitive work of developers, allowing you to focus on logic and get twice the result with half the effort' desc: 'Collection of many commonly used pages and layouts, reducing the repetitive work of developers, allowing you to focus on logic and get twice the result with half the effort'
}, },
nav: { nav: {
components: 'Comonents', components: 'Components',
js: 'JS', js: 'JS',
template: 'Template' template: 'Template'
}, },
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<u-avatar <u-avatar
:mode="mode" :mode="mode"
:size="size" :size="size"
:src="''" :src="src"
:text="text" :text="text"
:showLevel="showLevel" :showLevel="showLevel"
:showSex="showSex" :showSex="showSex"
......
...@@ -402,7 +402,7 @@ export default { ...@@ -402,7 +402,7 @@ export default {
} }
}, },
labelPositionChange(index) { labelPositionChange(index) {
this.labelPosition = index == 0 ? 'left' : 'right'; this.labelPosition = index == 0 ? 'left' : 'top';
}, },
codeChange(text) { codeChange(text) {
this.codeTips = text; this.codeTips = text;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<view class="u-demo-area"> <view class="u-demo-area">
<u-toast ref="uToast"></u-toast> <u-toast ref="uToast"></u-toast>
<u-tabs v-if="control" bg-color="#fafafa" :bold="bold" :active-color="activeColor" :list="list" <u-tabs v-if="control" bg-color="#fafafa" :bold="bold" :active-color="activeColor" :list="list"
@change="change" :current="current" :is-scroll="isScroll"></u-tabs> @change="change" :current="current" :is-scroll="isScroll" :offset="offset"></u-tabs>
</view> </view>
</view> </view>
<view class="u-config-wrap"> <view class="u-config-wrap">
...@@ -38,9 +38,11 @@ ...@@ -38,9 +38,11 @@
return { return {
list: [], list: [],
data: [{ data: [{
name: '关注' name: '关注',
count: 100
}, { }, {
name: '推荐' name: '推荐',
count: 7
}, { }, {
name: '电影' name: '电影'
},{ },{
...@@ -62,7 +64,8 @@ ...@@ -62,7 +64,8 @@
tabCountIndex: 0, tabCountIndex: 0,
activeColor: this.$u.color['primary'], activeColor: this.$u.color['primary'],
bold: true, bold: true,
control: true control: true,
offset: [5, -5]
} }
}, },
onLoad() { onLoad() {
...@@ -75,17 +78,20 @@ ...@@ -75,17 +78,20 @@
this.list = []; this.list = [];
this.list.push(this.data[0]); this.list.push(this.data[0]);
this.list.push(this.data[1]); this.list.push(this.data[1]);
this.offset = [5, 60]
} else if(index == 1) { } else if(index == 1) {
this.list = []; this.list = [];
this.list.push(this.data[0]); this.list.push(this.data[0]);
this.list.push(this.data[1]); this.list.push(this.data[1]);
this.list.push(this.data[2]); this.list.push(this.data[2]);
this.offset = [5, 20]
} else { } else {
this.list = []; this.list = [];
this.list.push(this.data[0]); this.list.push(this.data[0]);
this.list.push(this.data[1]); this.list.push(this.data[1]);
this.list.push(this.data[2]); this.list.push(this.data[2]);
this.list.push(this.data[3]); this.list.push(this.data[3]);
this.offset = [5, 5]
} }
this.tabCountIndex = index; this.tabCountIndex = index;
this.isScroll = false; this.isScroll = false;
...@@ -99,6 +105,7 @@ ...@@ -99,6 +105,7 @@
if(index == 0) { if(index == 0) {
this.isScroll = true; this.isScroll = true;
this.list = this.data; this.list = this.data;
this.offset = [5, -5]
} else { } else {
this.isScroll = false; this.isScroll = false;
this.countChange(this.tabCountIndex); this.countChange(this.tabCountIndex);
......
<template> <template>
<view class="wrap"> <view></view>
<u-waterfall v-model="flowList" ref="uWaterfall">
<template v-slot:left="{ leftList }">
<view class="demo-warter" v-for="(item, index) in leftList" :key="index">
<view class="" @tap="click1(item)">
<!-- 警告:微信小程序不支持嵌入lazyload组件,请自行如下使用image标签 -->
<!-- #ifndef MP-WEIXIN -->
<u-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="demo-img-wrap"><image class="demo-image" :src="item.image" mode="widthFix"></image></view>
<!-- #endif -->
<view class="demo-title">{{ item.title }}</view>
<view class="demo-price">{{ item.price }}</view>
<view class="demo-tag">
<view class="demo-tag-owner">自营</view>
<view class="demo-tag-text">放心购</view>
</view>
<view class="demo-shop">{{ item.shop }}</view>
<!-- 微信小程序无效,因为它不支持在template中引入组件 -->
<view class="u-close">
<u-icon name="close-circle-fill" color="#fa3534" size="34" @click="remove(item.id)"></u-icon>
</view>
</view>
</view>
</template>
<template v-slot:right="{ rightList }">
<view class="demo-warter" v-for="(item, index) in rightList" :key="index">
<!-- #ifndef MP-WEIXIN -->
<u-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="demo-img-wrap"><image class="demo-image" :src="item.image" mode="widthFix"></image></view>
<!-- #endif -->
<view class="demo-title">{{ item.title }}</view>
<view class="demo-price">{{ item.price }}</view>
<view class="demo-tag">
<view class="demo-tag-owner">自营</view>
<view class="demo-tag-text">放心购</view>
</view>
<view class="demo-shop">{{ item.shop }}</view>
<!-- 微信小程序无效,因为它不支持在template中引入组件 -->
<view class="u-close">
<u-icon name="close-circle-fill" color="#fa3534" size="34" @click="remove(item.id)"></u-icon>
</view>
</view>
</template>
</u-waterfall>
<u-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></u-loadmore>
</view>
</template> </template>
\ No newline at end of file
<script>
export default {
data() {
return {
loadStatus: 'loadmore',
flowList: [],
list: [
{
price: 35,
title: '北国风光,千里冰封,万里雪飘',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23327_s.jpg'
},
{
price: 75,
title: '望长城内外,惟余莽莽',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic.sc.chinaz.com/Files/pic/pic9/202002/zzpic23325_s.jpg'
},
{
price: 385,
title: '大河上下,顿失滔滔',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg'
},
{
price: 784,
title: '欲与天公试比高',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/zzpic23369_s.jpg'
},
{
price: 7891,
title: '须晴日,看红装素裹,分外妖娆',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2130_s.jpg'
},
{
price: 2341,
shop: '李白杜甫白居易旗舰店',
title: '江山如此多娇,引无数英雄竞折腰',
image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23346_s.jpg'
},
{
price: 661,
shop: '李白杜甫白居易旗舰店',
title: '惜秦皇汉武,略输文采',
image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23344_s.jpg'
},
{
price: 1654,
title: '唐宗宋祖,稍逊风骚',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg'
},
{
price: 1678,
title: '一代天骄,成吉思汗',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg'
},
{
price: 924,
title: '只识弯弓射大雕',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg'
},
{
price: 8243,
title: '俱往矣,数风流人物,还看今朝',
shop: '李白杜甫白居易旗舰店',
image: 'http://pic1.sc.chinaz.com/Files/pic/pic9/202002/zzpic23343_s.jpg'
}
]
};
},
onLoad() {
this.addRandomData();
},
onReachBottom() {
this.loadStatus = 'loading';
// 模拟数据加载
setTimeout(() => {
this.addRandomData();
this.loadStatus = 'loadmore';
}, 1000);
},
methods: {
addRandomData() {
for (let i = 0; i < 10; i++) {
let index = this.$u.random(0, this.list.length - 1);
// 先转成字符串再转成对象,避免数组对象引用导致数据混乱
let item = JSON.parse(JSON.stringify(this.list[index]));
item.id = this.$u.guid();
this.flowList.push(item);
}
},
remove(id) {
this.$refs.uWaterfall.remove(id);
},
clear() {
this.$refs.uWaterfall.clear();
},
click1(item){
console.log(item);
}
}
};
</script>
<style>
/* page不能写带scope的style标签中,否则无效 */
page {
background-color: rgb(240, 240, 240);
}
</style>
<style lang="scss" scoped>
.demo-warter {
border-radius: 8px;
margin: 5px;
background-color: #ffffff;
padding: 8px;
position: relative;
}
.u-close {
position: absolute;
top: 32rpx;
right: 32rpx;
}
.demo-img-wrap {
}
.demo-image {
width: 100%;
border-radius: 4px;
}
.demo-title {
font-size: 30rpx;
margin-top: 5px;
color: $u-main-color;
}
.demo-tag {
display: flex;
margin-top: 5px;
}
.demo-tag-owner {
background-color: $u-type-error;
color: #ffffff;
display: flex;
align-items: center;
padding: 4rpx 14rpx;
border-radius: 50rpx;
font-size: 20rpx;
line-height: 1;
}
.demo-tag-text {
border: 1px solid $u-type-primary;
color: $u-type-primary;
margin-left: 10px;
border-radius: 50rpx;
line-height: 1;
padding: 4rpx 14rpx;
display: flex;
align-items: center;
border-radius: 50rpx;
font-size: 20rpx;
}
.demo-price {
font-size: 30rpx;
color: $u-type-error;
margin-top: 5px;
}
.demo-shop {
font-size: 22rpx;
color: $u-tips-color;
margin-top: 5px;
}
</style>
...@@ -278,7 +278,8 @@ export default { ...@@ -278,7 +278,8 @@ export default {
name: '待收货' name: '待收货'
}, },
{ {
name: '待评价' name: '待评价',
count: 12
} }
], ],
current: 0, current: 0,
......
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
// 用户可能会在头像加载失败时,再次修改头像值,所以需要重新赋值 // 用户可能会在头像加载失败时,再次修改头像值,所以需要重新赋值
if(!n) { if(!n) {
// 如果传入null或者'',或者undefined,显示默认头像 // 如果传入null或者'',或者undefined,显示默认头像
this.avatar = base64Avatar;
this.error = true; this.error = true;
} else { } else {
this.avatar = n; this.avatar = n;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
color: value == item.value ? activeColor : inactiveColor color: value == item.value ? activeColor : inactiveColor
}"> }">
<u-icon v-if="value == item.value" name="checkbox-mark" :color="activeColor" size="32"></u-icon> <u-icon v-if="value == item.value" name="checkbox-mark" :color="activeColor" size="32"></u-icon>
</u-cell-item> </u-cell-item>
</u-cell-group> </u-cell-group>
</view> </view>
</scroll-view> </scroll-view>
......
...@@ -162,14 +162,18 @@ export default { ...@@ -162,14 +162,18 @@ export default {
}; };
}, },
watch: { watch: {
src(n) { src: {
immediate: true,
handler (n) {
if(!n) { if(!n) {
// 如果传入null或者'',或者false,或者undefined,标记为错误状态 // 如果传入null或者'',或者false,或者undefined,标记为错误状态
this.isError = true; this.isError = true;
this.loading = false;
} else { } else {
this.isError = false; this.isError = false;
} }
} }
}
}, },
computed: { computed: {
wrapStyle() { wrapStyle() {
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
export default { export default {
name: "u-loadmore", name: "u-loadmore",
props: { props: {
//当前页面背景颜色,如果背景为非白色的时候,需要把此值设置为背景的颜 // 组件背景
bgColor: { bgColor: {
type: String, type: String,
default: 'transparent' default: 'transparent'
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
width: width + 'rpx', width: width + 'rpx',
height: width + 'rpx', height: width + 'rpx',
color: inactiveColor, color: inactiveColor,
borderColor: charArrLength === index && mode == 'box' ? activeColor : 'none' borderColor: charArrLength === index && mode == 'box' ? activeColor : inactiveColor
}"> }">
<view class="u-placeholder-line" :style="{ <view class="u-placeholder-line" :style="{
display: charArrLength === index ? 'block' : 'none', display: charArrLength === index ? 'block' : 'none',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class=""> <view class="">
<view class="u-content" :class="[elId]" :style="{ <view class="u-content" :class="[elId]" :style="{
height: isLongContent && !showMore ? showHeight + 'rpx' : 'auto', height: isLongContent && !showMore ? showHeight + 'rpx' : 'auto',
textIndent: this.textIndent textIndent: textIndent
}"> }">
<slot></slot> <slot></slot>
</view> </view>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<view class="u-tabs-scroll-box" :class="{'u-tabs-scorll-flex': !isScroll}"> <view class="u-tabs-scroll-box" :class="{'u-tabs-scorll-flex': !isScroll}">
<view class="u-tabs-item" :style="[tabItemStyle(index)]" <view class="u-tabs-item" :style="[tabItemStyle(index)]"
v-for="(item, index) in getTabs" :key="index" :class="[preId + index]" @tap="emit(index)"> v-for="(item, index) in getTabs" :key="index" :class="[preId + index]" @tap="emit(index)">
<u-badge :count="item[count] || item['count'] || 0" :offset="offset" size="mini"></u-badge>
{{ item[name] || item['name']}} {{ item[name] || item['name']}}
</view> </view>
<view v-if="showBar" class="u-scroll-bar" :style="[tabBarStyle]"></view> <view v-if="showBar" class="u-scroll-bar" :style="[tabBarStyle]"></view>
...@@ -18,9 +19,7 @@ ...@@ -18,9 +19,7 @@
<script> <script>
import colorGradient from '../../libs/function/colorGradient'; import colorGradient from '../../libs/function/colorGradient';
let color = colorGradient; let color = colorGradient;
const { const { windowWidth } = uni.getSystemInfoSync();
windowWidth
} = uni.getSystemInfoSync();
const preId = 'UEl_'; const preId = 'UEl_';
/** /**
...@@ -43,6 +42,8 @@ ...@@ -43,6 +42,8 @@
* @property {String Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40) * @property {String Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40)
* @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff) * @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff)
* @property {String} name 组件内部读取的list参数中的属性名,见官网说明(默认name) * @property {String} name 组件内部读取的list参数中的属性名,见官网说明(默认name)
* @property {String} count 组件内部读取的list参数中的属性名(badge徽标数),同name属性的使用,见官网说明(默认count)
* @property {Array} offset 设置badge徽标数的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx(默认[5, 20])
* @property {Boolean} bold 激活选项的字体是否加粗(默认true) * @property {Boolean} bold 激活选项的字体是否加粗(默认true)
* @event {Function} change 点击标签时触发 * @event {Function} change 点击标签时触发
* @example <u-tabs-swiper ref="tabs" :list="list" :is-scroll="false"></u-tabs-swiper> * @example <u-tabs-swiper ref="tabs" :list="list" :is-scroll="false"></u-tabs-swiper>
...@@ -127,11 +128,23 @@ ...@@ -127,11 +128,23 @@
type: String, type: String,
default: 'window' default: 'window'
}, },
// 读取传入的数组对象的属性 // 读取传入的数组对象的属性(tab名称)
name: { name: {
type: String, type: String,
default: 'name' default: 'name'
}, },
// 读取传入的数组对象的属性(徽标数)
count: {
type: String,
default: 'count'
},
// 徽标数位置偏移
offset: {
type: Array,
default: () => {
return [5, 20]
}
},
// 活动tab字体是否加粗 // 活动tab字体是否加粗
bold: { bold: {
type: Boolean, type: Boolean,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<view class="u-scroll-box" :class="{'u-tabs-scorll-flex': !isScroll}"> <view class="u-scroll-box" :class="{'u-tabs-scorll-flex': !isScroll}">
<view class="u-tab-item u-line-1" :id="'u-tab-item-' + index" v-for="(item, index) in list" :key="index" @tap="clickTab(index)" <view class="u-tab-item u-line-1" :id="'u-tab-item-' + index" v-for="(item, index) in list" :key="index" @tap="clickTab(index)"
:style="[tabItemStyle(index)]"> :style="[tabItemStyle(index)]">
<u-badge :count="item[count] || item['count'] || 0" :offset="offset" size="mini"></u-badge>
{{ item[name] || item['name']}} {{ item[name] || item['name']}}
</view> </view>
<view v-if="showBar" class="u-tab-bar" :style="[tabBarStyle]"></view> <view v-if="showBar" class="u-tab-bar" :style="[tabBarStyle]"></view>
...@@ -38,7 +39,9 @@ ...@@ -38,7 +39,9 @@
* @property {String Number} item-width 标签的宽度(默认auto) * @property {String Number} item-width 标签的宽度(默认auto)
* @property {String Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40) * @property {String Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40)
* @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff) * @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff)
* @property {String} name 组件内部读取的list参数中的属性名,见官网说明(默认name) * @property {String} name 组件内部读取的list参数中的属性名(tab名称),见官网说明(默认name)
* @property {String} count 组件内部读取的list参数中的属性名(badge徽标数),同name属性的使用,见官网说明(默认count)
* @property {Array} offset 设置badge徽标数的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx(默认[5, 20])
* @property {Boolean} bold 激活选项的字体是否加粗(默认true) * @property {Boolean} bold 激活选项的字体是否加粗(默认true)
* @event {Function} change 点击标签时触发 * @event {Function} change 点击标签时触发
* @example <u-tabs ref="tabs" :list="list" :is-scroll="false"></u-tabs> * @example <u-tabs ref="tabs" :list="list" :is-scroll="false"></u-tabs>
...@@ -108,11 +111,23 @@ ...@@ -108,11 +111,23 @@
type: String, type: String,
default: '#ffffff' default: '#ffffff'
}, },
// 读取传入的数组对象的属性 // 读取传入的数组对象的属性(tab名称)
name: { name: {
type: String, type: String,
default: 'name' default: 'name'
}, },
// 读取传入的数组对象的属性(徽标数)
count: {
type: String,
default: 'count'
},
// 徽标数位置偏移
offset: {
type: Array,
default: () => {
return [5, 20]
}
},
// 活动tab字体是否加粗 // 活动tab字体是否加粗
bold: { bold: {
type: Boolean, type: Boolean,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment