details.vue 11 KB

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