接好了微信登录

This commit is contained in:
expdsn 2024-11-08 15:36:31 +08:00
parent bbfd1284e9
commit 33ea67f34b
6 changed files with 27 additions and 16 deletions

View File

@ -14,7 +14,7 @@ import WidgetAdder from './WidgetAdder'
import { Form, Input, Select } from 'ant-design-vue'
import HotAdder from './HotAdder'
import GameAdder from './GameAdder'
import work_add_main_checked from '/tab/icons/work_add_main_checked.png'
import work_add_main_checked from '/icons/work_add_main_checked.png'
import useAdderPageStore from './useAdderPageStore'
addIcons(MdKeyboardcommandkey, FaCompass, FaPencilRuler, IoGameController)

View File

@ -2,20 +2,26 @@ import { defineComponent } from 'vue'
import { OhVueIcon, addIcons } from 'oh-vue-icons'
import { FaUserAlt } from 'oh-vue-icons/icons'
import useUserStore from './useUserStore'
import { watch } from 'vue'
addIcons(FaUserAlt)
export default defineComponent(() => {
const { profile } = useUserStore()
const store = useUserStore()
watch(() => store.profile.avatar, (e) => {
console.log(e);
console.log('avatar change')
})
return () => {
return (
<div
class="w-full h-full rounded-full bg-black/20 flex justify-center items-center bg-center bg-no-repeat bg-cover"
style={{
backgroundImage: `url('${profile?.avatar}')`
backgroundImage: `url('${store.profile?.avatar}')`
}}
>
{!profile.avatar && <OhVueIcon name="fa-user-alt" fill="white" scale={1.2} />}
{!store.profile.avatar && <OhVueIcon name="fa-user-alt" fill="white" scale={1.2} />}
</div>
)
}

View File

@ -27,11 +27,14 @@ export default defineComponent(() => {
watch(wxCode, (url, _, onCleanUp) => {
if (!url) return
const it = setInterval(() => {
request('GET', `/api/wxlogin2/access?uuid=${_id.value}`).then((res) => {
request<string>('GET', `/api/wxlogin2/access?uuid=${_id.value}`, {
returnType: 'text'
}).then((res) => {
if (res) {
clearInterval(it)
console.log(res)
user.token = res
router.back()
message.success('登录成功')
}
})

View File

@ -23,13 +23,14 @@ export default defineStore('user', () => {
watch(token, (val) => {
localStorage.setItem('token', val)
})
const profile = reactive(defaultUserInfo)
const profile = reactive({ ...defaultUserInfo })
watch(
token,
(val) => {
if (!val) return
request<UserInfo>('GET', '/api/profile').then((res) => {
Object.assign(profile, res)
})
},
{ immediate: true }
@ -37,7 +38,8 @@ export default defineStore('user', () => {
const isLogin = computed(() => !!token.value && !!profile.id)
const logout = () => {
token.value = ''
Object.assign(profile, defaultUserInfo)
Object.assign(profile, { ...defaultUserInfo })
// profile.avatar = ''
}
return {
token,

View File

@ -84,13 +84,13 @@ export default defineComponent(() => {
-13%
</div>
<span class="text-[#fffbc2] text-[16px] ml-2">
{item.commdity[0].price}
{item.commdity[0]?.price}
</span>
<span class="text-[12px] text-[#bdbdbd] line-through decoration-current">
{item.commdity[0].oldprice}
{item.commdity[0]?.oldprice}
</span>
<span class="text-[12px] text-[#ebebeb] line-through decoration-current">
{item.commdity[0].oldprice}
{item.commdity[0]?.oldprice}
</span>
</div>
</div>

View File

@ -28,16 +28,16 @@ export default defineStore("gameDiscount", () => {
find: ''
})
const getList = async () => {
const res = await request<{
data: GameDiscount[];
}>('GET', `/api/gameDiscount?pageSize=${state.pageSize}&pageIndex=${state.pageIndex}&find=${state.find}`)
return res.data
const res = await request<
GameDiscount[]
>('GET', `/api/gameDiscount?pageSize=${state.pageSize}&pageIndex=${state.pageIndex}&find=${state.find}&type=all`)
return res
}
const getNews = async () => {
if (loading.value || noMoreData.value) return;
loading.value = true;
try {
loading.value = true;
const data = await getList()
if (data.length === 0) {
noMoreData.value = true;