buyCalculation.vue 11 KB

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