jiuyiUniapp/jiuyi2/pages/mine/setting/teen.vue

104 lines
2.2 KiB
Vue
Raw Normal View History

2024-12-29 19:06:34 +08:00
<script setup>
// 工具库
import util from '@/common/js/util.js'
//
import api from '@/api/index.js'
import {
useStore
} from 'vuex'
import {
ref,
computed,
getCurrentInstance,
2024-12-29 19:06:34 +08:00
} from 'vue';
// 密码
import payPwd from '@/components/mine/payPwd.vue'
//
const {
proxy
} = getCurrentInstance();
2024-12-29 19:06:34 +08:00
// vuex
const store = useStore()
// 用户信息
2025-02-04 13:45:10 +08:00
const userinfo = computed(() => store.state.userinfo)
2024-12-29 19:06:34 +08:00
// 开启青少年模式
function handleUpdate() {
2025-01-07 14:56:03 +08:00
api.mine.adolescentOpen({}).then(rs => {
2024-12-29 19:06:34 +08:00
if (rs.code == 200) {
2025-01-07 14:56:03 +08:00
// 更新用户信息
util.getUserinfo()
2024-12-29 19:06:34 +08:00
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
// 关闭青少年模式
function handleClose(userPassword) {
// 解除青少年模式
api.mine.adolescentClose({
path: [userPassword],
}).then(rs => {
if (rs.code == 200) {
util.alert('青少年模式已关闭')
store.commit('setState', {
key: 'userinfo',
value: {
...userinfo.value,
teenTime: null,
}
})
// 更新用户信息
util.getUserinfo()
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
2024-12-29 19:06:34 +08:00
</script>
<template>
<view class="app">
<view class="container pr">
<image class="background" src="/static/teen.png" mode="widthFix" />
<!-- <view class="">青少年模式说明</view> -->
<view class="notice pa c333 f28">
<view class="mtb30">开启青少年模式后将自动为您开启时间锁单日使用时间不超过40分钟晚上10点至早上6点无法使用九亿</view>
<view class="mtb30">青少年模式开启后如果到了使用时间需要输入密码解锁关闭青少年模式</view>
</view>
</view>
<view class="btn pro black mtb30 mlr60" v-if="userinfo.teenTime" @click="$refs.payPwdRef.open()">关闭青少年模式</view>
2024-12-29 19:06:34 +08:00
<view class="btn pro black mtb30 mlr60" v-else @click="handleUpdate">开启青少年模式</view>
<view class="fill" style="height: 30rpx;"></view>
<!-- 支付弹窗 -->
<payPwd ref="payPwdRef" @confirm="handleClose" />
2024-12-29 19:06:34 +08:00
</view>
</template>
<style lang="scss">
.app {
background-color: #eaceb9;
}
//
.background {
width: 100%;
}
// 提示
.notice {
margin: 0 120rpx;
bottom: 120rpx;
}
</style>