1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

91 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Component({
externalClasses: ['wr-class', 'header-class', 'title-class'],
options: {
multipleSlots: true,
},
relations: {
'../order-goods-card/index': {
type: 'descendant',
linked(target) {
this.children.push(target);
this.setHidden();
},
unlinked(target) {
this.children = this.children.filter((item) => item !== target);
},
},
'../goods-card/index': {
type: 'descendant',
linked(target) {
this.children.push(target);
this.setHidden();
},
unlinked(target) {
this.children = this.children.filter((item) => item !== target);
},
},
'../specs-goods-card/index': {
type: 'descendant',
linked(target) {
this.children.push(target);
this.setHidden();
},
unlinked(target) {
this.children = this.children.filter((item) => item !== target);
},
},
},
created() {
this.children = [];
},
properties: {
order: {
type: Object,
observer(order) {
if (!order?.goodsList) return;
const goodsCount = order.goodsList.length;
this.setData({
goodsCount,
});
},
},
useTopRightSlot: Boolean,
// 初始显示的商品数量,超出部分会隐藏。
defaultShowNum: {
type: null,
value: 10,
},
useLogoSlot: {
type: Boolean,
value: false,
},
},
data: {
showAll: true, // 是否展示所有商品设置为false可以使用展开更多功能
goodsCount: 0,
},
methods: {
setHidden() {
const isHidden = !this.data.showAll;
this.children.forEach(
(c, i) => i >= this.properties.defaultShowNum && c.setHidden(isHidden),
);
},
onOrderCardTap() {
this.triggerEvent('cardtap');
},
onShowMoreTap() {
this.setData({ showAll: true }, () => this.setHidden());
this.triggerEvent('showall');
},
},
});