liiistem-miniapp/pages/sharelist/sharelist.js
2025-09-16 13:41:49 +08:00

77 lines
No EOL
1.8 KiB
JavaScript

import R from '../../utils/request';
import C from '../../utils/constant';
import * as F from '../../utils/func';
Page({
data: {
cdnHost: C.cdnHost,
list: [],
page: 1,
status: '',
// money_flag: 'send',
listEndText: '',
},
onLoad(options) {
this.fetchList(1);
},
goDel(e) {
const {detail,index} =e.currentTarget.dataset;
if(detail.deleted == 1) return;
const {id}=detail;
wx.showModal({
title: '提示',
content: '置为失效后无法恢复,确认继续吗?',
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
R.post('/index.php/api/v1/del_share',{id}).then(()=>{
const {list} = this.data;
this.setData({
[`list[${index}]`] : {
...list[index],
deleted:1,
},
});
})
}
}
})
},
fetchList(page) {
const { status } = this.data;
// money_flag
R.get('/index.php/api/v1/share_link_list', { page }).then(({ model }) => {
const list = [];
model.forEach(item => {
list.push({
...item,
price: F.formatePrice(item.price),
expire_time: item.expire_time.split(' ')[0],
});
});
if (list.length == 0) {
this.setData({ listEndText: '没有更多了' });
} else {
this.setData({ listEndText: '点击加载更多。。。' });
}
if (page == 1) {
this.setData({ list,page });
} else {
const list2 = this.data.list.concat(list);
this.setData({ list: list2 ,page});
}
});
},
loadMore() {
const { page, listEndText } = this.data;
if (listEndText == '点击加载更多。。。') {
this.fetchList(page + 1);
}
},
onReachBottom() {
this.loadMore();
},
})