Compare commits
No commits in common. "287d0aa41df8883d95103ca621e6103e268b9f3e" and "887019ed5ec8ea5b90638b11d430378442cd23cf" have entirely different histories.
287d0aa41d
...
887019ed5e
@ -46,8 +46,7 @@ CREATE TABLE "order_products" (
|
|||||||
INSERT INTO "main"."shops"("id","address","name") VALUES (NULL,"0x73D081e82b35D6E6f9f5e72EBBB6b637d4f46992","全家便利商店");
|
INSERT INTO "main"."shops"("id","address","name") VALUES (NULL,"0x73D081e82b35D6E6f9f5e72EBBB6b637d4f46992","全家便利商店");
|
||||||
INSERT INTO "main"."shops"("id","address","name") VALUES (NULL,"0xDa68136fcB885a2ec44db6dcE946F656aF457A76","暨大圖文部");
|
INSERT INTO "main"."shops"("id","address","name") VALUES (NULL,"0xDa68136fcB885a2ec44db6dcE946F656aF457A76","暨大圖文部");
|
||||||
|
|
||||||
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,1,"悠遊卡","7233957360139", "10000000000000000");
|
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,1,"濃辛咖哩飯","7233957360139", "10000000000000000");
|
||||||
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,1,"退燒藥","4712521005896", "25000000000000000");
|
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,1,"霜淇淋","4718022345288", "5000000000000000");
|
||||||
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,1,"小酒杯","8809706849058", "50000000000000000");
|
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,2,"證件套","748009345271", "25000000000000000");
|
||||||
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,2,"便條紙","4979274503226", "7000000000000000");
|
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,2,"便條紙","4979274503226", "4000000000000000");
|
||||||
INSERT INTO "main"."products"("id","shop_id","name","code", "price") VALUES (NULL,2,"電池","4904530591785", "30000000000000000");
|
|
||||||
|
|||||||
@ -14,8 +14,7 @@ export default {
|
|||||||
pay: 'panel-block',
|
pay: 'panel-block',
|
||||||
credit: 'panel-block',
|
credit: 'panel-block',
|
||||||
info: 'panel-block',
|
info: 'panel-block',
|
||||||
log: 'panel-block',
|
log: 'panel-block'
|
||||||
repay: 'panel-block'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,17 +60,6 @@ export default {
|
|||||||
<p>掃描支付</p>
|
<p>掃描支付</p>
|
||||||
</template>
|
</template>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<RouterLink to="/client/repay" :class="this.navCSS['repay']">
|
|
||||||
<span class="panel-icon">
|
|
||||||
<i class="fas fa-book" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
<template v-if="this.path == 'repay'">
|
|
||||||
<strong>還款</strong>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<p>還款</p>
|
|
||||||
</template>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/client/log" :class="this.navCSS['log']">
|
<RouterLink to="/client/log" :class="this.navCSS['log']">
|
||||||
<span class="panel-icon">
|
<span class="panel-icon">
|
||||||
<i class="fas fa-book" aria-hidden="true"></i>
|
<i class="fas fa-book" aria-hidden="true"></i>
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import ShopPayQRcodeView from '../views/ShopPayQRcodeView.vue'
|
|||||||
import ShopLogView from '../views/ShopLogView.vue'
|
import ShopLogView from '../views/ShopLogView.vue'
|
||||||
import OrderView from '../views/OrderView.vue'
|
import OrderView from '../views/OrderView.vue'
|
||||||
import ClientLogView from '../views/ClientLogView.vue'
|
import ClientLogView from '../views/ClientLogView.vue'
|
||||||
import ClientRepayView from '../views/ClientRepayView.vue'
|
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
@ -88,11 +87,6 @@ const router = createRouter({
|
|||||||
name: 'log',
|
name: 'log',
|
||||||
component: ClientLogView
|
component: ClientLogView
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/client/repay',
|
|
||||||
name: 'repay',
|
|
||||||
component: ClientRepayView
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -47,9 +47,9 @@ export default {
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-2">
|
<div class="column is-2">
|
||||||
<ClientNav path="log"></ClientNav>
|
<ClientNav path="shoplog"></ClientNav>
|
||||||
<template v-if="this.$cookies.get('isShop') == 'true'">
|
<template v-if="this.$cookies.get('isShop') == 'true'">
|
||||||
<ShopNav path="log"></ShopNav>
|
<ShopNav path="shoplog"></ShopNav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -70,13 +70,16 @@ export default {
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<PageTitle title="使用者選項" subtitle=""></PageTitle>
|
<PageTitle title="Set Credit Limit" subtitle="根據 SBT 信用紀錄設定額度"></PageTitle>
|
||||||
</div>
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
|
|
||||||
<div class="tile is-ancestor">
|
<div class="tile is-ancestor">
|
||||||
<div class="tile is-vertical is-8">
|
<div class="tile is-vertical is-8">
|
||||||
<div class="tile">
|
<div class="tile">
|
||||||
<div class="tile is-parent is-vertical">
|
<div class="tile is-parent is-vertical">
|
||||||
|
|
||||||
|
|
||||||
<RouterLink to="/client/info" class="tile is-child notification is-info">
|
<RouterLink to="/client/info" class="tile is-child notification is-info">
|
||||||
<article>
|
<article>
|
||||||
<p class="title"><i class="fas fa-user"></i> 個人資料</p>
|
<p class="title"><i class="fas fa-user"></i> 個人資料</p>
|
||||||
@ -89,12 +92,6 @@ export default {
|
|||||||
<!-- <p class="subtitle">Top tile</p> -->
|
<!-- <p class="subtitle">Top tile</p> -->
|
||||||
</article>
|
</article>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<RouterLink to="/client/repay" class="tile is-child notification is-info">
|
|
||||||
<article>
|
|
||||||
<p class="title"><i class="fas fa-hand-holding-usd"></i> 還款</p>
|
|
||||||
<!-- <p class="subtitle">Top tile</p> -->
|
|
||||||
</article>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/client/log" class="tile is-child notification is-info">
|
<RouterLink to="/client/log" class="tile is-child notification is-info">
|
||||||
<article>
|
<article>
|
||||||
<p class="title"><i class="fas fa-history"></i> 借款紀錄</p>
|
<p class="title"><i class="fas fa-history"></i> 借款紀錄</p>
|
||||||
@ -107,20 +104,8 @@ export default {
|
|||||||
<!-- <p class="subtitle">Top tile</p> -->
|
<!-- <p class="subtitle">Top tile</p> -->
|
||||||
</article>
|
</article>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
|
||||||
</div>
|
<template v-if="this.isShop">
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="block">
|
|
||||||
<PageTitle title="店家選項" subtitle=""></PageTitle>
|
|
||||||
</div>
|
|
||||||
<template v-if="this.isShop">
|
|
||||||
<div class="block">
|
|
||||||
<div class="tile is-ancestor">
|
|
||||||
<div class="tile is-vertical is-8">
|
|
||||||
<div class="tile">
|
|
||||||
<div class="tile is-parent is-vertical">
|
|
||||||
<RouterLink to="/shop/pay" class="tile is-child notification is-info">
|
<RouterLink to="/shop/pay" class="tile is-child notification is-info">
|
||||||
<article>
|
<article>
|
||||||
<p class="title"><i class="fas fa-cash-register"></i> 店家結帳</p>
|
<p class="title"><i class="fas fa-cash-register"></i> 店家結帳</p>
|
||||||
@ -139,12 +124,16 @@ export default {
|
|||||||
<!-- <p class="subtitle">Top tile</p> -->
|
<!-- <p class="subtitle">Top tile</p> -->
|
||||||
</article>
|
</article>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -154,4 +143,3 @@ export default {
|
|||||||
<SuccessModal :active="successModalStatus" :successMsg="msg" @closeModal="successModalStatus = false"
|
<SuccessModal :active="successModalStatus" :successMsg="msg" @closeModal="successModalStatus = false"
|
||||||
link="/signup/linksbt" btnName="繼續"></SuccessModal>
|
link="/signup/linksbt" btnName="繼續"></SuccessModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@ -1,182 +0,0 @@
|
|||||||
<script>
|
|
||||||
import Web3 from 'web3';
|
|
||||||
import SBT from '@/assets/SBT.json'
|
|
||||||
import Bank from '@/assets/Bank.json'
|
|
||||||
import PageTitle from '../components/PageTitle.vue'
|
|
||||||
import WarningModal from '../components/WarningModal.vue'
|
|
||||||
import SuccessModal from '../components/SuccessModal.vue'
|
|
||||||
import ClientNav from '../components/ClientNav.vue'
|
|
||||||
import ShopNav from '../components/ShopNav.vue'
|
|
||||||
|
|
||||||
// To use Html5QrcodeScanner (more info below)
|
|
||||||
import { Html5QrcodeScanner } from "html5-qrcode";
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: { PageTitle, WarningModal, SuccessModal, ClientNav, ShopNav },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
SBTAddress: import.meta.env.VITE_SBT_ADDR,
|
|
||||||
BankAddress: import.meta.env.VITE_BANK_ADDR,
|
|
||||||
clientAddr: '',
|
|
||||||
web3: null,
|
|
||||||
token: null,
|
|
||||||
bank: null,
|
|
||||||
log: [],
|
|
||||||
warningModalStatus: false,
|
|
||||||
successModalStatus: false,
|
|
||||||
msg: '',
|
|
||||||
isWaiting: false,
|
|
||||||
products: {},
|
|
||||||
productCar: [],
|
|
||||||
orderId: '0'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async mounted() {
|
|
||||||
this.web3 = new Web3(window.ethereum)
|
|
||||||
if (this.$cookies.isKey('address')) {
|
|
||||||
this.clientAddr = this.$cookies.get('address')
|
|
||||||
} else {
|
|
||||||
console.log("Use default address")
|
|
||||||
this.clientAddr = import.meta.env.VITE_DEFAULT_SHOP
|
|
||||||
}
|
|
||||||
this.web3.eth.defaultAccount = this.clientAddr
|
|
||||||
this.token = new this.web3.eth.Contract(SBT, this.SBTAddress)
|
|
||||||
this.bank = new this.web3.eth.Contract(Bank, this.BankAddress)
|
|
||||||
|
|
||||||
var borrow = await this.token.getPastEvents("Borrow", { fromBlock: 0, toBlock: 'latest', filter: { client: this.clientAddr, bank: this.BankAddress } })
|
|
||||||
for (let i of borrow) {
|
|
||||||
let result = i.returnValues
|
|
||||||
let obj = {
|
|
||||||
bank: result['bank'],
|
|
||||||
shop: result['shop'],
|
|
||||||
id: result['id'],
|
|
||||||
amount: result['amount'],
|
|
||||||
repay: false
|
|
||||||
}
|
|
||||||
this.log.push(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
var repay = await this.token.getPastEvents("Repay", { fromBlock: 0, toBlock: 'latest', filter: { client: this.clientAddr, bank: this.BankAddress } })
|
|
||||||
for (let i of repay) {
|
|
||||||
let result = i.returnValues
|
|
||||||
for (let j of this.log) {
|
|
||||||
if ((result['bank'] == j.bank) && (result['id'] == j.id)) {
|
|
||||||
j.repay = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(this.log)
|
|
||||||
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
amountWei() {
|
|
||||||
if (!this.web3) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
var ans = 0
|
|
||||||
for (let item of this.log) {
|
|
||||||
if (item.repay == false){
|
|
||||||
ans += parseInt(item['amount'])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ans
|
|
||||||
},
|
|
||||||
amount() {
|
|
||||||
if (!this.web3) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.web3.utils.fromWei(this.amountWei.toString())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async repay() {
|
|
||||||
this.isWaiting = true
|
|
||||||
await this.bank.methods.repay().send({
|
|
||||||
from: this.clientAddr,
|
|
||||||
value: this.amountWei
|
|
||||||
})
|
|
||||||
try {
|
|
||||||
this.msg = "還款成功!"
|
|
||||||
this.successModalStatus = true
|
|
||||||
} catch (error) {
|
|
||||||
this.msg = "匯款失敗"
|
|
||||||
this.warningModalStatus = true
|
|
||||||
}
|
|
||||||
this.isWaiting = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<section class="blog-posts">
|
|
||||||
<div class="container">
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column is-2">
|
|
||||||
<ClientNav path="repay"></ClientNav>
|
|
||||||
<template v-if="this.$cookies.get('isShop') == 'true'">
|
|
||||||
<ShopNav path="repay"></ShopNav>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<div class="container">
|
|
||||||
<div class="block">
|
|
||||||
<PageTitle title="還款" subtitle="向本銀行償還帳款"></PageTitle>
|
|
||||||
</div>
|
|
||||||
<div class="block">
|
|
||||||
<table class="table is-fullwidth">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>#</th>
|
|
||||||
<th>銀行帳款編號</th>
|
|
||||||
<th>商店</th>
|
|
||||||
<th>金額</th>
|
|
||||||
<th>詳細資訊</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<template v-for="(item, index) in log">
|
|
||||||
<template v-if="item.repay == false">
|
|
||||||
<tr>
|
|
||||||
<td>{{ index }}</td>
|
|
||||||
<td>#{{ item.id }}</td>
|
|
||||||
<td>{{ item.shop }}</td>
|
|
||||||
<td>{{ this.web3.utils.fromWei(item.amount) }} ETH</td>
|
|
||||||
<td>
|
|
||||||
<RouterLink :to="'/order/' + item.id" class="button is-info is-outlined">查詢
|
|
||||||
</RouterLink>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
<tr>
|
|
||||||
<td colspan="3"></td>
|
|
||||||
<td><strong>共計 {{ amount }} ETH</strong></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="block">
|
|
||||||
<div class="column is-2 is-offset-5">
|
|
||||||
<template v-if="!isWaiting">
|
|
||||||
<button class="button is-info is-outlined is-large" @click="repay">還款</button>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<button class="button is-info is-outlined is-large is-loading"></button>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<WarningModal :active="warningModalStatus" :errorMsg="msg" @closeModal="warningModalStatus = false"></WarningModal>
|
|
||||||
<SuccessModal :active="successModalStatus" :successMsg="msg" @closeModal="successModalStatus = false"
|
|
||||||
:link="`/shop/pay/${this.orderId}`" btnName="繼續"></SuccessModal>
|
|
||||||
</template>
|
|
||||||
@ -65,18 +65,13 @@ export default {
|
|||||||
onScanSuccess(decodedText, decodedResult) {
|
onScanSuccess(decodedText, decodedResult) {
|
||||||
// handle the scanned code as you like, for example:
|
// handle the scanned code as you like, for example:
|
||||||
console.log(`Code matched = ${decodedText}`, decodedResult);
|
console.log(`Code matched = ${decodedText}`, decodedResult);
|
||||||
if (decodedText in this.products){
|
var product = this.products[decodedText]
|
||||||
var product = this.products[decodedText]
|
this.productCar.push({
|
||||||
this.productCar.push({
|
'name': product['name'],
|
||||||
'name': product['name'],
|
'id': product['id'],
|
||||||
'id': product['id'],
|
'price': product['price'],
|
||||||
'price': product['price'],
|
'count': 1
|
||||||
'count': 1
|
})
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.msg = "商品列表中沒有這項商品:"+decodedText
|
|
||||||
this.warningModalStatus = true
|
|
||||||
}
|
|
||||||
this.scanner.clear()
|
this.scanner.clear()
|
||||||
},
|
},
|
||||||
scan() {
|
scan() {
|
||||||
@ -135,7 +130,7 @@ export default {
|
|||||||
</div>
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<button class="button is-success is-outlined is-large" @click="scan">掃描商品條碼</button>
|
<button class="button is-success is-outlined is-large" @click="scan">掃描商品條碼</button>
|
||||||
<div id="reader" width="200px"></div>
|
<div id="reader" width="300px"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<table class="table is-fullwidth">
|
<table class="table is-fullwidth">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user