details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. uni.navigateTo({
  214. url:
  215. '/pages/finance/recharge?logo=' +
  216. this.logo +
  217. '&name=' +
  218. this.name +
  219. '&code=' +
  220. this.code +
  221. '&_address_qr=' +
  222. this._address_qr +
  223. '&__money_address=' +
  224. this.__money_address +
  225. '&mark=' +
  226. this.mark +
  227. '&ids=' +
  228. this.ids +
  229. '&keysAddr=' +
  230. this.keysAddr +
  231. '&charge=' +
  232. this.charge +
  233. '&address=' +
  234. this.address +
  235. '&way=' +
  236. this.way +
  237. '&waypath=' +
  238. this.waypath
  239. });
  240. // this.$refs.popup.open();
  241. },
  242. close() {
  243. this.$refs.popup.close();
  244. },
  245. withdraw() {
  246. uni.navigateTo({
  247. url: '/pages/finance/withdraw?logo=' + this.logo + '&name=' + this.name + '&code=' + this.code + '&money=' + this.price
  248. });
  249. },
  250. navTo(url) {
  251. uni.navigateTo({
  252. url
  253. });
  254. },
  255. nav(index) {
  256. const obj = this;
  257. obj.text = obj.list[index].mark;
  258. obj.balance = obj.list[index].balance;
  259. obj.number = obj.list[index].number;
  260. if (obj.list[index].pm == 1) {
  261. obj.pm = '+';
  262. obj.before = obj.subNum(obj.balance, obj.number);
  263. } else {
  264. obj.pm = '-';
  265. obj.before = this.addNum(obj.balance, obj.number);
  266. }
  267. this.$refs.mation.open();
  268. },
  269. addNum(num1, num2) {
  270. let sq1, sq2, multiple;
  271. try {
  272. sq1 = num1.toString().split('.')[1].length;
  273. } catch (e) {
  274. sq1 = 0;
  275. }
  276. try {
  277. sq2 = num2.toString().split('.')[1].length;
  278. } catch (e) {
  279. sq2 = 0;
  280. }
  281. multiple = Math.pow(10, Math.max(sq1, sq2) + 1);
  282. return (num1 * multiple + num2 * multiple) / multiple;
  283. },
  284. close2() {
  285. this.$refs.mation.close();
  286. },
  287. subNum(num1, num2) {
  288. let sq1, sq2, multiple;
  289. try {
  290. sq1 = num1.toString().split('.')[1].length;
  291. } catch (e) {
  292. sq1 = 0;
  293. }
  294. try {
  295. sq2 = num2.toString().split('.')[1].length;
  296. } catch (e) {
  297. sq2 = 0;
  298. }
  299. multiple = Math.pow(10, Math.max(sq1, sq2) + 1);
  300. return (num1 * multiple - num2 * multiple) / multiple;
  301. }
  302. }
  303. };
  304. </script>
  305. <style lang="scss">
  306. page {
  307. min-height: 100%;
  308. background-color: #ffffff;
  309. .container {
  310. width: 100%;
  311. padding: 60rpx 30rpx 120rpx 30rpx;
  312. }
  313. }
  314. .logo {
  315. text-align: center;
  316. image {
  317. width: 119rpx;
  318. height: 119rpx;
  319. }
  320. }
  321. .select-box {
  322. position: absolute;
  323. right: 0;
  324. padding: 30rpx 30rpx;
  325. font-size: 32rpx;
  326. font-weight: 500;
  327. color: #333333;
  328. image {
  329. width: 21rpx;
  330. height: 11rpx;
  331. margin-left: 15rpx;
  332. }
  333. .select-name {
  334. padding-right: 15rpx;
  335. }
  336. }
  337. .list {
  338. margin-top: 120rpx;
  339. }
  340. .list-box {
  341. padding: 60rpx 0rpx 30rpx 0rpx;
  342. font-size: 30rpx;
  343. font-weight: 400;
  344. color: #333333;
  345. .tpl-time {
  346. font-size: 24rpx;
  347. font-weight: 400;
  348. color: #999999;
  349. width: 100%;
  350. text-align: right;
  351. padding-top: 25rpx;
  352. }
  353. .list-tpl {
  354. image {
  355. width: 39rpx;
  356. height: 43rpx;
  357. }
  358. .tpl-name {
  359. padding: 0rpx 15rpx 0rpx 30rpx;
  360. }
  361. }
  362. .num {
  363. font-size: 36rpx;
  364. font-weight: 400;
  365. color: #fb3a2f;
  366. width: 50%;
  367. text-align: right;
  368. }
  369. }
  370. .empty-box {
  371. width: 100%;
  372. height: 500rpx;
  373. padding-top: 200rpx;
  374. }
  375. .submit-box {
  376. position: fixed;
  377. bottom: 0;
  378. left: 0;
  379. width: 100%;
  380. background-color: #5771df;
  381. color: #ffffff;
  382. .submit {
  383. padding: 20rpx 20%;
  384. }
  385. .tip {
  386. width: 2rpx;
  387. height: 37rpx;
  388. background: #ffffff;
  389. }
  390. }
  391. //弹窗
  392. .popup {
  393. background-color: #ffffff;
  394. border-radius: 25rpx;
  395. font-size: 30rpx;
  396. .cancel {
  397. text-align: center;
  398. width: 100%;
  399. line-height: 60rpx;
  400. .tip {
  401. background-color: #5771df;
  402. color: #ffffff;
  403. width: 70rpx;
  404. height: 70rpx;
  405. border-top-right-radius: 25rpx;
  406. }
  407. }
  408. .list-boxs {
  409. padding: 0rpx 80rpx;
  410. .password {
  411. padding: 50rpx 0rpx;
  412. width: 100%;
  413. input {
  414. width: 70%;
  415. height: 80rpx;
  416. border: 2rpx solid #999999;
  417. padding-left: 25rpx;
  418. box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.27);
  419. border-radius: 11rpx;
  420. }
  421. }
  422. .confirm-btn {
  423. padding-bottom: 120rpx;
  424. padding-top: 30rpx;
  425. text {
  426. background-color: #5771df;
  427. color: #ffffff;
  428. width: 70%;
  429. text-align: center;
  430. padding: 25rpx 90rpx;
  431. border-radius: 15rpx;
  432. }
  433. }
  434. }
  435. }
  436. .popup {
  437. height: 618rpx;
  438. background: #ffffff;
  439. box-shadow: 3rpx 3rpx 6rpx 0rpx rgba(31, 31, 31, 0.17);
  440. border-radius: 40rpx;
  441. width: 700rpx;
  442. .cancel {
  443. text-align: center;
  444. width: 100%;
  445. line-height: 60rpx;
  446. position: relative;
  447. .tip {
  448. color: #000000;
  449. width: 70rpx;
  450. height: 70rpx;
  451. position: absolute;
  452. top: 0;
  453. right: 0;
  454. background-color: #fff;
  455. }
  456. }
  457. .list-boxs {
  458. width: 90%;
  459. margin: 0 auto;
  460. margin-top: 100rpx;
  461. .textBox {
  462. padding: 24rpx 18rpx;
  463. .font {
  464. font-size: 28rpx;
  465. font-family: PingFang SC;
  466. font-weight: bold;
  467. color: #4f4f4f;
  468. }
  469. .number {
  470. font-size: 28rpx;
  471. font-family: PingFang SC;
  472. font-weight: bold;
  473. color: #fb3a2f;
  474. }
  475. .text {
  476. text-indent: 2em;
  477. font-size: 28rpx;
  478. font-family: PingFang SC;
  479. font-weight: bold;
  480. color: #4f4f4f;
  481. }
  482. }
  483. .xian {
  484. width: 100%;
  485. height: 1px;
  486. background: #e7dfe8;
  487. }
  488. }
  489. }
  490. </style>