123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- <template>
- <layout-page>
- <view class="box defaultBgc">
- <scroll-view class="scrollBox" scroll-y="true">
- <view class="content">
- <!-- 钱包 -->
- <view class="wallet">
- <view class="wallet-content">
- <view class="wallet-content-member">
- <view class="iconBox">
- <view class="iconBox-line">
- <uni-icons type="vip-filled" size="20" color="#ffbc00"></uni-icons>
- </view>
- </view>
- <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 class="title">积分</text>
- </view>
- <view class="wallet-content-cash wallet-content-item" @tap="handleTo('balance')">
- <text>{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
- <text class="title">余额</text>
- </view>
- </view>
- </view>
- <!-- 签到 -->
- <!-- <view class="signIn">
- <view class="signIn-content">
- <view class="signIn-content-items">
- <view class="item" v-for="(sign, i) in SignItems" :key="sign.day">
- <view class="box" :class="{ active: i < continuousDay }">
- <uni-icons type="vip" size="30" color="#ffbc00" style="text-align: center;"></uni-icons>
- <text class="text">+{{ sign.point }}</text>
- </view>
- <view class="day">
- <text>{{ i === todayNumber ? '今' : '第' + sign.day }}天</text>
- </view>
- </view>
- </view>
- <view class="tips">
- <button
- :disabled="todaySignIn"
- :class="{ disabled: todaySignIn }"
- @tap="handleSignIn"
- >
- {{ todaySignIn ? '已签到' : '签到'}}
- </button>
- </view>
- </view>
- </view> -->
- <!-- 积分规则、积分兑换 -->
- <view class="ss-m-t-20">
- <uni-section title="积分规则" type="line" style="background-color: #fff;">
- <uni-list>
- <uni-list-item v-for="(k, i) in integralRules" :key="i" :showArrow="false">
- <template v-slot:header>
- <text class="ss-m-t-10">{{ k.title }}</text>
- </template>
- <template v-slot:footer>
- <view class="d-flex align-center" style="width: 130px; text-align: start; position: relative;">
- <image src="/static/svg/integral.svg" style="width: 30px; height: 30px;"></image>
- <view class="color-primary ss-m-l-10">{{ k.point }}</view>
- <uni-tag :inverted="true" :text="k.complete ? '已完成' : '未完成'" :type="k.complete ? 'success' : 'error'" style="position: absolute; right: 0;" />
- </view>
- </template>
- </uni-list-item>
- </uni-list>
- </uni-section>
- <view class="ss-m-t-20">
- <uni-section title="积分兑换" type="line" style="background-color: #fff;">
- <view class="goods" >
- <view class="goods-item" v-for="(item,index) in goodsList" :key="index" @tap.stop="handleClickGoods">
- <image :src="item.url" class="goods-item-img" mode="widthFix"></image>
- <view class="goods-item-name">{{ item.name }}</view>
- <view>消耗积分<text class="goods-item-price">{{ item.point }}</text></view>
- </view>
- </view>
- </uni-section>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </layout-page>
- </template>
- <script setup>
- import { ref, watch } from 'vue'
- import layoutPage from '@/layout'
- import {
- // getRewardSignInConfigList,
- // getRewardSignInRecordSummary,
- // createRewardSignInRecord,
- getAccountBalance,
- getUserAccount,
- } from '@/api/sign'
- import { getTaskList } from '@/api/integral'
- import { onShow } from '@dcloudio/uni-app'
- import { userStore } from '@/store/user'
- import { showAuthModal } from '@/hooks/useModal'
- const useUserStore = userStore()
- // 设置自定义tabBar选中值
- // const SignItems = ref([])
- // 积分规则
- const integralRules = ref([])
- const getTask = async () => {
- const { data } = await getTaskList({ mark: '推荐任务', type: 0 })
- integralRules.value = data
- }
- // 商品列表
- const goodsList = [
- { name: '房券-高端酒店房券', point: 12000, url: 'https://minio.menduner.com/dev/menduner/hotalRoomVoucher.png' },
- { name: '门墩儿酒店英语学习年卡', point: 8000, url: 'https://minio.menduner.com/dev/menduner/englishCourses.jpg' },
- { name: '红酒-经典年份葡萄酒', point: 5000, url: 'https://minio.menduner.com/dev/menduner/redWine.png' },
- { name: '瑞幸咖啡券-瑞幸咖啡精致享受券', point: 2000, url: 'https://minio.menduner.com/dev/menduner/coffee.png' },
- { name: '减压捏捏乐', point: 500, url: 'https://minio.menduner.com/dev/menduner/pinchMusic.png' }
- ]
- const handleClickGoods = () => {
- uni.showToast({
- icon: 'none',
- title: '请前往网页版门墩儿商城兑换'
- })
- }
- // 连续签到天数
- // const continuousDay = ref(0)
- // 今天有无签到
- // const todaySignIn = ref(false)
- // 今天
- // const todayNumber = ref()
- const balance = ref({})
- watch([() => useUserStore.refreshToken, () => useUserStore.isLogin], () => {
- if (useUserStore.isLogin) {
- // getSummary()
- getBalance()
- }
- })
- onShow(() => {
- const currentPage = getCurrentPages()[0]; // 获取当前页面实例
- const currentTabBar = currentPage?.getTabBar?.();
- // 设置当前tab页的下标index
- currentTabBar?.setData({ selected: 2 });
- init()
- })
- function init () {
- // 获取签到列表
- // getSignIn()
- // 获取签到信息
- // getSummary()
- // 获取余额积分
- getBalance()
- // 获取积分规则列表
- getTask()
- }
- // 获取积分余额
- async function getBalance() {
- const { data } = await getAccountBalance()
- const { data: _data } = await getUserAccount()
- balance.value = {
- ...data,
- point: _data.point
- }
- }
- // 获取个人签到统计
- // async function getSummary() {
- // const { data } = await getRewardSignInRecordSummary()
- // if (!data) return
- // continuousDay.value = data.continuousDay // 连续签到第n天
- // todaySignIn.value = data.todaySignIn // 今天有无签到
- // todayNumber.value = todaySignIn.value ? continuousDay.value - 1 : continuousDay.value
- // }
- // 获取签到列表
- // async function getSignIn () {
- // try {
- // const { data } = await getRewardSignInConfigList()
- // SignItems.value = data
- // } catch (error) {
-
- // }
- // }
- // 签到
- // async function handleSignIn () {
- // uni.showLoading({
- // title: '正在签到'
- // })
- // try {
- // const { code } = await createRewardSignInRecord()
- // if (code !== 0) {
- // return
- // }
- // setTimeout(async () => {
- // const { code: _code } = await getSummary()
- // if (_code !== 0) {
- // return
- // }
- // uni.showToast({
- // title: '签到成功',
- // icon: 'success',
- // mask: true
- // })
- // // 更新积分
- // getBalance()
- // }, 1000)
- // } catch (error) {
-
- // } finally {
- // uni.hideLoading()
- // }
- // }
- function handleLogin () {
- if (!useUserStore.isLogin) {
- showAuthModal()
- return
- }
- }
- function toInfo () {
- uni.navigateTo({
- url: '/pagesA/info/index'
- })
- }
- function handleTo (page) {
- if (!useUserStore.isLogin) {
- showAuthModal()
- return
- }
- uni.navigateTo({
- url: `/pagesA/${page}/index`
- })
- }
- </script>
- <style scoped lang="scss">
- .box {
- overflow: hidden;
- height: 100vh;
- padding: 20rpx 0 0 0;
- box-sizing: border-box;
- .scrollBox{
- height: 100%;
-
- padding-bottom: 120rpx;
- box-sizing: border-box;
- }
- .content {
- padding-bottom: 24rpx;
- box-sizing: border-box;
- }
- .wallet {
- box-sizing: border-box;
- height: 200rpx;
- margin-bottom: 20rpx;
- &-content {
- display: flex;
- height: 100%;
- border-radius: 10rpx;
- background: #FFF;
-
- &-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: 100rpx;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- &-line {
- border: 4rpx solid #ffbc00;
- border-radius: 180rpx;
- padding: 10rpx;
- }
- }
- .name {
- flex: 1;
- .actvie {
- color: #ffbc00;
- }
-
- }
- }
- &-item {
- width: 25%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .title {
- font-size: .85em;
- }
- }
- &-integral {
- }
- &-cash {
-
- }
- }
- }
- .signIn {
- // padding: 0 20rpx;
- box-sizing: border-box;
- &-content {
- border-radius: 10rpx;
- background: #FFF;
- &-items {
- padding: 20rpx 20rpx;
- display: flex;
- height: 220rpx;
- box-sizing: border-box;
- .item {
- height: 140rpx;
- width: 100%;
- align-items: center;
- justify-content: center;
- padding: 0 10rpx;
- .box {
- height: 100%;
- width: 100%;
- display: flex;
- flex-direction: column;
- background: #f2f4f7;
- border-radius: 10rpx;
- &.active {
- color: #fff;
- background: rgba(16,137,123, .66);
- }
- .text {
- font-size: .75em;
- text-align: center;
- }
- }
- .day {
- margin-top: 10rpx;
- height: 60rpx;
- text-align: center;
- font-size: .5em;
- }
- }
- }
- .tips {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- height: 80rpx;
- font-size: .75em;
- color: #999;
- &-light {
- color: #00897B;
- padding: 0 10rpx;
- }
- button {
- width: 180rpx;
- height: 60rpx;
- font-size: 24rpx;
- margin: 0 10rpx;
- border: unset;
- background-color: #00897B;
- color: #FFF;
- &.disabled {
- // background-color: #a7a7a7 !important;
- opacity: .5;
- }
- }
- }
-
- }
- }
- .goods {
- padding: 0 15upx;
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- &-item {
- background: #FFFFFF;
- width: 48%;
- margin: 10upx 0;
- box-sizing: border-box;
- &-img {
- width: 100%;
- height: 250upx;
- display: block;
- margin: auto;
- }
- &-price {
- padding-top: 10upx;
- color: #00897B;
- font-size: 32upx;
- }
- &-name {
- width: 100%;
- white-space: nowrap;
- font-size: 28upx;
- line-height: 50upx;
- padding-bottom: 10upx;
- padding-top: 10upx;
- overflow:hidden;
- text-overflow:ellipsis;
- -webkit-box-orient:vertical;
- -webkit-line-clamp:2;
- }
- }
- }
- }
- :deep(.uni-section .uni-section-header__decoration) {
- background-color: #00897B !important;
- }
- </style>
|