details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view class="container">
  3. <!-- 状态栏占位 -->
  4. <!-- <view class="status_bar"></view> -->
  5. <!-- <view class="topbar-box">
  6. <view class="topbar">
  7. <view class="topbar-left"><image src="../../static/img/img16.png" mode=""></image></view>
  8. <view class="topbar-center"></view>
  9. <view class="topbar-right"></view>
  10. </view>
  11. </view> -->
  12. <!-- 自定义导航栏 -->
  13. <!-- <uni-nav-bar left-icon="back" class="nav-bar" @clickLeft="back">
  14. <view class="topbar-center">
  15. <view :class="{ action: current === 0 }" @click="changeCurrent(0)">商品</view>
  16. <view :class="{ action: current === 1 }" @click="changeCurrent(1)">参数</view>
  17. <view :class="{ action: current === 2 }" @click="changeCurrent(2)">介绍</view>
  18. </view>
  19. </uni-nav-bar> -->
  20. <!-- <view class="list-box"></view> -->
  21. <view class="good-img">
  22. <image :src="list.logo"></image>
  23. </view>
  24. <view class="param-box">
  25. <view class="param-price">{{ list.cost_money * 1 }}{{ list._cost_money_type }}</view>
  26. <view class="param-name">{{ list.name }}</view>
  27. <view class="param-list">
  28. <view class="list-item">
  29. <view class="item-title">使用周期</view>
  30. <view class="item-val">{{ list.first_step_time + list.second_step_time + list.third_step_time }}天</view>
  31. </view>
  32. <view class="list-item">
  33. <view class="item-title">电费</view>
  34. <view class="item-val">{{list.elect_fee|keept}}元/天</view>
  35. </view>
  36. <view class="list-item">
  37. <view class="item-title">预计日产出</view>
  38. <view class="item-val">{{list._day_get}}</view>
  39. </view>
  40. <view class="list-item">
  41. <view class="item-title">算力</view>
  42. <view class="item-val">{{list.step}}TB</view>
  43. </view>
  44. <view class="list-item">
  45. <view class="item-title">管理费</view>
  46. <view class="item-val">{{ list.service_ratio }}%</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="list">
  51. <view class="explain"><rich-text :nodes="list.detail"></rich-text></view>
  52. </view>
  53. <!-- <view class="list"> -->
  54. <!-- <view class="list-title">{{ list.name }}</view>
  55. <view class="flex list-item">
  56. <view class="item-name">价格</view>
  57. <view class="item-tpl">{{ list.cost_money * 1 }}{{ list._cost_money_type }}</view>
  58. </view>
  59. <view class="flex list-item" v-if="list.stand_money > 0">
  60. <view class="item-name">质押FIL数量(用户自行支付)</view>
  61. <view class="item-tpl">{{ list.stand_money * 1 }}</view>
  62. </view>
  63. <view class="flex list-item">
  64. <view class="item-name">托管运维费</view>
  65. <view class="item-tpl">{{ list.service_ratio }}%</view>
  66. </view>
  67. <view class="flex list-item">
  68. <view class="item-name">上架期</view>
  69. <view class="item-tpl">{{ list.stand_time }}天</view>
  70. </view> -->
  71. <!-- <view class="flex list-item">
  72. <view class="item-name">封装期</view>
  73. <view class="item-tpl">{{list.first_step_time}}</view>
  74. </view> -->
  75. <!-- <view class="flex list-item">
  76. <view class="item-name">合约期</view>
  77. <view class="item-tpl">{{ list.first_step_time + list.second_step_time + list.third_step_time }}天</view>
  78. </view> -->
  79. <!-- <view class="tpl" v-if="list.stand_money > 0">需完成应质押的FIL后,才能开始进入50天封装期</view> -->
  80. <!-- <view class="list-title">IPFS独享算力包-1T</view> -->
  81. <!-- 产品说明 -->
  82. <!-- <view class="tips">说明:</view> -->
  83. <!-- <view class="explain"><rich-text :nodes="list.detail"></rich-text></view> -->
  84. <!-- <view class="num-box flex">
  85. <view class="num-title">购买数量({{ list.step * 1 }}T)</view>
  86. <uni-number-box class="step" :value="num" :disabled="false" @eventChange="numberChange"></uni-number-box>
  87. </view>
  88. <view class="flex money-box">
  89. <view class="money-name">购买总数</view>
  90. <view class="money-num">{{ list.step * 1 * num}}T</view>
  91. </view>
  92. <view class="flex money-box">
  93. <view class="money-name">金额</view>
  94. <view class="money-num">{{ money * 1 }}{{ list._cost_money_type }}</view>
  95. </view>
  96. <view class="pay-box">支付方式:{{ list._cost_money_type }}</view>
  97. <view class="flex money-box">
  98. <view class="money-name">交易密码</view>
  99. <view class="money-num"><input class="input-box" type="password" v-model="password" placeholder="请输入交易密码" /></view>
  100. </view>
  101. <view class="check_box flex_item">
  102. <view><radio style="transform: scale(0.75)" @click="Getcheckbox" color="#6786FB" :checked="checked" /></view>
  103. <view class="">
  104. 请阅读并同意
  105. <text @click="ToIndex">《矿机租赁协议》</text>
  106. </view>
  107. </view> -->
  108. <!-- </view> -->
  109. <view class="submit-box">
  110. <view class="submit" @click="buy">{{ type == 3 ? '立即质押' : '立即购买' }}</view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import { miningDateils, buyMining } from '@/api/calculation.js';
  116. import uniNumberBox from '@/components/uni-number-box.vue';
  117. export default {
  118. components: {
  119. uniNumberBox
  120. },
  121. data() {
  122. return {
  123. id: '',
  124. type: '',
  125. num: 1,
  126. step: 0,
  127. password: '',
  128. price: '',
  129. list: {},
  130. checked: false,
  131. current: 0
  132. };
  133. },
  134. filters: {
  135. Keept(value) {
  136. if(!value) {
  137. return '0.00'
  138. }
  139. value = Math.round(value* 100)/100;
  140. return value
  141. }
  142. },
  143. onLoad(option) {
  144. this.id = option.id;
  145. this.type = option.type;
  146. this.loadData();
  147. },
  148. computed: {
  149. money() {
  150. return this.num * this.price * this.step;
  151. }
  152. },
  153. onShow() {},
  154. methods: {
  155. async loadData() {
  156. let obj = this;
  157. miningDateils({}, obj.id).then(({ data }) => {
  158. obj.list = data;
  159. // obj.money = obj.list.cost_money;
  160. obj.price = obj.list.cost_money;
  161. obj.step = obj.list.step;
  162. console.log(obj.list);
  163. });
  164. },
  165. //阅读并同意
  166. Getcheckbox() {
  167. let obj = this;
  168. obj.checked = !obj.checked;
  169. },
  170. ToIndex() {
  171. uni.navigateTo({
  172. url: '/pages/finance/xieyi'
  173. });
  174. },
  175. pay() {
  176. let obj = this;
  177. if (obj.password == '') {
  178. obj.$api.msg('请输入交易密码!');
  179. return;
  180. }
  181. if (obj.checked == false) {
  182. obj.$api.msg('请阅读并同意协议!');
  183. return;
  184. }
  185. buyMining(
  186. {
  187. num: obj.num * obj.step,
  188. trade_psw: obj.password
  189. },
  190. obj.id
  191. )
  192. .then(data => {
  193. obj.$api.msg(data.msg);
  194. obj.password = '';
  195. obj.num = 1;
  196. })
  197. .catch(e => {
  198. obj.password = '';
  199. obj.num = 1;
  200. if (e.msg == '交易密码错误') {
  201. return;
  202. }
  203. console.log(e);
  204. var reg = new RegExp('购买矿机所需的');
  205. if (e.msg.match(reg) == -1) {
  206. } else {
  207. setTimeout(function() {
  208. uni.navigateTo({
  209. url: '/pages/finance/recharge'
  210. });
  211. }, 1000);
  212. }
  213. });
  214. },
  215. numberChange(data) {
  216. let obj = this;
  217. obj.num = data.number;
  218. },
  219. buy() {
  220. // let list = JSON.stringify(this.list)
  221. uni.navigateTo({
  222. url: '/pages/calculation/pay?&id=' + this.id + '&type=' + this.type
  223. });
  224. // console.log(this.list,'--------------***********')
  225. // console.log('buy click')
  226. },
  227. changeCurrent(index) {
  228. this.current = index;
  229. },
  230. back() {
  231. uni.navigateBack({
  232. url: '/pages/calculation/buyCalculation'
  233. });
  234. }
  235. }
  236. };
  237. </script>
  238. <style lang="scss" scoped>
  239. page {
  240. min-height: 100%;
  241. background-color: #ffffff;
  242. .container {
  243. width: 100%;
  244. }
  245. }
  246. .list-box {
  247. // background-color: #5771df;
  248. width: 100%;
  249. height: 100rpx;
  250. }
  251. .list {
  252. // margin: 0rpx 31rpx;
  253. // padding: 45rpx 35rpx;
  254. // background-color: #ffffff;
  255. // border-radius: 15rpx;
  256. // position: relative;
  257. // top: -100rpx;
  258. .list-title {
  259. font-size: 34rpx;
  260. font-weight: 500;
  261. color: #333333;
  262. padding-bottom: 35rpx;
  263. }
  264. .list-item {
  265. font-size: 24rpx;
  266. font-weight: 500;
  267. color: #666666;
  268. padding-bottom: 35rpx;
  269. .item-tpl {
  270. font-size: 24rpx;
  271. font-weight: bold;
  272. color: #333333;
  273. }
  274. .tpls {
  275. color: #faba38;
  276. }
  277. }
  278. .tpl {
  279. font-size: 26rpx;
  280. font-weight: 500;
  281. color: #faba38;
  282. padding-bottom: 98rpx;
  283. }
  284. .num-box {
  285. font-size: 30rpx;
  286. font-weight: 500;
  287. color: #333333;
  288. padding-bottom: 83rpx;
  289. }
  290. .money-box {
  291. font-size: 32rpx;
  292. font-weight: 500;
  293. color: #333333;
  294. padding-bottom: 102rpx;
  295. .money-num {
  296. font-weight: bold;
  297. .input-box {
  298. text-align: right;
  299. }
  300. }
  301. }
  302. .pay-box {
  303. font-size: 32rpx;
  304. font-weight: 500;
  305. color: #333333;
  306. padding-bottom: 60rpx;
  307. }
  308. .tips {
  309. font-size: 26rpx;
  310. font-weight: 500;
  311. color: #5771df;
  312. padding-bottom: 25rpx;
  313. }
  314. .explain {
  315. // word-wrap: break-word;
  316. // font-size: 26rpx;
  317. // font-weight: 500;
  318. // color: #666666;
  319. // line-height: 38rpx;
  320. width: 662rpx;
  321. margin: 0 auto;
  322. padding-bottom: 141rpx;
  323. }
  324. }
  325. .submit-box {
  326. position: fixed;
  327. bottom: 0;
  328. padding: 25rpx 0;
  329. width: 100%;
  330. background-color: #fff;
  331. // border-top: 1px solid rgba(0,0,0,0.1);
  332. .submit {
  333. box-sizing: border-box;
  334. width: 662rpx;
  335. height: 91rpx;
  336. line-height: 91rpx;
  337. margin: 0 auto;
  338. background-color: #5771df;
  339. color: #ffffff;
  340. text-align: center;
  341. // padding: 25rpx 0rpx;
  342. border-radius: 50rpx;
  343. }
  344. }
  345. .check_box {
  346. padding: 25rpx 25rpx;
  347. font-size: 28rpx;
  348. padding-bottom: 60rpx;
  349. text {
  350. color: #6786fb;
  351. }
  352. }
  353. .status_bar {
  354. position: fixed;
  355. top: 0;
  356. background-color: #ffffff;
  357. z-index: 999;
  358. height: var(--status-bar-height);
  359. width: 100%;
  360. }
  361. // .topbar-box {
  362. // background-color: #bfa;
  363. // height: 100rpx;
  364. // width: 100%;
  365. // position: fixed;
  366. // top: var(--status-bar-height);
  367. // .topbar {
  368. // .topbar-left {
  369. // }
  370. // .topbar-center {
  371. // }
  372. // .topbar-right {
  373. // }
  374. // }
  375. // }
  376. .nav-bar {
  377. position: fixed;
  378. width: 100%;
  379. top: var(--status-bar-height);
  380. background-color: #fff;
  381. z-index: 999;
  382. .topbar-center {
  383. // width: 450rpx;
  384. height: 41px;
  385. margin: 0 auto;
  386. display: flex;
  387. justify-content: space-around;
  388. color: #9d989e;
  389. font-weight: bold;
  390. view {
  391. margin: 0 40rpx;
  392. }
  393. .action {
  394. color: #000;
  395. border-bottom: 3px #cc6551 solid;
  396. }
  397. }
  398. }
  399. .good-img {
  400. width: 330rpx;
  401. height: 330rpx;
  402. margin: 0 auto;
  403. image {
  404. width: 100%;
  405. height: 100%;
  406. }
  407. }
  408. .param-box {
  409. width: 660rpx;
  410. margin: 0 auto 20rpx;
  411. .param-price {
  412. font-size: 40rpx;
  413. font-weight: bold;
  414. color: #dc4423;
  415. padding: 34rpx 0;
  416. }
  417. .param-name {
  418. font-size: 32rpx;
  419. font-weight: bold;
  420. padding-bottom: 30rpx;
  421. }
  422. .param-list {
  423. box-sizing: border-box;
  424. background-color: #f7f8fc;
  425. color: #000;
  426. display: flex;
  427. flex-wrap: wrap;
  428. padding-bottom: 24rpx;
  429. // margin: 0 19rpx;
  430. .list-item {
  431. width: 30%;
  432. padding: 5rpx 0 0 5rpx;
  433. // height: 122rpx;
  434. .item-title {
  435. font-size: 30rpx;
  436. padding: 20rpx 0;
  437. color: #8c8b90;
  438. }
  439. .item-val {
  440. font-size: 30rpx;
  441. font-weight: bold;
  442. padding-bottom: 14rpx;
  443. }
  444. }
  445. }
  446. }
  447. </style>