index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="index-data">
  3. <view class="index-top">
  4. <top-head></top-head>
  5. <view class="top-text">
  6. <view class="text-item">{{$t('index.index.top.one')}}</view>
  7. <view class="text-item">{{$t('index.index.top.two')}}</view>
  8. <view class="text-item">{{$t('index.index.top.three')}}</view>
  9. <view class="text-item">{{$t('index.index.top.four')}}</view>
  10. </view>
  11. <view class="top-but">
  12. <button @click="goToUrl(1)">{{$t('index.index.investment')}}</button>
  13. </view>
  14. <view class="top-bottom">
  15. <image class="bottom-img" src="@/static/img/index/dagou.svg" mode="aspectFill"></image>
  16. <text class="bottom-text">{{$t('index.index.top.five')}}</text>
  17. <text class="bottom-text">{{$t('index.index.top.six')}}</text>
  18. </view>
  19. </view>
  20. <view class="index-list">
  21. <view class="list-title">
  22. <view class="title-img">
  23. <image src="@/static/img/index/bnb2.png" mode="aspectFill"></image>
  24. </view>
  25. <view class="title-text">{{$t('index.index.list.title')}}(100)</view>
  26. </view>
  27. <division></division>
  28. <earning-list></earning-list>
  29. </view>
  30. <view class="index-bottom"></view>
  31. </view>
  32. </template>
  33. <script>
  34. import {getInvestData, setInvest} from "@/api/contract";
  35. import tools from "@/common/js/tools";
  36. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  37. import {getMemberInfo} from "@/api/member";
  38. import Division from "@/pages/index/components/division";
  39. import TopHead from "@/pages/index/components/top-head";
  40. import EarningList from "@/pages/index/components/earning-list";
  41. export default {
  42. components: {EarningList, TopHead, Division},
  43. data() {
  44. return {
  45. applicationLocale: '',
  46. systemLocale: '',
  47. showLang: false,
  48. isAjax: false,
  49. langList: [{'name': 'zh-Hans', 'value': '简体中文'}, {'name': 'en', 'value': 'English'}, {
  50. 'name': 'ja',
  51. 'value': '日本語'
  52. }, {'name': 'ko', 'value': '한국어'}],
  53. tabNum: 0,
  54. investData: {
  55. id: 1,
  56. invest_money: '',
  57. sysAddress: "",
  58. sendNum: "",
  59. },
  60. memberData: {
  61. "id": 30,
  62. "address": "",
  63. "invite_code": "72592982",
  64. "level_id": 0,
  65. "levelName": "V0",
  66. "recommendNum": 0,
  67. "teamNum": 0
  68. },
  69. bnbNum: 0,
  70. babAddress: ''
  71. }
  72. },
  73. watch: {},
  74. async onLoad(query) {
  75. this.applicationLocale = uni.getLocale();
  76. this.getInvestData()
  77. this.bnbNum = await tokenpocketBnb.getBalance();
  78. this.getMyData()
  79. },
  80. mounted() {
  81. },
  82. methods: {
  83. goToUrl(type) {
  84. switch (type) {
  85. case 1:
  86. uni.navigateTo({
  87. 'url': 'pages/index/contract'
  88. })
  89. break
  90. case 2:
  91. uni.navigateTo({
  92. 'url': 'pages/index/contract'
  93. })
  94. break
  95. case 3:
  96. uni.navigateTo({
  97. 'url': 'pages/index/contract'
  98. })
  99. break
  100. }
  101. },
  102. setShowLang() {
  103. this.showLang = !this.showLang
  104. },
  105. setTabNum(tabNum) {
  106. if (tabNum !== this.tabNum) {
  107. this.tabNum = tabNum
  108. }
  109. },
  110. getMyData() {
  111. this.babAddress = tokenpocketBnb.getMyAddress()
  112. getMemberInfo().then((res) => {
  113. if (res.code === 1) {
  114. this.memberData = res.data
  115. }
  116. })
  117. },
  118. getInvestData() {
  119. getInvestData().then((res) => {
  120. if (res.code === 1) {
  121. this.investData = res.data
  122. } else {
  123. tools.goToError(4)
  124. }
  125. }).catch((e) => {
  126. tools.goToError(4)
  127. })
  128. },
  129. async setInvest() {
  130. if (this.bnbNum < this.investData.invest_money && !tools.isDevelopment()) {
  131. tools.error(this.$t('index.index.invest.no_usdt'))
  132. return
  133. }
  134. if (this.isAjax) {
  135. return
  136. }
  137. // this.isAjax = true
  138. tokenpocketBnb.getTransactionData(this.investData.sysAddress, 0.0001).then((data) => {
  139. try {
  140. tokenpocketBnb.sendTransaction(data).then((res) => {
  141. this.sendSetInvest(res)
  142. }).catch((e) => {
  143. tools.error(this.$t('index.index.invest.send_no'))
  144. })
  145. } catch (e) {
  146. tools.error(this.$t('index.index.invest.send_no'))
  147. }
  148. })
  149. },
  150. sendSetInvest(hashRes) {
  151. setInvest({'txid': hashRes, 'id': this.investData.id}).then((res) => {
  152. if (res.code === 1) {
  153. tools.success(res.msg)
  154. // setTimeout(()=>{
  155. // tools.leftClick()
  156. // },1500)
  157. } else {
  158. this.isAjax = false
  159. tools.error(res.msg)
  160. }
  161. })
  162. },
  163. },
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. //@import "/static/css/common.css";
  168. .index-data {
  169. .index-top {
  170. box-shadow: 0 0 24rpx 0 #000;
  171. box-sizing: border-box;
  172. overflow: hidden;
  173. padding: 40rpx 0;
  174. width: 100%;
  175. background: linear-gradient(0deg, rgb(64, 74, 96) 0%, rgb(9, 21, 36) 100%);
  176. .top-head {
  177. display: flex;
  178. justify-content: space-between;
  179. height: 84rpx;
  180. padding-left: 20rpx;
  181. .head-item {
  182. display: flex;
  183. justify-content: left;
  184. }
  185. .head-left {
  186. .left-img {
  187. margin-top: 1rpx;
  188. image {
  189. width: 80rpx;
  190. height: 80rpx;
  191. }
  192. }
  193. .left-text {
  194. padding-top: 5px;
  195. margin-left: 10px;
  196. .item-item {
  197. font-size: 22rpx;
  198. color: #fff;
  199. }
  200. .item-item:nth-of-type(1) {
  201. font-size: 32rpx;
  202. font-weight: bold;
  203. }
  204. }
  205. }
  206. .head-right {
  207. justify-content: right;
  208. .right-img {
  209. width: 70rpx;
  210. height: 70rpx;
  211. image {
  212. width: 70rpx;
  213. height: 70rpx;
  214. }
  215. }
  216. .right-text {
  217. margin-left: 20rpx;
  218. height: 70rpx;
  219. line-height: 70rpx;
  220. width: 200rpx;
  221. overflow: hidden;
  222. text-overflow: ellipsis;
  223. color: rgb(116, 132, 164);
  224. }
  225. }
  226. }
  227. .top-text {
  228. clear: both;
  229. padding: 40rpx;
  230. margin-top: 40rpx;
  231. .text-item {
  232. color: #fff;
  233. font-size: 50rpx;
  234. font-weight: bold;
  235. }
  236. }
  237. .top-but {
  238. width: 80%;
  239. margin: 60rpx auto 0;
  240. button {
  241. height: 90rpx;
  242. line-height: 90rpx;
  243. text-align: center;
  244. background: rgb(0, 87, 255);
  245. color: #fff;
  246. border-radius: 20rpx;
  247. font-weight: bold;
  248. }
  249. }
  250. .top-bottom {
  251. padding: 40rpx;
  252. .bottom-img {
  253. display: inline-block;
  254. width: 24rpx;
  255. height: 24rpx;
  256. margin-right: 10rpx;
  257. }
  258. .bottom-text {
  259. font-size: 24rpx;
  260. color: #7484a4;
  261. }
  262. .bottom-text:nth-of-type(2) {
  263. margin-left: 0.5em;
  264. text-decoration: underline;
  265. }
  266. }
  267. }
  268. .index-list {
  269. background: #fff;
  270. width: 90%;
  271. margin: 40rpx auto;
  272. border-radius: 10px;
  273. padding: 20px 10px;
  274. overflow: hidden;
  275. font-size: 13px;
  276. box-shadow: 0 8rpx 16rpx 0 rgba(0, 0, 0, 0.08);
  277. .list-title {
  278. display: flex;
  279. justify-content: left;
  280. .title-img {
  281. background: rgb(0, 87, 255);
  282. padding: 10rpx;
  283. border-radius: 20rpx;
  284. image {
  285. width: 80rpx;
  286. height: 80rpx;
  287. }
  288. }
  289. .title-text {
  290. margin-left: 20rpx;
  291. line-height: 100rpx;
  292. font-size: 34rpx;
  293. font-weight: bold;
  294. }
  295. }
  296. }
  297. .index-bottom {
  298. height: 50rpx;
  299. }
  300. }
  301. </style>