pledge.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view class="all">
  3. <view class="navList flex">
  4. <view v-for="(item, index) in navList" :key="index" class="navItem"
  5. :class="{ activeItem: tabCurrentIndex === index,tip:index == 0 }" @click="tabClick(index)">{{ item }}
  6. </view>
  7. </view>
  8. <view style="padding-top: 44px;" v-if="tabCurrentIndex == 0">
  9. <view class="listBox">
  10. <view class="titleTetx">数量</view>
  11. <view class="flex listTpl">
  12. <input type="number" class="inputBox" v-model="number" placeholder="请输入数量" />
  13. <view class="flex_item">
  14. <view class="listTip">USDT</view>
  15. <view class="listAll" @click="number=money">全部</view>
  16. </view>
  17. </view>
  18. <view class="flex tipBox">
  19. <view class="tip1">可用余额{{money}}USDT</view>
  20. <view class="tip1">限额{{baseData.min_sell}}到{{baseData.max_sell}}个</view>
  21. </view>
  22. </view>
  23. <view class="listBox" style="padding-top: 0rpx;">
  24. <view class="listTpl">
  25. <input type="number" class="inputBox" v-model="price" placeholder="请输入单价" />
  26. </view>
  27. <view class="flex tipBox">
  28. <view class="tip1">单价不得大于参考汇率</view>
  29. </view>
  30. </view>
  31. <view class="submission">
  32. <button class="golden" type="golden" hover-class="none" @click="submission">一键卖币</button>
  33. </view>
  34. <view class="tips">*参考汇率{{baseData.us_price}}</view>
  35. </view>
  36. <view class="listItemBox" v-if="tabCurrentIndex == 1">
  37. <view class="listItem" v-for="item,index in list" :key="index">
  38. <view class="itemInfo flex">
  39. <view class="flex_item">
  40. <image src="/static/image/img20.png" style="width: 55rpx;height: 55rpx;" mode="widthFix"></image>
  41. <view class="name">{{item.real_name}}</view>
  42. </view>
  43. <image src="/static/image/img21.png" style="width: 40rpx;height: 31rpx;" mode="widthFix"></image>
  44. </view>
  45. <view class="itemTpl">{{item.price}}</view>
  46. <view class="itemTip flex">
  47. <view class="tipBox">
  48. <view class="tipText">数量:{{item.num}}</view>
  49. <view class="tipText">{{item.add_time|dateFormat}}</view>
  50. </view>
  51. <view class="tipBtn" @click="commitorder(item)">买入</view>
  52. </view>
  53. </view>
  54. <uni-load-more :status="loadingType"></uni-load-more>
  55. </view>
  56. <u-action-sheet :show="showBank" :actions="bankList" title="请选择银行卡"
  57. @close="showBank = false" @select="bankSelect">
  58. </u-action-sheet>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. getsell,
  64. sellPush,
  65. sellBuy
  66. } from '@/api/game.js';
  67. import {
  68. getIndex
  69. } from '@/api/index.js';
  70. import {
  71. mapState
  72. } from 'vuex';
  73. import {
  74. qianBao
  75. } from '@/api/wallet.js';
  76. import {
  77. getBank
  78. } from '@/api/set.js';
  79. import dayjs from '@/libs/dayjs/dayjs.min.js';
  80. export default {
  81. computed: {
  82. ...mapState('user', ['hasLogin','userInfo'])
  83. },
  84. filters: {
  85. dateFormat: function(value) {
  86. return dayjs(value * 1000).format('YYYY/MM/DD HH:mm');
  87. }
  88. },
  89. data() {
  90. return {
  91. tabCurrentIndex: 0,
  92. navList: ['卖出', '买入'],
  93. number: '',
  94. money:'',
  95. price: '',
  96. page: 1,
  97. limit: 10,
  98. list: [],
  99. loadingType: 'more',
  100. baseData:{
  101. min_sell:'',
  102. max_sell:''
  103. },
  104. loaded:false,
  105. showBank:false,
  106. bankList:[],
  107. bank_id:'',
  108. }
  109. },
  110. onNavigationBarButtonTap(res) {
  111. uni.navigateTo({
  112. url: '/pages/index/order'
  113. })
  114. },
  115. onShow() {
  116. this.init();
  117. },
  118. onLoad() {
  119. this.getIndex()
  120. },
  121. methods: {
  122. qianBao() {
  123. const that = this;
  124. qianBao().then((res) => {
  125. that.money = +res.data.like_usdt;
  126. })
  127. },
  128. getBank() {
  129. const obj = this;
  130. getBank().then((res) => {
  131. let data = res.data.list
  132. let reg = /^(.{4})(?:\d+)(.{4})$/
  133. data.forEach(item => {
  134. item.bank_code1 = item.bank_code.replace(reg, "**** $2")
  135. item.name = item.bank+' '+item.bank_code1
  136. })
  137. obj.bankList = data
  138. console.log(obj.bankList,'obj.bankList')
  139. })
  140. },
  141. bankSelect(e){
  142. const obj = this;
  143. this.bank_id = e.id
  144. if(this.bank_id){
  145. uni.showModal({
  146. title: '请输入支付密码',
  147. editable:true,
  148. success: res => {
  149. if(res.confirm){
  150. sellPush({
  151. type: 'USDT',
  152. num: obj.number,
  153. price: obj.price,
  154. phone: obj.userInfo.phone || '',
  155. trade_psw: res.content,
  156. sell_type: 'money',
  157. bank_id:obj.bank_id
  158. }).then((
  159. data
  160. ) => {
  161. uni.showModal({
  162. title: '提示',
  163. content: data.msg,
  164. icon:'none'
  165. });
  166. })
  167. .catch(e => {
  168. console.log(e);
  169. });
  170. }
  171. },
  172. fail: () => {},
  173. complete: () => {}
  174. });
  175. }
  176. },
  177. getIndex(){
  178. getIndex({})
  179. .then(({
  180. data
  181. }) => {
  182. this.baseData = data
  183. console.log(data);
  184. })
  185. .catch(e => {});
  186. },
  187. // 购买订单
  188. commitorder(item) {
  189. uni.showModal({
  190. title: '请输入支付密码',
  191. editable:true,
  192. success: res => {
  193. if (res.confirm) {
  194. if (res.content) {
  195. uni.showLoading({
  196. title: '支付中。。。',
  197. mask: true
  198. });
  199. sellBuy({
  200. id: item.id,
  201. trade_psw: res.content,
  202. }).then((
  203. data
  204. ) => {
  205. uni.hideLoading();
  206. uni.showModal({
  207. title: '提示',
  208. content: data.msg,
  209. showCancel: false,
  210. });
  211. })
  212. .catch(e => {
  213. uni.hideLoading()
  214. console.log(e);
  215. });
  216. }
  217. }
  218. },
  219. });
  220. },
  221. // 挂出
  222. submission() {
  223. let obj = this;
  224. if(obj.bankList.length > 0){
  225. obj.showBank = true
  226. }else{
  227. uni.showModal({
  228. title: '提示',
  229. content: '请先去添加银行卡',
  230. icon:'none'
  231. });
  232. }
  233. },
  234. init() {
  235. this.page = 1;
  236. this.list = [];
  237. this.loadingType = 'more';
  238. this.loadData();
  239. this.qianBao();
  240. this.getBank()
  241. },
  242. tabClick(index) {
  243. this.tabCurrentIndex = index;
  244. },
  245. async loadData(source) {
  246. const that = this;
  247. //这里是将订单挂载到tab列表下
  248. let navItem = that;
  249. if (source === 'tabChange' && navItem.loaded === true) {
  250. //tab切换只有第一次需要加载数据
  251. return;
  252. }
  253. if (navItem.loadingType === 'loading') {
  254. //防止重复加载
  255. return;
  256. }
  257. if (navItem.loadingType === 'noMore') {
  258. //防止重复加载
  259. return;
  260. }
  261. // 修改当前对象状态为加载中
  262. navItem.loadingType = 'loading';
  263. getsell({
  264. page: navItem.page,
  265. limit: navItem.limit
  266. })
  267. .then(({
  268. data
  269. }) => {
  270. // 保存我的总金额
  271. let arr = data.list.map(e => {
  272. e.num = e.num * 1;
  273. e.price = e.price * 1;
  274. return e;
  275. });
  276. navItem.list = navItem.list.concat(arr);
  277. if (navItem.limit == data.length) {
  278. navItem.page++;
  279. //判断是否还有数据, 有改为 more, 没有改为noMore
  280. navItem.loadingType = 'more';
  281. return;
  282. } else {
  283. //判断是否还有数据, 有改为 more, 没有改为noMore
  284. navItem.loadingType = 'noMore';
  285. }
  286. uni.hideLoading();
  287. that.loaded = true;
  288. })
  289. .catch(e => {
  290. console.log(e);
  291. });
  292. },
  293. }
  294. };
  295. </script>
  296. <style lang="scss">
  297. .all {
  298. width: 750rpx;
  299. height: 100%;
  300. background-color: #051137;
  301. padding-top: var(--status-bar-height);
  302. color: #fff;
  303. }
  304. .navList {
  305. padding: 20rpx 50rpx;
  306. background: #1F2A4A;
  307. line-height: 1;
  308. position: fixed;
  309. top: 44px;
  310. left: 0;
  311. width: 100%;
  312. z-index: 9;
  313. .navItem {
  314. color: #fff;
  315. font-size: 30rpx;
  316. text-align: center;
  317. width: 50%;
  318. &.activeItem {
  319. color: #0C5AFA;
  320. position: relative;
  321. &:after {
  322. content: '';
  323. position: absolute;
  324. left: 36%;
  325. bottom: -20rpx;
  326. width: 30%;
  327. height: 8rpx;
  328. // transform: translateX(-50%);
  329. border-bottom: 4rpx solid #0C5AFA;
  330. border-radius: 0rpx 20rpx 0rpx 0rpx;
  331. }
  332. }
  333. &.tip {
  334. border-right: 1rpx solid #333D5B;
  335. }
  336. }
  337. }
  338. .listBox {
  339. padding: 62rpx 32rpx;
  340. .titleTetx {
  341. font-weight: bold;
  342. font-size: 24rpx;
  343. color: #FFFFFF;
  344. padding-bottom: 25rpx;
  345. }
  346. .tipBox {
  347. padding-top: 15rpx;
  348. font-size: 24rpx;
  349. }
  350. }
  351. .listTpl {
  352. border-bottom: 1rpx solid #6A7288;
  353. padding-bottom: 25rpx;
  354. .inputBox {
  355. font-size: 35rpx;
  356. color: #FFFFFF;
  357. }
  358. .listTip {}
  359. .listAll {
  360. padding-left: 30rpx;
  361. font-size: 24rpx;
  362. color: #0C5AFA;
  363. }
  364. }
  365. .submission {
  366. padding: 80rpx 25rpx;
  367. padding-bottom: 25rpx;
  368. .golden {
  369. background: #0C5AFA;
  370. color: #ffffff;
  371. }
  372. }
  373. .tips {
  374. text-align: center;
  375. }
  376. .listItemBox {
  377. padding-top: 44px;
  378. .listItem {
  379. padding: 34rpx 34rpx;
  380. border-bottom: 1rpx solid #6A7288;
  381. .name {
  382. font-family: PingFang SC;
  383. font-weight: bold;
  384. font-size: 30rpx;
  385. color: #FFFFFF;
  386. padding-left: 25rpx;
  387. }
  388. .itemTpl {
  389. font-family: PingFang SC;
  390. font-weight: bold;
  391. font-size: 36rpx;
  392. color: #0C5AFA;
  393. padding-top: 25rpx;
  394. }
  395. .itemTip {
  396. .tipText {
  397. font-family: PingFang SC;
  398. font-weight: 500;
  399. font-size: 24rpx;
  400. color: #C1C1C1;
  401. padding-top: 15rpx;
  402. }
  403. .tipBtn {
  404. font-family: PingFang SC;
  405. font-weight: bold;
  406. font-size: 24rpx;
  407. color: #FFFFFF;
  408. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  409. border-radius: 7rpx;
  410. padding: 15rpx 35rpx;
  411. }
  412. }
  413. }
  414. }
  415. </style>