detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <v-page class="pledgeRonqi">
  3. <v-header
  4. class=""
  5. :border="false"
  6. :title="$t('pledge.e6')"
  7. :leftClick="() => _router.replace('/pages/pledge/index')"
  8. >
  9. <template #right>
  10. <v-link :to="{ path: '/pages/pledge/order' }">
  11. <van-icon class="fn-20 pld-mt" name="orders-o" />
  12. </v-link>
  13. </template>
  14. </v-header>
  15. <view class="pledgeDetailMain">
  16. <view class="pledgeMain">
  17. <view class="lunbo">
  18. <img
  19. width="100%"
  20. height="100%"
  21. fit="cover"
  22. :src="pledge.spread_img"
  23. />
  24. </view>
  25. </view>
  26. <view class="pledgeIntroduce">
  27. <view class="pledgeDetailTitle">
  28. <view class="pledgeTitleLine"></view>
  29. <view class="pledgeTitleFont">{{
  30. $t("pledge.introduce")
  31. }}</view>
  32. </view>
  33. <view class="pledgeDetailContent">
  34. {{ pledge.content }}
  35. </view>
  36. </view>
  37. <view class="pledgeDetailForm">
  38. <view class="pledgeDetailList">
  39. <text class="detailTextLeft">{{
  40. $t("pledge.bzkyzc")
  41. }}</text>
  42. <text class="detailTextRight"
  43. >{{ pledge.coin_num }} {{ pledge.coin_name }}</text
  44. >
  45. </view>
  46. <view class="pledgeDetailList">
  47. <text class="detailTextLeft">{{$t('pledge.e5')}}</text>
  48. <text class="detailTextRight">{{pledge.min_amount}}-{{pledge.max_amount}}</text>
  49. </view>
  50. <view class="pledgeDetailList">
  51. <text class="detailTextLeft">{{$t('pledge.cycle')}}</text>
  52. <text class="detailTextRight"
  53. >{{ pledge.cycle }} {{ $t("exchange.f0") }}</text
  54. >
  55. </view>
  56. <view class="pledgeDetailList">
  57. <text class="detailTextLeft">{{$t('pledge.e7')}}</text>
  58. <text class="detailTextRight">{{ pledge.min_rate }}%~{{ pledge.max_rate }}%</text>
  59. </view>
  60. <view class="pledgeDetailList">
  61. <text class="detailTextLeft">{{$t('pledge.e8')}}</text>
  62. <text class="detailTextRight">{{ pledge.min_power }}MH/s~{{ pledge.max_power }}MH/s</text>
  63. </view>
  64. <view class="pledgeDetailList">
  65. <text class="detailTextLeft">{{$t('pledge.zynum')}}</text>
  66. <view class="detailTextRight detailInput">
  67. <input
  68. class="pledgeZynum"
  69. v-model="form.num"
  70. type="text"
  71. :placeholder="$t('pledge.zdyxt')"
  72. @input="inputAmount"
  73. placeholder-style="text-align:right;"
  74. />
  75. </view>
  76. </view>
  77. <view class="pledgeDetailList">
  78. <text class="detailTextLeft">{{$t('pledge.e9')}}</text>
  79. <text class="detailTextRight">{{ min_result }}ETH-{{ max_result }}ETH</text>
  80. </view>
  81. <!-- <view class="pledgeDetailList">
  82. <text class="detailTextLeft"
  83. >{{ $t("pledge.maxnum") }}:{{ this.maxnum }},{{
  84. $t("pledge.minnum")
  85. }}:{{ this.minnum }}</text
  86. >
  87. </view> -->
  88. </view>
  89. </view>
  90. <view class="pledgeDetailFooter">
  91. <view class="van-button__text">
  92. <!-- <button ref="btn" @click="pledgeCreateOrder" class="pledgeLjzy">
  93. {{ $t("pledge.ljzy") }}
  94. </button> -->
  95. <button ref="btn" @click="openPopup" class="pledgeLjzy">{{$t("pledge.ljzy")}}</button>
  96. </view>
  97. <view class="safe-area"></view>
  98. <uni-popup
  99. ref="popup"
  100. type="bottom"
  101. :animation="true"
  102. :isMaskClick="false"
  103. >
  104. <view class="x-popup">
  105. <text class="x-popup__title">{{ $t("pledge.a1") }}</text>
  106. <view class="x-form">
  107. <view class="x-form__item">
  108. <text class="x-form--label">{{ $t("pledge.a2") }}</text>
  109. <view class="x-form__item-container">
  110. <input class="x-form--input" type="number" @input="inputAmount" v-model="form.num" />
  111. <text class="x-form__append">{{ pledge.coin_name }}</text>
  112. </view>
  113. <!-- <text class="x-form--tips">≈ {{tusdt_num}} USDT + {{taxn_num}} {{two_coin_name}}</text> -->
  114. </view>
  115. </view>
  116. <view class="x-popup__tips">
  117. <text>{{$t('pledge.e9')}}:{{ min_result }}ETH-{{ max_result }}ETH</text>
  118. </view>
  119. <!-- <view class="x-popup__tips">
  120. <text>{{ $t("pledge.a3") }}:1 USDT ≈ {{ (1 / quotation).toFixed(4) }} {{two_coin_name}}</text>
  121. <text>
  122. {{ $t("pledge.a4") }}{{ 100 - proportion}}%USDT + {{proportion}}% {{two_coin_name}},{{ $t("pledge.a5") }}
  123. </text>
  124. </view> -->
  125. <!-- <view class="x-popup__btn" @click="tapSubmit"> 提交 </view> -->
  126. <view class="x-popup__btn" @click="pledgeCreateOrder"> {{ $t("pledge.a6") }} </view>
  127. </view>
  128. </uni-popup>
  129. </view>
  130. <van-toast id="van-toast" />
  131. </v-page>
  132. </template>
  133. <script>
  134. import Pledge from "@/api/pledge";
  135. import app from "@/app";
  136. // import UniPopup from "uni_modules/uni-popup/components/uni-popup/uni-popup";
  137. export default {
  138. // components: { UniPopup },
  139. data() {
  140. return {
  141. pledge: {},
  142. app,
  143. taskHeight: 0,
  144. pledgenum: 0,
  145. minnum: 0,
  146. maxnum: 0,
  147. min_result:0,
  148. max_result:0,
  149. form: {
  150. id: "",
  151. num: "",
  152. },
  153. tusdt_num:0,
  154. taxn_num:0,
  155. quotation:0,
  156. proportion:0,
  157. two_coin_name:"",
  158. };
  159. },
  160. methods: {
  161. /**
  162. * 打开弹窗
  163. */
  164. openPopup() {
  165. if(this.form.num == '' || this.form.num == 0){
  166. this.$toast(this.$t("pledge.qtxhlfwndsz"));
  167. return;
  168. }
  169. this.$refs.popup.open("bottom");
  170. let param = this.getParam();
  171. this.getquotation(param);
  172. },
  173. /**
  174. * 关闭弹窗
  175. */
  176. tapSubmit() {
  177. this.$refs.popup.close();
  178. },
  179. getDetail(param) {
  180. let ajax = Pledge.getDetail({ id: param });
  181. ajax.then((res) => {
  182. this.pledge = res.data;
  183. console.log(res.data.spread_img,'spread_img')
  184. this.minnum = res.data.min_amount;
  185. this.maxnum = res.data.max_amount;
  186. }).catch(() => {});
  187. },
  188. inputAmount(){
  189. const {min_rate,max_rate,cycle,eth_price} = this.pledge
  190. if(Number(this.form.num)){
  191. this.min_result = (((Number(this.form.num)*min_rate*cycle)/eth_price)*0.01).toFixed(6)
  192. this.max_result = (((Number(this.form.num)*max_rate*cycle)/eth_price)*0.01).toFixed(6)
  193. }
  194. },
  195. setData(){
  196. let proportion = this.proportion;
  197. this.tusdt_num = this.form.num * ((100-proportion)/100);
  198. this.taxn_num = this.form.num * (proportion/100) / this.quotation;
  199. this.tusdt_num = this.tusdt_num.toFixed(2);
  200. this.taxn_num = this.taxn_num.toFixed(4);
  201. },
  202. getquotation(param) {
  203. let ajax = Pledge.getquotation({ id: param });
  204. ajax.then((res) => {
  205. // 支付比例
  206. let proportion = res.data.proportion;
  207. console.log(res);
  208. this.quotation = res.data.price;
  209. this.proportion = proportion;
  210. // 支付usdt
  211. // if($proportion != 0){
  212. this.tusdt_num = this.form.num * ((100-proportion)/100);
  213. this.taxn_num = this.form.num * (proportion/100) / this.quotation;
  214. this.tusdt_num = this.tusdt_num.toFixed(2);
  215. this.taxn_num = this.taxn_num.toFixed(4);
  216. this.two_coin_name = res.data.two_coin_name;
  217. // }
  218. }).catch(() => {});
  219. },
  220. getParam() {
  221. // // #ifdef H5
  222. // let url = window.location.href;
  223. // // #endif
  224. // // #ifdef APP-PLUS
  225. // // let url =
  226. // // #endif
  227. // let idStr = url.split("?id=")[1];
  228. // let id = idStr.split("&")[0];
  229. return this.id;
  230. },
  231. pledgeCreateOrder() {
  232. this.$refs.popup.close();
  233. this.form.id = this.getParam();
  234. let patten = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
  235. let num = this.form.num;
  236. if (!patten.test(num)) {
  237. let numTips = this.$t("common.enter") + this.$t("common.money");
  238. this.$toast(numTips);
  239. return;
  240. }
  241. //check MinMaxNum
  242. if (num > this.maxnum || num < this.mixnum) {
  243. this.$toast(this.$t("pledge.qtxhlfwndsz"));
  244. return;
  245. }
  246. let data = this.form;
  247. let ajax = Pledge.buygoods(data, { btn: this.$refs.btn });
  248. ajax.then((res) => {
  249. // this.$route.push('/order');
  250. // #ifdef H5
  251. this.$dialog
  252. .confirm({
  253. title: this.$t("option.c1"),
  254. message: this.$t("pledge.goorder"),
  255. cancel: true,
  256. cancelButtonText: this.$t("common.cancelButtonText"),
  257. confirmButtonText: this.$t("common.confirmButtonText"),
  258. })
  259. .then(() => {
  260. this._router.replace("/pages/pledge/order");
  261. })
  262. .catch(() => {
  263. if (this.query.from) {
  264. this.$back();
  265. } else {
  266. this._router.replace("/pages/pledge/order");
  267. }
  268. });
  269. // #endif
  270. // #ifdef APP-PLUS
  271. if (this.query.from) {
  272. this.$back();
  273. } else {
  274. this._router.replace("/pages/pledge/order");
  275. }
  276. // #endif
  277. // this.$toast(this.$t('reg.c5'));
  278. }).catch(() => {});
  279. },
  280. jumpBack() {
  281. // this.$router.push({ path: "/pages/pledge/index" });
  282. uni.navigateTo({
  283. url:"/pages/pledge/index",
  284. fail() {
  285. uni.switchTab({
  286. url:"/pages/pledge/index"
  287. })
  288. }
  289. })
  290. },
  291. },
  292. onLoad(opt) {
  293. // let param = this.getParam();
  294. this.id = opt.id
  295. this.getDetail(this.id);
  296. },
  297. destroyed() {},
  298. };
  299. </script>
  300. <style lang="scss" scoped>
  301. .x-popup {
  302. background-color: #fff;
  303. padding: 34rpx;
  304. color: #333;
  305. .x-popup__title {
  306. font-size: 34rpx;
  307. }
  308. .x-form {
  309. .x-form__item {
  310. .x-form--label {
  311. text-align: left;
  312. display: block;
  313. margin-bottom: 8rpx;
  314. }
  315. .x-form__item-container {
  316. position: relative;
  317. display: block;
  318. .x-form--input {
  319. background-color: rgba(rgb(165, 165, 165), 0.2);
  320. height: 80rpx;
  321. border-radius: 20rpx;
  322. padding-right: 130rpx;
  323. padding-left: 20rpx;
  324. }
  325. .x-form__append {
  326. position: absolute;
  327. top: 50%;
  328. right: 20rpx;
  329. transform: translateY(-50%);
  330. }
  331. }
  332. .x-form--tips {
  333. display: block;
  334. text-align: left;
  335. margin-top: 8rpx;
  336. }
  337. }
  338. }
  339. .x-popup__tips {
  340. background-color: rgba(rgb(165, 165, 165), 0.2);
  341. padding: 32rpx 16rpx;
  342. margin-top: 16rpx;
  343. text-indent: 1em;
  344. margin-bottom: 36rpx;
  345. text {
  346. display: block;
  347. text-align: left;
  348. }
  349. }
  350. .x-popup__btn {
  351. background-image: $gradient-red;
  352. height: 80rpx;
  353. line-height: 80rpx;
  354. color: #fff;
  355. border-radius: 20rpx;
  356. }
  357. }
  358. .lunbo {
  359. margin: 30upx;
  360. height: 300upx;
  361. }
  362. .pledgeDetailMain {
  363. // height: 1100upx;
  364. overflow: auto;
  365. }
  366. .pledgeTitleLine {
  367. width: 11upx;
  368. height: 40upx;
  369. background: #ffc119;
  370. }
  371. .pledgeTitleFont {
  372. font-size: 36upx;
  373. margin-left: 15upx;
  374. position: relative;
  375. top: -8upx;
  376. }
  377. .pledgeDetailTitle {
  378. display: flex;
  379. flex-direction: row;
  380. padding: 30upx 30upx 0;
  381. }
  382. .pledgeDetailContent {
  383. padding: 15upx 30upx 0upx 30upx;
  384. max-height: 276upx;
  385. overflow: auto;
  386. }
  387. .detailTextLeft {
  388. }
  389. .detailTextRight {
  390. position: absolute;
  391. right: 0px;
  392. }
  393. input::-ms-input-placeholder {
  394. text-align: right;
  395. }
  396. input::-webkit-input-placeholder {
  397. text-align: right;
  398. }
  399. .detailInput {
  400. top: 20upx;
  401. width: 250upx;
  402. }
  403. .pledgeZynum {
  404. text-align: right;
  405. }
  406. .pledgeDetailFooter {
  407. width: 750upx;
  408. text-align: center;
  409. // position: fixed;
  410. width: 690upx;
  411. bottom: 30upx;
  412. z-index: 100;
  413. padding-bottom:30upx;
  414. margin: 0 30upx;
  415. }
  416. .pledgeLjzy {
  417. background-color: #ffc119;
  418. }
  419. .safe-area{
  420. padding-bottom: constant(safe-area-inset-bottom);
  421. padding-bottom: env(safe-area-inset-bottom);
  422. }
  423. .pld-mt {
  424. margin-top: 30upx;
  425. }
  426. </style>