1 line
9.3 KiB
Plaintext
1 line
9.3 KiB
Plaintext
{"version":3,"file":"index.js","sources":["../../../../../src/pages/settings/index.vue","../../../../../uniPage:/cGFnZXMvc2V0dGluZ3MvaW5kZXgudnVl"],"sourcesContent":["<route lang=\"json5\" type=\"page\">\n{\n layout: 'default',\n style: {\n navigationBarTitleText: '设置',\n },\n}\n</route>\n<template>\n <view class=\"setting-root h-full p-5\">\n <!-- 用户头像 如果不存在头像就访问占位符,函数imgUrl默认为占位符 -->\n <view class=\"flex items-center justify-center mb-6 pos-relative\">\n <wd-img\n v-if=\"sinfo.userAvatar != undefined\"\n :width=\"100\"\n :height=\"100\"\n round\n mode=\"aspectFill\"\n :src=\"sinfo.userAvatar ? imgUrl(sinfo.userAvatar) : imgUrl('')\"\n ></wd-img>\n <view\n @click=\"updateAvatar\"\n class=\"text-white pos-absolute bottom-[-10px] right-[33%] bg-[#ff7f50] rounded p-[2px]\"\n >\n 修改\n </view>\n </view>\n\n <!-- 国际化设置 -->\n <view class=\"card mb-4 p-4 bg-white rounded-lg shadow\">\n <view class=\"text-gray-800 text-lg mb-2\">国际化设置</view>\n <wd-picker\n :columns=\"languageOptions\"\n label=\"选择语言\"\n v-model=\"selectedLanguage\"\n @confirm=\"handleLanguageChange\"\n />\n </view>\n\n <!-- 账户设置 -->\n <view class=\"card mb-4 p-4 bg-white rounded-lg shadow\">\n <view class=\"wd-cell\" @click=\"showUserNamePopup = true\">\n <text class=\"text-gray-800\">账户名称</text>\n <text class=\"text-gray-400 ml-auto\">{{ sinfo.userName }}</text>\n <wd-icon name=\"right\" size=\"16\" class=\"ml-2\"></wd-icon>\n </view>\n <view class=\"wd-cell\" @click=\"goToBindPhone\">\n <text class=\"text-gray-800\">手机号绑定</text>\n <text class=\"text-gray-400 ml-auto\">{{ sinfo.phone }}</text>\n <wd-icon name=\"right\" size=\"16\" class=\"ml-2\"></wd-icon>\n </view>\n <view class=\"wd-cell\" @click=\"!sinfo.isAuth ? goToRealNameAuth() : toast('你已经实名了')\">\n <text class=\"text-gray-800\">实名认证</text>\n <text v-if=\"sinfo.isAuth\" class=\"text-gray-400 ml-auto\">已实名</text>\n <text v-else class=\"text-gray-400 ml-auto\">未实名</text>\n <wd-icon name=\"right\" size=\"16\" class=\"ml-2\"></wd-icon>\n </view>\n </view>\n\n <!-- 修改用户名的弹窗 -->\n <wd-popup v-model=\"showUserNamePopup\" position=\"center\" custom-style=\"padding: 20px;\">\n <view class=\"flex flex-col gap-3\">\n <view class=\"text-gray-800 mb-4\">修改用户名</view>\n <input v-model=\"newUserName\" type=\"text\" placeholder=\"请输入新的用户名\" />\n <view class=\"btn-group mt-4\">\n <button class=\"confirm-btn\" @click=\"updateUserName\">确认</button>\n <button class=\"cancel-btn\" @click=\"showUserNamePopup = false\">取消</button>\n </view>\n </view>\n </wd-popup>\n\n <!-- 退出登录按钮 -->\n <view class=\"card mb-4 p-4 bg-white rounded-lg shadow\">\n <button class=\"logout-button\" @click=\"logout\">退出登录</button>\n </view>\n </view>\n\n <LoadingAnimation v-model=\"loading\" />\n</template>\n\n<script setup lang=\"js\">\nimport { ref, computed } from 'vue'\nimport { useConfigStore } from '@/store/config'\nimport { useUserStore } from '@/store'\nimport { httpPost, httpGet } from '@/utils/http'\nimport LoadingAnimation from '@/components/LoadingAnimation.vue'\nimport { imgUrl, toast } from '@/utils/commUtils'\nimport { chooseImage } from '@/service/fileservice'\nimport { getUserInfo } from '@/service/userService'\n\nconst configStore = useConfigStore()\nconst userStore = useUserStore()\n\nconst languages = configStore.languages\nconst selectedLanguage = ref(languages['zh-Hans'])\n\nconst sinfo = ref({})\nconst showUserNamePopup = ref(false)\nconst newUserName = ref('')\n\nconst loading = ref(false)\n\nconst languageOptions = computed(() =>\n Object.entries(languages).map(([key, value]) => ({\n value: key,\n label: value,\n })),\n)\n\nconst handleLanguageChange = ({ value }) => {\n configStore.changeLanguage(selectedLanguage.value)\n}\n\nconst goToRealNameAuth = () => {\n uni.navigateTo({\n url: '/pages/permission/real-name-auth',\n })\n}\n\nconst goToBindPhone = () => {\n uni.navigateTo({\n url: '/pages/permission/bind-phone',\n })\n}\n\n// 获取页面信息\nconst getSettingInfo = async () => {\n const settingInfo = await httpGet('/setting/info')\n try {\n if (settingInfo.code === 200) {\n sinfo.value = settingInfo.data\n } else {\n toast(settingInfo.message)\n }\n } catch (e) {\n console.log(e)\n }\n}\n\n// 修改用户名的请求\nconst updateUserName = async () => {\n if (!newUserName.value) {\n toast('用户名不能为空')\n return\n }\n const response = await httpPost('/setting/updateUserName', {}, { userName: newUserName.value })\n if (response.code === 200) {\n sinfo.value.userName = newUserName.value\n toast('用户名修改成功')\n showUserNamePopup.value = false\n // 更新设置页面信息\n await getSettingInfo()\n // 更新用户信息\n await getUserInfo()\n } else {\n toast(response.message)\n }\n}\n\n// 更新用户头像\nconst updateAvatar = async () => {\n // 选择并上传图片,返回上传后的path\n try {\n const path = await chooseImage()\n if (!path || path == '') {\n toast('图片上传失败,请检查你的网络情况!')\n return\n }\n const res = await httpPost('/setting/updateUserAvatar', {}, { userAvatar: path })\n if (res.code == 200 && res.data) {\n toast('头像更新成功')\n // 更新设置页面信息\n await getSettingInfo()\n // 更新用户信息\n await getUserInfo()\n }\n } catch (e) {\n console.log(e)\n toast('头像更新失败')\n }\n}\n\nconst logout = async () => {\n const logRes = await httpGet('/user/logout')\n if (logRes.code == 200) {\n uni.showToast({ title: '退出成功', icon: 'none' })\n } else {\n uni.showToast({ title: logRes.msg, icon: 'none' })\n }\n userStore.clearUserInfo()\n uni.reLaunch({\n url: '/pages/login/index',\n })\n}\n\nonLoad(async () => {\n loading.value = true\n await getSettingInfo()\n loading.value = false\n})\n</script>\n\n<style lang=\"scss\" scoped>\n.setting-root {\n @apply bg-[#F5F5F5] h-full p-5;\n height: 100vh;\n}\n\n.card {\n @apply mb-4 p-4 bg-white rounded-lg shadow;\n}\n\n.wd-cell {\n @apply flex items-center py-4 px-5 border-b border-gray-200;\n}\n\n.wd-cell:last-child {\n @apply border-b-0;\n}\n\n.text-gray-800 {\n @apply text-gray-800;\n}\n\n.text-gray-400 {\n @apply text-gray-400;\n}\n\n.logout-button {\n @apply w-full py-3 bg-red-500 text-white text-lg rounded;\n}\n\n.btn-group {\n display: flex;\n justify-content: space-between;\n}\n\n.confirm-btn {\n background-color: #4caf50;\n color: white;\n border: none;\n border-radius: 4px;\n}\n\n.cancel-btn {\n background-color: #f44336;\n color: white;\n border: none;\n border-radius: 4px;\n}\n</style>\n","import MiniProgramPage from 'D:/App/Work/addr/acdr-ui/src/pages/settings/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["useConfigStore","useUserStore","ref","computed","uni","httpGet","toast","httpPost","getUserInfo","chooseImage","onLoad"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOQ,MAAA,mBAAA,MAAA;;;;AAAA,UAAA,cAAAA,aAAAA,eAAA;AAAA,UAAA,YAAAC,WAAAA,aAAA;AAAA,UAAA,YAAA,YAAA;AAAA,UAAA,mBAAAC,cAAA,IAAA,UAAA,SAAA,CAAA;AAAA,UAAA,QAAAA,cAAA,IAAA,EAAA;AAAA,UAAA,oBAAAA,cAAA,IAAA,KAAA;AAAA,UAAA,cAAAA,cAAA,IAAA,EAAA;AAAA,UAAA,UAAAA,cAAA,IAAA,KAAA;AAAA,UAAA,kBAAAC,cAAAA;AAAAA,MAAA,MAAA,OAAA,QAAA,SAAA,EAAA,IAAA,CAAA,CAAA,KAAA,KAAA,OAAA;AAAA,QAAA,OAAA;AAAA,QAAA,OAAA;AAAA,MAAA,EAAA;AAAA,IAAA;AAAA,UAAA,uBAAA,CAAA,EAAA,YAAA;AAAA,kBAAA,eAAA,iBAAA,KAAA;AAAA,IAAA;AAAA,UAAA,mBAAA,MAAA;AAAAC,oBAAAA,MAAA,WAAA;AAAA,QAAA,KAAA;AAAA,MAAA,CAAA;AAAA,IAAA;AAAA,UAAA,gBAAA,MAAA;AAAAA,oBAAAA,MAAA,WAAA;AAAA,QAAA,K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