xiaomei 10 mesiacov pred
rodič
commit
459d3a6f29

+ 22 - 0
src/api/home.js

@@ -743,4 +743,26 @@ export default {
       data
     })
   },
+  //赠送茶宝说明
+  chabaoInfo(data) {
+    return request.request({
+      url: 'ledger/chabao',
+      method: "post",
+      headers: {
+        'Accept-Language': localStorage.getItem('language') || 'zh-cn',
+      },
+      data
+    })
+  },
+  //赠送茶宝
+  chabaoGift(data) {
+    return request.request({
+      url: '/ledger/chabaoGift',
+      method: "post",
+      headers: {
+        'Accept-Language': localStorage.getItem('language') || 'zh-cn',
+      },
+      data
+    })
+  },
 }

+ 9 - 1
src/language/en.json

@@ -204,5 +204,13 @@
   "lang203": "Swipe up to load more",
   "lang204": "All orders",
   "lang205": "Asset Details",
-  "lang206": "Transfer: "
+  "lang206": "Transfer: ",
+  "lang207": "The other party's address",
+  "lang208": "Enter the wallet address of the other party",
+  "lang209": "Amount of gift",
+  "lang210": "Network fee",
+  "lang211": "Please enter the wallet address of the other party",
+  "lang212": "Please enter the amount of gift",
+  "lang213": "Are you sure to give ChaBao",
+  "lang214": "Confirm the gift"
 }

+ 12 - 1
src/language/zh.json

@@ -204,5 +204,16 @@
   "lang203": "上滑加载更多",
   "lang204": "全部订单",
   "lang205": "资产明细",
-  "lang206": "转让:"
+  "lang206": "转让:",
+  "lang207": "对方地址",
+  "lang208": "输入对方钱包地址",
+  "lang209": "赠送数量",
+  "lang210": "网络费",
+  "lang211": "请输入对方钱包地址",
+  "lang212": "请输入赠送的数量",
+  "lang213": "是否确定赠送茶宝",
+  "lang214": "确认赠送",
+  "lang215": "",
+  "lang216": "",
+  "lang217": ""
 }

+ 9 - 0
src/router/index.js

@@ -32,6 +32,7 @@ import setting from '../views/mine/setting.vue';  //设置
 import TransferDetail from '../views/mine/TransferDetail.vue'; //详情
 import recharge from '../views/mine/recharge.vue'; //充值
 import rechargeRecord from '../views/mine/rechargeRecord.vue'; //充值记录
+import sendChaBao from '../views/mine/sendChaBao.vue'; //赠送茶宝
 Vue.use(VueRouter);
 const routes = [
 
@@ -206,6 +207,14 @@ const routes = [
           requiresAuth: true
         }
       },
+      {
+        path: 'sendChaBao',
+        name: 'sendChaBao',
+        component: sendChaBao,
+        meta: {
+          requiresAuth: true
+        }
+      },
     ],
   },
 ];

+ 25 - 9
src/views/mine/assets.vue

@@ -16,8 +16,13 @@
           <div class="total">
             <span>{{ Math.floor(assets * 100) / 100 || 0 }}</span>
           </div>
-          <div class="buy" @click="navigation('recharge')">
-            <van-button class="buy_btn" type="primary">{{ $t('lang81') }}</van-button>
+          <div class="buy_box">
+            <div class="buy" @click="navigation('recharge')">
+              <van-button class="buy_btn" type="primary">{{ $t('lang138') }}</van-button>
+            </div>
+            <div class="buy" @click="navigation('sendChaBao')">
+              <van-button class="buy_btn" type="primary">{{ $t('lang186') }}</van-button>
+            </div>
           </div>
         </div>
 
@@ -125,7 +130,7 @@
           <div class="f-r">
             <span> {{ $t('lang89') }} </span>
             <div class="d">
-              <van-field v-model="price" :placeholder="$t('lang93')" class="input" />
+              <van-field v-model="price" :placeholder="$t('lang93')" type="number" class="input" />
               <span class="s">{{ $t('lang174') }}</span>
             </div>
           </div>
