buyCalculation.vue 10 KB

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