jufubao-base 1.0.61-beta5 → 1.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+ import {mapState,mapMutations} from "vuex";
3
+
4
+ export default {
5
+ data() {
6
+ return {
7
+ ajaxCardList: null, //接口返回原始数据
8
+
9
+ //卡券列表
10
+ cardOrgList:[], //原始数据
11
+ cardList:null, //计算后的卡列表
12
+ cardPageNum: 0, //当前页面
13
+ cardPageLen: 5, //每页获取数据调试
14
+ cardComputedList:[], //当前获取的数据列表
15
+ cardLoading: false, //加载状态值设置
16
+ cardNextTop: 0, //计算到每一个节点的距离顶部Top值
17
+ contentStatus: false, //内容框是否已经进行过计算距离顶部Top值状态
18
+ hasContent: true, //是否可以进行继续加载状态
19
+
20
+ //转换按钮
21
+ hasChangeStatus: false,//是否有转换按钮
22
+
23
+ cardItemEntry: '//img.jufubao.cn/component/card/card_item_entry.png?v1=11',
24
+ cardItem: '//img.jufubao.cn/component/card/card_item.png?v1=11'
25
+ }
26
+ },
27
+ computed:{
28
+ ...mapState(['srollPreview'])
29
+ },
30
+
31
+ created() {
32
+ this.setSrollPreview({
33
+ pageWindowPrevStart: 0,
34
+ pageWindowPrevEnd: uni.getSystemInfoSync().safeArea.height,
35
+ });
36
+ },
37
+
38
+ methods:{
39
+ ...mapMutations(['setSrollPreview']),
40
+ setCardItemShow({height , top},index){
41
+ //预览模式只获取10条
42
+ if(this.$configProject.isPreview) {
43
+ console.log(this.cardPageLen, index, this.cardPageLen > index)
44
+ return this.cardPageLen > index;
45
+ }
46
+
47
+ //打包模式
48
+ let fiexd = 50;
49
+ let boxTop = top + height + fiexd;
50
+ let boxBottom = top - (fiexd);
51
+ let {pageWindowPrevStart, pageWindowPrevEnd} = this.srollPreview;
52
+ return boxTop > pageWindowPrevStart && boxBottom < pageWindowPrevEnd;
53
+ },
54
+
55
+ getBoxTop(){
56
+ return new Promise((resolve, reject)=>{
57
+ const query = uni.createSelectorQuery().in(this);
58
+ query.select('.card-content').boundingClientRect(data=>{
59
+ this.cardNextTop = data.top;
60
+ this.contentStatus = true;
61
+ resolve();
62
+ }).exec()
63
+ })
64
+
65
+ },
66
+
67
+ async handleCardComputed(paddingBottom=30){
68
+ this.$xdShowLoading({});
69
+ if(this.contentStatus === false) await this.getBoxTop();
70
+ this.$nextTick(()=>{
71
+ const query = uni.createSelectorQuery().in(this);
72
+ query.selectAll('.computed-box').boundingClientRect(data => {
73
+ let arr = data.map(item=>{
74
+ let card = this.cardComputedList.filter(it=>{
75
+ return item.dataset.card === it.card_number;
76
+ })[0];
77
+ card['height'] = item.height;
78
+ card['top'] = this.cardNextTop;
79
+ this.cardNextTop = this.cardNextTop + card['height'] + (paddingBottom * this.$rpxNum)
80
+ return card
81
+ });
82
+ this.cardList = (this.cardList||[]).concat(arr);
83
+ this.$xdHideLoading();
84
+ }).exec();
85
+ })
86
+ },
87
+
88
+ handleCardInit(cardList, paddingBottom =30){
89
+ let newCardList = this.$xdUniHelper.cloneDeep(cardList);
90
+ let validCardList = this.getCardGroupItem(newCardList.list.filter((item) => {
91
+ return item["is_valid"] === "N";
92
+ }), newCardList['site_entry_settings'],'Y').map((item,index)=>{
93
+ item['index'] = index;
94
+ return item
95
+ });
96
+ this.cardOrgList = this.$xdUniHelper.cloneDeep(validCardList);
97
+ this.cardComputedList = this.cardOrgList.slice(
98
+ this.cardPageNum*this.cardPageLen,
99
+ this.cardPageNum*this.cardPageLen + this.cardPageLen
100
+ );
101
+ this.handleCardComputed(paddingBottom).then().catch();
102
+ },
103
+
104
+ onJfbReachBottom(){
105
+ if(this.cardLoading || !this.hasContent) return;
106
+ this.cardLoading = true;
107
+ this.$xdShowLoading({});
108
+ this.cardPageNum++;
109
+ this.$nextTick(()=>{
110
+ setTimeout(()=>{
111
+ this.cardLoading = false;
112
+ this.$xdHideLoading();
113
+ this.cardComputedList = this.cardOrgList.slice(
114
+ this.cardPageNum*this.cardPageLen,
115
+ this.cardPageNum*this.cardPageLen + this.cardPageLen
116
+ );
117
+ this.handleCardComputed().then().catch();
118
+ if(this.cardComputedList.length < this.cardPageLen) {
119
+ this.hasContent = false;
120
+ }
121
+ },500)
122
+ })
123
+
124
+ },
125
+
126
+ onJfbScroll({e}){
127
+ this.setSrollPreview({
128
+ pageWindowPrevStart: e.scrollTop,
129
+ pageWindowPrevEnd:e.scrollTop + uni.getSystemInfoSync().safeArea.height
130
+ })
131
+ },
132
+
133
+ }
134
+ }
135
+
136
+