123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <view class="container">
- <view class="infoBox">
- <view class="title">{{$t("transfer.收款地址")}}</view>
- <view class="inputBox">
- <view class="flex_item inpitTpl">
- <image src="/static/img/img21.png" style="width: 33rpx;height: 36rpx;margin-right: 25rpx;"></image>
- <input type="text" :placeholder='$t("transfer.请输入或长按粘贴地址")' v-model="address" style="width: 100%;"/>
- </view>
- </view>
- </view>
- <view class="infoBox">
- <view class="title">{{$t("transfer.转账金额")}}</view>
- <view class="inputBox flex">
- <view class="flex_item inpitTpl">
- <image src="/static/img/img21.png" style="width: 33rpx;height: 36rpx;margin-right: 25rpx;"></image>
- <input type="text" :placeholder='$t("transfer.请输入转账金额")' v-model="money"/>
- </view>
- <view class="all" @click="money = userInfo.NUSD * 1">{{$t("transfer.全部")}}</view>
- </view>
- <view class="tipTpl">{{$t("transfer.可转账余额")}}:{{userInfo.NUSD * 1}}NUSD</view>
- </view>
- <!-- <view class="infoBox">
- <view class="title">手续费</view>
- <view class="inputBox flex">
- <input type="text" v-model="free"/>
- <view class="tip">USTD</view>
- </view>
- </view> -->
- <view class="footBox">
- <!-- <view class="flex numBox">
- <view class="numName">实际到账</view>
- <view class="num">{{num}}</view>
- </view> -->
- <view class="btnBox">
- <view class="submitBtn" :class="{ submitNo: !payOn }" @click="payOn ? transfer() : ''">{{$t("property.转账")}}</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {getUserInfo,trade} from '@/api/login.js';
- export default {
- data () {
- return {
- address:"",
- money:"",
- free:"--",
- num:"--",
- userInfo:'',
- payOn:true
- }
- },
- onLoad () {
- this.getUserInfo()
- },
- onShow () {
- uni.setNavigationBarTitle({
- title: this.$t("property.转账")
- });
- },
- methods: {
- transfer(){
- let obj = this
- if(obj.address == ''){
- uni.showToast({
- title: this.$t("transfer.请输入收款地址"),
- icon: "none",
- });
- return;
- }
- if(obj.money == ''){
- uni.showToast({
- title: this.$t("transfer.请输入转账金额"),
- icon: "none",
- });
- return;
- }
- obj.payOn = false
- ethereum.request({
- method: 'eth_requestAccounts'
- }).then((account) => {
- const PKR_TRADE = 'PKR_TRADE' + (new Date()).getTime();
- ethereum.request({
- "method": "personal_sign",
- "params": [
- PKR_TRADE,
- account[0]
- ]
- }).then((res) => {
- obj.trade(res,PKR_TRADE);
- });
- });
- },
- trade(sign,msg){
- let obj = this
- trade({
- sign,
- msg,
- address:obj.address,
- token:'NUSD',
- num:obj.money,
- }).then(function(res){
- if(res.code == 0){
- obj.payOn = true
- uni.showToast({
- title: obj.$t("transfer.参数错误"),
- icon: "error",
- });
- }else{
- uni.showToast({
- title:obj.$t("transfer.转账成功"),
- icon: "success",
- });
- obj.payOn = true
- setTimeout(function () {
- obj.$router.go(0)
- }, 1000);
- }
- }).catch(e => {
- obj.payOn = true
- console.log(e,11111);
- });
- },
- getUserInfo(){
- let obj = this
- getUserInfo({}).then(({data}) => {
- obj.userInfo = data
- }).catch(e => {
- console.log(e.msg);
- });
- },
- },
- }
- </script>
- <style lang="scss">
- page {
- width: 100%;
- .container {
- width: 100%;
- }
- }
- .infoBox{
- color: #fff;
- padding: 58rpx 38rpx 0rpx 38rpx;
- .title{
- font-weight: bold;
- font-size: 32rpx;
- padding-bottom: 10rpx;
- }
- .inputBox{
- border-bottom: 1rpx solid #CBCBCA;
- padding: 30rpx 0rpx;
- .all{
- font-weight: 500;
- font-size: 28rpx;
- color: #ABB1CC;
- background: linear-gradient(258deg, #FFF0CF 0%, #CBA16B 30.0048828125%, #FCE9CF 67.67578125%, #C29963 100%);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- }
- .tip{
- font-weight: 500;
- font-size: 30rpx;
- color: #888785;
- }
- }
- .tipTpl{
- font-weight: 500;
- font-size: 24rpx;
- color: #888785;
- padding-top: 15rpx;
- }
- }
- .footBox{
- position: fixed;
- bottom: 0;
- width: 100%;
- background: #1A1A17;
- color: #fff;
- padding: 50rpx 42rpx;
- .numBox{
- .numName{
- font-weight: 500;
- font-size: 26rpx;
- color: #888785;
- }
- }
- .btnBox{
- .submitBtn{
- background: linear-gradient(258deg, #FFF0CF, #CBA16B, #FCE9CF, #C29963);
- border-radius: 10rpx;
- font-weight: bold;
- font-size: 32rpx;
- color: #31190B;
- text-align: center;
- padding: 20rpx 0rpx;
- }
- .submitNo {
- background: #999999 !important;
- color: #fff !important;
- }
- }
- }
- </style>
|