index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <view class="container">
  3. <view class="flex topTabBox">
  4. <view class="topListType position-relative" v-for="(item,ind) in typeList" @click="tabType(ind)">
  5. <view>
  6. {{$t(item.name)}}
  7. </view>
  8. <view class="topListTip" :class="{show:ind==typeIndex}">
  9. </view>
  10. </view>
  11. </view>
  12. <view class="tyoeList">
  13. <view class="list" v-for="item in typeList[typeIndex].list">
  14. <view class="flex oneBox">
  15. <view class="oneLeft flex-start">
  16. <image class="img" v-if="typeIndex!=4" :src="item.image" mode="scaleToFill"></image>
  17. <view class="nameBox flex">
  18. <view class="name">
  19. {{item.name}}
  20. </view>
  21. <view class="money" v-if="typeIndex!=4">
  22. {{item.money}}USDT
  23. </view>
  24. </view>
  25. </view>
  26. <view class="oneRight" v-if="typeIndex==0">
  27. {{$t('order.待支付')}}
  28. </view>
  29. <view class="oneRight" v-if="typeIndex==1">
  30. {{$t('order.待完成')}}
  31. </view>
  32. <view class="oneRight" v-if="typeIndex==2">
  33. <!-- 1 待结单 0待收益 2已结单 -->
  34. {{item.finish == 1 ?'待结单':item.finish == 0 ? $t('order.待收益'):'已结单'}}
  35. </view>
  36. <view class="oneRight" v-if="typeIndex==3">
  37. {{$t('order.已完成')}}
  38. </view>
  39. <view class="oneRight" v-if="typeIndex==4">
  40. {{item.status_chs}}
  41. </view>
  42. </view>
  43. <view class="position-relative twoBox flex">
  44. <view class="item">
  45. <view class="ll" v-if="typeIndex!=4&&typeIndex!=3">
  46. <text class="title">{{$t('order.日收益')}}:</text>
  47. <text class="num">{{item.up_ratio}}</text>
  48. </view>
  49. <view class="ll" v-if="typeIndex!=4&&typeIndex!=3">
  50. <text class="title">{{$t('order.周期')}}:</text>
  51. <text class="num">{{item.day}}{{$t('order.天')}}</text>
  52. </view>
  53. <view class="ll" v-if="typeIndex==4">
  54. <text class="title">{{$t('order.预约时间')}}:</text>
  55. <text class="num">{{item._created_time}}</text>
  56. </view>
  57. <view class="ll" v-if="typeIndex!=4">
  58. <text class="title">{{$t('order.匹配时间')}}:</text>
  59. <text class="num" v-if="typeIndex!=3">{{item.deal_time_text}}</text>
  60. <text class="num" v-else>{{item.createtime}}</text>
  61. </view>
  62. </view>
  63. <view class="payButtom" v-if="typeIndex==0&&!onOrderSn(item)" @click="openPayPassword(item)">
  64. {{$t('order.支付')}}
  65. </view>
  66. <view class="text-right" v-if="typeIndex==1">
  67. <view class="payText">
  68. {{$t('order.待收益')}}:{{item.income | failNumber}}
  69. </view>
  70. <view v-if="item.showswitch == 1" class="payButtom margin-t-20" @click="payVote(item.id)">
  71. {{$t('order.补票')}}
  72. </view>
  73. </view>
  74. <view class="payText" v-if="typeIndex==2">
  75. {{$t('order.已收益')}}:{{item.income | failNumber}}
  76. </view>
  77. <!-- <view class="payText" v-if="typeIndex==3" >
  78. {{$t('order.总收益')}}:{{item.money-money_now}}
  79. </view> -->
  80. </view>
  81. <view class="flex plan" v-if="typeIndex == 2 && item.finish == 1">
  82. <view class="planItem" @click="clickPlan(item.order_sn,1)">方案1</view>
  83. <view class="planItem" @click="clickPlan(item.order_sn,2)">方案2</view>
  84. </view>
  85. </view>
  86. </view>
  87. <u-loadmore :status="loading" line :loadmoreText="$t('base.加载更多')" :loadingText="$t('base.正在加载')"
  88. :nomoreText="$t('base.没有更多了')" />
  89. <!-- <uni-popup type="bottom" ref="popup" :mask-click="false" @maskClick='colsePayPassword'>
  90. <inputPassword @commit='KeyInfo' @colse='colsePayPassword'></inputPassword>
  91. </uni-popup> -->
  92. <taber></taber>
  93. </view>
  94. </template>
  95. <script>
  96. import {
  97. auctionOrders,
  98. payLog,
  99. appointmentList,
  100. pay,
  101. pay_check,
  102. tax,
  103. finish
  104. } from '@/api/index.js';
  105. import {
  106. mapState,
  107. mapMutations
  108. } from "vuex";
  109. import taber from "@/components/footer/footer.vue";
  110. import inputPassword from "@/components/input-password/input-password.vue";
  111. export default {
  112. components: {
  113. taber,
  114. inputPassword
  115. },
  116. data() {
  117. return {
  118. typeIndex: 0, //默认选中的切换
  119. typeList: [{
  120. name: 'order.待支付',
  121. list: [],
  122. type: 1
  123. },
  124. {
  125. name: 'order.待完成',
  126. list: [],
  127. type: 2
  128. },
  129. {
  130. name: 'order.待收益',
  131. list: [],
  132. type: 3
  133. },
  134. {
  135. name: 'order.紫金记录',
  136. list: [],
  137. type: 4
  138. },
  139. {
  140. name: 'order.预约记录',
  141. list: [],
  142. type: 5
  143. }
  144. ],
  145. page: 1,
  146. limit: 10,
  147. loading: 'loadmore', //加载状态
  148. actionItem: {},
  149. }
  150. },
  151. computed: {
  152. ...mapState("user", ['userInfo', 'orderList']),
  153. },
  154. onShow() {
  155. this.tabType(this.typeIndex, true)
  156. },
  157. onReachBottom() {
  158. this.loadData();
  159. },
  160. filters: {
  161. failNumber:function(number){
  162. return +(+number).toFixed(2)
  163. }
  164. },
  165. methods: {
  166. ...mapMutations("user", ['setOrderSn']),
  167. // 补票
  168. payVote(id) {
  169. const that = this;
  170. uni.showModal({
  171. title: that.$t('base.温馨提示'),
  172. content: that.$t('order.是否补票'),
  173. cancelText:that.$t('base.关闭'),
  174. confirmText:that.$t('base.确定'),
  175. success: res => {
  176. if (res.confirm) {
  177. tax({
  178. id
  179. }).then((res) => {
  180. that.tabType(that.typeIndex, true)
  181. uni.showToast({
  182. title: that.$t('order.补票成功'),
  183. });
  184. }).catch((res)=>{
  185. uni.showToast({
  186. title:res.msg,
  187. icon:'error'
  188. });
  189. })
  190. }
  191. },
  192. });
  193. },
  194. // 订单支付缓存
  195. onOrderSn(sn) {
  196. if (this.orderList.indexOf(sn.shuju.order_sn) > -1) {
  197. return true
  198. } else {
  199. return false
  200. }
  201. },
  202. // 转账
  203. async openPayPassword(item) {
  204. const that = this;
  205. if (this.onOrderSn(item)) {
  206. return
  207. }
  208. uni.showLoading({
  209. mask: true
  210. });
  211. try {
  212. const alertData = await pay_check({
  213. order_sn: item.shuju.order_sn,
  214. });
  215. const txHash = await ethereum.request({
  216. method: 'eth_sendTransaction',
  217. params: [{
  218. from: that.userInfo.address, // The user's active address.
  219. to: item.shuju.data.to,
  220. value: 0,
  221. data: item.shuju.data.data,
  222. }]
  223. })
  224. const req = await pay({
  225. order_sn: item.shuju.order_sn,
  226. hash: txHash,
  227. });
  228. that.tabType(that.typeIndex, true);
  229. that.setOrderSn(item.shuju.order_sn);
  230. uni.showToast({
  231. title: that.$t('order.支付成功')
  232. })
  233. } catch (e) {
  234. console.log(e, '错误‘');
  235. uni.showToast({
  236. title: e.msg,
  237. icon: 'error'
  238. })
  239. }
  240. },
  241. tabType(item, reload = false) {
  242. const that = this;
  243. if (item == that.typeIndex && !reload) {
  244. return
  245. }
  246. that.typeIndex = item;
  247. that.page = 1;
  248. that.typeList[item].list = [];
  249. that.loading = 'loadmore';
  250. that.loadData();
  251. },
  252. // 请求载入数据
  253. async loadData() {
  254. const that = this;
  255. const arr = this.typeList[this.typeIndex];
  256. if (that.loading == 'nomore' || that.loding == "loading") {
  257. return
  258. }
  259. that.loading = 'loading';
  260. switch (arr.type) {
  261. case 1:
  262. that.getAuctionOrders(arr)
  263. break;
  264. case 2:
  265. that.getAuctionOrders(arr)
  266. break;
  267. case 3:
  268. that.getAuctionOrders(arr)
  269. break;
  270. case 4:
  271. that.payLog(arr)
  272. break;
  273. case 5:
  274. that.appointmentList(arr)
  275. break;
  276. default:
  277. break;
  278. }
  279. },
  280. // 预约记录
  281. getAuctionOrders(item) {
  282. const that = this;
  283. auctionOrders({
  284. type: item.type
  285. }).then((res) => {
  286. item.list = res.data.map((rs) => {
  287. rs.money = +(+rs.money).toFixed(2);
  288. rs.income = +rs.income;
  289. return rs
  290. });
  291. that.loading = 'nomore'
  292. }).catch((res) => {
  293. console.log(res);
  294. })
  295. },
  296. // 紫金记录
  297. payLog(item) {
  298. const that = this;
  299. payLog({
  300. page: that.page,
  301. limit: that.limit,
  302. }).then((res) => {
  303. const list = res.data.list.map((rs) => {
  304. rs.money = +(+rs.money).toFixed(2);
  305. return rs
  306. })
  307. item.list = item.list.concat(list);
  308. if (list.length != that.limit) {
  309. that.loading = 'nomore'
  310. } else {
  311. that.page++
  312. that.loading = 'loadmore'
  313. }
  314. }).catch((res) => {
  315. console.log(res);
  316. })
  317. },
  318. // 预约记录
  319. appointmentList(item) {
  320. const that = this;
  321. appointmentList({
  322. page: that.page,
  323. limit: that.limit,
  324. }).then((res) => {
  325. let arr = res.data.list;
  326. item.list = item.list.concat(arr);
  327. console.log(arr.length, that.limit);
  328. if (arr.length != that.limit) {
  329. that.loading = 'nomore'
  330. } else {
  331. console.log('==');
  332. that.page++
  333. that.loading = 'loadmore'
  334. }
  335. console.log(res);
  336. }).catch((res) => {
  337. console.log(res);
  338. })
  339. },
  340. //待结算选择方案
  341. clickPlan(order_sn,type){
  342. const that = this;
  343. finish({
  344. order_sn: order_sn,
  345. type: type,
  346. }).then((res) => {
  347. if(res.code == 0){
  348. uni.showToast({
  349. title:res.msg,
  350. icon: 'error'
  351. })
  352. }else{
  353. that.typeIndex = 2;
  354. that.page = 1;
  355. that.typeList[that.typeIndex].list = [];
  356. that.loading = 'loadmore';
  357. that.loadData();
  358. }
  359. }).catch((res) => {
  360. console.log(res);
  361. })
  362. },
  363. },
  364. }
  365. </script>
  366. <style lang="scss">
  367. .container {
  368. width: 100%;
  369. padding: 30rpx;
  370. padding-top: var(--status-bar-height);
  371. }
  372. .topTabBox {
  373. position: fixed;
  374. top: 0;
  375. left: 0;
  376. right: 0;
  377. z-index: 999;
  378. background-color: rgba(255, 255, 255, 0.5);
  379. padding-bottom: 10rpx;
  380. .topListType {
  381. font-size: $font-base;
  382. font-weight: bold;
  383. padding-top: 30rpx;
  384. padding-bottom: 20rpx;
  385. flex-grow: 1;
  386. text-align: center;
  387. color: $font-color-light;
  388. .topListTip {
  389. width: 52rpx;
  390. height: 10rpx;
  391. background: linear-gradient(270deg, #1EC978, #DFFFEF);
  392. border-radius: 5rpx;
  393. position: absolute;
  394. left: 50%;
  395. margin-left: -26rpx;
  396. bottom: 0;
  397. display: none;
  398. &.show {
  399. display: block;
  400. }
  401. }
  402. }
  403. }
  404. .tyoeList {
  405. padding: 30rpx 0;
  406. padding-top: 130rpx;
  407. .list {
  408. padding: 30rpx;
  409. background-color: #FFF;
  410. border-radius: 10rpx;
  411. margin-bottom: 30rpx;
  412. .oneBox {
  413. align-items: flex-start;
  414. .oneLeft {
  415. align-items: stretch;
  416. line-height: 1;
  417. .img {
  418. flex-shrink: 0;
  419. width: 94rpx;
  420. height: 94rpx;
  421. }
  422. .nameBox {
  423. padding-left: 10rpx;
  424. flex-direction: column;
  425. align-items: stretch;
  426. .name {
  427. font-weight: bold;
  428. font-size: $font-lg;
  429. color: $font-color-dark;
  430. }
  431. .money {
  432. background-color: #FFF7B2;
  433. color: #905900;
  434. border: 2rpx solid #D3BF8D;
  435. font-size: 26rpx;
  436. padding: 8rpx 16rpx;
  437. border-radius: 6rpx;
  438. }
  439. }
  440. }
  441. .oneRight {
  442. font-size: $font-base;
  443. color: $font-color-dark;
  444. }
  445. }
  446. .twoBox {
  447. font-size: $font-base;
  448. line-height: 1;
  449. .text-right{
  450. display: flex;
  451. flex-direction: column;
  452. }
  453. .item {
  454. padding-top: 10rpx;
  455. .ll {
  456. padding-top: 10rpx;
  457. .title {
  458. color: $font-color-disabled;
  459. }
  460. .num {
  461. color: $font-color-base;
  462. }
  463. }
  464. }
  465. .payText {
  466. color: $font-color-disabled;
  467. }
  468. .payButtom {
  469. width: 160rpx;
  470. background: linear-gradient(90deg, #38F855, #21EDD3);
  471. border-radius: 10px;
  472. padding: 20rpx;
  473. text-align: center;
  474. }
  475. }
  476. .plan{
  477. padding: 15rpx 55rpx;
  478. .planItem{
  479. // background: #1DBC71;
  480. border: 2rpx solid #1DBC71;
  481. border-radius: 50rpx;
  482. font-size: 28rpx;
  483. font-weight: 500;
  484. color: #1DBC71;
  485. line-height: 55rpx;
  486. padding: 0rpx 70rpx;
  487. flex-shrink: 0;
  488. margin-top: 10rpx;
  489. }
  490. }
  491. }
  492. }
  493. </style>