'提现模块'

This commit is contained in:
2021-09-25 11:59:49 +08:00
parent 3a48656538
commit ed4c0492fb
21 changed files with 2756 additions and 8 deletions

159
apis/interfaces/wallet.js Normal file
View File

@@ -0,0 +1,159 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
* moduleName: 钱包
*/
import {request} from '../index.js'
// 导出助记词
const seed = () => {
return request({
url: 'chain/safe/seed'
})
}
const hash = (data) => {
return request({
url: 'chain/wallet/hash',
method: 'POST',
data: data
})
}
// 收款码
const code = () => {
return request({
url: 'chain/account/code'
})
}
// 原石余额
const sum = () => {
return request({
url: 'chain/account/balance'
})
}
// 原石价格
const price = () => {
return request({
url: 'nodes/price'
})
}
// 账户记录
const logs = (data) => {
return request({
url: 'chain/account/logs',
data: data
})
}
// 设置安全密码
const security = (data) => {
return request({
url: 'chain/safe/security',
method: 'POST',
data
})
}
// 转账
const transfer = (data) => {
return request({
url: 'chain/account/transfer',
method: 'POST',
data
})
}
// 钱包私钥
const privatekey = (code) => {
return request({
url : "chain/safe/private_key",
data: {
code
}
})
}
// 获取可提现信息
const withdraw = () => {
return request({
url : "withdraw"
})
}
// 提现记录
const withdrawLogs = (data) => {
return request({
url : "withdraw/logs",
data:data
})
}
// 提现
const withdrawDo = (data) => {
return request({
url : "withdraw",
method: 'POST',
data:data
})
}
// 验证支付密码是否正确
const securityCheck = (password) => {
return request({
url : "chain/safe/security/check",
method: 'POST',
data:{
code : password,
}
})
}
// 修改密码
const securityReset = (data) => {
return request({
url : "chain/safe/security",
method: 'PUT',
data:data
})
}
// 提现服务条款
const cmsWithdraw = () => {
return request({
url : "cms/withdraw"
})
}
// 私钥规则
const keyrules = () => {
return request({
url: 'cms/keyrules'
})
}
export {
seed,
hash,
code,
sum,
price,
logs,
security,
transfer,
privatekey,
withdraw,
withdrawLogs,
withdrawDo,
securityCheck,
securityReset,
cmsWithdraw,
keyrules
}

View File

@@ -0,0 +1,238 @@
<template>
<view class="numberJpan" :style="wc" v-show="flag" >
<!-- <view class="myshuru" :style="obj" @tap.stop="flag=true">
<view class="srk" :style="'width:'+100/(length||6)+'%'" v-for=" i in length||6" :id="(i-1)==xz?'numberJpanActive':''" >
{{arr[i-1]}}
</view>
</view> -->
<view class="myshuru" :style="obj" @tap.stop="flag=true">
<view class="gb" @tap="close()" :style="gsbstyle">×</view>
<view class="shuruTitle">
请输入支付密码
</view>
<view class="center-x">
<view class="srk" :style="'width:'+100/(length||6)+'%'" v-for=" i in length||6" :id="(i-1)==xz?'numberJpanActive':''" :key="i" >
<!-- #ifdef MP-WEIXIN -->
{{showNum?arr[i]==null?'':arr[i]:arr[i]!=null?"●" : ""}}
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
{{showNum?arr[i-1]==null?'':arr[i-1]:arr[i-1]!=null?"●" : ""}}
<!-- #endif -->
</view>
</view>
</view>
<view class="jpan" :style="tsfY">
<view class="nav" @tap="close()">
<uni-icons type="arrowdown"></uni-icons>
</view>
<view class="main">
<!-- #ifdef MP-WEIXIN -->
<view v-for="i in 9" :key="i" @tap="numshuzi(i+1)">{{i+1}}</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view v-for="i in 9" :key="i" @tap="numshuzi(i)">{{i}}</view>
<!-- #endif -->
<view> </view>
<view @tap="numshuzi(0)">0</view>
<view @tap="del()">
<uni-icons type="arrowthinleft"></uni-icons>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name:'number-jpan',
data() {
return {
wc:{
'background-color':"rgba(0, 0, 0, .0)"
},
obj:{
"opacity":0,
"top":'50%'
},
flag:false,
clear1:"",
clear2:"",
arr:[],
xz:0,
gsbstyle:{
"opacity":0
},
tsfY:{
'transform':'translateY(100%)'
}
};
},
props:['length','showNum'],
methods:{
del(){
if(this.xz>0){
//let arr1=this.arr
//arr1[this.xz]=""
//this.arr=arr1
this.arr.pop();
this.xz--;
}
uni.vibrateShort();
},
numshuzi(num){
let arr1=this.arr
arr1[this.xz]=num
this.arr=arr1
uni.vibrateShort();
this.xz++
if(this.xz==this.length){
let str=""
for(let item of this.arr){
str+=item
}
this.$emit('closeChange',str)
this.close()
}
},
open(){
this.flag=true;
this.arr=[];
this.xz=0;
this.clear1=setTimeout(()=>{
this.wc='background-color:rgba(0, 0, 0, .5)';
this.obj='opacity:1;top:40%';
this.gsbstyle="opacity:1";
this.tsfY='transform:translateY(0%)';
},100)
},
close(){
this.wc={
'background-color':"rgba(0, 0, 0, .0)"
}
this.obj={
"opacity":0,
"top":'50%'
}
this.gsbstyle={
"opacity":0
}
this.clear2=setTimeout(()=>{
this.flag=false
},1000)
this.tsfY={
'transform':'translateY(100%)'
}
},
xuanze(i){
this.xz=i
uni.vibrateShort();
}
}
}
</script>
<style lang="scss">
#numberJpanActive{
background-color: $mian-color;
color: #FFFFFF;
}
.jpan{
width: 100vw;
height: 30vh;
background-color: #FFFFFF;
position: absolute;
bottom: 0;
transform: translateY(100%);
transition: all .5s;
.nav{
text-align: center;
line-height: 50upx;
box-sizing: border-box;
border-bottom: 1px solid #EEEEEE;
}
.main{
width: 100%;
height: calc(30vh - 50upx);
view{
box-sizing: border-box;
float: left;
width: 33.33%;
height: 25%;
font-size: 40upx;
text-align: center;
line-height:7.5vh;
border: 1px solid #f4f4f4;
}
view:active{
background-color: #EEEEEE;
}
}
}
.numberJpan{
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0);
transition: all .5s;
z-index: 999;
.myshuru{
transition: all .5s;
position: absolute;
width: 70vw;
height: 350upx;
top: 50%;
opacity: 0;
transform: translate(-50%,-50%);
background-color: #FFFFFF;
left: 50%;
color: #000000;
border-radius: 20upx;
overflow: hidden;
.shuruTitle{
margin: 100upx auto;
font-weight: 900;
text-align: center;
font-size: 30upx;
}
.center-x{
width: 90%;
height: 80upx;
border: 1px solid #EEEEEE;
border-radius: 20upx;
position: absolute;
overflow: hidden;
left: 50%;
transform: translateX(-50%);
bottom: 50upx;
.srk{
height: 100%;
line-height: 80upx;
text-align: center;
float: left;
box-sizing: border-box;
border-left: 1px solid #EEEEEE;
transition: all .4s;
}
.srk:nth-child(1){
border-left:0px;
border-radius: 20upx 0 0 20upx;
}
}
}
}
.gb{
position: absolute;
font-size: 50upx;
top: 0;
color: #AAAAAA;
left: 30upx;
transition: all .5s;
}
</style>

