pledge.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. </view>
  57. </template>
  58. <script>
  59. import {
  60. getsell,
  61. sellPush,
  62. sellBuy
  63. } from '@/api/game.js';
  64. import {
  65. getIndex
  66. } from '@/api/index.js';
  67. import {
  68. mapState
  69. } from 'vuex';
  70. import {
  71. qianBao
  72. } from '@/api/wallet.js';
  73. import dayjs from '@/libs/dayjs/dayjs.min.js';
  74. export default {
  75. computed: {
  76. ...mapState('user', ['hasLogin'])
  77. },
  78. filters: {
  79. dateFormat: function(value) {
  80. return dayjs(value * 1000).format('YYYY/MM/DD HH:mm');
  81. }
  82. },
  83. data() {
  84. return {
  85. tabCurrentIndex: 1,
  86. navList: ['卖出', '买入'],
  87. number: '',
  88. price: '',
  89. page: 1,
  90. limit: 10,
  91. list: [],
  92. loadingType: 'more',
  93. baseData:{
  94. min_sell:'',
  95. max_sell:''
  96. },
  97. loaded:false,
  98. }
  99. },
  100. onNavigationBarButtonTap(res) {
  101. uni.navigateTo({
  102. url: '/pages/index/order'
  103. })
  104. },
  105. onShow() {
  106. this.init();
  107. },
  108. onLoad() {
  109. this.getIndex()
  110. },
  111. methods: {
  112. qianBao() {
  113. const that = this;
  114. qianBao().then((res) => {
  115. that.money = +res.data.like_usdt;
  116. })
  117. },
  118. getIndex(){
  119. getIndex({})
  120. .then(({
  121. data
  122. }) => {
  123. this.baseData = data
  124. console.log(data);
  125. })
  126. .catch(e => {});
  127. },
  128. // 购买订单
  129. commitorder(item) {
  130. uni.showModal({
  131. title: '请输入支付密码',
  132. editable:true,
  133. success: res => {
  134. if (res.confirm) {
  135. if (res.content) {
  136. uni.showLoading({
  137. title: '支付中。。。',
  138. mask: true
  139. });
  140. sellBuy({
  141. id: item.id,
  142. trade_psw: res.content,
  143. }).then((
  144. data
  145. ) => {
  146. uni.hideLoading();
  147. uni.showModal({
  148. title: '提示',
  149. content: data.msg,
  150. showCancel: false,
  151. });
  152. })
  153. .catch(e => {
  154. uni.hideLoading()
  155. console.log(e);
  156. });
  157. }
  158. }
  159. },
  160. });
  161. },
  162. // 挂出
  163. submission() {
  164. sellPush({
  165. type: 'USDT',
  166. num: this.number,
  167. price: this.price,
  168. phone: '',
  169. trade_psw: '',
  170. sell_type: 'money',
  171. }).then(({
  172. data
  173. }) => {
  174. })
  175. .catch(e => {
  176. console.log(e);
  177. });
  178. },
  179. init() {
  180. this.page = 1;
  181. this.list = [];
  182. this.loadingType = 'more';
  183. this.loadData();
  184. this.qianBao();
  185. },
  186. tabClick(index) {
  187. this.tabCurrentIndex = index;
  188. },
  189. async loadData(source) {
  190. const that = this;
  191. //这里是将订单挂载到tab列表下
  192. let navItem = that;
  193. if (source === 'tabChange' && navItem.loaded === true) {
  194. //tab切换只有第一次需要加载数据
  195. return;
  196. }
  197. if (navItem.loadingType === 'loading') {
  198. //防止重复加载
  199. return;
  200. }
  201. if (navItem.loadingType === 'noMore') {
  202. //防止重复加载
  203. return;
  204. }
  205. // 修改当前对象状态为加载中
  206. navItem.loadingType = 'loading';
  207. getsell({
  208. page: navItem.page,
  209. limit: navItem.limit
  210. })
  211. .then(({
  212. data
  213. }) => {
  214. // 保存我的总金额
  215. let arr = data.list.map(e => {
  216. e.num = e.num * 1;
  217. e.price = e.price * 1;
  218. return e;
  219. });
  220. navItem.list = navItem.list.concat(arr);
  221. if (navItem.limit == data.length) {
  222. navItem.page++;
  223. //判断是否还有数据, 有改为 more, 没有改为noMore
  224. navItem.loadingType = 'more';
  225. return;
  226. } else {
  227. //判断是否还有数据, 有改为 more, 没有改为noMore
  228. navItem.loadingType = 'noMore';
  229. }
  230. uni.hideLoading();
  231. that.loaded = true;
  232. })
  233. .catch(e => {
  234. console.log(e);
  235. });
  236. },
  237. }
  238. };
  239. </script>
  240. <style lang="scss">
  241. .all {
  242. width: 750rpx;
  243. height: 100%;
  244. background-color: #051137;
  245. padding-top: var(--status-bar-height);
  246. color: #fff;
  247. }
  248. .navList {
  249. padding: 20rpx 50rpx;
  250. background: #1F2A4A;
  251. line-height: 1;
  252. position: fixed;
  253. top: 44px;
  254. left: 0;
  255. width: 100%;
  256. z-index: 9;
  257. .navItem {
  258. color: #fff;
  259. font-size: 30rpx;
  260. text-align: center;
  261. width: 50%;
  262. &.activeItem {
  263. color: #0C5AFA;
  264. position: relative;
  265. &:after {
  266. content: '';
  267. position: absolute;
  268. left: 36%;
  269. bottom: -20rpx;
  270. width: 30%;
  271. height: 8rpx;
  272. // transform: translateX(-50%);
  273. border-bottom: 4rpx solid #0C5AFA;
  274. border-radius: 0rpx 20rpx 0rpx 0rpx;
  275. }
  276. }
  277. &.tip {
  278. border-right: 1rpx solid #333D5B;
  279. }
  280. }
  281. }
  282. .listBox {
  283. padding: 62rpx 32rpx;
  284. .titleTetx {
  285. font-weight: bold;
  286. font-size: 24rpx;
  287. color: #FFFFFF;
  288. padding-bottom: 25rpx;
  289. }
  290. .tipBox {
  291. padding-top: 15rpx;
  292. font-size: 24rpx;
  293. }
  294. }
  295. .listTpl {
  296. border-bottom: 1rpx solid #6A7288;
  297. padding-bottom: 25rpx;
  298. .inputBox {
  299. font-size: 35rpx;
  300. color: #FFFFFF;
  301. }
  302. .listTip {}
  303. .listAll {
  304. padding-left: 30rpx;
  305. font-size: 24rpx;
  306. color: #0C5AFA;
  307. }
  308. }
  309. .submission {
  310. padding: 80rpx 25rpx;
  311. padding-bottom: 25rpx;
  312. .golden {
  313. background: #0C5AFA;
  314. color: #ffffff;
  315. }
  316. }
  317. .tips {
  318. text-align: center;
  319. }
  320. .listItemBox {
  321. padding-top: 44px;
  322. .listItem {
  323. padding: 34rpx 34rpx;
  324. border-bottom: 1rpx solid #6A7288;
  325. .name {
  326. font-family: PingFang SC;
  327. font-weight: bold;
  328. font-size: 30rpx;
  329. color: #FFFFFF;
  330. padding-left: 25rpx;
  331. }
  332. .itemTpl {
  333. font-family: PingFang SC;
  334. font-weight: bold;
  335. font-size: 36rpx;
  336. color: #0C5AFA;
  337. padding-top: 25rpx;
  338. }
  339. .itemTip {
  340. .tipText {
  341. font-family: PingFang SC;
  342. font-weight: 500;
  343. font-size: 24rpx;
  344. color: #C1C1C1;
  345. padding-top: 15rpx;
  346. }
  347. .tipBtn {
  348. font-family: PingFang SC;
  349. font-weight: bold;
  350. font-size: 24rpx;
  351. color: #FFFFFF;
  352. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  353. border-radius: 7rpx;
  354. padding: 15rpx 35rpx;
  355. }
  356. }
  357. }
  358. }
  359. </style>