123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- <template>
- <view>
- <!-- 头部 -->
- <headContent borderBottom>
- <template #left>
- <reverse-back />
- </template>
- </headContent>
- <view class="content">
- <view class="pages-title">
- 地址管理
- </view>
- <view class="currency-type">
- <view class="currency-lable">
- <template v-if="currencyInfo">
- <image class="lable-title" :src="currencyInfo.logo" mode="aspectFit"></image>
- <text class="lable-tag">{{ currencyInfo.name }}</text>
- </template>
- </view>
- <view class="select-currency" @click.stop="selectCurrency">
- <text class="select-text">请选择币种</text>
- <text class="select-icon iconfont"></text>
- </view>
- </view>
- <view class="add-box">
- <view class="add-type">
- <text @click.stop="type = 'TRC20'"
- :class="['link-btn' , type === 'TRC20' ? 'active-link-btn' : '']">TRC20</text>
- <text @click.stop="type = 'ERC20'"
- :class="['link-btn' , type === 'ERC20' ? 'active-link-btn' : '']">ERC20</text>
- </view>
- <view class="address-text">
- <text class="address-lable">地址</text>
- <view class="address-info">
- <textarea class="address-input" v-model="address" maxlength="100" auto-height
- placeholder-class="placeholder-class" placeholder="请输入地址" />
- <text class="address-moer" @click.stop="getClipboardData()">粘贴</text>
- <text class="address-link"></text>
- <text class="address-icon iconfont" @click.stop="getScanCode"></text>
- </view>
- </view>
- <view class="address-text">
- <text class="address-lable">钱包备注</text>
- <view class="address-info"><textarea class="address-input" v-model="notes" maxlength="20"
- auto-height placeholder-class="placeholder-class" placeholder="请输入备注" />
- </view>
- </view>
- </view>
- <view class="add-address">
- <view class="add-btn" @click.stop="submitAddress()">
- 添加
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- Api_addAddress
- } from "@/api/index.js"
- import {
- scanCode
- } from "@/utils/common.js"
- export default {
- name: 'addAddress',
- data() {
- return {
- currencyInfo: null,
- type: 'ERC20',
- address: '',
- notes: ''
- };
- },
- onLoad() {
- const eventChannel = this.getOpenerEventChannel();
- // 监听setCurrency事件,获取上一页面通过eventChannel传送到当前页面的数据
- eventChannel.on('setCurrency', data => {
- this.currencyInfo = data
- })
- },
- onShow() {},
- mounted() {
- },
- methods: {
- // 选择币种的回调
- setBiInfo(e) {
- if (e) {
- this.currencyInfo = e
- }
- },
- getScanCode() {
- scanCode().then(res => {
- this.address = res
- }).catch(err => {})
- },
- // 选择币种
- selectCurrency() {
- uni.navigateTo({
- url: `/pages/content/select-currency?type=addAddress`
- })
- },
- submitAddress() {
- if (this.currencyInfo && this.address && this.notes) {
- const obj = {
- currency_id: this.currencyInfo.id,
- type: this.type,
- wallet_address: this.address,
- notes: this.notes
- }
- Api_addAddress(obj).then(res => {
- uni.redirectTo({
- url: '/pages/content/address'
- });
- }).catch(err => {
- })
- }
- },
- getClipboardData(){
- uni.getClipboardData({
- success: res => {
- // console.log( 'getClipboardData = res' , res.data);
- this.address = res.data
- },
- fail:err => {
- console.log( 'getClipboardData = res' , err);
- uni.showToast({
- title:'当前暂无可粘贴内容',
- icon:'none'
- })
- }
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- width: 100%;
- padding: 0 $pages-padding;
- .pages-title {
- height: 120rpx;
- font-size: 60rpx;
- font-weight: bold;
- line-height: 130rpx;
- }
- .currency-type {
- width: 100%;
- min-height: 100rpx;
- display: flex;
- align-items: stretch;
- justify-content: space-between;
- padding: 20rpx 20rpx 20rpx 30rpx;
- background-color: #f6f6f6;
- margin-bottom: 20rpx;
- border-radius: 10rpx;
- .currency-lable {
- display: flex;
- align-items: center;
- .lable-title {
- width: 50rpx;
- height: 50rpx;
- border-radius: 50%;
- }
- .lable-tag {
- font-size: 30rpx;
- font-weight: 700;
- padding-left: 20rpx;
- }
- }
- .select-currency {
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #010101;
- .select-icon {
- font-size: 24rpx;
- color: #010101;
- transform: rotate(180deg);
- }
- }
- }
- .add-box {
- width: 100%;
- padding: 30rpx 20rpx;
- border-radius: 10rpx;
- background-color: #f6f6f6;
- .add-type {
- width: 100%;
- .link-btn {
- display: inline-block;
- width: 140rpx;
- height: 72rpx;
- background: #f6f5f3;
- border-radius: 8px;
- text-align: center;
- line-height: 70rpx;
- font-size: 28rpx;
- font-weight: 400;
- color: #666666;
- border-radius: 8rpx;
- border: 1rpx solid #f6f5f3;
- &:nth-child(n + 2) {
- margin-left: 20rpx;
- }
- }
- .active-link-btn {
- background: #ffffff;
- border-color: #05c175;
- color: #FFBA6A;
- }
- }
- .address-text {
- width: 100%;
- padding-top: 40rpx;
- .address-lable {
- font-size: 30rpx;
- }
- .address-info {
- width: 100%;
- height: 80rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- overflow: hidden;
- border-bottom: 1rpx solid $border-color4;
- .address-input {
- height: 100%;
- font-size: 26rpx;
- padding-right: 20rpx;
- }
- .address-moer {
- flex-shrink: 0;
- font-size: 26rpx;
- color: #FFBA6A;
- }
- .address-link {
- width: 1rpx;
- height: 70%;
- background-color: $border-color4;
- margin: 0 16rpx;
- }
- .address-icon {
- flex-shrink: 0;
- font-size: 40rpx;
- color: #000;
- margin-right: 10rpx;
- }
- .placeholder-class {
- // color: #f6f5f3;
- }
- }
- }
- // <view class="address-text">
- // <text class="address-lable">钱包备注</text>
- // <view class="address-info">
- // <input class="address-input" focus placeholder="自动获得焦点" />
- // </view>
- // </view>
- }
- .add-address {
- width: 100%;
- height: 160rpx;
- padding: 40rpx 10rpx;
- .add-btn {
- width: 100%;
- height: 100%;
- text-align: center;
- line-height: 80rpx;
- background-color: $Theme-Color;
- font-size: 32rpx;
- color: #fff;
- border-radius: 10rpx;
- }
- }
- }
- </style>
|