將發送名片的vuex換到pinia

main
Wayne 3 years ago
parent ffea1f6c7c
commit 41bd11ab97

@ -1,13 +1,15 @@
import { defineStore } from 'pinia'
import { getUserData } from "@/api/user";
import { toggleSendWithAD } from "@/api";
import { toggleSendWithAD,setUserTpl } from "@/api";
export const useUserStore = defineStore('user', {
state: () => {
return {
userData: {
is_send_ad: 0,
nc_template: 0,
nfc_template: 0,
},
}
},
@ -29,13 +31,15 @@ export const useUserStore = defineStore('user', {
return true;
}
return false;
}
// async setUserTpl(context, payload) {
// var res = await setUserTpl(payload);
// if (res.code === 200) {
// context.commit("setTpl", payload);
// }
// },
},
async setUserTpl(payload) {
let res = await setUserTpl(payload);
if (res.code === 200) {
this.userData.nc_template = payload
return true;
}
return false;
},
},
persist: true
})

@ -12,13 +12,17 @@ import { cardFactory } from '@/utils/card'
import { genCard1 } from '@/utils/card2'
import { genVipCard } from '@/utils/vipcard'
import { useStore } from 'vuex'
import { useUserStore } from '@/store/user'
import { useCardStore } from '@/store/card'
const store = useStore()
const userStore = useUserStore()
const cardStore = useCardStore()
const state = ref({
// active: 0,
showCusCard: false,
card_title: computed(() => store.state.user.userInfo.card_title),
card_title: computed(() => cardStore.cusCard.card_title),
vip_card: [],
flexContent: {},
})
@ -28,7 +32,7 @@ const activeName = ref('0');
let flexRef = ref(null)
const userInfo = computed(() => {
return store.state.user.userInfo
return userStore.userData
})
onMounted(async () => {
@ -50,7 +54,7 @@ watch(() => activeName.value, function (newVal, oldVal) {
}
}, { immediate: true })
watch(() => userInfo.value.cus_card, function (newVal, oldVal) {
watch(() => cardStore.cusCard.cus_card, function (newVal, oldVal) {
if (userInfo.value.level > 1 && newVal.length > 0) {
state.value.showCusCard = true
}
@ -169,7 +173,7 @@ function showChangeTpl() {
}
const changeTpl = (val) => {
store.dispatch('user/setUserTpl', val)
userStore.setUserTpl(val)
showDraw.value = false
}

Loading…
Cancel
Save