|
@@ -9,17 +9,27 @@
|
|
|
<view class="wallet-content-member">
|
|
|
<view class="iconBox">
|
|
|
<view class="iconBox-line">
|
|
|
- <uni-icons type="vip-filled" size="40" color="#ffbc00"></uni-icons>
|
|
|
+ <uni-icons type="vip-filled" size="20" color="#ffbc00"></uni-icons>
|
|
|
</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
- <view class="wallet-content-integral wallet-content-item">
|
|
|
+ <view class="name">
|
|
|
+ <text v-if="useUserStore.isLogin" @tap="toInfo" class="active">
|
|
|
+ {{ useUserStore?.baseInfo?.name || useUserStore?.userInfo?.phone }}
|
|
|
+ </text>
|
|
|
+ <text v-else @tap="handleLogin">点击登录</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="wallet-content-integral wallet-content-item" @tap="handleTo('integral')">
|
|
|
<text>{{ balance.point || 0 }}</text>
|
|
|
- <text>积分</text>
|
|
|
+ <text class="title">积分</text>
|
|
|
</view>
|
|
|
- <view class="wallet-content-cash wallet-content-item">
|
|
|
+ <view class="wallet-content-cash wallet-content-item" @tap="handleTo('balance')">
|
|
|
<text>{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
|
|
|
- <text>余额</text>
|
|
|
+ <text class="title">余额</text>
|
|
|
+ </view>
|
|
|
+ <view class="wallet-content-coupon wallet-content-item" @tap="handleTo('coupon')">
|
|
|
+ <text>{{ myCoupon }}</text>
|
|
|
+ <text class="title">优惠券</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -54,6 +64,8 @@
|
|
|
v-for="item in items"
|
|
|
:key="item.id"
|
|
|
class="item"
|
|
|
+ :class="{ disabled: !item.canTake }"
|
|
|
+ @tap="onGetCoupon(item.id, item.canTake)"
|
|
|
>
|
|
|
<view class="img">
|
|
|
<image
|
|
@@ -72,7 +84,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref } from 'vue'
|
|
|
+import { ref, watch } from 'vue'
|
|
|
import layoutPage from '@/layout'
|
|
|
import {
|
|
|
getRewardSignInConfigList,
|
|
@@ -81,11 +93,17 @@ import {
|
|
|
getAccountBalance,
|
|
|
getUserAccount,
|
|
|
getDiyTemplateUsed,
|
|
|
- getDiyTemplate
|
|
|
+ getDiyTemplate,
|
|
|
+ getCouponTemplatePage,
|
|
|
+ takeCoupon,
|
|
|
+ getCouponPage
|
|
|
} from '@/api/sign'
|
|
|
import { onShow, onLoad } from '@dcloudio/uni-app'
|
|
|
-// 设置自定义tabBar选中值
|
|
|
+import { userStore } from '@/store/user'
|
|
|
+import { showAuthModal } from '@/hooks/useModal'
|
|
|
|
|
|
+const useUserStore = userStore()
|
|
|
+// 设置自定义tabBar选中值
|
|
|
|
|
|
const SignItems = ref([])
|
|
|
|
|
@@ -101,25 +119,48 @@ const signLoading = ref(false)
|
|
|
|
|
|
const balance = ref({})
|
|
|
|
|
|
+const pageInfo = ref({
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 20
|
|
|
+})
|
|
|
+const total = ref(0)
|
|
|
const items = ref([])
|
|
|
-const more = ref('noMore')
|
|
|
+const more = ref('more')
|
|
|
+
|
|
|
+const myCoupon = ref(0)
|
|
|
+
|
|
|
+watch(() => useUserStore.isLogin, () => {
|
|
|
+ if (useUserStore.isLogin) {
|
|
|
+ init()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+watch(() => useUserStore.refreshToken, () => {
|
|
|
+ init()
|
|
|
+})
|
|
|
|
|
|
onShow(() => {
|
|
|
const currentPage = getCurrentPages()[0]; // 获取当前页面实例
|
|
|
const currentTabBar = currentPage?.getTabBar?.();
|
|
|
// 设置当前tab页的下标index
|
|
|
currentTabBar?.setData({ selected: 2 });
|
|
|
+ init()
|
|
|
})
|
|
|
-onLoad(() => {
|
|
|
+
|
|
|
+function init () {
|
|
|
// 获取签到列表
|
|
|
getSignIn()
|
|
|
// 获取签到信息
|
|
|
getSummary()
|
|
|
// 获取余额积分
|
|
|
getBalance()
|
|
|
+ pageInfo.value.pageNo = 1
|
|
|
+ items.value = []
|
|
|
// 获取模板
|
|
|
- handleGetTmpUsed()
|
|
|
-})
|
|
|
+ getAllCouponPage()
|
|
|
+ getMyCoupon()
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
// 获取积分余额
|
|
|
async function getBalance() {
|
|
@@ -176,6 +217,41 @@ async function handleSignIn () {
|
|
|
}
|
|
|
|
|
|
|
|
|
+// 获取优惠券分页
|
|
|
+async function getAllCouponPage () {
|
|
|
+ try {
|
|
|
+ const { data } = await getCouponTemplatePage({ ...pageInfo.value })
|
|
|
+ console.log(data)
|
|
|
+ if (!data || !data.list || !data.list.length) {
|
|
|
+ if (pageInfo.value.pageNo === 1) {
|
|
|
+ more.value = 'more'
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pageInfo.value.pageNo--
|
|
|
+ more.value = 'more'
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items.value.push(...data.list)
|
|
|
+ total.value = +data.total
|
|
|
+ more.value = total.value === items.value.length ? 'noMore' : 'more'
|
|
|
+ } catch (error) {
|
|
|
+ if (pageInfo.value.pageNo === 1) {
|
|
|
+ more.value = 'more'
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pageInfo.value.pageNo--
|
|
|
+ more.value = 'more'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function getMyCoupon () {
|
|
|
+ const { data } = await getCouponPage({ pageNo:1, pageSize: 1, status: 1 })
|
|
|
+ if (data) {
|
|
|
+ myCoupon.value = +data.total
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 优惠券列表
|
|
|
async function handleGetTmpUsed () {
|
|
|
try {
|
|
|
const { data } = await getDiyTemplateUsed()
|
|
@@ -206,15 +282,70 @@ async function handleGetTmpUsed () {
|
|
|
return
|
|
|
}
|
|
|
const { data: _data } = await getDiyTemplate(ids.join(','))
|
|
|
- items.value.push(..._data)
|
|
|
+ items.value = _data
|
|
|
more.value = 'noMore'
|
|
|
} catch (error) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function loadingMore () {}
|
|
|
+async function loadingMore () {
|
|
|
+ pageInfo.value.pageNo++
|
|
|
+ getAllCouponPage()
|
|
|
+}
|
|
|
+
|
|
|
+function handleLogin () {
|
|
|
+ if (!useUserStore.isLogin) {
|
|
|
+ showAuthModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function toInfo () {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pagesA/info/index'
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+async function onGetCoupon(id, canTake) {
|
|
|
+ if (!canTake) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.showLoading({
|
|
|
+ title: '领取中'
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ code,
|
|
|
+ msg
|
|
|
+ } = await takeCoupon(id)
|
|
|
+ if (code !== 0) {
|
|
|
+ uni.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.showToast({
|
|
|
+ title: '领取成功',
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
+ getMyCoupon()
|
|
|
+ pageInfo.value.pageNo = 1
|
|
|
+ items.value = []
|
|
|
+ await getAllCouponPage()
|
|
|
+ } catch (error) {
|
|
|
+
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+function handleTo (page) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pagesA/${page}/index`
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
@@ -248,25 +379,47 @@ $px: 20rpx;
|
|
|
|
|
|
&-member {
|
|
|
width: 50%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ position: relative;
|
|
|
+ &:after {
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ width: 4rpx;
|
|
|
+ height: 30%;
|
|
|
+ right: 0;
|
|
|
+ top: 35%;
|
|
|
+ background: #00897B;
|
|
|
+ }
|
|
|
.iconBox {
|
|
|
- width: 100%;
|
|
|
+ width: 100rpx;
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
&-line {
|
|
|
- border: 10rpx solid #ffbc00;
|
|
|
+ border: 4rpx solid #ffbc00;
|
|
|
border-radius: 180rpx;
|
|
|
padding: 10rpx;
|
|
|
}
|
|
|
}
|
|
|
+ .name {
|
|
|
+ flex: 1;
|
|
|
+ .actvie {
|
|
|
+ color: #ffbc00;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
&-item {
|
|
|
- width: 25%;
|
|
|
+ width: 16.6%;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
+ .title {
|
|
|
+ font-size: .85em;
|
|
|
+ }
|
|
|
}
|
|
|
&-integral {
|
|
|
}
|
|
@@ -352,6 +505,21 @@ $px: 20rpx;
|
|
|
background: #FFF;
|
|
|
padding: $px;
|
|
|
font-size: .85em;
|
|
|
+ &.disabled {
|
|
|
+ position: relative;
|
|
|
+ &::after {
|
|
|
+ content: '已领取';
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background: rgba(255,255,255,.75);
|
|
|
+ }
|
|
|
+ }
|
|
|
.img {
|
|
|
image {
|
|
|
width: 128rpx;
|
|
@@ -359,7 +527,6 @@ $px: 20rpx;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
</style>
|