mytz.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <image src="../../static/img/tzbg.png" mode=""></image>
  6. <view class="money"><text class="money-icon">¥</text>{{ userInfo.now_money | getMoneyStyle }}</view>
  7. <view class="tzzz" @click="navto('/pages/vip/tzzz')">
  8. 通证转账
  9. </view>
  10. <view class="zzjl" @click="navto('/pages/vip/zzjl')">
  11. 转账记录
  12. </view>
  13. </view>
  14. </view>
  15. <view class="navbar">
  16. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)" v-if="item.text!=='全部'">{{ item.text }}</view>
  17. </view>
  18. <swiper :current="tabCurrentIndex" :style="{'height':maxheight+'px'}" class="swiper-box" duration="300" @change="changeTab">
  19. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  20. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  21. <!-- 空白页 -->
  22. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  23. <!-- 订单列表 -->
  24. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  25. <view class="title-box">
  26. <view class="title">
  27. <text>{{ item.title }}</text>
  28. </view>
  29. <view class="time">
  30. <text>{{ item.add_time }}</text>
  31. </view>
  32. </view>
  33. <view class="money">
  34. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  35. </view>
  36. <view class="jg"></view>
  37. </view>
  38. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  39. </scroll-view>
  40. </swiper-item>
  41. </swiper>
  42. <!-- <view class="add-btn" @click="addmoney">立刻充值</view> -->
  43. </view>
  44. </template>
  45. <script>
  46. import { mapState, mapMutations } from 'vuex';
  47. import { spreadCommission, userBalance } from '@/api/wallet.js';
  48. import { getMoneyStyle } from '@/utils/rocessor.js';
  49. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  50. import empty from '@/components/empty';
  51. export default {
  52. filters: {
  53. getMoneyStyle
  54. },
  55. components: {
  56. empty,
  57. uniLoadMore
  58. },
  59. onReady() {
  60. // 初始化获取页面宽度
  61. uni.createSelectorQuery()
  62. .select('.content')
  63. .fields(
  64. {
  65. size: true
  66. },
  67. data => {
  68. console.log(data);
  69. console.log(Math.floor((data.width / 750) * 300));
  70. // 保存头部高度
  71. this.maxheight =data.height - Math.floor((data.width / 750) * 570);
  72. console.log(this.maxheight);
  73. }
  74. )
  75. .exec();
  76. },
  77. data() {
  78. return {
  79. // 头部图高度
  80. maxheight:'',
  81. tabCurrentIndex: 0,
  82. navList: [
  83. {
  84. state: 2,
  85. text: '收入',
  86. loadingType: 'more',
  87. orderList: [],
  88. page: 1, //当前页数
  89. limit: 10 //每次信息条数
  90. },
  91. {
  92. state: 1,
  93. text: '支出',
  94. loadingType: 'more',
  95. orderList: [
  96. ],
  97. page: 1, //当前页数
  98. limit: 10 //每次信息条数
  99. },
  100. ],
  101. money: ''
  102. };
  103. },
  104. computed: {
  105. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  106. },
  107. onLoad(options) {},
  108. onShow() {
  109. this.loadData();
  110. // 获取用户余额
  111. },
  112. methods: {
  113. // 页面跳转
  114. navto(e) {
  115. uni.navigateTo({
  116. url: e
  117. });
  118. },
  119. //获取收入支出信息
  120. async loadData(source) {
  121. //这里是将订单挂载到tab列表下
  122. let index = this.tabCurrentIndex;
  123. let navItem = this.navList[index];
  124. let state = navItem.state;
  125. if (source === 'tabChange' && navItem.loaded === true) {
  126. //tab切换只有第一次需要加载数据
  127. return;
  128. }
  129. if (navItem.loadingType === 'loading') {
  130. //防止重复加载
  131. return;
  132. }
  133. // 修改当前对象状态为加载中
  134. navItem.loadingType = 'loading';
  135. spreadCommission(
  136. {
  137. page: navItem.page,
  138. limit: navItem.limit
  139. },
  140. state
  141. )
  142. .then(({ data }) => {
  143. console.log(data);
  144. // if (data.count > 0) {
  145. // navItem.orderList = navItem.orderList.concat(data.list);
  146. // console.log(navItem.orderList);
  147. // navItem.page++;
  148. // }
  149. if (data.length > 0) {
  150. navItem.orderList = navItem.orderList.concat(data[0].list);
  151. console.log(navItem.orderList);
  152. navItem.page++;
  153. }
  154. if (navItem.limit == data.length) {
  155. //判断是否还有数据, 有改为 more, 没有改为noMore
  156. navItem.loadingType = 'more';
  157. return;
  158. } else {
  159. //判断是否还有数据, 有改为 more, 没有改为noMore
  160. navItem.loadingType = 'noMore';
  161. }
  162. uni.hideLoading();
  163. this.$set(navItem, 'loaded', true);
  164. })
  165. .catch(e => {
  166. console.log(e);
  167. });
  168. },
  169. //swiper 切换
  170. changeTab(e) {
  171. this.tabCurrentIndex = e.target.current;
  172. this.loadData('tabChange');
  173. },
  174. //顶部tab点击
  175. tabClick(index) {
  176. this.tabCurrentIndex = index;
  177. },
  178. addmoney() {
  179. uni.navigateTo({
  180. url: '/pages/money/recharge'
  181. })
  182. }
  183. }
  184. };
  185. </script>
  186. <style lang="scss">
  187. page {
  188. background: #ffffff;
  189. height: 100%;
  190. }
  191. .content-money {
  192. padding-bottom: 30rpx;
  193. background: $page-color-base;
  194. .moneyTx {
  195. position: absolute;
  196. top: 150rpx;
  197. right: 0rpx;
  198. width: 150rpx;
  199. padding: 10rpx 30rpx;
  200. border: 2px solid #ffffff;
  201. border-top-left-radius: 99rpx;
  202. border-bottom-left-radius: 99rpx;
  203. color: #ffffff;
  204. line-height: 1;
  205. font-size: $font-base;
  206. }
  207. .buttom-box {
  208. background-color: #ffffff;
  209. text-align: center;
  210. margin: 0 30rpx;
  211. padding: 20rpx 0;
  212. border-radius: $border-radius-sm;
  213. margin-top: -60rpx;
  214. .buttom {
  215. font-size: $font-lg;
  216. flex-grow: 1;
  217. }
  218. .interval {
  219. width: 2px;
  220. height: 60rpx;
  221. background-color: #eeeeee;
  222. }
  223. .icon {
  224. height: 50rpx;
  225. width: 48rpx;
  226. margin: 0 auto;
  227. .icon-img {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. }
  232. }
  233. }
  234. .money-box {
  235. // background-color: $base-color;
  236. // padding-top: var(--status-bar-height);
  237. height: 400rpx;
  238. color: #FF4C4C;
  239. text-align: center;
  240. position: relative;
  241. .tzzz {
  242. width: 139rpx;
  243. line-height: 50rpx;
  244. background: #fff;
  245. border-radius: 7rpx;
  246. position: absolute;
  247. top: 20rpx;
  248. right: 0;
  249. text-align: center;
  250. font-size: 26rpx;
  251. font-family: PingFang SC;
  252. font-weight: bold;
  253. color: #E83F30;
  254. }
  255. .zzjl {
  256. width: 139rpx;
  257. line-height: 50rpx;
  258. background: #fff;
  259. border-radius: 7rpx;
  260. position: absolute;
  261. top: 90rpx;
  262. right: 0;
  263. text-align: center;
  264. font-size: 26rpx;
  265. font-family: PingFang SC;
  266. font-weight: bold;
  267. color: #E83F30;
  268. }
  269. image {
  270. position: absolute;
  271. top: 0;
  272. right: 0;
  273. height: 100%;
  274. width: 100%;
  275. // z-index: 1;
  276. }
  277. .text {
  278. padding-top: 147rpx;
  279. font-size: $font-sm;
  280. position: relative;
  281. }
  282. .money {
  283. padding-top: 175rpx;
  284. // margin: auto 0;
  285. font-size: 56rpx;
  286. font-weight: bold;
  287. color: #fff;
  288. position: relative;
  289. .money-icon {
  290. font-size: 38rpx;
  291. font-weight: bold;
  292. color: #Fff;
  293. }
  294. }
  295. }
  296. .navbar {
  297. display: flex;
  298. height: 40px;
  299. padding: 0 5px;
  300. background: #fff;
  301. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  302. position: relative;
  303. z-index: 10;
  304. .nav-item {
  305. flex: 1;
  306. display: flex;
  307. justify-content: center;
  308. align-items: center;
  309. height: 100%;
  310. font-size: 15px;
  311. color: #999999;
  312. position: relative;
  313. &.current {
  314. color: $base-color;
  315. &:after {
  316. content: '';
  317. position: absolute;
  318. left: 50%;
  319. bottom: 0;
  320. transform: translateX(-50%);
  321. width: 44px;
  322. height: 0;
  323. border-bottom: 2px solid $base-color;
  324. }
  325. }
  326. }
  327. }
  328. // 列表
  329. .swiper-box {
  330. padding-top: 10rpx;
  331. .order-item {
  332. padding: 20rpx 30rpx;
  333. line-height: 1.5;
  334. position: relative;
  335. // border-bottom: 1rpx black solid;
  336. .title-box {
  337. .title {
  338. font-size: $font-lg;
  339. color: $font-color-base;
  340. }
  341. .time {
  342. font-size: $font-base;
  343. color: $font-color-light;
  344. }
  345. }
  346. .money {
  347. // color: #fd5b23;
  348. color: #901B21;
  349. font-size: $font-lg;
  350. }
  351. .jg {
  352. width: 701rpx;
  353. height: 2rpx;
  354. background: #F0F4F8;
  355. margin: 0 auto;
  356. position: absolute;
  357. bottom: 0;
  358. }
  359. }
  360. }
  361. .list-scroll-content {
  362. height: 100%;
  363. }
  364. .content {
  365. height: 100%;
  366. .empty-content {
  367. background-color: #ffffff;
  368. }
  369. }
  370. .add-btn {
  371. position: fixed;
  372. bottom: 51rpx;
  373. right: 39rpx;
  374. width: 674rpx;
  375. height: 88rpx;
  376. background: $base-color;
  377. border-radius: 44rpx;
  378. color: #fff;
  379. text-align: center;
  380. line-height: 88rpx;
  381. font-size: 34rpx;
  382. }
  383. </style>