123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <template>
- <view class="mobile-setting-page">
- <view class="setting-list-box">
- <view class="list-row no-jt-row img-list-row">
- <text>头像</text>
- <img class="head-img" :src="settingData.icon" v-if="settingData.icon">
- <icon class="phone-default-userImg setting-default-userImg" v-else></icon>
- </view>
- <view class="list-row no-jt-row">
- <text>用户名</text>
- <text class="row-content">{{settingData.userName}}</text>
- </view>
- <!-- <view class="list-row" @click="goToPage('realName')">
- <text>真实姓名</text>
- <text class="row-content">{{settingData.realName}}</text>
- </view>
- <view class="list-row" @click="goToPage('gender')">
- <text>性别</text>
- <text class="row-content" v-if="settingData.gender===0"></text>
- <text class="row-content" v-if="settingData.gender===1">男</text>
- <text class="row-content" v-if="settingData.gender===2">女</text>
- </view>
-
- <view class="list-row" @click="goToPage('shengri')">
- <text>生日</text>
- <text class="row-content">{{settingData.birthday}}</text>
- </view>
-
- <view class="list-row" @click="goToPage('tel')">
- <text>电话</text>
- <text class="row-content">{{settingData.tel}}</text>
- </view>
- <view class="list-row" @click="goToPage('xgmm')">
- <text>修改密码</text>
- <text class="row-content">{{settingData.xgmm}}</text>
- </view> -->
- <view class="list-row no-jt-row" @click="goToPage('qlhc')">
- <text>清理缓存</text>
- <text class="row-content"></text>
- </view>
- </view>
- <view @click="quitClick" class="exit-login-btn">退出登录</view>
- <real-name-dialog ref="realNameDialogRef" @confirm-btn="realNameBtn"></real-name-dialog>
- <tel-dialog ref="telDialogRef" @confirm-btn="telBtn"></tel-dialog>
- <password-dialog ref="passwordDialogRef" @confirm-btn="passwordBtn"></password-dialog>
- <birthday-dialog ref="birthdayDialogRef" @confirm-btn="birthdayBtn"></birthday-dialog>
- <gender-dialog ref="genderDialogRef" @confirm-btn="genderBtn"></gender-dialog>
- </view>
- </template>
- <script setup>
- import {reactive,ref} from "vue";
- import {logout} from '@/api/login.js'
- import {toast} from "@/utils/common";
- import {onLoad} from '@dcloudio/uni-app';
- import {getUserInfo,getUserUpRealName,getUserUpTel,getUserUpPassword,getUserUpBirthday,getUserUpGender} from '@/api/my.js'
- import {useUserCache} from "@/utils/userCache.js"
- import cacheManager from '@/utils/cacheManager.js';
- import realNameDialog from './components/realNameDialog.vue';
- import telDialog from './components/telDialog.vue';
- import passwordDialog from './components/passwordDialog.vue';
- import birthdayDialog from './components/birthdayDialog.vue';
- import genderDialog from './components/genderDialog.vue';
- let settingData = reactive({
- icon: '',
- userName: '',
- realName: '',
- gender:'',
- birthday: '',
- tel:'',
- });
-
- onLoad(() => {
- getSettingInit()
- })
-
- function getSettingInit(){
- getUserInfo({}).then(res => {
- settingData.icon = res.data.icon;
- settingData.userName = res.data.userName;
- settingData.realName = res.data.realName;
- settingData.gender = res.data.gender;
- settingData.birthday = res.data.birthday;
- settingData.tel = res.data.tel;
- })
- }
-
- /***** 跳转 *****/
- function goToPage(data){
- switch (data) {
- case 'realName':
- realNameDialogRef.value.handleShow();
- break;
- case 'gender':
- genderDialogRef.value.handleShow();
- break;
- case 'shengri':
- birthdayDialogRef.value.handleShow();
- break;
- case 'tel':
- telDialogRef.value.handleShow();
- break;
- case 'xgmm':
- passwordDialogRef.value.handleShow();
- break;
- case 'qlhc':
- clearLocation()
- break;
- }
- }
-
-
- function clearLocation(){
- // 清理考试缓存
- useUserCache().removeCache('kaoshiCache');
- }
-
- function quitClick(){
- uni.showModal({
- title: '提示',
- content: '你确定要执行这个操作吗?',
- success: (res) => {
- if (res.confirm) {
- // 确定
- quit()
- } else if (res.cancel) {
- // 取消
- }
- }
- });
-
- }
-
- function quit (){
- logout().then(res=>{
- toast('退出登录成功')
- uni.navigateTo({
- url: '/pages/login'
- });
- cacheManager.clearAll();
-
- }).catch(err => {
- toast('退出登录失败,请稍后重试')
- })
-
- }
- /***** 真实姓名 *****/
- const realNameDialogRef = ref(null);
- function realNameBtn(data){
- console.log(data,'data');
- settingData.realName = data;
- const opt = {
- realName: settingData.realName,
- }
- getUserUpRealName(opt).then(res => {
- if (res.data) {
- uni.showToast({
- title: '更新成功'
- })
- realNameDialogRef.value.handleClose();
- }
- })
- }
-
- /***** 电话 *****/
- const telDialogRef = ref(null);
- function telBtn(data){
- console.log(data,'data');
- settingData.tel = data;
- const opt = {
- tel: settingData.tel,
- }
- getUserUpTel(opt).then(res => {
- if (res.data) {
- uni.showToast({
- title: '更新成功'
- })
- telDialogRef.value.handleClose();
- }
- })
- }
-
- /***** 修改日期 *****/
- const birthdayDialogRef = ref(null);
- function birthdayBtn(data){
- settingData.birthday = data;
- const opt = {
- brithday: settingData.birthday,
- }
- getUserUpBirthday(opt).then(res => {
- if (res.data) {
- uni.showToast({
- title: '更新成功'
- })
- birthdayDialogRef.value.handleClose();
- }
- })
- }
-
- /***** 修改性别 *****/
- const genderDialogRef = ref(null);
- function genderBtn(data){
- settingData.gender = data;
- const opt = {
- gender: data,
- }
- getUserUpGender(opt).then(res => {
- if (res.data) {
- uni.showToast({
- title: '更新成功'
- })
- birthdayDialogRef.value.handleClose();
- }
- })
- }
-
- /***** 修改密码 *****/
- const passwordDialogRef = ref(null);
- function passwordBtn(data){
- const opt = {
- passwordOld: data.oldPassWord,
- passwordNew: data.newPassWord,
- }
- getUserUpdatePassword(opt).then(res => {
- if (res.data) {
- uni.showToast({
- title: '更新成功'
- })
- passwordDialogRef.value.handleClose();
- }
- })
- }
- </script>
- <style>
- </style>
|