add-address.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <headContent borderBottom>
  5. <template #left>
  6. <reverse-back />
  7. </template>
  8. </headContent>
  9. <view class="content">
  10. <view class="pages-title">
  11. 地址管理
  12. </view>
  13. <view class="currency-type">
  14. <view class="currency-lable">
  15. <template v-if="currencyInfo">
  16. <image class="lable-title" :src="currencyInfo.logo" mode="aspectFit"></image>
  17. <text class="lable-tag">{{ currencyInfo.name }}</text>
  18. </template>
  19. </view>
  20. <view class="select-currency" @click.stop="selectCurrency">
  21. <text class="select-text">请选择币种</text>
  22. <text class="select-icon iconfont">&#xe8b5;</text>
  23. </view>
  24. </view>
  25. <view class="add-box">
  26. <view class="add-type">
  27. <text @click.stop="type = 'TRC20'"
  28. :class="['link-btn' , type === 'TRC20' ? 'active-link-btn' : '']">TRC20</text>
  29. <text @click.stop="type = 'ERC20'"
  30. :class="['link-btn' , type === 'ERC20' ? 'active-link-btn' : '']">ERC20</text>
  31. </view>
  32. <view class="address-text">
  33. <text class="address-lable">地址</text>
  34. <view class="address-info">
  35. <textarea class="address-input" v-model="address" maxlength="100" auto-height
  36. placeholder-class="placeholder-class" placeholder="请输入地址" />
  37. <text class="address-moer" @click.stop="getClipboardData()">粘贴</text>
  38. <text class="address-link"></text>
  39. <text class="address-icon iconfont" @click.stop="getScanCode">&#xe8b6;</text>
  40. </view>
  41. </view>
  42. <view class="address-text">
  43. <text class="address-lable">钱包备注</text>
  44. <view class="address-info"><textarea class="address-input" v-model="notes" maxlength="20"
  45. auto-height placeholder-class="placeholder-class" placeholder="请输入备注" />
  46. </view>
  47. </view>
  48. </view>
  49. <view class="add-address">
  50. <view class="add-btn" @click.stop="submitAddress()">
  51. 添加
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. Api_addAddress
  60. } from "@/api/index.js"
  61. import {
  62. scanCode
  63. } from "@/utils/common.js"
  64. export default {
  65. name: 'addAddress',
  66. data() {
  67. return {
  68. currencyInfo: null,
  69. type: 'ERC20',
  70. address: '',
  71. notes: ''
  72. };
  73. },
  74. onLoad() {
  75. const eventChannel = this.getOpenerEventChannel();
  76. // 监听setCurrency事件,获取上一页面通过eventChannel传送到当前页面的数据
  77. eventChannel.on('setCurrency', data => {
  78. this.currencyInfo = data
  79. })
  80. },
  81. onShow() {},
  82. mounted() {
  83. },
  84. methods: {
  85. // 选择币种的回调
  86. setBiInfo(e) {
  87. if (e) {
  88. this.currencyInfo = e
  89. }
  90. },
  91. getScanCode() {
  92. scanCode().then(res => {
  93. this.address = res
  94. }).catch(err => {})
  95. },
  96. // 选择币种
  97. selectCurrency() {
  98. uni.navigateTo({
  99. url: `/pages/content/select-currency?type=addAddress`
  100. })
  101. },
  102. submitAddress() {
  103. if (this.currencyInfo && this.address && this.notes) {
  104. const obj = {
  105. currency_id: this.currencyInfo.id,
  106. type: this.type,
  107. wallet_address: this.address,
  108. notes: this.notes
  109. }
  110. Api_addAddress(obj).then(res => {
  111. uni.redirectTo({
  112. url: '/pages/content/address'
  113. });
  114. }).catch(err => {
  115. })
  116. }
  117. },
  118. getClipboardData(){
  119. uni.getClipboardData({
  120. success: res => {
  121. // console.log( 'getClipboardData = res' , res.data);
  122. this.address = res.data
  123. },
  124. fail:err => {
  125. console.log( 'getClipboardData = res' , err);
  126. uni.showToast({
  127. title:'当前暂无可粘贴内容',
  128. icon:'none'
  129. })
  130. }
  131. });
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .content {
  138. width: 100%;
  139. padding: 0 $pages-padding;
  140. .pages-title {
  141. height: 120rpx;
  142. font-size: 60rpx;
  143. font-weight: bold;
  144. line-height: 130rpx;
  145. }
  146. .currency-type {
  147. width: 100%;
  148. min-height: 100rpx;
  149. display: flex;
  150. align-items: stretch;
  151. justify-content: space-between;
  152. padding: 20rpx 20rpx 20rpx 30rpx;
  153. background-color: #f6f6f6;
  154. margin-bottom: 20rpx;
  155. border-radius: 10rpx;
  156. .currency-lable {
  157. display: flex;
  158. align-items: center;
  159. .lable-title {
  160. width: 50rpx;
  161. height: 50rpx;
  162. border-radius: 50%;
  163. }
  164. .lable-tag {
  165. font-size: 30rpx;
  166. font-weight: 700;
  167. padding-left: 20rpx;
  168. }
  169. }
  170. .select-currency {
  171. display: flex;
  172. align-items: center;
  173. font-size: 24rpx;
  174. color: #010101;
  175. .select-icon {
  176. font-size: 24rpx;
  177. color: #010101;
  178. transform: rotate(180deg);
  179. }
  180. }
  181. }
  182. .add-box {
  183. width: 100%;
  184. padding: 30rpx 20rpx;
  185. border-radius: 10rpx;
  186. background-color: #f6f6f6;
  187. .add-type {
  188. width: 100%;
  189. .link-btn {
  190. display: inline-block;
  191. width: 140rpx;
  192. height: 72rpx;
  193. background: #f6f5f3;
  194. border-radius: 8px;
  195. text-align: center;
  196. line-height: 70rpx;
  197. font-size: 28rpx;
  198. font-weight: 400;
  199. color: #666666;
  200. border-radius: 8rpx;
  201. border: 1rpx solid #f6f5f3;
  202. &:nth-child(n + 2) {
  203. margin-left: 20rpx;
  204. }
  205. }
  206. .active-link-btn {
  207. background: #ffffff;
  208. border-color: #05c175;
  209. color: #FFBA6A;
  210. }
  211. }
  212. .address-text {
  213. width: 100%;
  214. padding-top: 40rpx;
  215. .address-lable {
  216. font-size: 30rpx;
  217. }
  218. .address-info {
  219. width: 100%;
  220. height: 80rpx;
  221. display: flex;
  222. justify-content: space-between;
  223. align-items: center;
  224. overflow: hidden;
  225. border-bottom: 1rpx solid $border-color4;
  226. .address-input {
  227. height: 100%;
  228. font-size: 26rpx;
  229. padding-right: 20rpx;
  230. }
  231. .address-moer {
  232. flex-shrink: 0;
  233. font-size: 26rpx;
  234. color: #FFBA6A;
  235. }
  236. .address-link {
  237. width: 1rpx;
  238. height: 70%;
  239. background-color: $border-color4;
  240. margin: 0 16rpx;
  241. }
  242. .address-icon {
  243. flex-shrink: 0;
  244. font-size: 40rpx;
  245. color: #000;
  246. margin-right: 10rpx;
  247. }
  248. .placeholder-class {
  249. // color: #f6f5f3;
  250. }
  251. }
  252. }
  253. // <view class="address-text">
  254. // <text class="address-lable">钱包备注</text>
  255. // <view class="address-info">
  256. // <input class="address-input" focus placeholder="自动获得焦点" />
  257. // </view>
  258. // </view>
  259. }
  260. .add-address {
  261. width: 100%;
  262. height: 160rpx;
  263. padding: 40rpx 10rpx;
  264. .add-btn {
  265. width: 100%;
  266. height: 100%;
  267. text-align: center;
  268. line-height: 80rpx;
  269. background-color: $Theme-Color;
  270. font-size: 32rpx;
  271. color: #fff;
  272. border-radius: 10rpx;
  273. }
  274. }
  275. }
  276. </style>