View File

@@ -0,0 +1,93 @@
<template>
<view>
<block v-if="list.length > 0">
<view class="record--item" v-for="(item, index) in list" :key="index">
<view class="title ellipsis">{{item.hash || '-'}}</view>
<view class="time ellipsis">{{item.block_time || '-'}}</view>
<view class="webkit-box variation">
<view class="ellipsis" :class="item.is_in ? 'add': 'remove'">{{item.is_in ? '+': '-'}}{{item.amount}}</view>
<view class="symbol">{{item.assets.symbol}}</view>
</view>
</view>
</block>
<block v-else>
<no-list v-if='logsType === 0' name='no-record' txt="没有任何记录~" />
<no-list v-if='logsType === 2' name='no-in' txt="没有任何收入记录~" />
<no-list v-if='logsType === 1' name='no-out' txt="没有任何支出记录~" />
</block>
</view>
</template>
<script>
export default {
name:"property",
props:{
list: {
type: Array,
default: () => {
return []
}
},
logsType:{
type:Number
}
},
data() {
return {
};
}
}
</script>
<style lang="scss" scoped>
.record--item{
padding: $padding 320rpx $padding 0;
border-bottom: solid 1rpx $border-color;
position: relative;
min-height: 50rpx;
.variation{
position: absolute;
right: 0;
top: $margin;
bottom: $margin;
width: 300rpx;
text-align: right;
font-weight: bold;
&>label{
font-size: 80%;
}
.symbol{
color: $mian-color;
font-weight: normal;
font-size: $title-size-m;
}
.add{
color: $mian-color;
}
.remove{
color: $mian-color;
}
}
.title{
line-height: 50rpx;
}
.time{
font-size: $title-size-m;
color: $mian-color;
}
}
// 数据空
.record--null{
padding-top: $padding * 3;
text-align: center;
color: $mian-color;
font-size: $title-size;
height: 50vh;
box-sizing: border-box;
line-height: 60rpx;
image{
width: 168rpx;
}
}
</style>

View File

@@ -129,22 +129,62 @@
"style": {
"navigationBarTitleText": "企业认证"
}
},{
}, {
"path": "pages/news/index",
"name": "news",
"auth": true,
"style": {
"navigationBarTitleText": "消息中心"
}
},{
}, {
"path": "pages/news/detail",
"name": "newsDetail",
"auth": true,
"style": {
"navigationBarTitleText": "消息列表"
}
}
],
}, {
"path": "pages/wallet/property",
"name": "walletProperty",
"style": {
"navigationBarTitleText": "能量钱包",
"enablePullDownRefresh": false,
"navigationBarTextStyle": "white",
"app-plus": {
"titleNView": {
"backgroundColor": "#b11eff",
"type": "transparent",
"buttons": [{
"float": "right",
"fontSize": "14",
"text": "管理",
"background": "rgba(255,255,255,0)"
}],
"backButton": {
"background": "rgba(255,255,255,0)"
}
}
}
}
}, {
"path": "pages/wallet/extract",
"style": {
"navigationBarTitleText": "提现能量",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#774ffd",
"navigationBarTextStyle": "white"
},
"name": "Extract"
}, {
"path": "pages/wallet/resetPassword",
"style": {
"navigationBarTitleText": "重置密码",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#774ffd",
"navigationBarTextStyle": "white"
},
"name": "ResetPassword"
} ],
"globalStyle": {
"navigationStyle": "custom",
"backgroundColor": "#F5F5F5"

View File

@@ -122,7 +122,7 @@
<view class="withdraw-name">
当前能量球价值<view class="withdraw-number">0.00</view>
</view>
<view class="withdraw-btn">
<view class="withdraw-btn" @click="$Router.push({name: 'Extract'})">
去提现
</view>
</view>
@@ -131,8 +131,8 @@
我的资产
</view>
<view class="assets-list" v-if="userData.account">
<view class="assets-label">
<view class="assets-label-name">能量球钱包<image @click="showHelp('wallet')" class="assets-label-icon" src="/static/user/userAssets_tips.png"></image></view>
<view class="assets-label" @click="$Router.push({name:'walletProperty'})">
<view class="assets-label-name">能量球钱包<image @click.stop="showHelp('wallet')" class="assets-label-icon" src="/static/user/userAssets_tips.png"></image></view>
<view class="assets-label-number">{{userData.account.coins || 0}}</view>
</view>
<view class="assets-label">

65
pages/wallet/add.vue Normal file
View File

@@ -0,0 +1,65 @@
<template>
<view class="content webkit-box">
<!-- logo -->
<image class="logo" src="@/static/img/oc-logo.png" mode="widthFix"></image>
<!-- 副标题 -->
<view class="sub-title">激活您的OC Chain区块链钱包地址</br>地址可以理解为您的个人银行卡卡号与他人转账时是区块链上两个地址的交易行为</view>
<!-- 按钮 -->
<navigator class="wallet-btn" url="./mnemonic" open-type="redirect">激活钱包</navigator>
<!-- <navigator class="wallet-btn hollow" url="./guide">导入钱包</navigator> -->
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
page {
background-color: white;
}
</style>
<style lang="scss" scoped>
.content{
position: relative;
height: 100vh;
padding: 0 15vw;
text-align: center;
.logo{
width: 138rpx;
vertical-align: top;
margin-bottom: 30vh;
}
.sub-title{
font-size: $title-size-m;
color: $text-gray;
}
.wallet-btn{
width: 100%;
background-color: $mian-color;
height: 90rpx;
line-height: 90rpx;
margin-top: $margin * 2;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
&.hollow{
background-color: white;
color: $mian-color;
border:solid 2rpx $mian-color;
box-sizing: border-box;
}
}
}
</style>

View File

@@ -0,0 +1,50 @@
<template>
<view>
<view class="clauseCont">
<rich-text :nodes="clauseData"></rich-text>
</view>
</view>
</template>
<script>
import {
cmsWithdraw
} from '@/apis/interfaces/wallet.js'
export default {
data() {
return {
clauseData: [] //服务条款
};
},
onLoad() {
// 获取服务条款
this.clauseInfo()
},
methods: {
// 服务条款
clauseInfo() {
cmsWithdraw().then(res => {
this.clauseData = res.content.replace(/\<img/gi,
'<img style="max-width:100%; height:auto; vertical-align: top;"')
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
}
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color;
}
.clauseCont {
padding: $padding + 10 $padding * 2;
width: 100%;
box-sizing: border-box;
}
</style>

136
pages/wallet/code.vue Normal file
View File

@@ -0,0 +1,136 @@
<template>
<view class="webkit-box code">
<view class="webkit-box code-content">
<view class="sub-title">扫码转入OC COIN</view>
<view class="code-img">
<image :src="code" mode="widthFix" />
</view>
<view class="hr"></view>
<view class="sub-title">钱包地址</view>
<view class="hash">{{address || '-'}}</view>
<view class="buttons">
<button class="item red" type="default" @click="showShare()">分享</button>
<button class="item greed" type="default" @click="copyAddress">复制</button>
</view>
</view>
<view class="footer">OC CHNIA</view>
</view>
</template>
<script>
import { code } from '@/apis/interfaces/wallet'
export default {
data() {
return {
address: '',
code: ''
};
},
mounted() {
code().then(res=>{
this.code = res.image
this.address = res.address
}).catch(err=>{
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods:{
copyAddress(){
uni.setClipboardData({
data: this.address
})
},
showShare(){
uni.share({
provider: 'weixin',
title: '我正在使用ocChain钱包收款',
scene: 'WXSceneSession',
href: 'https://live.funnyzhibo.com/blockdownload',
imageUrl: 'https://live.funnyzhibo.com/oc-chain.png',
summary: '我的收款地址' + this.address
})
}
}
}
</script>
<style lang="scss" scoped>
.code{
height: 100vh;
background:linear-gradient(to bottom, $mian-color, $mian-color-deep);
padding-bottom: env(safe-area-inset-bottom);
padding-bottom: constant(safe-area-inset-bottom);
box-sizing: border-box;
// 收款码
.code-content{
text-align: center;
background: white;
margin: 0 8vw;
border-radius: $radius;
padding: $padding * 2;
height: 70vh;
box-shadow: 0 0 6rpx 6rpx rgba($color: #000000, $alpha: .02);
box-sizing: border-box;
.sub-title{
font-size: $title-size + 8;
}
.code-img{
width: 20vh;
height: 20vh;
margin: $margin * 3 0 $margin * 2;
display: inline-block;
background-image: url(../../static/background/wallet-code-background.png);
padding: $padding;
box-sizing: border-box;
background-position: center;
background-size: cover;
image{
width: 100%;
}
}
.hr{
height: 1rpx;
background: $border-color;
margin: $margin * 2 0;
}
.hash{
word-wrap: break-word;
font-size: $title-size;
padding: $padding 0;
}
.buttons{
display: flex;
padding-top: $padding * 2;
.item{
width: 40%;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
font-size: $title-size;
color: white;
&::after{
border: none;
}
&.red{
background: $red-color;
}
&.greed{
background: $mian-color;
}
}
}
}
// 底部
.footer{
height: 10vh;
line-height: 10vh;
text-align: center;
font-size: $title-size + 10;
font-weight: bold;
color: #58876e;
}
}
</style>

138
pages/wallet/create.vue Normal file
View File

@@ -0,0 +1,138 @@
<template>
<view>
<!-- 设置钱包密码 -->
<view class="password">
<view class="prompt">请设置6位数字密码建议不要使用连续的数字</view>
<view class="group">
<view class="inputs">
<label>密码</label>
<input type="digit" v-model="password" maxlength="6" placeholder="请设置密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="digit" v-model="verify" maxlength="6" placeholder="请确认密码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" form-type="submit" @click="createWallet">确认</button>
</view>
</view>
</template>
<script>
import {
security
} from '@/apis/interfaces/wallet'
export default {
data() {
return {
password: '',
verify: ''
}
},
methods: {
// 激活钱包
createWallet() {
if (this.password === '' || this.verify === '') {
uni.showToast({
icon: 'none',
title: '请设置密码'
})
return
}
if (this.password !== this.verify) {
uni.showToast({
icon: 'none',
title: '两次输入密码不一致'
})
return
}
security({
code: this.password
}).then(res => {
uni.navigateBack()
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
}
}
}
</script>
<style lang="scss" scoped>
// 副标题
.sub-title {
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 设置密码
.password {
padding: 0 $padding * 2;
.prompt {
margin-top: $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.group {
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs {
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child {
border-bottom: none;
}
label {
color: $text-gray;
font-size: $title-size-m;
}
input {
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
}
}
// 按钮
.buttons {
padding: $padding * 2;
.text {
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button {
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

389
pages/wallet/extract.vue Normal file
View File

@@ -0,0 +1,389 @@
<template>
<view class="WithdrawingCoin ">
<view class="withdrawing-content">
<view class="item-name">账户能量球将提现到银行卡</view>
<view class="item">
<view style="flex: 1;">
<input class="input_num" v-model="withdraw_input" @input='inputNum' type="number"
placeholder-style="color:#999;font-weight:normal; font-size:30rpx;" placeholder="请输入能量球数量" />
<view v-if="total"> {{total}}</view>
</view>
<view class="all" @click="all">全部提现</view>
</view>
<view class="item">
<input class="input_num" v-model="card" type="number"
placeholder-style="color:#999;font-weight:normal; font-size:30rpx;" placeholder="请输入您要收款得银行卡卡号" />
</view>
<view class="item">
<input class="input_num" v-model="name" maxlength="10"
placeholder-style="color:#999;font-weight:normal; font-size:30rpx;" placeholder="请输入收款人姓名" />
</view>
<number-jpan :length="6" @closeChange="closeChange($event)" ref="numberPad"></number-jpan>
<view class="item-total">
<view class="total"><span>能量球总数 : {{balance}}</span><span class="money">总估值(CNY){{(balance*price).toFixed(2)}}</span></view>
</view>
</view>
<view class="btn" @click="open">提现至银行卡</view>
<view class="ew_lists" v-if="withdrawLists.length>0">
<view class="" v-for="(item,index) in withdrawLists " :key="index">
<view class="receiptCode">
回执单号{{item.receipt_code}}
</view>
<view class="item">
<view class="left">
<span>能量球:{{item.total}}</span>
<span>金额{{item.arrival}}</span>
</view>
<view class="right">
<span> {{item.created_at}} 提现</span>
<span> {{item.paid_at?item.paid_at+'到账':'努力打款中'}}</span>
</view>
</view>
</view>
<view class="hasmore">
{{has_more?'努力加载中~':'我是有底线的~'}}
</view>
</view>
<no-list v-else name='no-records' txt="暂无任何提现记录哦~" />
</view>
</template>
<script>
import {
withdraw,
withdrawLogs,
withdrawDo
} from '@/apis/interfaces/wallet.js';
import numberJpan from "@/components/numberJpan/numberJpan.vue";
export default {
data() {
return {
balance: 0, // 钱包能量球数量
price: 0, // 当前能量球价格
card: '', // 银行卡号
name: '', // 姓名
password: '', //
withdraw_input: '', // 提现能量球数量
total: '', // 提现能量球转化成的钱数
page: 1,
has_more: true,
withdrawLists: [],
};
},
components: {
'number-jpan': numberJpan
},
onLoad() {
this.reset()
},
onReachBottom() {
if (this.withdrawLists.length > 0) {
if (this.has_more) {
this.withdrawLogs()
} else {
uni.showToast({
title: '没有更多~',
icon: 'none'
})
}
}
},
methods: {
// 提现基本信息
withdraw() {
withdraw().then(res => {
this.balance = Number(res.balance)
this.price = Number(res.price)
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
// 提现记录
withdrawLogs() {
withdrawLogs({
page: this.page
}).then(res => {
this.withdrawLists = this.withdrawLists.concat(res.data)
if (res.page.has_more) {
this.page = this.page + 1
this.has_more = true
} else {
this.has_more = false
}
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
// 输入提现能量球数量
inputNum(e) {
let number = Number(e.detail.value)
if (number <= this.balance) {
this.total = Number(e.detail.value) * this.price
} else {
uni.showToast({
title: '最大值能超过' + this.balance+'',
icon: 'none',
duration: 2000
});
this.withdraw_input = ''
this.total = 0
}
},
// 点击全部
all() {
if (this.balance > 0) {
this.withdraw_input = this.balance
this.total = this.balance * this.price
} else {
uni.showToast({
title: '啥也没有,我也做不到~',
icon: 'none',
duration: 2000
})
}
},
// 打开密码 出发提现功能
open() {
if (this.total > 0) {
let params = {
name: this.name,
card: this.card,
total: this.withdraw_input
}
if (params.name === '' || params.card === '' || params.total === 0) {
uni.showToast({
title: '重新确认提现信息',
icon: 'none',
duration: 2000
})
} else {
this.$refs.numberPad.open()
}
} else {
uni.showToast({
title: '啥也没有,我也做不到~',
icon: 'none',
duration: 2000
})
}
},
// 输入密码成功后,,,
closeChange(e) {
uni.showLoading({
title: '提现中~'
})
let params = {
name: this.name,
card: this.card,
total: this.withdraw_input,
code: e
}
withdrawDo(params).then(res => {
uni.showToast({
title: '申请提现成功,耐心等待打款',
icon: 'none',
duration: 2000
})
this.reset()
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none',
duration: 2000
})
})
},
reset() {
this.name = ''
this.card = ''
this.page = 1
this.has_more = true
this.withdraw_input = ''
this.total = 0
this.withdrawLists = []
this.withdrawLogs();
this.withdraw();
}
}
}
</script>
<style lang="scss">
.hasmore {
color: #808080;
font-size: $title-size-m;
text-align: center;
padding: $padding*2;
}
.nomore {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: #808080;
margin-top: $margin*4;
image {
width: 320rpx;
margin-bottom: $margin*2;
}
}
.receiptCode {
color: #808080;
text-align: left;
// margin: $margin 0;
font-size: $title-size-m;
}
.WithdrawingCoin {
background-color: #fff;
width: 100%;
min-height: 100vh;
padding-bottom: 100rpx;
}
.all {
color: $mian-color;
width: 160rpx;
text-align: center;
}
.withdrawing-content {
min-height: 300rpx;
background-color: #fff;
box-shadow: 0 0 30rpx 1rpx rgba($color: #000000, $alpha: 0.2);
margin: $margin*1.4;
border-radius: $radius*1.5;
padding: $padding*1.4;
font-size: $title-size-m;
.item-name {
text-align: center;
padding: $padding * .6;
color: #303030;
font-weight: bold;
margin-bottom: $margin;
font-size: $title-size *1.4;
}
.item {
border-bottom: solid 1rpx #f8f8f8;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
padding: $padding 0;
span:nth-child(1) {
color: #666;
margin-right: 20rpx;
}
.input_num {
font-size: $title-size*1.5;
color: #3a3a3a;
font-weight: bolder;
flex: 1;
}
}
.item-total {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: $padding*2 0 0 0;
color: #3a3a3a;
.total {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
.money {
padding-top: $padding *0.5;
}
}
.lists {
color: $text-price;
}
}
}
.btn {
// background-color: $text-price;
background-image: linear-gradient(to right, $text-price, $mian-color);
color: #fff;
border-radius: 50rpx;
text-align: center;
padding: $padding ;
margin: $margin * 2;
font-size: $title-size;
font-weight: bold;
}
.ew_lists {
padding: $padding *2;
border-top: solid 4rpx #f8f8f8;
.item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
border-bottom: solid 1rpx #f8f8f8;
background-color: #fff;
padding: 0 0 $padding*0.8 0;
.left,
.right {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
}
.left {
font-size: $title-size-m;
font-weight: bold;
color: #808080;
span:nth-child(2) {
color: $text-price;
font-size: $title-size-m;
font-weight: normal;
padding-top: $padding *0.5;
}
}
.right {
font-size: $title-size-m;
align-items: flex-end;
color: #666;
span:nth-child(1) {
padding-bottom: $padding*0.5;
}
}
}
}
</style>

125
pages/wallet/guide.vue Normal file
View File

@@ -0,0 +1,125 @@
<template>
<view>
<form>
<!-- 副标题 -->
<view class="sub-title">输入您的钱包助记词导入</view>
<!-- 助记词 -->
<view class="word">
<textarea placeholder="输入助记词"></textarea>
</view>
<!-- 设置钱包密码 -->
<view class="password">
<view class="group">
<view class="inputs">
<label>钱包名称</label>
<input type="text" placeholder="输入钱包名称" />
</view>
</view>
<view class="title">不少于8个字符建议包含大小写符号特殊字符</view>
<view class="group">
<view class="inputs">
<label>密码</label>
<input type="password" placeholder="请设置密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="password" placeholder="请确认密码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<view class="text">什么是助记词</view>
<button type="default" form-type="submit">开始导入</button>
</view>
</form>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
// 副标题
.sub-title{
line-height: 90rpx;
color: $text-gray;
text-align: center;
margin: $margin;
font-size: $title-size-m;
}
// 助记词
.word{
background-color: white;
margin: $margin * 2;
padding: $padding + 10;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
& textarea{
height: 200rpx;
}
}
// 设置密码
.password{
padding: 0 $padding * 2;
.title{
margin-top: $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.group{
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs{
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child{
border-bottom: none;
}
label{
color: $text-gray;
font-size: $title-size-m;
}
input{
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
}
}
// 按钮
.buttons{
padding: $padding * 2;
.text{
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

144
pages/wallet/index.vue Normal file
View File

@@ -0,0 +1,144 @@
<template>
<view class="animate__animated animate__fadeInRight">
<!-- 数字资产 -->
<view class="property">
<view class="title">总资产()</view>
<view class="number">0.00</view>
</view>
<!-- 资产列表 -->
<view class="lists">
<view class="lists-header">
资产列表
<uni-icons type="plus" size="24" color="#009b69"></uni-icons>
</view>
<view class="item" v-for="(item, index) in 2" :key="index" @click="propertyInfo(item)">
<view class="cost">
<image class="logo" src="" mode="" />
<view class="title ellipsis">OC COIN</view>
<view class="text ellipsis">0.21</view>
</view>
<view class="balance">
<view class="title ellipsis">120,330.00</view>
<view class="text ellipsis">25269.3000</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
methods:{
propertyInfo(e){
console.log(e)
uni.navigateTo({
url: './property'
})
}
}
}
</script>
<style scoped>
</style>
<style lang="scss" scoped>
// 数字资产
.property{
overflow: hidden;
position: relative;
margin-top: $margin;
margin-left: $margin + ($margin / 2);
background-color: $mian-color;
border-radius: $radius 0 0 $radius;
padding: ($padding * 3) ($padding * 3) ($padding * 3) ($padding * 2);
color: white;
font-weight: bold;
&::before,&::after{
background-color: rgba($color: $red-color, $alpha: .03);
border-radius: 50%;
content: " ";
position: absolute;
}
&::before{
top: -300rpx;
left: 40%;
height: 400rpx;
width: 400rpx;
}
&::after{
bottom: -200rpx;
left: -100rpx;
height: 300rpx;
width: 300rpx;
}
.title{
font-size: $title-size;
}
.number{
font-size: $title-size + 18;
}
}
// 资产列表
.lists{
padding: $margin + ($margin / 2);
.lists-header{
display: flex;
font-size: $title-size + 2;
color: $text-color;
font-weight: bold;
padding: $padding 0 ($padding/2) 0;
justify-content: space-between;
justify-items: center;
align-items: center;
}
.item{
background-color: white;
border-radius: $radius;
box-shadow: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .02);
margin-top: $margin;
padding: $padding * 2;
display: flex;
&:first-child{
margin-top: 0;
}
.cost{
position: relative;
margin-right: $margin;
padding-left: 108rpx;
width: 50%;
box-sizing: border-box;
.logo{
position: absolute;
left: 0;
top: 0;
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background-color: $border-color;
margin-right: $margin;
}
}
.balance{
padding-left: $padding;
width: 50%;
text-align: right;
box-sizing: border-box;
}
.title{
font-weight: bold;
font-size: $title-size;
}
.text{
font-size: $title-size-m;
color: $text-gray;
}
}
}
</style>

108
pages/wallet/mnemonic.vue Normal file
View File

@@ -0,0 +1,108 @@
<template>
<view>
<!-- 提示信息 -->
<view class="prompt">
请按照顺序记录并确保正确备份助记词
</view>
<!-- 助记词 -->
<ul class="mnemonic">
<li v-for="(item, index) in mnemonic" :key="index">{{item}}</li>
</ul>
<!-- 按钮 -->
<view class="buttons">
<view class="text">助记词是用户账户的唯一标识不能分享给他人掌握该助记词即可控制该账户与钱包</view>
<button type="default" @click="goto('/pages/wallet/validation')">验证助记词</button>
</view>
<!-- <view class="skip">暂时不验证<navigator url="/pages/index/index" open-type="switchTab">点此跳过</navigator></view> -->
</view>
</template>
<script>
import { seed } from "../../apis/interfaces/wallet"
export default {
data() {
return {
mnemonic: [], // 助记词
sign : '' // 校验签名
}
},
onLoad() {
seed().then(res => {
this.mnemonic = res.seed.split(' ')
this.sign = res.sign
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods: {
goto(url){
uni.redirectTo({
url: url + '?seed=' + this.mnemonic + '&sign=' + this.sign
})
}
}
}
</script>
<style lang="scss" scoped>
// 提示信息
.prompt{
color: $text-gray;
text-align: center;
line-height: 90rpx;
font-size: $title-size-m;
}
// 跳过
.skip{
padding: $padding * 2;
text-align: center;
color: $text-gray;
navigator{
color: $mian-color;
margin-left: $margin/2;
display: inline-block;
}
}
// 助记词
.mnemonic{
margin: $margin $margin * 2;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
padding: $padding;
list-style: none;
display: flex;
flex-wrap: wrap;
li{
text-align: center;
height: 58rpx;
line-height: 58rpx;
width: 58rpx;
margin: $margin / 2;
color: $text-color;
background: rgba($color: $border-color, $alpha: .4);
}
}
// 按钮
.buttons{
padding: $padding $padding * 2;
.text{
text-align: center;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $red-color;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

108
pages/wallet/privatekey.vue Normal file
View File

@@ -0,0 +1,108 @@
<template>
<view>
<!-- 私钥 -->
<view class="keys">
<view class="title">您已接收OC Chain托管</view>
<view class="key">{{key || '-'}}</view>
<view class="copykey" @click="copykey">复制我的私钥</view>
</view>
<!-- 疑问 -->
<view class="doubt" v-if="rules.length > 0">
<view class="doubt-item" v-for="(item, index) in rules" :key="index">
<view class="title">{{item.title || '-'}}</view>
<view class="content">{{item.description || '-'}}</view>
</view>
</view>
<!-- 免责说明 -->
<view class="liability">
<navigator url="/pages/wallet/cmsWithDraw">免责条款</navigator>
</view>
</view>
</template>
<script>
import { privatekey, keyrules } from '@/apis/interfaces/wallet'
export default {
data() {
return {
key: "",
rules: []
};
},
mounted() {
Promise.all([privatekey(this.$Route.query.password), keyrules()]).then(res => {
let privatekey = res[0],
keyrules = res[1]
this.key = privatekey.private_key
this.rules = keyrules
})
},
methods:{
copykey(){
uni.setClipboardData({
data: this.key
})
}
}
}
</script>
<style lang="scss">
.keys{
margin: $margin * 2;
background: white;
padding: $padding * 2;
box-shadow: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .02);
border-radius: $radius;
.title{
text-align: center;
font-weight: bold;
font-size: $title-size + 4;
color: $text-color;
}
.key{
padding: $padding * 2 0;
text-align: center;
color: $mian-color;
word-wrap: break-word;
}
.copykey{
background-color: $mian-color;
color: white;
height: 95rpx;
line-height: 95rpx;
text-align: center;
font-size: $title-size;
border-radius: $radius-m;
font-weight: bold;
}
}
.doubt{
margin: $margin $margin * 2;
.doubt-item{
padding: $padding 0;
.title{
font-weight: bold;
color: $text-color;
line-height: 50rpx;
font-size: $title-size + 2;
}
.content{
color: $text-gray-lg;
font-size: $title-size-m;
line-height: 40rpx;
}
}
}
.liability{
text-align: center;
color: $text-gray;
@extend .ios-bottom;
navigator{
font-size: $title-size-sm;
display: inline-block;
line-height: 90rpx;
padding: 0 ($padding * 2);
}
}
</style>

343
pages/wallet/property.vue Normal file
View File

@@ -0,0 +1,343 @@
<template>
<view class="propertyIndex">
<view class="propery">
<view class="propery-content">
<view class="currency">能量球 ( {{ price || '0' }} CNY)</view>
<view class="balance">{{ balance.balance || '0' }}</view>
<view class="frozen">{{ balance.frozen || '0' }} 冻结中</view>
<view class="balance-flex">
<view class="balance-flex-item" @click="showAddress">区块链地址</view>
<view class="balance-flex-item" @click="showPrivatekey('privatekey')">我的私钥</view>
</view>
</view>
</view>
<!-- 账户记录 -->
<view class="record">
<view class="record-tabs">
<view class="tabs-item" :class="logsType === 0 ? 'show': ''" @click="onLogsType(0)">全部</view>
<view class="tabs-item" :class="logsType === 2 ? 'show': ''" @click="onLogsType(2)">收入</view>
<view class="tabs-item" :class="logsType === 1 ? 'show': ''" @click="onLogsType(1)">支出</view>
</view>
<record :list="logs" :logsType="logsType" />
<!-- ios安全距离 -->
<view class="ios-bottom"></view>
</view>
<!-- 支付密码 -->
<uni-popup ref="showPassword">
<view class="validationPassword">
<view class="from">
<view class="title">验证密码</view>
<input class="input" v-model="password" password placeholder="请验证安全密码"/>
</view>
<view class="buttons">
<view class="button cancel" @click="payPassword('cancel', passwordPages)">取消</view>
<view class="button confirm" @click="payPassword('confirm', passwordPages)">验证</view>
</view>
</view>
</uni-popup>
<!-- 原密码弹窗 -->
<!-- <number-jpan :length="6" @closeChange="closeChange($event)" ref="numberPad"></number-jpan> -->
</view>
</template>
<script>
import record from '@/components/property/record'
import {
sum,
price,
logs,
code,
securityCheck // 输入旧密码是否正确
} from '@/apis/interfaces/wallet'
import numberJpan from "@/components/numberJpan/numberJpan.vue";
export default {
components: {
record
},
data() {
return {
balance: {},
price: '0.00',
logs: [],
logsType: 0,
password: '',
passwordPages: ''
};
},
onShow() {
Promise.all([
sum(),
price(),
logs()
]).then(res => {
this.balance = res[0]
this.price = res[1]
this.logs = res[2]
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods: {
// 弹出私钥
showPrivatekey(pages){
this.passwordPages = pages
this.$refs.showPassword.open('center')
},
// 验证私钥
payPassword(type){
if(type === 'confirm'){
if(this.password === '') {
uni.showToast({
title: '请输入安全密码',
icon : 'none'
})
return
}
securityCheck(this.password).then(res => {
this.$refs.showPassword.close()
switch (this.passwordPages){
case 'privatekey':
this.$Router.push({name:'Privatekey', params: {password: this.password}})
break;
case 'resetPassword':
this.$Router.push({name:'ResetPassword', params: {password: this.password}})
break;
}
this.password = ''
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none',
})
})
return
}
this.$refs.showPassword.close()
},
// 交易记录
onLogsType(index) {
if (this.logsType === index) return
this.logsType = index
this.logs = []
logs({
flag: this.logsType
}).then(res => {
this.logs = res
})
},
// 区块地址
showAddress() {
uni.showModal({
title: '我的区块链地址',
content: '\n地址可以理解为银行卡卡号与他人转账时是区块链上的两个地址间的交易行为\n\n' + this.balance.address,
cancelText: '复制',
cancelColor: '#b11eff',
success: (res) => {
if (res.cancel) {
uni.setClipboardData({
data: this.balance.address
})
}
}
})
}
},
onNavigationBarButtonTap(e) {
if (e.index === 0) {
uni.showActionSheet({
// itemList: ['转账', '收款', '提币', '修改密码'],
itemList: ['提现', '修改密码'],
success: (res) => {
switch (res.tapIndex) {
case 0:
console.log('提现了,')
this.$Router.push({
name: 'Extract'
})
break;
case 1:
this.showPrivatekey('resetPassword')
break;
}
uni.hideLoading()
}
})
}
}
}
</script>
<style lang="scss" scoped>
.propertyIndex{
width: 100%;
min-height: 100vh;
background-color: #FFFFFF;
}
// 验证密码弹出层
.validationPassword{
background-color: white;
border-radius: $radius-m;
width: 70vw;
.from{
padding: $padding*2;
.title{
text-align: center;
font-size: $title-size;
padding-bottom: $padding*2;
font-weight: bold;
color: $text-price;
}
.input{
text-align: center;
height: 90rpx;
font-size: $title-size;
border-radius: $radius-m;
background: $border-color-lg;
padding: 0 ($padding*2);
}
}
.buttons{
display: flex;
border-top: solid 1rpx $border-color;
.button{
width: 50%;
font-size: $title-size;
line-height: 90rpx;
height: 90rpx;
text-align: center;
box-sizing: border-box;
&.cancel{
border-right: solid 1rpx $border-color;
color: $text-gray;
}
&.confirm{
color: $text-price;
}
}
}
// .button{
// background-color: $text-price;
// color: white;
// border-radius: $radius-m;
// border: none;
// margin-top: $margin*2;
// font-size: $title-size;
// height: 90rpx;
// line-height: 90rpx;
// }
// .close{
// @extend .button;
// text-align: center;
// color: $text-gray;
// margin-top: $margin;
// background-color: transparent;
// }
}
// 账户
.propery {
position: relative;
padding-top: var(--status-bar-height);
background-image: linear-gradient(to right, #7c52fc, #976dff);
&::before {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
content: " ";
background-image: url(@/static/background/wallet-back.png);
background-size: 100%;
background-repeat: no-repeat;
}
.propery-content {
position: relative;
z-index: 1;
padding: $padding *3 $padding *1.4;
text-align: center;
.currency {
font-size: $title-size-m;
color: rgba($color: white, $alpha: .8);
}
.balance {
font-size: $title-size * 2;
padding: ($padding / 2) 0;
color: white;
}
.frozen {
background: rgba($color: #000000, $alpha: .1);
color: rgba($color: white, $alpha: .7);
display: inline-block;
padding: 0 $padding;
font-size: $title-size-m;
height: 50rpx;
line-height: 50rpx;
border-radius: $radius-m;
border: solid 1rpx rgba($color: white, $alpha: .4)
}
.balance-flex {
display: flex;
justify-content: center;
margin-top: $margin * 3;
.balance-flex-item {
background-color: white;
width: 200rpx;
height: 75rpx;
line-height: 75rpx;
color: $text-price;
margin: 0 $margin;
border-radius: $radius-m;
font-size: $title-size;
}
}
}
}
// 记录
.record {
background-color: white;
border-radius: $radius $radius 0 0;
padding: $padding ($padding * 2);
margin-top: -$margin;
position: relative;
z-index: 2;
.record-tabs {
display: flex;
justify-content: space-around;
font-weight: bold;
font-size: $title-size;
color: $text-gray;
line-height: 70rpx;
margin-bottom: $margin;
.tabs-item {
position: relative;
padding: 0 $padding;
&.show {
color: $text-price;
&::before {
position: absolute;
bottom: 0;
left: $padding;
right: $padding;
height: 4rpx;
content: " ";
background-color: $text-price;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,150 @@
<template>
<view>
<!-- 设置钱包密码 -->
<view class="password">
<view class="prompt">请设置6位数字密码建议不要使用连续的数字</view>
<view class="group">
<view class="inputs">
<label>密码</label>
<input type="digit" v-model="password" maxlength="6" password placeholder="请设置新密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="digit" v-model="verify" maxlength="6" password placeholder="请确认新密码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" form-type="submit" @click="createWallet">确认</button>
</view>
</view>
</template>
<script>
import {
securityReset
} from '@/apis/interfaces/wallet'
export default {
data() {
return {
password: '',
verify: '',
oldPassword: ''
}
},
onLoad() {
this.oldPassword = this.$Route.query.password
},
methods: {
// 激活钱包
createWallet() {
if (this.password === '' || this.verify === '') {
uni.showToast({
icon: 'none',
title: '请设置密码'
})
return
}
if (this.password !== this.verify) {
uni.showToast({
icon: 'none',
title: '两次输入密码不一致'
})
return
}
securityReset({
new_code: this.password,
old_code: this.oldPassword
}).then(res => {
uni.showModal({
title: '提示',
content: '密码已重置',
showCancel:false,
success: res=> {
uni.navigateBack()
}
})
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
}
}
}
</script>
<style lang="scss" scoped>
// 副标题
.sub-title {
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 设置密码
.password {
padding: 0 $padding * 2;
.prompt {
margin-top: $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.group {
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs {
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child {
border-bottom: none;
}
label {
color: $text-gray;
font-size: $title-size-m;
}
input {
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
}
}
// 按钮
.buttons {
padding: $padding * 2;
.text {
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button {
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

77
pages/wallet/results.vue Normal file
View File

@@ -0,0 +1,77 @@
<template>
<view>
<view class="webkit-box results">
<uni-icons type="checkbox-filled" size="88" color="#009b69"></uni-icons>
<view class="title">交易已提交</view>
<view class="sub-title">预计10秒内到账可在交易记录中查询以实际到账时间为准</view>
<view class="hash">
<view class="hash-title">交易哈希</view>
<view class="hash-text">{{hash}}</view>
</view>
<button class="results-button" type="default" @click="navBack">返回</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
hash: ''
};
},
onLoad(e){
this.hash = e.hash
},
methods:{
navBack(){
uni.navigateBack()
}
}
}
</script>
<style lang="scss" scoped>
.results{
height: 100vh;
box-sizing: border-box;
text-align: center;
padding-left: $padding * 3;
padding-right: $padding * 3;
padding-bottom: 20vh;
.title{
font-size: $title-size + 8;
color: $text-color;
font-weight: bold;
line-height: 80rpx;
padding: $padding 0;
}
.sub-title{
color: $text-gray;
line-height: 40rpx;
}
.hash{
background-color: white;
padding: $padding * 2;
border-radius: $radius-lg;
margin-top: $margin * 2;
font-size: $title-size;
color: $text-color;
.hash-title{
padding-bottom: $padding;
}
.hash-text{
word-break:break-all;
}
}
.results-button{
margin-top: $margin * 3;
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
color: white;
font-size: $title-size;
font-weight: bold;
}
}
</style>

216
pages/wallet/transfer.vue Normal file
View File

@@ -0,0 +1,216 @@
<template>
<view>
<!-- 账户余额 -->
<view class="transfer-block">
<view class="unit">OCC</view>
<view class="transfer-flex">
<view class="item ellipsis">
<label>数量</label>{{balance.balance || '0.00'}}
</view>
<view class="item ellipsis">
<label>估值(CNY)</label>{{cny || '0.00'}}
</view>
</view>
</view>
<view class="sub-title">
<text>请认真确认地址及数量地址错误无法找回</text>
</view>
<!-- 转账信息 -->
<view class="password">
<view class="group">
<view class="inputs input-scan">
<label>接收地址</label>
<input type="text" placeholder="请输入接收地址" v-model="address" />
<view class="input-scan-icon" @click="scanCode">
<uni-icons type="scan" size="22" color="#009b69"></uni-icons>
</view>
</view>
<view class="inputs">
<label>转账数量</label>
<input type="number" placeholder="请输入转账数量" v-model="number" />
</view>
</view>
<view class="group">
<view class="inputs">
<label>交易密码</label>
<input type="password" placeholder="请输入安全密码" v-model="password" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" @click="submitTransfer">转账</button>
</view>
</view>
</template>
<script>
import { sum, price, transfer } from '@/apis/interfaces/wallet'
export default {
data() {
return {
balance: {},
cny: '0.00',
address: '',
number: '',
password: ''
}
},
onLoad(e){
if(e.hashAddress) this.address = e.hashAddress
},
mounted() {
Promise.all([
sum(),
price()
]).then(res => {
this.balance = res[0]
if (res[0].balance > 0) this.cny = (res[1] * res[0].balance).toFixed(2)
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods: {
// 转账
submitTransfer(){
if(this.address === '' || this.number === '' || this.password === ''){
let messageText
if(this.address === '') messageText = '请输入接收地址'
else if(this.number === '') messageText = '请输入转账数量'
else if(this.password === '') messageText = '请输入安全密码'
uni.showToast({
icon: 'none',
title: messageText
})
return
}
// 提交转账信息
transfer({
to: this.address,
amount: this.number,
security_code: this.password
}).then(res => {
uni.redirectTo({
url: './results?hash=' + res.txHash + '&number=' + this.number
})
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
// 扫码
scanCode(){
uni.scanCode({
scanType: ['qrCode'],
success: res=> {
this.address = res.result
}
})
}
}
}
</script>
<style lang="scss" scoped>
// 账户余额
.transfer-block{
background-color: white;
margin: $margin * 2;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
padding: $padding $padding + 10;
.unit{
font-weight: bold;
font-size: $title-size + 10;
line-height: 90rpx;
color: $text-color;
}
.transfer-flex{
display: flex;
padding: $padding 0;
border-top: solid 1rpx $border-color;
.item{
width: 50%;
font-size: $title-size-m;
& > label{
color: $text-gray;
padding-right: $padding/2;
}
}
}
}
// 提示信息
.sub-title{
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 转账信息
.password{
padding: 0 $padding * 2;
.group{
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs{
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child{
border-bottom: none;
}
label{
color: $text-gray;
font-size: $title-size-m;
}
input{
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
.input-scan{
position: relative;
padding-right: ($padding*2) + 70;
.input-scan-icon{
position: absolute;
bottom: $padding;
right: $padding;
height: 70rpx;
width: 70rpx;
line-height: 70rpx;
text-align: center;
}
}
}
}
// 按钮
.buttons{
padding: $padding * 2;
.text{
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

169
pages/wallet/validation.vue Normal file
View File

@@ -0,0 +1,169 @@
<template>
<view>
<!-- 提示信息 -->
<view class="prompt">
验证您的钱包助记词
</view>
<!-- 助记词 -->
<view class="mnemonic">
<view
class="item"
v-for="(item, index) in validation"
:key="index"
:class="item === null ? 'hide': ''"
@click="onKeys('removeKey', index)"
>{{ item }}</view>
</view>
<!-- 选择助记词 -->
<block v-if="mnemonic.length > 0">
<view class="mnemonic-title">
按顺序填写助记词
</view>
<view class="mnemonic-select">
<view class="item" v-for="(item, index) in mnemonic" :key="index" @click="onKeys('addKey', index)">{{ item }}</view>
</view>
</block>
<!-- 按钮 -->
<view class="buttons">
<button type="default" @click="verifyMnemonic">验证</button>
</view>
</view>
</template>
<script>
import { hash } from "../../apis/interfaces/wallet"
export default {
data() {
return {
validation : new Array(15).fill(null), // 验证key
mnemonic : [], // 助记词key
sign : '', // 助记词校验签名
seedString : '', // 助记词原词
}
},
onLoad(e) {
let seed = e.seed.split(',')
seed.sort(() => {
return Math.random() - .5
});
this.mnemonic = seed
this.sign = e.sign
this.seedString = e.seed
},
methods: {
// 填写助记词
onKeys(type, index){
if(type === 'addKey') {
this.$set(this.validation, this.validation.findIndex(val => val === null), this.mnemonic[index])
this.$delete(this.mnemonic, index)
return
}
if(type === 'removeKey' && this.validation[index] !== null) {
this.mnemonic.push(this.validation[index])
this.$delete(this.validation, index)
this.validation.push(null)
}
},
// 验证助记词
verifyMnemonic(){
if(this.validation.findIndex(val => val === null) > -1){
uni.showToast({
title: '请完整填写助记词',
icon : 'none'
})
return
}
let seed = this.validation.toString().replace(/,/g, ',')
if (this.seedString !== seed) {
uni.showToast({
title: '验证失败,请确认您的助记词',
icon : 'none'
})
return
}
uni.redirectTo({
url: './create'
})
}
}
}
</script>
<style lang="scss" scoped>
// 提示信息
.prompt{
color: $text-gray;
text-align: center;
line-height: 90rpx;
font-size: $title-size-m;
}
// 选择助记词
.mnemonic-title{
padding-top: $padding * 2;
margin: 0 $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.mnemonic-select{
display: flex;
flex-wrap: wrap;
padding: $padding $padding + $padding / 2;
.item{
background-color: white;
line-height: 68rpx;
height: 68rpx;
width: 68rpx;
text-align: center;
margin: $margin / 2;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
}
}
// 助记词
.mnemonic{
margin: $margin ($margin * 2);
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
padding: $padding;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
.item{
background: rgba($color: $border-color, $alpha: .4);
width: 58rpx;
height: 58rpx;
line-height: 58rpx;
text-align: center;
color: $text-color;
margin: $margin / 2;
&.hide{
border:dashed 1px $border-color;
box-sizing: border-box;
background-color: white;
}
}
}
// 按钮
.buttons{
padding: $padding $padding * 2;
.text{
text-align: center;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $red-color;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
&[disabled]{
background: rgba($color: $mian-color, $alpha: .8);
}
}
}
</style>

BIN
static/icons/logs-null.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
static/imgs/cart_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB