details.vue 11 KB

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