buyCalculation.vue 13 KB

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