mytz.vue 8.2 KB

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