top-up.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="">
  3. <!-- 头部 -->
  4. <headContent>
  5. <template #left>
  6. <reverse-back path="pages/content/top-up" />
  7. </template>
  8. <template #content>
  9. <view class="haed-title">
  10. 充币
  11. </view>
  12. </template>
  13. <template #right>
  14. <view @click.stop="lookRecord()" class="head-record iconfont">&#xe642;</view>
  15. </template>
  16. </headContent>
  17. <view class="currency-box">
  18. <view class="currency-item">
  19. <view class="currency-info">
  20. <template v-if="biInfo">
  21. <image class="currency-icon" :src="biInfo.logo" mode="aspectFit"></image>
  22. <text class="currency-name">{{ biInfo.name }}</text>
  23. </template>
  24. </view>
  25. <view class="select-currency" @click.stop="selectCurrency">
  26. <text>请选择币种</text>
  27. <text class="iconfont">&#xe88e;</text>
  28. </view>
  29. </view>
  30. <view class="link-name">
  31. <view class="link-lable">链名称</view>
  32. <view class="link-btns">
  33. <text @click.stop="setCode('erc20')"
  34. :class="['link-btn' , linkLable === 'erc20' ? 'active-link-btn' : '']">ERC20</text>
  35. <text @click.stop="setCode('trc20')"
  36. :class="['link-btn' , linkLable === 'trc20' ? 'active-link-btn' : '']">TRC20</text>
  37. </view>
  38. </view>
  39. <view class="currency-code">
  40. <!-- https://ext.dcloud.net.cn/plugin?id=39 -->
  41. <tki-qrcode ref="qrcode" :size="350" :showLoading="false" :val="linkVal[linkLable]" />
  42. </view>
  43. <view class="currency-btn" @click.stop="saveCode()">保存二维码</view>
  44. <view class="link-val">
  45. {{ linkVal[linkLable] }}
  46. </view>
  47. <view class="currency-btn currency-copy" @click.stop="setCopy(linkVal[linkLable])">复制地址</view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. Api_getTopUp
  54. } from "@/api/index.js"
  55. import reverseBack from "@/components/headModules/reverse-back.vue"
  56. export default {
  57. name: 'top-up',
  58. components: {
  59. reverseBack
  60. },
  61. data() {
  62. return {
  63. biInfo: null,
  64. linkLable: 'erc20',
  65. linkVal: {
  66. erc20: '',
  67. trc20: ''
  68. }
  69. };
  70. },
  71. onLoad(opt) {
  72. const key = opt?.key || '';
  73. this.biInfo = this.$getStorageSync('select')[key];
  74. this.getTopUp()
  75. },
  76. methods: {
  77. getTopUp() {
  78. Api_getTopUp({
  79. currency: this.biInfo.id
  80. }).then(res => {
  81. this.linkVal = res;
  82. this.makeCode()
  83. }).catch(err => {
  84. }).finally(() => {
  85. })
  86. },
  87. setCode(item) {
  88. this.linkLable = item;
  89. this.makeCode()
  90. },
  91. makeCode() {
  92. this.$nextTick(() => {
  93. this.$refs.qrcode._makeCode()
  94. })
  95. },
  96. saveCode() {
  97. // #ifndef H5
  98. this.$nextTick(() => {
  99. this.$refs.qrcode._saveCode()
  100. })
  101. // #endif
  102. },
  103. setCopy(val) {
  104. if (val) {
  105. uni.setClipboardData({
  106. data: val,
  107. success: function() {
  108. uni.showToast({
  109. icon:"none",
  110. title: '复制成功'
  111. })
  112. }
  113. });
  114. }
  115. },
  116. // pages/content/top-up
  117. selectCurrency() {
  118. const pages = getCurrentPages()
  119. console.log('pages = ', pages)
  120. if (pages.length > 1 && pages[pages.length - 1].route === 'pages/content/select-currency') {
  121. uni.navigateBack()
  122. } else {
  123. uni.navigateTo({
  124. url: '/pages/content/select-currency'
  125. });
  126. }
  127. },
  128. // 查看充值记录
  129. lookRecord() {
  130. const pages = getCurrentPages()
  131. if (pages.length > 2 && pages[pages.length - 2].route === 'pages/content/charge-record') {
  132. uni.navigateBack({
  133. delta: 1
  134. })
  135. } else {
  136. uni.navigateTo({
  137. url: "/pages/content/charge-record"
  138. });
  139. };
  140. }
  141. }
  142. }
  143. </script>
  144. <style>
  145. page {
  146. background-color: #F6F7FB;
  147. }
  148. </style>
  149. <style lang="scss" scoped>
  150. .head-record {
  151. font-size: 60rpx;
  152. }
  153. .currency-box {
  154. width: 100%;
  155. padding: 30rpx 40rpx;
  156. .currency-item {
  157. width: 100%;
  158. display: flex;
  159. justify-content: space-between;
  160. align-items: center;
  161. .currency-info {
  162. flex-shrink: 0;
  163. display: flex;
  164. align-items: center;
  165. .currency-icon {
  166. width: 46rpx;
  167. height: 46rpx;
  168. flex-shrink: 0;
  169. }
  170. .currency-name {
  171. font-size: 28rpx;
  172. padding-left: 7px;
  173. font-weight: 700;
  174. }
  175. }
  176. .select-currency {
  177. flex-shrink: 0;
  178. display: flex;
  179. align-items: center;
  180. font-size: 24rpx;
  181. .iconfont {
  182. color: #ccc;
  183. }
  184. }
  185. }
  186. .currency-code {
  187. margin: 36rpx auto 0;
  188. width: 350rpx;
  189. height: 350rpx;
  190. background-color: #fff;
  191. }
  192. .currency-btn {
  193. width: 360rpx;
  194. height: 80rpx;
  195. background-color: $Theme-Color;
  196. margin: 54rpx auto 0;
  197. border-radius: 6rpx;
  198. text-align: center;
  199. line-height: 80rpx;
  200. font-size: 30rpx;
  201. color: #fff;
  202. }
  203. .link-val {
  204. width: 100%;
  205. min-height: 103rpx;
  206. padding: 35rpx 0;
  207. font-size: 24rpx;
  208. font-family: PingFang SC, PingFang SC-Regular;
  209. font-weight: 400;
  210. text-align: center;
  211. color: #1a1a1a;
  212. line-height: 33rpx;
  213. }
  214. .currency-copy {
  215. color: $Theme-Color;
  216. background-color: #fff;
  217. margin: 0 auto;
  218. border: 1rpx solid $Theme-Color;
  219. line-height: 78rpx;
  220. }
  221. }
  222. .link-name {
  223. width: 100%;
  224. padding-top: 40rpx;
  225. font-size: 24rpx;
  226. font-family: PingFang SC, PingFang SC-Bold;
  227. font-weight: 700;
  228. .link-lable {
  229. // width: 72px;
  230. // height: 33px;
  231. color: #1a1a1a;
  232. line-height: 1.2;
  233. }
  234. .link-btns {
  235. width: 100%;
  236. padding-top: 16rpx;
  237. .link-btn {
  238. display: inline-block;
  239. width: 180rpx;
  240. height: 72rpx;
  241. background: #f6f5f3;
  242. border-radius: 8px;
  243. text-align: center;
  244. line-height: 70rpx;
  245. font-size: 28rpx;
  246. font-weight: 400;
  247. color: #666666;
  248. border-radius: 8rpx;
  249. border: 1rpx solid #f6f5f3;
  250. &:nth-child(n + 2) {
  251. margin-left: 20rpx;
  252. }
  253. }
  254. .active-link-btn {
  255. background: #ffffff;
  256. border-color: #05c175;
  257. color: #FFBA6A;
  258. }
  259. }
  260. }
  261. // <view class="link-name">
  262. // <view class="link-lable">链名称</view>
  263. // <view class="link-btns">
  264. // <text class="link-btn">ERC20</text>
  265. // <text class="link-btn">TRC20</text>
  266. // </view>
  267. // </view>
  268. </style>