账户设置密码,转账

This commit is contained in:
唐明明
2022-06-10 12:14:02 +08:00
parent 8b454d6db1
commit 9a1a4b9c50
17 changed files with 3510 additions and 231 deletions

View File

@@ -27,10 +27,12 @@ const request = (parameter, hideLoding = true) => {
})
return
}
console.log(store.getters.getToken)
console.log(uni.getStorageSync('token'))
// 注入header
config.header = {
'Accept': 'application/json',
'Authorization': store.getters.getToken || ''
'Authorization': store.getters.getToken || uni.getStorageSync('token')
}
// 加载提示
if(!hideLoding) uni.showLoading({

View File

@@ -24,7 +24,7 @@ const recharge = (data) => {
})
}
// 订单信息
// 充值订单信息
const payment = (data) => {
return request({
url: "user/transaction/recharge/payment",
@@ -33,8 +33,62 @@ const payment = (data) => {
})
}
// 充值记录
const log = (data) => {
return request({
url: 'user/transaction/recharge/lists'
})
}
// 获取钱包地址
const code = () => {
return request({
url: 'chain/account/code'
})
}
// 转账初始化
const transfer = () => {
return request({
url: 'user/transaction/transfer'
})
}
// 设置支付密码
const setpassword = data => {
return request({
url: 'user/transaction/setpassword',
method: 'POST',
data
})
}
// 获取验证码
const getSms = data => {
return request({
url: 'user/transaction/setpassword/sms',
method: 'POST'
})
}
// 提交转账
const submitTransfer = data => {
return request({
url: 'user/transaction/transfer/store',
method: 'POST',
data
})
}
export {
dt,
recharge,
payment
payment,
log,
code,
transfer,
setpassword,
getSms,
submitTransfer
}

View File

@@ -216,7 +216,7 @@
"path": "pages/account/recharge",
"name": "AccountRecharge",
"style": {
"navigationBarTitleText": "DT积分充值",
"navigationBarTitleText": "充值",
"navigationBarBackgroundColor": "#FFFFFF",
"app-plus": {
"titleNView": {
@@ -261,10 +261,47 @@
"path": "pages/store/shop/shopList",
"name": "ShopList",
"style": {
"navigationBarTitleText": "更多店铺",
"navigationBarTitleText": "店铺",
"navigationBarBackgroundColor": "#FFFFFF",
"enablePullDownRefresh": true
}
}, {
"path": "pages/account/log",
"name": "AccountLog",
"style": {
"navigationBarTitleText": "充值记录",
"navigationBarBackgroundColor": "#FFFFFF"
}
}, {
"path": "pages/account/transfer",
"name": "AccountTransfer",
"style": {
"navigationBarTitleText": "转账",
"navigationBarBackgroundColor": "#F3F6FB"
}
}, {
"path": "pages/account/resetPassword",
"name": "AccountResetPassword",
"style": {
"navigationBarTitleText": "钱包密码",
"navigationBarBackgroundColor": "#F3F6FB"
}
}, {
"path": "pages/account/results",
"name": "Accountresults",
"style": {
"navigationBarTitleText": "转账结果",
"navigationBarBackgroundColor": "#FFFFFF"
}
}, {
"path": "pages/account/code",
"name": "AccountCode",
"style": {
"navigationBarTitleText": "收款码",
"navigationBarBackgroundColor": "#34CE98",
"backgroundColorTop": "#34CE98",
"navigationBarTextStyle": "white"
}
}
],
"tabBar": {

124
pages/account/code.vue Normal file
View File

@@ -0,0 +1,124 @@
<template>
<view class="vertical code">
<view class="vertical code-content">
<view class="sub-title">扫码转入DT积分</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 greed" type="default" @click="copyAddress">复制</button>
</view>
</view>
<view class="footer">共力生态</view>
</view>
</template>
<script>
import { code } from '@/apis/interfaces/account'
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
})
}
}
}
</script>
<style lang="scss" scoped>
.code{
height: 100vh;
background:linear-gradient(to bottom, $main-color, #22ab98);
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;
}
.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: 28rpx;
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: $text-price;
}
&.greed{
background: $main-color;
}
}
}
}
// 底部
.footer{
height: 10vh;
line-height: 10vh;
text-align: center;
font-size: 28rpx;
color: rgba(255, 255, 255, .5);
}
}
</style>

View File

