buyCalculation.vue 8.5 KB

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