Add Movement !
This commit is contained in:
101
src/components/CSendCoins/CSendCoins.ts
Executable file
101
src/components/CSendCoins/CSendCoins.ts
Executable file
@@ -0,0 +1,101 @@
|
||||
import { computed, defineComponent, onMounted, PropType, ref, watch } from 'vue'
|
||||
|
||||
import { ICircuit, IOperators, ISendCoin, ISpecialField, IUserFields } from '../../model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useQuasar } from 'quasar'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CSendCoins',
|
||||
emits: ['close'],
|
||||
props: {
|
||||
showprop: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
to_user: {
|
||||
type: Object as PropType<IUserFields>,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const show = ref(false)
|
||||
const userStore = useUserStore()
|
||||
const circuitStore = useCircuitStore()
|
||||
|
||||
|
||||
const from_username = ref(userStore.my.username)
|
||||
const circuitsel = ref('')
|
||||
const qty = ref(1)
|
||||
const causal = ref('')
|
||||
const bothcircuits = ref(<any>[])
|
||||
|
||||
const circuitloaded = ref(<ICircuit|undefined>undefined)
|
||||
|
||||
|
||||
watch(() => circuitsel.value, (newval, oldval) => {
|
||||
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === newval)
|
||||
})
|
||||
|
||||
watch(() => props.showprop, (newval, oldval) => {
|
||||
console.log('props.showprop', props.showprop, newval)
|
||||
show.value = newval
|
||||
})
|
||||
|
||||
function mounted() {
|
||||
|
||||
|
||||
// ....
|
||||
|
||||
bothcircuits.value = userStore.IsMyCircuitByUser(props.to_user)
|
||||
|
||||
if (bothcircuits.value.length === 1) {
|
||||
circuitsel.value = bothcircuits.value[0]
|
||||
}
|
||||
|
||||
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
|
||||
|
||||
show.value = true
|
||||
}
|
||||
|
||||
function hide() {
|
||||
emit('close', true)
|
||||
}
|
||||
|
||||
function sendCoin() {
|
||||
console.log('sendcoin', qty.value, props.to_user.username)
|
||||
|
||||
if (props.to_user.username && qty.value && circuitloaded.value) {
|
||||
const myrecsendcoin: ISendCoin = {
|
||||
qty: qty.value,
|
||||
dest: props.to_user.username,
|
||||
circuitname: circuitsel.value,
|
||||
causal: causal.value,
|
||||
symbol: circuitloaded.value.symbol,
|
||||
}
|
||||
console.log('myrecsendcoin', myrecsendcoin)
|
||||
if (circuitloaded.value) {
|
||||
tools.sendCoinsByCircuit($q, circuitloaded.value, myrecsendcoin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
tools,
|
||||
show,
|
||||
bothcircuits,
|
||||
from_username,
|
||||
circuitsel,
|
||||
circuitloaded,
|
||||
qty,
|
||||
hide,
|
||||
sendCoin,
|
||||
causal,
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user