details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view class="container">
  3. <view class="logo"><image :src="logo"></image></view>
  4. <view class="select-box flex_item">
  5. <view @tap="handleTap('picker')">{{ title }}</view>
  6. <lb-picker
  7. ref="picker"
  8. v-model="value"
  9. mode="selector"
  10. :list="typeList"
  11. :dataset="{ name: 'type' }"
  12. @change="handleChange"
  13. @confirm="handleConfirm"
  14. @cancel="handleCancel"
  15. ></lb-picker>
  16. <image src="../../static/img/xiaj.png"></image>
  17. </view>
  18. <view class="list" v-show="list.length > 0">
  19. <view class="list-box" v-for="(ls, index) in list" :key="index" @click="nav(index)">
  20. <view class="flex">
  21. <view class="list-tpl flex_item">
  22. <image src="../../static/img/qian.png"></image>
  23. <view class="tpl-name">{{ ls.title }}</view>
  24. </view>
  25. <view class="num clamp" v-if="ls.pm === 0">- {{ ls.number }}</view>
  26. <view class="num clamp" v-else>+ {{ ls.number }}</view>
  27. </view>
  28. <view class="tpl-time">{{ ls.add_time }}</view>
  29. </view>
  30. </view>
  31. <view class="empty-box" v-show="list.length == 0"><u-empty></u-empty></view>
  32. <view class="flex submit-box">
  33. <view class="submit" @click="recharge">充币</view>
  34. <view class="tip"></view>
  35. <view class="submit" @click="withdraw">提币</view>
  36. </view>
  37. <uni-popup ref="popup" type="center">
  38. <view class="popup">
  39. <view class="cancel flex" @click="close">
  40. <view></view>
  41. <view class="tip">x</view>
  42. </view>
  43. <view class="list-boxs">
  44. <view class="popup-text">购买数量:</view>
  45. <view class="password"><input type="number" v-model="num" placeholder="请输入算力数量" /></view>
  46. <view class="popup-text">币种选择:</view>
  47. <view class="content" @click="useOutClickSide"><easy-select ref="easySelect" :options="moneyTypeList" :value="name" @selectOne="selectOne"></easy-select></view>
  48. <view class="confirm-btn" @click="pay"><text>确认充币</text></view>
  49. </view>
  50. </view>
  51. </uni-popup>
  52. <uni-popup ref="mation" type="center">
  53. <view class="popup">
  54. <view class="cancel flex" @click="close2"><view class="tip">x</view></view>
  55. <view class="list-boxs">
  56. <view class="textBox flex">
  57. <view class="font">交易前:</view>
  58. <view class="number">{{ before * 1 }} {{ code }}</view>
  59. </view>
  60. <view class="xian"></view>
  61. <view class="textBox flex">
  62. <view class="font">交易额:</view>
  63. <view class="number">{{ pm }}{{ number * 1 }} {{ code }}</view>
  64. </view>
  65. <view class="xian"></view>
  66. <view class="textBox flex">
  67. <view class="font">交易后:</view>
  68. <view class="number">{{ balance * 1 }} {{ code }}</view>
  69. </view>
  70. <view class="xian"></view>
  71. <scroll-view scroll-y="true" class="textBox">
  72. <view class="font">流水详情:</view>
  73. <view class="text">{{ text }}</view>
  74. </scroll-view>
  75. </view>
  76. </view>
  77. </uni-popup>
  78. </view>
  79. </template>
  80. <script>
  81. import { moneyLog, recharge,wallet } from '@/api/finance.js';
  82. import LbPicker from '@/components/lb-picker';
  83. export default {
  84. components: {
  85. LbPicker,
  86. },
  87. data() {
  88. return {
  89. code: '',
  90. title: '筛选',
  91. type: '',
  92. value: '',
  93. index: 0,
  94. typeList: [],
  95. list: '',
  96. num: '',
  97. moneyTypeList: [],
  98. money: '',
  99. name: '',
  100. logo: '',
  101. price: '',
  102. mark: '',
  103. charge: 0,
  104. _address_qr: '',
  105. __money_address: '',
  106. ids: '',
  107. keysAddr: '',
  108. text: '',
  109. balance: '',
  110. before: '',
  111. number: '',
  112. pm: '',
  113. way: [],
  114. address: '',
  115. waypath: '',
  116. less: '',
  117. page: 1,
  118. limit: 5,
  119. isLast: true
  120. };
  121. },
  122. onLoad(option) {
  123. console.log(option, 'detail-option');
  124. this.waypath = option.waypath;
  125. console.log(this.waypath, '+++++++++++++++++++++');
  126. this.way = option.way;
  127. console.log('detail', this.way);
  128. this.code = option.code;
  129. this.logo = option.logo;
  130. this.name = option.name;
  131. this.price = option.price;
  132. this.charge = option.charge;
  133. this.address = option.address;
  134. console.log(this.address, 'detail');
  135. this._address_qr = option._address_qr;
  136. this.__money_address = option.__money_address;
  137. this.mark = option.mark;
  138. this.ids = option.ids;
  139. this.keysAddr = option.keysAddr;
  140. this.moneyType();
  141. this.loadData();
  142. },
  143. onShow() {},
  144. methods: {
  145. async loadData() {
  146. let obj = this;
  147. moneyLog(
  148. {
  149. page: 1,
  150. limit: 10000,
  151. type: obj.type
  152. },
  153. obj.code
  154. ).then(({ data }) => {
  155. obj.typeList = data.type_list;
  156. obj.list = data.list;
  157. console.log(obj.list);
  158. });
  159. },
  160. // 所有币种
  161. async moneyType() {
  162. let obj = this;
  163. wallet({}).then(({ data }) => {
  164. const arr = Object.keys(data.back);
  165. console.log(arr);
  166. let ar = [];
  167. arr.forEach(e => {
  168. ar.push(data.back[e]);
  169. });
  170. obj.moneyTypeList = ar.filter(e => {
  171. console.log(e);
  172. if(e.can_trade == 1){
  173. return e;
  174. }
  175. else{
  176. return ;
  177. }
  178. });
  179. console.log(obj.moneyTypeList);
  180. if (obj.logo == '') {
  181. obj.logo = obj.moneyTypeList[0].LOGO;
  182. obj.name = obj.moneyTypeList[0].name;
  183. obj.code = obj.moneyTypeList[0].code;
  184. obj.money = obj.moneyTypeList[0].money.money;
  185. }
  186. });
  187. },
  188. pay() {
  189. let obj = this;
  190. recharge(
  191. {
  192. num: obj.num,
  193. money_type: obj.code
  194. },
  195. obj.buyId
  196. )
  197. .then(({ data }) => {
  198. obj.$api.msg(data.msg);
  199. obj.$refs.popup.close();
  200. obj.num = '';
  201. obj.code = '';
  202. uni.navigateTo({
  203. url: '/pages/finance/recharge?LOGO=' + data._address_qr + '&order_id=' + data.order_id + '&ddress=' + data.__money_address + '&id=' + data.id
  204. });
  205. })
  206. .catch(e => {
  207. obj.$refs.popup.close();
  208. });
  209. },
  210. selectOne(options) {
  211. this.name = options.name;
  212. this.code = options.code;
  213. },
  214. useOutClickSide() {
  215. this.$refs.easySelect.hideOptions && this.$refs.easySelect.hideOptions();
  216. },
  217. handleTap(name) {
  218. this.$refs[name].show();
  219. },
  220. handleChange(e) {
  221. // this.title = e.item.title;
  222. // this.type = e.item.type;
  223. },
  224. handleConfirm(e) {
  225. this.title = e.item.title;
  226. this.type = e.item.type;
  227. this.loadData();
  228. },
  229. handleCancel(e) {},
  230. recharge() {
  231. let url = '/pages/finance/recharge?logo=' +
  232. this.logo +
  233. '&name=' +
  234. this.name +
  235. '&code=' +
  236. this.code +
  237. '&_address_qr=' +
  238. this._address_qr +
  239. '&__money_address=' +
  240. this.__money_address +
  241. '&mark=' +
  242. this.mark +
  243. '&ids=' +
  244. this.ids +
  245. '&keysAddr=' +
  246. this.keysAddr +
  247. '&charge=' +
  248. this.charge +
  249. '&address=' +
  250. this.address +
  251. '&way=' +
  252. this.way +
  253. '&waypath=' +
  254. this.waypath
  255. if(this.code === 'FIL') {
  256. console.log("555555555")
  257. url='/pages/finance/recharge'
  258. }
  259. uni.navigateTo({
  260. url:url
  261. // '/pages/finance/recharge?logo=' +
  262. // this.logo +
  263. // '&name=' +
  264. // this.name +
  265. // '&code=' +
  266. // this.code +
  267. // '&_address_qr=' +
  268. // this._address_qr +
  269. // '&__money_address=' +
  270. // this.__money_address +
  271. // '&mark=' +
  272. // this.mark +
  273. // '&ids=' +
  274. // this.ids +
  275. // '&keysAddr=' +
  276. // this.keysAddr +
  277. // '&charge=' +
  278. // this.charge +
  279. // '&address=' +
  280. // this.address +
  281. // '&way=' +
  282. // this.way +
  283. // '&waypath=' +
  284. // this.waypath
  285. });
  286. // this.$refs.popup.open();
  287. },
  288. close() {
  289. this.$refs.popup.close();
  290. },
  291. withdraw() {
  292. uni.navigateTo({
  293. url: '/pages/finance/withdraw?logo=' + this.logo + '&name=' + this.name + '&code=' + this.code + '&money=' + this.price
  294. });
  295. },
  296. navTo(url) {
  297. uni.navigateTo({
  298. url
  299. });
  300. },
  301. nav(index) {
  302. const obj = this;
  303. obj.text = obj.list[index].mark;
  304. obj.balance = obj.list[index].balance;
  305. obj.number = obj.list[index].number;
  306. if (obj.list[index].pm == 1) {
  307. obj.pm = '+';
  308. obj.before = obj.subNum(obj.balance, obj.number);
  309. } else {
  310. obj.pm = '-';
  311. obj.before = this.addNum(obj.balance, obj.number);
  312. }
  313. this.$refs.mation.open();
  314. },
  315. addNum(num1, num2) {
  316. let sq1, sq2, multiple;
  317. try {
  318. sq1 = num1.toString().split('.')[1].length;
  319. } catch (e) {
  320. sq1 = 0;
  321. }
  322. try {
  323. sq2 = num2.toString().split('.')[1].length;
  324. } catch (e) {
  325. sq2 = 0;
  326. }
  327. multiple = Math.pow(10, Math.max(sq1, sq2) + 1);
  328. return (num1 * multiple + num2 * multiple) / multiple;
  329. },
  330. close2() {
  331. this.$refs.mation.close();
  332. },
  333. subNum(num1, num2) {
  334. let sq1, sq2, multiple;
  335. try {
  336. sq1 = num1.toString().split('.')[1].length;
  337. } catch (e) {
  338. sq1 = 0;
  339. }
  340. try {
  341. sq2 = num2.toString().split('.')[1].length;
  342. } catch (e) {
  343. sq2 = 0;
  344. }
  345. multiple = Math.pow(10, Math.max(sq1, sq2) + 1);
  346. return (num1 * multiple - num2 * multiple) / multiple;
  347. }
  348. }
  349. };
  350. </script>
  351. <style lang="scss">
  352. page {
  353. min-height: 100%;
  354. background-color: #ffffff;
  355. .container {
  356. width: 100%;
  357. padding: 60rpx 30rpx 120rpx 30rpx;
  358. }
  359. }
  360. .logo {
  361. text-align: center;
  362. image {
  363. width: 119rpx;
  364. height: 119rpx;
  365. }
  366. }
  367. .select-box {
  368. position: absolute;
  369. right: 0;
  370. padding: 30rpx 30rpx;
  371. font-size: 32rpx;
  372. font-weight: 500;
  373. color: #333333;
  374. image {
  375. width: 21rpx;
  376. height: 11rpx;
  377. margin-left: 15rpx;
  378. }
  379. .select-name {
  380. padding-right: 15rpx;
  381. }
  382. }
  383. .list {
  384. margin-top: 120rpx;
  385. }
  386. .list-box {
  387. padding: 60rpx 0rpx 30rpx 0rpx;
  388. font-size: 30rpx;
  389. font-weight: 400;
  390. color: #333333;
  391. .tpl-time {
  392. font-size: 24rpx;
  393. font-weight: 400;
  394. color: #999999;
  395. width: 100%;
  396. text-align: right;
  397. padding-top: 25rpx;
  398. }
  399. .list-tpl {
  400. image {
  401. width: 39rpx;
  402. height: 43rpx;
  403. }
  404. .tpl-name {
  405. padding: 0rpx 15rpx 0rpx 30rpx;
  406. }
  407. }
  408. .num {
  409. font-size: 36rpx;
  410. font-weight: 400;
  411. color: #fb3a2f;
  412. width: 50%;
  413. text-align: right;
  414. }
  415. }
  416. .empty-box {
  417. width: 100%;
  418. height: 500rpx;
  419. padding-top: 200rpx;
  420. }
  421. .submit-box {
  422. position: fixed;
  423. bottom: 0;
  424. left: 0;
  425. width: 100%;
  426. background-color: #5771df;
  427. color: #ffffff;
  428. .submit {
  429. padding: 20rpx 20%;
  430. }
  431. .tip {
  432. width: 2rpx;
  433. height: 37rpx;
  434. background: #ffffff;
  435. }
  436. }
  437. //弹窗
  438. .popup {
  439. background-color: #ffffff;
  440. border-radius: 25rpx;
  441. font-size: 30rpx;
  442. .cancel {
  443. text-align: center;
  444. width: 100%;
  445. line-height: 60rpx;
  446. .tip {
  447. background-color: #5771df;
  448. color: #ffffff;
  449. width: 70rpx;
  450. height: 70rpx;
  451. border-top-right-radius: 25rpx;
  452. }
  453. }
  454. .list-boxs {
  455. padding: 0rpx 80rpx;
  456. .password {
  457. padding: 50rpx 0rpx;
  458. width: 100%;
  459. input {
  460. width: 70%;
  461. height: 80rpx;
  462. border: 2rpx solid #999999;
  463. padding-left: 25rpx;
  464. box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.27);
  465. border-radius: 11rpx;
  466. }
  467. }
  468. .confirm-btn {
  469. padding-bottom: 120rpx;
  470. padding-top: 30rpx;
  471. text {
  472. background-color: #5771df;
  473. color: #ffffff;
  474. width: 70%;
  475. text-align: center;
  476. padding: 25rpx 90rpx;
  477. border-radius: 15rpx;
  478. }
  479. }
  480. }
  481. }
  482. .popup {
  483. height: 618rpx;
  484. background: #ffffff;
  485. box-shadow: 3rpx 3rpx 6rpx 0rpx rgba(31, 31, 31, 0.17);
  486. border-radius: 40rpx;
  487. width: 700rpx;
  488. .cancel {
  489. text-align: center;
  490. width: 100%;
  491. line-height: 60rpx;
  492. position: relative;
  493. .tip {
  494. color: #000000;
  495. width: 70rpx;
  496. height: 70rpx;
  497. position: absolute;
  498. top: 0;
  499. right: 0;
  500. background-color: #fff;
  501. }
  502. }
  503. .list-boxs {
  504. width: 90%;
  505. margin: 0 auto;
  506. margin-top: 100rpx;
  507. .textBox {
  508. padding: 24rpx 18rpx;
  509. .font {
  510. font-size: 28rpx;
  511. font-family: PingFang SC;
  512. font-weight: bold;
  513. color: #4f4f4f;
  514. }
  515. .number {
  516. font-size: 28rpx;
  517. font-family: PingFang SC;
  518. font-weight: bold;
  519. color: #fb3a2f;
  520. }
  521. .text {
  522. text-indent: 2em;
  523. font-size: 28rpx;
  524. font-family: PingFang SC;
  525. font-weight: bold;
  526. color: #4f4f4f;
  527. }
  528. }
  529. .xian {
  530. width: 100%;
  531. height: 1px;
  532. background: #e7dfe8;
  533. }
  534. }
  535. }
  536. </style>