diff --git a/src/api/index.js b/src/api/index.js index 209f49a..9e7a1a4 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -4,8 +4,10 @@ export const GetBetOptList = async (type) => await alovaInst.Get(`/dice/shake?type=${type}`); export const GetUserInfo = async (uid) => await alovaInst.Get(`/dice/userShakeInfo?uid=${uid}`); -export const GetBetRecord = async (uid) => - await alovaInst.Get(`/dice/userShakeRecord?uid=${uid}`); +export const GetBetRecord = async (data) => + await alovaInst.Get( + `/dice/userShakeRecord?uid=${data.uid}&PageNum=${data.PageNum}&PageSize=${data.PageSize}` + ); export const GetLotteryRecord = async (uid) => await alovaInst.Get(`/dice/draw?uid=${uid}`); export const GetPeriod = async () => await alovaInst.Get(`/dice/periods`); diff --git a/src/pages/bet_record/index.vue b/src/pages/bet_record/index.vue index 9e7c181..2a62fd7 100644 --- a/src/pages/bet_record/index.vue +++ b/src/pages/bet_record/index.vue @@ -90,6 +90,12 @@ const uid = ref(""); // ]); const data = ref([]); +const page = ref({ + page: 1, + size: 10, + total: 0, +}); + Taro.useLoad((opt) => { uid.value = opt.uid; }); @@ -98,8 +104,27 @@ Taro.useDidShow(() => { getList(); }); +Taro.useReachBottom(async () => { + if (page.value.page * page.value.size >= page.value.total) { + Taro.showToast({ + title: "没有更多了", + icon: "none", + }); + return; + } + page.value.page++; + await getList(); +}); + const getList = async () => { - const res = await GetBetRecord(uid.value); + Taro.showLoading({ + title: "加载中", + }); + const res = await GetBetRecord({ + uid: uid.value, + PageNum: page.value.page, + PageSize: page.value.size, + }); // console.log(res); data.value = res.data.map((item) => ({ type: 1, @@ -111,6 +136,8 @@ const getList = async () => { state: item.State, periods_num: item.PeriodsNum, })); + page.value.total = res.data.total || 0; + Taro.hideLoading(); };