@@ -330,6 +335,7 @@ export default {
           this.page = 1;
           this.nft_list = [];
           this.getNftList();
+          this.price = ""
           Notify({ type: 'success', message: this.$t('lang152') });
         } else {
           this.$toast(res.msg);
@@ -441,6 +447,7 @@ export default {
   font-weight: 550;
   background: #fff;
   padding: 14px 0;
+  height: 50px;
   z-index: 999;
   .arrow_img {
     position: absolute;
@@ -493,6 +500,10 @@ export default {
     margin: 0 6px;
   }
   .navbar {
+    position: fixed;
+    top: 50px;
+    z-index: 999;
+    width: 100%;
     color: #000;
     height: 50px;
     display: flex;
@@ -510,7 +521,7 @@ export default {
   .pd {
     min-height: 100vh;
     padding: 4px;
-    margin-top: 4px;
+    margin-top: 54px;
     background-color: #fff;
   }
   .total_box {
@@ -538,11 +549,16 @@ export default {
     .text {
       color: rgba(#fff, 0.8);
     }
-    .buy {
+    .buy_box {
       position: absolute;
-      right: 14px;
       bottom: 14px;
-
+      display: flex;
+      width: 100%;
+      padding: 0 14px;
+      align-items: center;
+      justify-content: space-between;
+    }
+    .buy {
       &_btn {
         color: #29b286;
         height: 30px;
@@ -588,7 +604,7 @@ export default {
   .bare {
     text-align: center;
     font-size: 14px;
-    padding: 60px 14px;
+    padding: 110px 14px 60px;
     color: #aaa;
   }
   .list {
@@ -668,7 +684,7 @@ export default {
     }
   }
   .pd1 {
-    padding: 14px;
+    padding: 64px 14px 14px;
   }
   .goods_list {
     position: relative;

+ 1 - 1
src/views/mine/recharge.vue

@@ -24,7 +24,7 @@
           <div class="box">
             <div class="box_item">
               <span class="left">{{ $t('lang148') }}</span>
-              <van-field v-model="amount" :placeholder="$t('lang119')" class="input" input-align="right" />
+              <van-field v-model="amount" :placeholder="$t('lang119')" type="number" class="input" input-align="right" />
             </div>
             <div class="box_item">
               <span class="left">{{ $t('lang124') }}</span>

+ 387 - 0
src/views/mine/sendChaBao.vue

@@ -0,0 +1,387 @@
+<template>
+  <div class="assets">
+    <div class="head">
+      <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
+      <span>{{ $t('lang186') }}</span>
+    </div>
+    <div class="pd">
+      <div class="">
+        <div class="total_box">
+          <div>
+            <span class="text">{{ $t('lang147') }}</span>
+          </div>
+          <div class="total">
+            <span>{{ Math.floor(assets * 100) / 100 || 0 }}</span>
+          </div>
+          <div class="bo">
+            <!-- <img src="@/assets/images/chance.png" class="icon" />
+            <span>{{ $t('lang121') }}</span> -->
+          </div>
+          <div @click="navigation('share')" class="mx">{{ $t('lang122') }}</div>
+        </div>
+
+        <div class="list">
+          <div class="box">
+            <div class="box_item">
+              <span class="left">{{ $t('lang207') }}</span>
+              <!-- <van-field v-model="send_address" placeholder="输入对方钱包地址" class="input" input-align="right" /> -->
+              <van-field v-model="send_address" type="textarea" style="height: 46px" :placeholder="$t('lang208')" class="input" input-align="right" />
+            </div>
+            <div class="box_item">
+              <span class="left">{{ $t('lang209') }}</span>
+              <van-field v-model="amount" :placeholder="$t('lang119')" type="number" class="input" input-align="right" />
+            </div>
+            <div class="box_item">
+              <span class="left">{{ $t('lang210') }}</span>
+              <span>{{ parseFloat((networkfee * 100).toFixed(2)) }}%</span>
+            </div>
+            <!-- <div class="box_item">
+              <span class="left">{{ $t('lang125') }}</span>
+              <van-field v-model="value" :placeholder="$t('lang118')" class="input" input-align="right" />
+            </div> -->
+          </div>
+        </div>
+        <div class="buy" @click="submit">
+          <van-button class="buy_btn" type="primary">{{ $t('lang214') }}</van-button>
+        </div>
+        <div class="tips">
+          <div>{{ $t('lang116') }}</div>
+          <div>{{ tip }}</div>
+        </div>
+      </div>
+    </div>
+    <van-overlay :show="show">
+      <div class="wrapper" @click.stop>
+        <van-loading type="spinner" class="loading" />
+      </div>
+    </van-overlay>
+  </div>
+</template>
+
+<script>
+import { homeApi } from '@/api/index';
+import { dateFormat } from '@/utils/formatTool.js';
+import packApi from '@/methods/pack.js';
+import { getErc20Contract } from '@/utils/contractHelp';
+import usdt from '@/methods/usdt.js';
+import { formatAmount } from '@/utils/format.js';
+import { Dialog, Notify, Toast } from 'vant';
+export default {
+  data() {
+    return {
+      assets: 0,
+      amount: '',
+      payToken: undefined, //支付币种
+      walletBalance: 0,
+      show: false,
+      send_address: '',
+      tip: '',
+      networkfee: 0,
+    };
+  },
+  mounted() {
+    this.getUserInfo();
+    this.chabaoInfo();
+  },
+  methods: {
+    //返回上一页
+    back() {
+      this.$router.back();
+    },
+    navigation(name) {
+      this.$router.push({ name });
+    },
+    chabaoInfo() {
+      homeApi.chabaoInfo().then(res => {
+        if (res.code == 200) {
+          console.log(res.data);
+          this.networkfee = res.data.value;
+          this.tip = res.data.text;
+        } else {
+        }
+      });
+    },
+    getUserInfo() {
+      homeApi.getUserInfo().then(res => {
+        if (res.code == 200) {
+          this.assets = res.data.balance;
+          this.account = res.data.address;
+        }
+      });
+    },
+    // getPayToken() {
+    //   packApi.getPayToken(this.account).then(res => {
+    //     this.payToken = res;
+    //     // this.handleApproveBtnShow(); //获取授权余额
+    //     this.getWalletBalance(); //获取钱包余额
+    //   });
+    // },
+    // // 查询链上钱包余额
+    // async getWalletBalance() {
+    //   const erc20Contract = getErc20Contract(this.payToken);
+    //   let bal = await erc20Contract.methods.balanceOf(this.account).call();
+    //   this.walletBalance = (formatAmount(bal, 18) * 1).toFixed(2);
+    // },
+    submit() {
+      if (!this.send_address) {
+        return this.$toast(this.$t('lang211'));
+      }
+      if (!this.amount) {
+        return this.$toast(this.$t('lang212'));
+      }
+      let _this = this;
+      Dialog.confirm({
+        title: _this.$t('lang136'),
+        message: _this.$t('lang213'),
+        confirmButtonText: _this.$t('lang111'),
+        cancelButtonText: _this.$t('lang135'),
+      })
+        .then(() => {
+          _this.show = true;
+          homeApi
+            .chabaoGift({
+              amount: _this.amount,
+              address: _this.send_address,
+            })
+            .then(res => {
+              if (res.code == 200) {
+                _this.amount = '';
+                _this.send_address = '';
+                _this.show = false;
+                _this.getUserInfo();
+                Notify({ type: 'success', message: _this.$t('lang152') });
+              } else if (res.code == 15001) {
+                _this.show = false;
+                Toast({ message: `${res.msg}` });
+                setTimeout(() => {
+                  this.$router.push('recharge');
+                }, 300);
+              } else {
+                _this.show = false;
+                Toast({ message: `${res.msg}` });
+              }
+            })
+            .catch(err => {
+              _this.show = false;
+              _this.$toast(err.msg);
+              return;
+            });
+        })
+        .catch(() => {
+          // on cancel
+        });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.head {
+  position: fixed;
+  top: 0;
+  left: 0;
+  width: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  color: rgba(#000, 0.8);
+  letter-spacing: 1.5px;
+  font-weight: 550;
+  background: #fff;
+  padding: 15px 0;
+  // z-index: 99;
+  .arrow_img {
+    position: absolute;
+    left: 20px;
+    width: 10px;
+    height: 16px;
+    // transform: translate(0, -50%);
+  }
+}
+.f-sb {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.f-sa {
+  display: flex;
+  align-items: center;
+  justify-content: space-around;
+}
+.f-sb-n {
+  display: flex;
+  align-items: flex-end;
+  justify-content: space-between;
+}
+.f-col {
+  display: flex;
+  flex-direction: column;
+}
+.assets {
+  min-height: 100vh;
+  padding: 50px 0 0;
+  // background-color: #fafbfc;
+  .top {
+    color: #000;
+    padding-bottom: 16px;
+    margin: 0 6px;
+  }
+  .pd {
+    padding: 4px;
+    margin-top: 4px;
+    // background-color: #fff;
+  }
+  .total_box {
+    position: relative;
+    display: flex;
+    // align-items: center;
+    flex-direction: column;
+    justify-content: space-between;
+    // position: relative;
+    font-size: 13px;
+    color: #fff;
+    height: 140px;
+    // border-radius: 16px;
+    padding: 20px 20px;
+    box-sizing: border-box;
+    border-radius: 10px;
+    margin: 10px;
+    background: linear-gradient(to right, #1ab986, #25d7bb);
+
+    .total {
+      font-size: 28px;
+      // text-align: center;
+      padding-top: 10px;
+    }
+    .bo {
+      font-size: 12px;
+      display: flex;
+      align-items: center;
+      color: rgba(#fff, 0.8);
+      margin: 10px 10px 0 0;
+
+      .icon {
+        width: 20px;
+        height: 20px;
+        margin-right: 6px;
+        border-radius: 50%;
+        padding: 4px;
+        background-color: rgba(#000, 0.1);
+      }
+    }
+    .mx {
+      position: absolute;
+      right: 20px;
+      width: fit-content;
+      font-size: 11px;
+      color: rgba(#f7f7f7, 0.9);
+      padding: 2px 12px;
+      border-radius: 10px;
+      background-color: rgba(#000, 0.1);
+    }
+    .text {
+      color: rgba(#fff, 0.8);
+    }
+    .buy {
+      position: absolute;
+      right: 14px;
+      bottom: 14px;
+
+      &_btn {
+        color: #29b286;
+        height: 30px;
+        line-height: 30px;
+        font-size: 14px;
+        background-color: #ffffff;
+        border: none;
+        padding: 0 16px;
+        white-space: nowrap;
+        border-radius: 30px;
+      }
+    }
+  }
+
+  .bare {
+    text-align: center;
+    font-size: 14px;
+    padding: 60px 14px;
+    color: #888;
+  }
+  .list {
+    border-radius: 20px;
+    padding: 0 20px;
+    margin-top: 16px;
+    background-color: #fff;
+    margin: 16px 6px;
+
+    .box {
+      width: 100%;
+      color: rgba(51, 51, 51, 1);
+      font-size: 14px;
+      padding: 18px 0 18px;
+      .box_item:last-child {
+        border-bottom: none;
+      }
+      .box_item:first-child {
+        align-items: flex-start;
+      }
+      
+      &_item {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        padding: 16px 0;
+        border-bottom: 0.5px solid rgba(190, 190, 190, 0.15);
+
+        .key {
+          color: #aaa;
+          font-size: 12px;
+        }
+        .left {
+          font-size: 13px;
+        }
+        .mobile {
+          font-size: 14px;
+          color: #000;
+          font-weight: 550;
+        }
+        .input {
+          width: 180px;
+        }
+      }
+    }
+  }
+  .buy {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    margin-top: 30px;
+    &_btn {
+      width: 80%;
+      height: 46px;
+      line-height: 46px;
+      font-size: 14px;
+      background-color: #29b286;
+      border: none;
+      padding: 0 10px;
+      white-space: nowrap;
+      border-radius: 30px;
+    }
+  }
+  .tips {
+    color: #aaa;
+    font-size: 12px;
+    line-height: 180%;
+    padding: 14px;
+  }
+}
+.wrapper {
+  // display: flex;
+  // justify-content: center;
+  .loading {
+    position: absolute;
+    left: 46%;
+    top: 46%;
+  }
+}
+</style>

+ 2 - 2
src/views/mine/setting.vue

@@ -7,12 +7,12 @@
 
     <div class="content">
       <div class="list">
-        <div @click="showPopup(0)" class="li">
+        <div class="li">
           <div class="li_left">
             <span>{{ $t('lang97') }}</span>
           </div>
           <span style="color: #aaaaaa" v-if="userinfo.nickname">{{ userinfo.nickname }}</span>
-          <span style="color: #aaaaaa" v-else>{{ $t('lang98') }}</span>
+          <span style="color: #aaaaaa" v-else></span>
         </div>
         <div @click="showPopup(1)" class="li">
           <div class="li_left">