|
@@ -114,8 +114,6 @@ const todaySignIn = ref(false)
|
|
|
|
|
|
// 今天
|
|
|
const todayNumber = ref()
|
|
|
-// 加载
|
|
|
-const signLoading = ref(false)
|
|
|
|
|
|
const balance = ref({})
|
|
|
|
|
@@ -129,16 +127,21 @@ const more = ref('more')
|
|
|
|
|
|
const myCoupon = ref(0)
|
|
|
|
|
|
-watch(() => useUserStore.isLogin, () => {
|
|
|
+// watch(() => useUserStore.isLogin, () => {
|
|
|
+// if (useUserStore.isLogin) {
|
|
|
+// init()
|
|
|
+// }
|
|
|
+// })
|
|
|
+
|
|
|
+watch([() => useUserStore.refreshToken, () => useUserStore.isLogin], () => {
|
|
|
if (useUserStore.isLogin) {
|
|
|
- init()
|
|
|
+ getMyCoupon()
|
|
|
+ initCoupon()
|
|
|
+ getSummary()
|
|
|
+ getBalance()
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-watch(() => useUserStore.refreshToken, () => {
|
|
|
- init()
|
|
|
-})
|
|
|
-
|
|
|
onShow(() => {
|
|
|
const currentPage = getCurrentPages()[0]; // 获取当前页面实例
|
|
|
const currentTabBar = currentPage?.getTabBar?.();
|
|
@@ -154,10 +157,9 @@ function init () {
|
|
|
getSummary()
|
|
|
// 获取余额积分
|
|
|
getBalance()
|
|
|
- pageInfo.value.pageNo = 1
|
|
|
- items.value = []
|
|
|
- // 获取模板
|
|
|
- getAllCouponPage()
|
|
|
+ // 获取优惠券列表
|
|
|
+ initCoupon()
|
|
|
+ // 获取我的优惠券总数
|
|
|
getMyCoupon()
|
|
|
|
|
|
}
|
|
@@ -192,15 +194,19 @@ async function getSignIn () {
|
|
|
}
|
|
|
// 签到
|
|
|
async function handleSignIn () {
|
|
|
- if (signLoading.value) {
|
|
|
- return
|
|
|
- }
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在签到'
|
|
|
+ })
|
|
|
try {
|
|
|
- signLoading.value = true
|
|
|
- await createRewardSignInRecord()
|
|
|
+ const { code } = await createRewardSignInRecord()
|
|
|
+ if (code !== 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
setTimeout(async () => {
|
|
|
- await getSummary()
|
|
|
-
|
|
|
+ const { code: _code } = await getSummary()
|
|
|
+ if (_code !== 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
uni.showToast({
|
|
|
title: '签到成功',
|
|
|
icon: 'success',
|
|
@@ -212,7 +218,7 @@ async function handleSignIn () {
|
|
|
} catch (error) {
|
|
|
|
|
|
} finally {
|
|
|
- signLoading.value = false
|
|
|
+ uni.hideLoading()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -221,7 +227,7 @@ async function handleSignIn () {
|
|
|
async function getAllCouponPage () {
|
|
|
try {
|
|
|
const { data } = await getCouponTemplatePage({ ...pageInfo.value })
|
|
|
- console.log(data)
|
|
|
+ // console.log(data)
|
|
|
if (!data || !data.list || !data.list.length) {
|
|
|
if (pageInfo.value.pageNo === 1) {
|
|
|
more.value = 'more'
|
|
@@ -252,42 +258,42 @@ async function getMyCoupon () {
|
|
|
}
|
|
|
|
|
|
// 优惠券列表
|
|
|
-async function handleGetTmpUsed () {
|
|
|
- try {
|
|
|
- const { data } = await getDiyTemplateUsed()
|
|
|
- if (!data?.home?.components) {
|
|
|
- uni.showToast({
|
|
|
- title: '暂无优惠券',
|
|
|
- icon: 'none',
|
|
|
- mask: true
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- const idsItem = data.home.components.find(e => e.id === 'CouponCard')
|
|
|
- if (!idsItem) {
|
|
|
- uni.showToast({
|
|
|
- title: '暂无优惠券',
|
|
|
- icon: 'none',
|
|
|
- mask: true
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- const ids = idsItem?.property?.couponIds
|
|
|
- if (!ids) {
|
|
|
- uni.showToast({
|
|
|
- title: '暂无优惠券',
|
|
|
- icon: 'none',
|
|
|
- mask: true
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- const { data: _data } = await getDiyTemplate(ids.join(','))
|
|
|
- items.value = _data
|
|
|
- more.value = 'noMore'
|
|
|
- } catch (error) {
|
|
|
+// async function handleGetTmpUsed () {
|
|
|
+// try {
|
|
|
+// const { data } = await getDiyTemplateUsed()
|
|
|
+// if (!data?.home?.components) {
|
|
|
+// uni.showToast({
|
|
|
+// title: '暂无优惠券',
|
|
|
+// icon: 'none',
|
|
|
+// mask: true
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// const idsItem = data.home.components.find(e => e.id === 'CouponCard')
|
|
|
+// if (!idsItem) {
|
|
|
+// uni.showToast({
|
|
|
+// title: '暂无优惠券',
|
|
|
+// icon: 'none',
|
|
|
+// mask: true
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// const ids = idsItem?.property?.couponIds
|
|
|
+// if (!ids) {
|
|
|
+// uni.showToast({
|
|
|
+// title: '暂无优惠券',
|
|
|
+// icon: 'none',
|
|
|
+// mask: true
|
|
|
+// })
|
|
|
+// return
|
|
|
+// }
|
|
|
+// const { data: _data } = await getDiyTemplate(ids.join(','))
|
|
|
+// items.value = _data
|
|
|
+// more.value = 'noMore'
|
|
|
+// } catch (error) {
|
|
|
|
|
|
- }
|
|
|
-}
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
async function loadingMore () {
|
|
|
if (more.value === 'noMore') {
|
|
@@ -298,6 +304,12 @@ async function loadingMore () {
|
|
|
getAllCouponPage()
|
|
|
}
|
|
|
|
|
|
+function initCoupon () {
|
|
|
+ pageInfo.value.pageNo = 1
|
|
|
+ items.value = []
|
|
|
+ getAllCouponPage()
|
|
|
+}
|
|
|
+
|
|
|
function handleLogin () {
|
|
|
if (!useUserStore.isLogin) {
|
|
|
showAuthModal()
|
|
@@ -335,9 +347,7 @@ async function onGetCoupon(id, canTake) {
|
|
|
icon: 'success'
|
|
|
})
|
|
|
getMyCoupon()
|
|
|
- pageInfo.value.pageNo = 1
|
|
|
- items.value = []
|
|
|
- await getAllCouponPage()
|
|
|
+ initCoupon()
|
|
|
} catch (error) {
|
|
|
|
|
|
} finally {
|
|
@@ -346,6 +356,10 @@ async function onGetCoupon(id, canTake) {
|
|
|
}
|
|
|
|
|
|
function handleTo (page) {
|
|
|
+ if (!useUserStore.isLogin) {
|
|
|
+ showAuthModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
uni.navigateTo({
|
|
|
url: `/pagesA/${page}/index`
|
|
|
})
|