details.vue 12 KB

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