index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="container" style="padding-top: 100rpx;">
  3. <topView :backg="'#15130E'"></topView>
  4. <view class="imageBox">
  5. <image style="width: 100%;height: 450rpx;" src="/static/img/img02.png"></image>
  6. <view class="flex_item titleBox">
  7. <image src="../../static/img/img04.png" style="width: 41rpx;height: 23rpx;"></image>
  8. <view class="title">{{ $t("index.矿机购买") }}</view>
  9. <image src="../../static/img/img04.png" style="width: 41rpx;height: 23rpx;"></image>
  10. </view>
  11. <view class="tip">{{ $t("index.购买更高") }}</view>
  12. </view>
  13. <view class="infoBox">
  14. <view class="flex reg" @click="navTo('/pages/index/exchange')">
  15. <view class="flex_item">
  16. <image src="../../static/img/img08.png" style="width: 86rpx;height: 100rpx;"></image>
  17. <view class="name">{{ $t("index.闪兑") }}</view>
  18. </view>
  19. <view class="flex_item">
  20. <view class="goText">{{ $t("index.立即前往") }}</view>
  21. <view><u-icon name="arrow-right" size="16" style="position: relative;top: 3rpx;"></u-icon></view>
  22. </view>
  23. </view>
  24. <view class="listBox">
  25. <view class="itemTpl flex" v-for="item,index in list"
  26. :key="index" @click="navTo('/pages/index/details?id='+item.id)">
  27. <view class="flex_item infoTpl">
  28. <image style="width: 191rpx;height: 191rpx;border: 1rpx solid #9A7B52;border-radius: 25rpx;"
  29. :src="'https://www.bscnice.com'+item.image"></image>
  30. <view class="info">
  31. <view class="name">{{item.name}}</view>
  32. <view class="tip">{{ $t("index.价格") }}:<text class="price">{{item.price * 1}}NUSD</text></view>
  33. <view class="tip">{{ $t("index.总收益") }}:<text class="price">{{item.send_all * 1}}NUSD</text></view>
  34. </view>
  35. </view>
  36. <view class="flex_item">
  37. <view class="goText">{{ $t("index.查看详情") }}</view>
  38. <view><u-icon name="arrow-right" size="14" style="position: relative;top: 3rpx;"></u-icon></view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="flex reg" @click="navTo('/pages/index/detailsTpl')">
  43. <view class="flex_item">
  44. <image src="../../static/img/img09.png" style="width: 96rpx;height:79rpx;"></image>
  45. <view class="name">{{ $t("index.我的矿机") }}</view>
  46. </view>
  47. <view class="flex_item">
  48. <view class="goText">{{ $t("index.查看详情") }}</view>
  49. <view><u-icon name="arrow-right" size="16" style="position: relative;top: 3rpx;"></u-icon></view>
  50. </view>
  51. </view>
  52. <view class="flex navList">
  53. <view class="navItme" @click="navTo('/pages/index/invite')">
  54. <image src="/static/img/img10.png" style="width: 103rpx;height: 97rpx;"></image>
  55. <view class="navName">{{ $t("index.我的邀请") }}</view>
  56. <view class="navText">{{ $t("index.邀请团队信息") }}</view>
  57. </view>
  58. <view class="navItme" @click="navTo('/pages/index/property')">
  59. <image src="/static/img/img11.png" style="width: 95rpx;height: 110rpx;"></image>
  60. <view class="navName">{{ $t("index.我的资产") }}</view>
  61. <view class="navText">{{ $t("index.资产明细") }}</view>
  62. </view>
  63. <view class="navItme" @click="navTo('/pages/index/income')">
  64. <image src="/static/img/img12.png" style="width: 146rpx;height:106rpx;"></image>
  65. <view class="navName">{{ $t("index.我的收益") }}</view>
  66. <view class="navText">{{ $t("index.收益明细") }}</view>
  67. </view>
  68. </view>
  69. <view class="shareBox">
  70. <view class="shareTitle">{{ $t("index.邀请地址") }}</view>
  71. <view class="flex shareTpl">
  72. <view class="addr clamp">{{userInfo.address}}</view>
  73. <view class="copyBtn" @click="copyClick(userInfo.address)">{{ $t("index.复制") }}</view>
  74. </view>
  75. </view>
  76. <view style="text-align: center;padding-top: 85rpx;">
  77. <image src="/static/img/img13.png" style="width: 617rpx;height:382rpx;"></image>
  78. </view>
  79. </view>
  80. <image src="/static/img/img03.png" style="width: 100%;height: 320rpx;"></image>
  81. <u-popup :show="popShow" mode="center" class="popBox" @close="popShow = false" @open="popShow = true">
  82. <view class="imgBox">
  83. <image src="../../static/img/img29.png" style="width:492rpx;height: 458rpx;"></image>
  84. </view>
  85. <view class="inputBox">
  86. <input type="text" v-model="address"/>
  87. </view>
  88. <view class="submitBnt" :class="{ submitNo: !payOn }" @click="payOn ? submit() : ''">{{$t("index.确认绑定")}}</view>
  89. </u-popup>
  90. </view>
  91. </template>
  92. <script>
  93. import topView from '../components/topView.vue';
  94. import { mining } from '@/api/index.js';
  95. import {bandgingSpead} from '@/api/login.js';
  96. import {mapState,mapActions,mapMutations} from "vuex";
  97. export default {
  98. components: {
  99. topView
  100. },
  101. data () {
  102. return {
  103. list:[],
  104. popShow:false,
  105. address:'',
  106. payOn:true
  107. }
  108. },
  109. onLoad(option) {
  110. if(option.address){
  111. uni.setStorageSync('address', option.address);
  112. }else{
  113. uni.setStorageSync('address', '');
  114. }
  115. },
  116. onShow() {
  117. this.loadDate()
  118. },
  119. computed: {
  120. ...mapState('user', ['userInfo']),
  121. },
  122. methods: {
  123. submit () {
  124. let obj = this;
  125. obj.payOn = false
  126. ethereum.request({
  127. method: 'eth_requestAccounts'
  128. }).then((account) => {
  129. const PKR_BIND = 'PKR_BIND' + (new Date()).getTime();
  130. ethereum.request({
  131. "method": "personal_sign",
  132. "params": [
  133. PKR_BIND,
  134. account[0]
  135. ]
  136. }).then((res) => {
  137. obj.bing(res,PKR_BIND);
  138. });
  139. });
  140. },
  141. bing(sign,msg){
  142. let obj = this;
  143. bandgingSpead({
  144. address: obj.address,
  145. sign,
  146. msg,
  147. }).then((res) => {
  148. obj.popShow = false
  149. if(res.code == 1){
  150. obj.payOn = true
  151. uni.setStorageSync('address', '');
  152. uni.showToast({
  153. title: obj.$t('common.绑定成功'),
  154. duration: 1500,
  155. mask: false,
  156. icon: 'none',
  157. })
  158. obj.loadDate()
  159. }else{
  160. obj.payOn = true
  161. uni.showToast({
  162. title: res.msg,
  163. duration: 1500,
  164. mask: false,
  165. icon: 'none',
  166. })
  167. }
  168. }).catch(e => {
  169. obj.payOn = true
  170. });
  171. },
  172. loadDate(){
  173. let obj = this
  174. mining({}).then(function(res){
  175. if (res.code == 402) {
  176. uni.showModal({
  177. title: obj.$t('common.温馨提示'),
  178. content: obj.$t('common.请先绑定推荐人'),
  179. showCancel: false,//没有取消按钮的弹框
  180. buttonText:obj.$t('common.确定'),
  181. success: function (res) {
  182. if (res.confirm) {
  183. obj.address = uni.getStorageSync("address") || "";
  184. obj.popShow = true
  185. } else if (res.cancel) {
  186. }
  187. }
  188. });
  189. }else {
  190. obj.list = res.data.list
  191. }
  192. })
  193. },
  194. copyClick (value) {
  195. if (value == "" || value == null) {
  196. uni.showToast({
  197. title: this.$t('common.内容为空'),
  198. icon: "none",
  199. });
  200. return;
  201. }
  202. let text = 'https://www.bscnice.com/index/#/pages/index/index?address='+value
  203. const result = this.uniCopy(text);
  204. if (result === false) {
  205. uni.showToast({
  206. title: this.$t("common.不支持"),
  207. });
  208. } else {
  209. uni.showToast({
  210. title: this.$t("common.复制成功"),
  211. icon: "none",
  212. });
  213. }
  214. },
  215. uniCopy (content) {
  216. /**
  217. * 小程序端 和 app端的复制逻辑
  218. */
  219. //#ifndef H5
  220. uni.setClipboardData({
  221. data: content,
  222. success: function () {
  223. console.log("success");
  224. return true;
  225. },
  226. });
  227. //#endif
  228. /**
  229. * H5端的复制逻辑
  230. */
  231. // #ifdef H5
  232. if (!document.queryCommandSupported("copy")) {
  233. //为了兼容有些浏览器 queryCommandSupported 的判断
  234. // 不支持
  235. return false;
  236. }
  237. let textarea = document.createElement("textarea");
  238. textarea.value = content;
  239. textarea.readOnly = "readOnly";
  240. document.body.appendChild(textarea);
  241. textarea.select(); // 选择对象
  242. textarea.setSelectionRange(0, content.length); //核心
  243. let result = document.execCommand("copy"); // 执行浏览器复制命令
  244. textarea.remove();
  245. return result;
  246. // #endif
  247. },
  248. navTo(url){
  249. uni.navigateTo({
  250. url:url
  251. })
  252. },
  253. },
  254. }
  255. </script>
  256. <style lang="scss">
  257. page {
  258. width: 100%;
  259. min-height: 100vh;
  260. .container {
  261. width: 100%;
  262. min-height: 100vh;
  263. }
  264. }
  265. .imageBox{
  266. .titleBox{
  267. justify-content: center;
  268. .title{
  269. font-weight: bold;
  270. font-size: 36rpx;
  271. color: #FFFFFF;
  272. padding: 0rpx 25rpx;
  273. }
  274. }
  275. .tip{
  276. text-align: center;
  277. color: #999999;
  278. font-size: 22rpx;
  279. padding: 18rpx;
  280. }
  281. }
  282. .infoBox{
  283. padding: 25rpx 30rpx;
  284. color: #FFFFFF;
  285. .reg{
  286. background: #1A1A17;
  287. padding: 23rpx 55rpx;
  288. box-shadow: 1rpx 1rpx 1rpx 1rpx rgba(0,0,0,0.24);
  289. border-radius: 30rpx;
  290. .name{
  291. padding-left: 25rpx;
  292. font-weight: bold;
  293. font-size: 35rpx;
  294. }
  295. }
  296. }
  297. .listBox{
  298. padding-top: 30rpx;
  299. .itemTpl{
  300. margin-bottom: 25rpx;
  301. background: #1A1A17;
  302. padding: 25rpx 25rpx;
  303. box-shadow: 1rpx 1rpx 1rpx 1rpx rgba(0,0,0,0.24);
  304. border-radius: 30rpx;
  305. .infoTpl{
  306. align-items: flex-start;
  307. .info{
  308. padding-left: 20rpx;
  309. .name{
  310. font-weight: bold;
  311. font-size: 36rpx;
  312. color: #FFFFFF;
  313. padding-bottom: 45rpx;
  314. }
  315. .tip{
  316. font-size: 24rpx;
  317. color: #999999;
  318. padding-top: 15rpx;
  319. .price{
  320. color:#E3C49C;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. .navList{
  328. margin:25rpx 0;
  329. .navItme{
  330. background: #1A1A17;
  331. padding: 25rpx 0rpx;
  332. padding-bottom: 40rpx;
  333. box-shadow: 1rpx 1rpx 1rpx 1rpx rgba(0,0,0,0.24);
  334. border-radius: 30rpx;
  335. text-align: center;
  336. width: 31%;
  337. .navName{
  338. padding-top: 10rpx;
  339. font-weight: bold;
  340. font-size: 33rpx;
  341. }
  342. .navText{
  343. padding-top: 10rpx;
  344. opacity: 0.18;
  345. font-size: 24rpx;
  346. }
  347. }
  348. }
  349. .shareBox{
  350. .shareTitle{
  351. font-weight: bold;
  352. font-size: 29rpx;
  353. color: #FFFFFF;
  354. margin-bottom: 30rpx;
  355. }
  356. .shareTpl{
  357. background: #1A1A17;
  358. border-radius: 25rpx;
  359. .addr{
  360. padding: 18rpx 25rpx;
  361. width: 80%;
  362. }
  363. .copyBtn{
  364. padding: 18rpx 35rpx;
  365. background: linear-gradient(258deg, #FFF0CF, #CBA16B, #FCE9CF, #C29963);
  366. border-radius: 30rpx;
  367. font-weight: bold;
  368. font-size: 30rpx;
  369. color: #31190B;
  370. }
  371. }
  372. }
  373. //绑定弹窗
  374. /deep/.u-popup__content{
  375. background: #1A1A17;
  376. border-radius: 25rpx;
  377. padding: 25rpx 25rpx;
  378. width: 90%;
  379. }
  380. .imgBox{
  381. text-align: center;
  382. }
  383. .inputBox{
  384. background: #fff;
  385. border-radius: 50rpx;
  386. padding: 25rpx 25rpx;
  387. width: 100%;
  388. }
  389. .submitBnt{
  390. background: linear-gradient(258deg, #FFF0CF, #CBA16B, #FCE9CF, #C29963);
  391. border-radius: 43rpx;
  392. font-weight: bold;
  393. font-size: 34rpx;
  394. line-height: 90rpx;
  395. text-align: center;
  396. margin: 60rpx 0;
  397. }
  398. .submitNo {
  399. background: #999999 !important;
  400. color: #fff !important;
  401. }
  402. //
  403. .goText{
  404. font-size: 22rpx;
  405. color: #FFFFFF;
  406. opacity: 0.7;
  407. padding-right: 15rpx;
  408. }
  409. </style>