market.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <view class="container">
  3. <image class="logo-img" src="../../static/img/img01.png"></image>
  4. <view class="list-box">
  5. <scroll-view scroll-x class="list-title">
  6. <!-- <view class="title" :class="{ blue: tabCurrent == '全部' }" @click="tabClick('全部', 1)">全部</view> -->
  7. <view
  8. class="title"
  9. v-for="(ls, index) in moneyTypeList"
  10. :key="index"
  11. :class="{ blue: tabCurrent == ls.code, grey: ls.has_mining == 0 }"
  12. @click="tabClick(ls.code, ls.has_mining)"
  13. v-if="ls.name === 'FIL'"
  14. >
  15. {{ ls.name }}
  16. </view>
  17. </scroll-view>
  18. <view class="flex_item list-name" v-if="tabCurrent !== '全部'">
  19. <view class="name" :class="{ black: tabType == 1 }" @click="tabTypeClick(1)">算力包</view>
  20. <!--<view class="name" :class="{ black: tabType == 2 }" @click="tabTypeClick(2)">独享矿机</view>
  21. <view class="name" :class="{ black: tabType == 3 }" @click="tabTypeClick(3)">联合挖矿</view> -->
  22. <!-- <view class='name' :class="{'black':tabCurrent==4}">分类名称</view> -->
  23. </view>
  24. <view class="jg" v-else></view>
  25. <view class="list-cell" v-if="list.length > 0" v-for="(ls, index) in list" :key="index" :class="{ 'mini-list-cell': tabCurrent === '全部' }">
  26. <view class="flex">
  27. <view>
  28. <view class="cell-title flex">
  29. <image :src="ls.logo"></image>
  30. <view class="title">{{ ls.name }}</view>
  31. </view>
  32. <view class="tags">
  33. <!-- <view class="cell-tip">{{ ls.first_step_time + ls.second_step_time + ls.third_step_time }}天矿机</view> -->
  34. <template v-if="ls.tags[0] !== '0'">
  35. <view class="cell-tip" v-for="item in ls.tags" :key="item">{{ item }}</view>
  36. <!-- <view class="cell-tag">特价</view> -->
  37. </template>
  38. </view>
  39. </view>
  40. <image v-if="ls.stock == 0" class="all-list" src="../../static/img/img51.png"></image>
  41. </view>
  42. <view class="flex cell-tpl">
  43. <view class="tpl">
  44. <view class="">单价</view>
  45. <view class="" v-if="ls.get_money_type == 'BZZ'">{{ ls._cost_money }}/节点</view>
  46. <view class="" v-else>{{ ls._cost_money }}/T</view>
  47. </view>
  48. <view class="tpl">
  49. <view class="">有效算力</view>
  50. <view class="" v-if="ls.get_money_type == 'BZZ'">{{ ls.step }}节点</view>
  51. <view class="" v-else>{{ ls.step }}T</view>
  52. </view>
  53. <view class="tpl">
  54. <view class="">合约周期</view>
  55. <view class="">{{ ls.first_step_time + ls.second_step_time }}天 + {{ ls.third_step_time }}天</view>
  56. </view>
  57. <!-- <view class="tpl">
  58. <view class="">上架期</view>
  59. <view class="">{{ ls.stand_time }}天</view>
  60. </view> -->
  61. </view>
  62. <view class="cell-info flex">
  63. <view class="tip">剩余数量:{{ ls | dataStock }}</view>
  64. <view class="zhiya-btn" v-if="ls.stock > 0" @click="ToBuy(ls)">{{ ls.type == 3 ? '立即质押' : '立即购买' }}</view>
  65. <view class="zhiya-btn grey" v-if="ls.stock == 0">已售罄</view>
  66. </view>
  67. <view class="luckbox">
  68. 购买当前矿机所需幸运值<span>{{ls.cost_times}}</span>,您当前拥有的幸运值为<span>{{ls.luck_point - ls.exchange_point}}</span>
  69. </view>
  70. </view>
  71. <view class="empty-box" v-show="list.length === 0"><u-empty text="敬请期待" mode="data"></u-empty></view>
  72. </view>
  73. <uni-popup ref="popup" type="center">
  74. <view class="popup">
  75. <view class="cancel flex" @click="close">
  76. <view></view>
  77. <view class="tip">x</view>
  78. </view>
  79. <view class="list-box">
  80. <view class="popup-text">购买数量:</view>
  81. <view class="password"><input type="number" v-model="num" /></view>
  82. <view class="popup-text">支付密码:</view>
  83. <view class="password"><input type="password" v-model="password" /></view>
  84. <view class="confirm-btn" @click="pay"><text>确认购买</text></view>
  85. </view>
  86. </view>
  87. </uni-popup>
  88. </view>
  89. </template>
  90. <script>
  91. import { mining, buyMining } from '@/api/market.js';
  92. import { wallet } from '@/api/finance.js';
  93. export default {
  94. filters: {
  95. dataStock: function(ls) {
  96. let type = 'T';
  97. // if (+ls.stock >= 1024) {
  98. // // type = 'P';
  99. // return `${ls.stock/1024 }/${ls.all_stock/1024 }${type}`;
  100. // } else {
  101. // return `${ls.stock}/${ls.all_stock}${type}`;
  102. // }
  103. return `${+ls.stock}${type}/${+ls.all_stock}${type}`;
  104. }
  105. },
  106. data() {
  107. return {
  108. tabCurrent: '全部',
  109. tabType: 1,
  110. moneyTypeList: [],
  111. list: [],
  112. buyId: '',
  113. password: '',
  114. num: ''
  115. };
  116. },
  117. onLoad(option) {
  118. this.moneyType();
  119. this.loadData();
  120. },
  121. onShow() {},
  122. //下拉刷新
  123. onPullDownRefresh() {
  124. this.moneyType();
  125. },
  126. methods: {
  127. // 所有币种
  128. async moneyType() {
  129. let obj = this;
  130. // console.log(obj.moneyTypeList);
  131. wallet({}).then(({ data }) => {
  132. console.log(data);
  133. obj.like_rmb = data.all_rmb;
  134. obj.like_usdt = data.all_usdt;
  135. const arr = Object.keys(data.back);
  136. console.log(arr);
  137. let ar = [];
  138. arr.forEach(e => {
  139. ar.push(data.back[e]);
  140. });
  141. obj.moneyTypeList = ar;
  142. console.log(obj.moneyTypeList, 'swpie');
  143. });
  144. },
  145. // 请求载入数据
  146. async loadData() {
  147. let obj = this;
  148. uni.showLoading({
  149. title: '加载中...'
  150. });
  151. if (obj.tabCurrent === '全部') {
  152. obj.list = [];
  153. mining({
  154. page: 1,
  155. limit: 1000
  156. }).then(({ data }) => {
  157. uni.hideLoading();
  158. console.log(data.data, '9999999999999999999999999999999999');
  159. obj.list = data.data.map(e => {
  160. e.step = +e.step;
  161. e._cost_money = +e._cost_money.replace(e.cost_money_type, '') + e.cost_money_type;
  162. return e;
  163. });
  164. console.log(obj.list, 'obj.list++++++++++++');
  165. });
  166. // for(let i = 0 ; i<obj.moneyTypeList.length;i++){
  167. // if(obj.moneyTypeList[i].has_mining !==0){
  168. // mining({
  169. // page:1,
  170. // limit:1000,
  171. // type: obj.tabType,
  172. // get_money_type: obj.moneyTypeList[i].code
  173. // }).then(({ data }) => {
  174. // console.log(data)
  175. // let arr = data.data.map(e => {
  176. // e.step = +e.step;
  177. // e._cost_money = +e._cost_money.replace(e.cost_money_type, '') + e.cost_money_type;
  178. // return e;
  179. // });
  180. // obj.list = obj.list.concat(arr)
  181. // // console.log( obj.list.length)
  182. // let len = obj.list.length
  183. // for (let i = 0; i < len; i++) {
  184. // // obj.list[i].tags = obj.list[i].tags.splice(',')
  185. // for (let j = 0; j < len; j++) {
  186. // if (obj.list[i].step > obj.list[j].step) {
  187. // let z = obj.list[i];
  188. // obj.list[i] = obj.list[j];
  189. // obj.list[j] = z;
  190. // }
  191. // }
  192. // }
  193. // // console.log(obj.list, 'new obj.list-------------')
  194. // uni.hideLoading();
  195. // })
  196. // }
  197. // }
  198. // let len = obj.list.length;
  199. } else {
  200. mining({
  201. page: 1,
  202. limit: 1000,
  203. type: obj.tabType,
  204. get_money_type: obj.tabCurrent
  205. }).then(({ data }) => {
  206. console.log(data, '1111');
  207. obj.list = data.data.map(e => {
  208. e.step = +e.step;
  209. e._cost_money = +e._cost_money.replace(e.cost_money_type, '') + e.cost_money_type;
  210. return e;
  211. });
  212. console.log(obj.list, 'obj.list++++++++++++');
  213. let len = obj.list.length;
  214. for (let i = 0; i < len; i++) {
  215. // obj.list[i].tags = obj.list[i].tags.splice(',')
  216. for (let j = 0; j < len; j++) {
  217. if (obj.list[i].step > obj.list[j].step) {
  218. let z = obj.list[i];
  219. obj.list[i] = obj.list[j];
  220. obj.list[j] = z;
  221. }
  222. }
  223. }
  224. console.log(obj.list, 'new obj.list-------------');
  225. uni.hideLoading();
  226. });
  227. }
  228. },
  229. ToBuy(ls) {
  230. // let obj = this;
  231. // obj.buyId = id;
  232. // this.$refs.popup.open();
  233. uni.navigateTo({
  234. url: '/pages/market/details?id=' + ls.id + '&type=' + ls.type
  235. });
  236. },
  237. pay() {
  238. let obj = this;
  239. buyMining(
  240. {
  241. num: obj.num,
  242. trade_psw: obj.password
  243. },
  244. obj.buyId
  245. )
  246. .then(({ data }) => {
  247. obj.$api.msg('购买成功!');
  248. obj.loadData();
  249. obj.password = '';
  250. obj.num = '';
  251. obj.$refs.popup.close();
  252. })
  253. .catch(e => {
  254. obj.loadData();
  255. obj.password = '';
  256. obj.num = '';
  257. obj.$refs.popup.close();
  258. });
  259. },
  260. close() {
  261. this.$refs.popup.close();
  262. },
  263. tabClick(index, has_mining) {
  264. if (index === '全部') {
  265. console.log('ddddddddd');
  266. }
  267. if (has_mining == 0) {
  268. this.$api.msg('敬请期待!');
  269. } else {
  270. this.tabCurrent = index;
  271. this.loadData();
  272. }
  273. },
  274. tabTypeClick(index) {
  275. this.tabType = index;
  276. this.loadData();
  277. }
  278. }
  279. };
  280. </script>
  281. <style lang="scss">
  282. page {
  283. min-height: 100%;
  284. background-color: #ffffff;
  285. .container {
  286. width: 100%;
  287. }
  288. }
  289. .logo-img {
  290. margin: 40rpx 6%;
  291. width: 88%;
  292. height: 209rpx;
  293. }
  294. .list-box {
  295. .list-title {
  296. overflow: hidden;
  297. white-space: nowrap;
  298. .title {
  299. display: inline-block;
  300. background-color: #44969d;
  301. font-size: 30rpx;
  302. font-weight: bold;
  303. color: #ffffff;
  304. width: 24.49%;
  305. margin-right: 5rpx;
  306. text-align: center;
  307. line-height: 60rpx;
  308. }
  309. .blue {
  310. background-color: #44969d;
  311. }
  312. .grey {
  313. background-color: #dbdbdb !important;
  314. }
  315. }
  316. .list-name {
  317. padding: 24rpx 50rpx;
  318. .name {
  319. font-size: 28rpx;
  320. margin-right: 15%;
  321. font-weight: 500;
  322. color: #666666;
  323. }
  324. .black {
  325. color: #333333;
  326. border-bottom: 2rpx solid #5771df;
  327. padding-bottom: 10rpx;
  328. font-size: 30rpx;
  329. font-weight: bold;
  330. }
  331. }
  332. }
  333. .more {
  334. color: #606266;
  335. font-size: 24rpx;
  336. font-weight: normal;
  337. border-bottom: 1rpx solid #606266;
  338. }
  339. .all-list {
  340. width: 180rpx;
  341. height: 180rpx;
  342. position: absolute;
  343. top: 10rpx;
  344. right: 10rpx;
  345. }
  346. .list-cell {
  347. box-sizing: border-box;
  348. width: 670rpx;
  349. margin: 0 auto;
  350. padding: 40rpx 40rpx;
  351. border-radius: 30rpx 30rpx;
  352. background: #f3feff;
  353. margin-bottom: 20rpx;
  354. position: relative;
  355. .cell-title {
  356. padding: 29rpx 38rpx 29rpx 15rpx;
  357. font-size: 38rpx;
  358. font-weight: bold;
  359. color: #333333;
  360. image {
  361. width: 40rpx;
  362. height: 40rpx;
  363. margin-right: 15rpx;
  364. }
  365. }
  366. .tags {
  367. .cell-tip {
  368. display: inline-block;
  369. padding: 11rpx 18rpx 9rpx 20rpx;
  370. font-size: 30rpx;
  371. font-weight: bold;
  372. color: #0ec1a1;
  373. background-color: #e3f6fa;
  374. border-radius: 24rpx 24rpx;
  375. margin-right: 20rpx;
  376. margin-top: 15rpx;
  377. }
  378. .cell-tag {
  379. display: inline-block;
  380. margin-left: 20rpx;
  381. padding: 4rpx 18rpx 3rpx 20rpx;
  382. font-size: 30rpx;
  383. font-weight: bold;
  384. color: red;
  385. // background-color: #fff;
  386. // border-radius: 24rpx 24rpx;
  387. border: 4rpx red solid;
  388. }
  389. }
  390. .cell-tpl {
  391. padding: 50rpx 0rpx 34rpx;
  392. font-size: 30rpx;
  393. font-weight: bold;
  394. color: #333333;
  395. line-height: 40rpx;
  396. // text-align: center;
  397. }
  398. .cell-info {
  399. .tip {
  400. font-size: 34rpx;
  401. font-weight: bold;
  402. color: #44969d;
  403. line-height: 55px;
  404. }
  405. .zhiya-btn {
  406. background-color: #44969d;
  407. width: 150rpx;
  408. text-align: center;
  409. line-height: 60rpx;
  410. font-size: 26rpx;
  411. border-radius: 50rpx;
  412. color: #ffffff;
  413. }
  414. .grey {
  415. background-color: #999999;
  416. }
  417. }
  418. .luckbox {
  419. margin-left: -40rpx;
  420. width: 670rpx;
  421. background: #7bbbc0;
  422. border-radius: 0px 0px 10rpx 10rpx;
  423. padding: 32rpx;
  424. font-size: 24rpx;
  425. font-family: PingFang SC;
  426. font-weight: 500;
  427. color: #333333;
  428. span {
  429. font-size: 30rpx;
  430. color: #ff0000;
  431. }
  432. }
  433. }
  434. .empty-box {
  435. width: 100%;
  436. height: 500rpx;
  437. }
  438. //弹窗
  439. .popup {
  440. background-color: #ffffff;
  441. border-radius: 25rpx;
  442. font-size: 30rpx;
  443. .cancel {
  444. text-align: center;
  445. width: 100%;
  446. line-height: 60rpx;
  447. .tip {
  448. background-color: #5771df;
  449. color: #ffffff;
  450. width: 70rpx;
  451. height: 70rpx;
  452. border-top-right-radius: 25rpx;
  453. }
  454. }
  455. .list-box {
  456. padding: 0rpx 80rpx;
  457. .password {
  458. padding: 50rpx 0rpx;
  459. width: 100%;
  460. input {
  461. width: 70%;
  462. height: 80rpx;
  463. border: 2rpx solid #999999;
  464. padding-left: 25rpx;
  465. box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.27);
  466. border-radius: 11rpx;
  467. }
  468. }
  469. .confirm-btn {
  470. padding-bottom: 120rpx;
  471. padding-top: 30rpx;
  472. text {
  473. background-color: #44969d;
  474. color: #ffffff;
  475. width: 70%;
  476. text-align: center;
  477. padding: 25rpx 90rpx;
  478. border-radius: 15rpx;
  479. }
  480. }
  481. }
  482. }
  483. .jg {
  484. height: 20rpx;
  485. }
  486. .mini-list-cell {
  487. padding: 0rpx 40rpx 10rpx;
  488. .cell-tpl {
  489. padding: 10rpx 0 8rpx;
  490. }
  491. .cell-info {
  492. .tip {
  493. font-size: 34rpx;
  494. font-weight: bold;
  495. color: #44969d;
  496. opacity: 0;
  497. line-height: 40px;
  498. }
  499. .zhiya-btn {
  500. background-color: #44969d;
  501. width: 150rpx;
  502. text-align: center;
  503. line-height: 60rpx;
  504. font-size: 26rpx;
  505. border-radius: 50rpx;
  506. color: #ffffff;
  507. }
  508. .grey {
  509. background-color: #999999;
  510. }
  511. }
  512. }
  513. </style>