@@ -1,9 +1,13 @@
<template>
<view class="content">
<view class="dt-header">
<view class="dt-header-number">
<view class="title">DT积分余额</view>
<view class="num">{{score}}</view>
</view>
<button class="transfer" size="mini" @click="onTransfer('AccountCode')">收款</button>
<button class="transfer" size="mini" @click="onTransfer('AccountTransfer')">转账</button>
</view>
<block v-if="logs.length > 0">
<view class="logs-title">账户记录</view>
<view class="logs-item">
@@ -52,6 +56,10 @@
}).catch(err => {
console.log(err)
})
},
// 转账
onTransfer(name){
this.$Router.push({name})
}
},
onNavigationBarButtonTap() {
@@ -68,17 +76,40 @@
background: $window-color;
min-height: 100vh;
.dt-header{
display: flex;
justify-content: space-between;
flex-direction: row;
background: $main-color;
padding: $padding*3 $padding $padding*2;
align-items: center;
.dt-header-number{
width: calc(100% - 330rpx);
.title{
color: rgba(255, 255, 255, .9);
font-size: 28rpx;
@extend .nowrap;
}
.num{
font-weight: bold;
font-size: 60rpx;
padding-top: 10rpx;
color: white;
@extend .nowrap;
}
}
.transfer[size="mini"]{
width: 150rpx;
height: 80rpx;
border-radius: 40rpx;
line-height: 80rpx;
background: white;
font-size: 30rpx;
color: $main-color;
margin: 0;
font-weight: bold;
&::after{
display: none;
}
}
}
// 账户记录

90
pages/account/log.vue Normal file
View File

@@ -0,0 +1,90 @@
<template>
<view class="logs">
<block v-if="logs.length > 0">
<view class="logs-item" v-for="(item, index) in logs" :key="index">
<view class="logs-item-flex">
<view class="title">充值DT积分</view>
<view class="price">{{item.amount}}</view>
</view>
<view class="logs-item-flex">
<view class="time">{{item.created_at}}</view>
<view class="status">{{item.status_text}}</view>
</view>
</view>
</block>
<block v-else>
<view class="vertical pages-empty">
<u-empty
icon="http://cdn.uviewui.com/uview/empty/list.png"
textColor="#999"
text="暂无充值记录"
>
</u-empty>
</view>
</block>
</view>
</template>
<script>
import { log } from '@/apis/interfaces/account.js'
export default {
data() {
return {
logs: [],
pages: {}
};
},
created() {
log().then(res => {
this.logs = res.data
this.pages = res.pages
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}
}
</script>
<style lang="scss">
// 数据为空
.pages-empty{
height: 80vh;
}
// 记录
.logs{
background-color: $window-color;
min-height: 100vh;
overflow: hidden;
box-sizing: border-box;
padding: 10rpx 0;
.logs-item{
border-radius: $radius;
background: white;
margin: ($margin - 10) $margin;
padding: $padding;
&-flex{
display: flex;
justify-content: space-between;
.title{
font-weight: bold;
font-size: 32rpx;
}
.price{
font-size: 30rpx;
font-weight: bold;
line-height: 40rpx;
color: $text-price;
}
.time,
.status{
font-size: 26rpx;
line-height: 40rpx;
color: gray;
}
}
}
}
</style>

View File

@@ -115,7 +115,7 @@
}
},
onNavigationBarButtonTap() {
console.log('充值记录')
this.$Router.push({name: 'AccountLog'})
}
}
</script>

View File

