user.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="container">
  3. <view class="topBox">
  4. <view class="topName">我的资产</view>
  5. <view class="topMoney">${{money}}</view>
  6. <view class="flex topInfo">
  7. <!-- <view class="flex_item infoTpl" @click="navTo('/pages/user/transfer')">
  8. <image src="/static/image/img27.png" style="width: 48rpx;height: 48rpx;" mode="widthFix"></image>
  9. <view class="tplName">转账</view>
  10. </view> -->
  11. <view class="flex_item infoTpl" @click="navTo('/pages/index/recharge')">
  12. <image src="/static/image/img28.png" style="width: 44rpx;height: 44rpx;" mode="widthFix"></image>
  13. <view class="tplName">充值</view>
  14. </view>
  15. <view class="flex_item infoTpl" @click="navTo('/pages/user/withdrawal')">
  16. <image src="/static/image/img29.png" style="width: 45rpx;height: 42rpx;" mode="widthFix"></image>
  17. <view class="tplName">提币</view>
  18. </view>
  19. </view>
  20. <view class="flex_item moneyBox">
  21. <image src="/static/image/img26.png" style="width: 30rpx;height:30rpx" mode="scaleToFill"></image>
  22. <view class="moneyName">资产正在保护中</view>
  23. </view>
  24. </view>
  25. <view class="listBox">
  26. <view class="listName">我的资产</view>
  27. <view class="flex listTpl" v-for="(item) in list" @click="navTo(`/pages/user/money?type=${item.name}`)">
  28. <view class="flex_item TplInfo">
  29. <image :src="item.LOGO" class="typeLogo" mode="scaleToFill"></image>
  30. <view class="infoName">{{item.name}}</view>
  31. </view>
  32. <view class="flex_item tplTip">
  33. <view class="tipBox">
  34. <view>{{item.money.money*1}}</view>
  35. <view class="tip">≈{{item.rmb*1}}RMB</view>
  36. </view>
  37. <image src="/static/image/img31.png" style="width: 18rpx;height: 27rpx;" mode="widthFix"></image>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. // import {
  45. // getIndex,
  46. // } from "@/api/index.js";
  47. import {
  48. mapState,
  49. mapMutations
  50. } from 'vuex';
  51. import {
  52. getUserInfo,
  53. getUser
  54. } from '@/api/user.js';
  55. import {
  56. qianBao
  57. } from '@/api/wallet.js';
  58. import {
  59. saveUrl,
  60. interceptor
  61. } from '@/utils/loginUtils.js';
  62. export default {
  63. data() {
  64. return {
  65. dataMoney: {},
  66. money: '',
  67. list: {}
  68. };
  69. },
  70. onShow() {
  71. // 判断是否已经登录
  72. if (this.hasLogin) {
  73. this.loadBaseData();
  74. this.getUserWallet();
  75. }
  76. // this.getIndex()
  77. },
  78. computed: {
  79. ...mapState('user', ['hasLogin', 'userInfo']),
  80. ...mapState(['baseURL', 'urlFile']),
  81. },
  82. methods: {
  83. ...mapMutations('user', ['setUserInfo']),
  84. // 获取用户余额信息
  85. getUserWallet() {
  86. const that = this;
  87. qianBao().then((res) => {
  88. that.dataMoney = res.data.back.USDT.money;
  89. that.money = +res.data.like_usdt;
  90. that.list = res.data.back;
  91. })
  92. },
  93. // 加载初始数据
  94. loadBaseData() {
  95. const obj = this
  96. getUserInfo({})
  97. .then(({
  98. data
  99. }) => {
  100. obj.setUserInfo(data);
  101. })
  102. .catch(e => {
  103. console.log(e);
  104. });
  105. },
  106. /**
  107. * 统一跳转接口,拦截未登录路由
  108. * navigator标签现在默认没有转场动画,所以用view
  109. */
  110. navTo(url) {
  111. if (!this.hasLogin) {
  112. // 保存地址
  113. saveUrl();
  114. // 登录拦截
  115. interceptor();
  116. } else {
  117. uni.navigateTo({
  118. url
  119. });
  120. }
  121. },
  122. }
  123. };
  124. </script>
  125. <style lang="scss">
  126. .container {
  127. padding: 25rpx 25rpx;
  128. }
  129. .typeLogo {
  130. height: 80rpx;
  131. width: 80rpx;
  132. }
  133. .topBox {
  134. width: 100%;
  135. background: #1F2A4A;
  136. border-radius: 15rpx;
  137. padding: 40rpx 45rpx;
  138. position: relative;
  139. .topName {
  140. font-weight: bold;
  141. font-size: 27rpx;
  142. color: #FFFFFF;
  143. }
  144. .topMoney {
  145. font-weight: bold;
  146. font-size: 60rpx;
  147. color: #FFFFFF;
  148. padding: 65rpx 0rpx;
  149. }
  150. .topInfo {
  151. font-size: 27rpx;
  152. color: #FFFFFF;
  153. justify-content: space-around;
  154. .infoTpl {
  155. .tplName {
  156. padding-left: 15rpx;
  157. }
  158. }
  159. }
  160. .moneyBox {
  161. position: absolute;
  162. right: 0;
  163. top: 45rpx;
  164. background: #F2DA95;
  165. border-radius: 27rpx 0rpx 0rpx 27rpx;
  166. font-weight: bold;
  167. font-size: 24rpx;
  168. color: #030E16;
  169. padding: 8rpx 22rpx;
  170. .moneyName {
  171. padding-left: 15rpx;
  172. }
  173. }
  174. }
  175. .listBox {
  176. padding: 50rpx 0rpx;
  177. color: #FFFFFF;
  178. .listName {
  179. font-family: PingFang SC;
  180. font-weight: 500;
  181. font-size: 36rpx;
  182. color: #FFFFFF;
  183. }
  184. .listTpl {
  185. padding: 35rpx 0rpx;
  186. .TplInfo {
  187. .infoName {
  188. font-family: PingFang SC;
  189. font-weight: 500;
  190. font-size: 32rpx;
  191. color: #FFFFFF;
  192. padding-left: 31rpx;
  193. }
  194. }
  195. .tplTip {
  196. .tipBox {
  197. padding-right: 30rpx;
  198. font-family: PingFang SC;
  199. font-weight: 500;
  200. font-size: 32rpx;
  201. color: #FFFFFF;
  202. .tip {
  203. font-family: PingFang SC;
  204. font-weight: 500;
  205. font-size: 26rpx;
  206. color: #999999;
  207. }
  208. }
  209. }
  210. }
  211. }
  212. </style>