接好了微信登录

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 { Form, Input, Select } from 'ant-design-vue'
import HotAdder from './HotAdder' import HotAdder from './HotAdder'
import GameAdder from './GameAdder' 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' import useAdderPageStore from './useAdderPageStore'
addIcons(MdKeyboardcommandkey, FaCompass, FaPencilRuler, IoGameController) addIcons(MdKeyboardcommandkey, FaCompass, FaPencilRuler, IoGameController)

View File

@ -2,20 +2,26 @@ import { defineComponent } from 'vue'
import { OhVueIcon, addIcons } from 'oh-vue-icons' import { OhVueIcon, addIcons } from 'oh-vue-icons'
import { FaUserAlt } from 'oh-vue-icons/icons' import { FaUserAlt } from 'oh-vue-icons/icons'
import useUserStore from './useUserStore' import useUserStore from './useUserStore'
import { watch } from 'vue'
addIcons(FaUserAlt) addIcons(FaUserAlt)
export default defineComponent(() => { export default defineComponent(() => {
const { profile } = useUserStore() const store = useUserStore()
watch(() => store.profile.avatar, (e) => {
console.log(e);
console.log('avatar change')
})
return () => { return () => {
return ( return (
<div <div
class="w-full h-full rounded-full bg-black/20 flex justify-center items-center bg-center bg-no-repeat bg-cover" class="w-full h-full rounded-full bg-black/20 flex justify-center items-center bg-center bg-no-repeat bg-cover"
style={{ 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> </div>
) )
} }

View File

@ -27,11 +27,14 @@ export default defineComponent(() => {
watch(wxCode, (url, _, onCleanUp) => { watch(wxCode, (url, _, onCleanUp) => {
if (!url) return if (!url) return
const it = setInterval(() => { 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) { if (res) {
clearInterval(it) clearInterval(it)
console.log(res) console.log(res)
user.token = res
router.back()
message.success('登录成功') message.success('登录成功')
} }
}) })

View File

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

View File

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

View File

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