@@ -0,0 +1,203 @@
<template>
<view class="content">
<!-- 设置支付密码 -->
<view class="password">
<view class="prompt">
<view class="prompt-code">验证码已发送至{{phone}} <button size="mini" :disabled="getCodeState" @click="getCode">{{sendCode}}</button></view>
<view>请设置6位数字密码建议不要使用连续的数字</view>
</view>
<view class="group">
<view class="inputs">
<label>设密码</label>
<input type="number" v-model="password" maxlength="6" password placeholder="请设置支付密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="number" v-model="verify" maxlength="6" password placeholder="请确认支付密码" />
</view>
<view class="inputs">
<label>验证码</label>
<input type="number" v-model="code" maxlength="4" placeholder="请输入验证码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" form-type="submit" @click="createWallet">确认</button>
</view>
</view>
</template>
<script>
import { setpassword, getSms } from '@/apis/interfaces/account'
export default {
data() {
return {
sendCode : '',
getCodeState: false,
phone : '',
code : '',
password : '',
verify : ''
}
},
onLoad() {
this.phone = this.$Route.query.phone
this.getCode()
},
methods: {
// 获取验证码
getCode(){
let outTime;
let smsTime = 60;
getSms().then(res => {
uni.showToast({
title: res,
icon: "none",
});
this.getCodeState = true;
this.sendCode = smsTime + 's后重新获取';
outTime = setInterval(() => {
if (smsTime <= 1) {
this.getCodeState = false;
this.sendCode = '重新获取';
clearInterval(outTime);
return
}
this.sendCode = smsTime + 's后重新获取';
smsTime -= 1;
}, 1000);
}).catch((err) => {
uni.showToast({
title: err.message,
icon: "none",
});
});
},
// 激活钱包
createWallet() {
if (this.password === '' || this.verify === '') {
uni.showToast({
icon: 'none',
title: '请设置支付密码'
})
return
}
if (this.password !== this.verify) {
uni.showToast({
icon: 'none',
title: '两次输入密码不一致'
})
return
}
setpassword({
password: this.password,
password_confirmation: this.verify,
code: this.code
}).then(res => {
uni.showModal({
title: '提示',
content: '支付密码设置成功',
showCancel:false,
success: res=> {
uni.navigateBack()
}
})
}).catch(err => {
console.log(err)
uni.showToast({
icon: 'none',
title: err.message
})
})
}
}
}
</script>
<style lang="scss" scoped>
.content{
background: $window-color;
min-height: 100vh;
overflow: hidden;
}
// 副标题
.sub-title {
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 设置密码
.password {
padding: 0 $padding;
.prompt {
margin-top: $margin * 2;
font-size: $title-size-m;
color: gray;
text-align: center;
&-code{
line-height: 50rpx;
button[size="mini"]{
vertical-align: top;
margin-left: 20rpx;
font-size: $title-size-m;
background: transparent;
color: $main-color;
height: 50rpx;
line-height: 50rpx;
width: auto;
padding: 0;
&::after{
display: none;
}
}
}
}
.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 $padding;
button {
border-radius: 45rpx;
height: 90rpx;
line-height: 90rpx;
background-color: $main-color;
color: white;
font-weight: bold;
font-size: $title-size;
&::after{
display: none;
}
}
}
</style>

81
pages/account/results.vue Normal file
View File

@@ -0,0 +1,81 @@
<template>
<view>
<view class="vertical results">
<uni-icons type="checkbox-filled" size="88" color="#34CE98"></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;
border-radius: 45rpx;
background-color: $main-color;
color: white;
font-size: $title-size;
font-weight: bold;
&::after{
display: none;
}
}
}
</style>

227
pages/account/transfer.vue Normal file
View File

@@ -0,0 +1,227 @@
<template>
<view class="transfer">
<!-- 账户余额 -->
<view class="transfer-block">
<view class="unit">DT积分</view>
<view class="transfer-flex">
<view class="item ellipsis">
<label>余额</label>{{balance || '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="#34CE98"></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 { transfer, submitTransfer } from '@/apis/interfaces/account'
export default {
data() {
return {
balance : '0.00',
address : '',
number : '',
password : ''
}
},
onLoad(e){
if(e.hashAddress) this.address = e.hashAddress
},
onShow() {
uni.showLoading({
title: '获取账户信息',
})
transfer().then(res => {
let phone = res.mobile
this.balance = res.balance
if(!res.has_transfer_password){
uni.showModal({
title : '提示',
content : '暂未设置账户密码,无法发起转账,请设置后重试',
cancelText : '稍后设置',
confirmText : '立即设置',
success : modalRes => {
if(modalRes.confirm){
this.$Router.push({name: 'AccountResetPassword', params: {phone}})
return
}
this.$Router.back()
}
})
}
uni.hideLoading()
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
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
}
// 提交转账信息
submitTransfer({
addr: this.address,
amount: this.number,
transfer_password: this.password
}).then(res => {
uni.redirectTo({
url: './results?hash=' + res.hash + '&number=' + this.amount
})
}).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{
background: $window-color;
min-height: 100vh;
overflow: hidden;
}
// 账户余额
.transfer-block{
background-color: window-color;
margin: $margin;
border-radius: $radius;
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: 100%;
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 $margin $margin;
font-size: $title-size-m;
}
// 转账信息
.password{
padding: 0 $padding;
.group{
margin-top: $margin;
border-radius: $radius;
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 $padding;
button{
height: 90rpx;
line-height: 90rpx;
background-color: $main-color;
border-radius: 45rpx;
color: white;
font-weight: bold;
font-size: $title-size;
&::after{
display: none;
}
}
}
</style>

View File

@@ -100,13 +100,6 @@
<uni-icons class="forward" type="forward" color="#999" />
</view>
</view>
<view class="btns-box">
<view class="btns-box-item">
<image class="icon" src="@/static/user/userIcon_03.png" mode="widthFix" />
供应商申请
<uni-icons class="forward" type="forward" color="#999" />
</view>
</view>
<view class="btns-box">
<view class="btns-box-item">
<image class="icon" src="@/static/user/userIcon_03.png" mode="widthFix" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB