buyCalculation.vue 13 KB

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