loan.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="content-bg"><image src="../../static/img/user-integralP.png" mode=""></image></view>
  5. <view class="money-box"><view class="money"> 66 </view></view>
  6. <view class="rule" @click="open()">转赠规则</view>
  7. </view>
  8. <view class="btn flex">
  9. <view class="btn-item" @click="navto('/pages/conversion/candy')">转换为糖果</view>
  10. <view class="btn-item" @click="navto('/pages/conversion/transfers')">贷款转赠</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)">{{ item.text }}</view>
  14. </view>
  15. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  16. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  17. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  18. <!-- 空白页 -->
  19. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  20. <!-- 订单列表 -->
  21. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  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>
  34. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  35. </scroll-view>
  36. </swiper-item>
  37. </swiper>
  38. <uni-popup ref="popup" type="center">
  39. <view class="popup-box">
  40. <view class="popup-title">转赠规则</view>
  41. <view class="popup-main">
  42. <view class="popup-little">一、活动时间</view>
  43. <view class="popup-text">xxxx年xx月xx日xx时举办活动</view>
  44. <view class="popup-little">二、规则</view>
  45. <view class="popup-text">本次活动奖励共二挡,活动奖励按 最高档发放</view>
  46. <view class="popup-little">一、活动时间</view>
  47. <view class="popup-text">xxxx年xx月xx日xx时举办活动</view>
  48. <view class="popup-little">二、规则</view>
  49. <view class="popup-text">本次活动奖励共二挡,活动奖励按 最高档发放</view>
  50. </view>
  51. </view>
  52. <view class="close" @click="close"><image src="../../static/img/Close.png" mode=""></image></view>
  53. </uni-popup>
  54. <view class="btn-box" @click="navto('/pages/money/recharge')">
  55. 立即充值
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import { getSp,spExchange } from '@/api/market.js';
  61. import { spreadCommission, userBalance } from '@/api/wallet.js';
  62. import { mapState, mapMutations } from 'vuex';
  63. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  64. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  65. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  66. export default {
  67. components: {
  68. empty,
  69. uniLoadMore,
  70. uniPopup
  71. },
  72. onReady(res) {
  73. var _this = this;
  74. uni.getSystemInfo({
  75. success: resu => {
  76. const query = uni.createSelectorQuery();
  77. query.select('.swiper-box').boundingClientRect();
  78. query.exec(function(res) {
  79. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  80. console.log('打印页面的剩余高度', _this.height);
  81. });
  82. },
  83. fail: res => {}
  84. });
  85. },
  86. data() {
  87. return {
  88. // 头部图高度
  89. maxheight: '',
  90. tabCurrentIndex: 0,
  91. navList: [
  92. {
  93. state: 0,
  94. text: '收入',
  95. loadingType: 'more',
  96. orderList: [],
  97. page: 1, //当前页面
  98. limit: 10 //每次信息条数
  99. },
  100. {
  101. state: 1,
  102. text: '支出',
  103. loadingType: 'more',
  104. orderList: [],
  105. page: 1, //当前页面
  106. limit: 10 //每次信息条数
  107. }
  108. ],
  109. money: 0,
  110. };
  111. },
  112. onLoad(options) {},
  113. onShow() {
  114. this.loadData();
  115. //获取用户余额
  116. userBalance({}).then(({ data }) => {
  117. console.log(data)
  118. this.money = data.now_money;
  119. });
  120. console.log(this.jf)
  121. },
  122. computed: {
  123. integral() {
  124. return this.$store.state.user.userInfo.integral
  125. }
  126. },
  127. methods: {
  128. navto(e) {
  129. uni.navigateTo({
  130. url: e
  131. });
  132. },
  133. // 点击返回 我的页面
  134. toBack() {
  135. uni.navigateBack({});
  136. },
  137. async loadData(source) {
  138. //这里时将订单挂载到tab列表下
  139. let index = this.tabCurrentIndex;
  140. let navItem = this.navList[index];
  141. let state = navItem.state + 3;
  142. if (source === 'tabChange' && navItem.loaded === true) {
  143. //tab切换只有第一次需要加载数据
  144. return;
  145. }
  146. if (navItem.loadingType === 'loading') {
  147. //防止重复加载
  148. return;
  149. }
  150. //修改当前对象状态为加载中
  151. navItem.loadingType = 'loading';
  152. spreadCommission(
  153. {
  154. page: navItem.page,
  155. limit: navItem.limit
  156. },
  157. state
  158. )
  159. .then(({ data }) => {
  160. if (data.length > 0) {
  161. navItem.orderList = navItem.orderList.concat(data[0].list);
  162. console.log(navItem.orderList);
  163. navItem.page++;
  164. }
  165. //判断是否还有数据, 有改为more, 没有改为noMore
  166. if (navItem.limit == data.length) {
  167. navItem.loadingType = 'more';
  168. return;
  169. } else {
  170. navItem.loadingType = 'noMore';
  171. }
  172. uni.hideLoading();
  173. this.$set(navItem, 'loaded', true);
  174. })
  175. .catch(e => {
  176. console.log(e);
  177. });
  178. },
  179. //swiper 切换
  180. changeTab(e) {
  181. this.tabCurrentIndex = e.target.current;
  182. this.loadData('tabChange');
  183. },
  184. //顶部tab点击
  185. tabClick(index) {
  186. this.tabCurrentIndex = index;
  187. },
  188. open() {
  189. this.$refs.popup.open();
  190. },
  191. close() {
  192. this.$refs.popup.close();
  193. },
  194. }
  195. };
  196. </script>
  197. <style lang="scss">
  198. page {
  199. background: #f1f1f1;
  200. height: 100%;
  201. }
  202. .status_bar {
  203. height: var(--status-bar-height);
  204. width: 100%;
  205. }
  206. .content-money {
  207. padding-bottom: 30rpx;
  208. position: relative;
  209. height: 400rpx;
  210. .content-bg {
  211. position: absolute;
  212. top: 0;
  213. left: 0;
  214. right: 0;
  215. width: 750rpx;
  216. height: 400rpx;
  217. image {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. }
  222. .rule {
  223. z-index: 11;
  224. position: absolute;
  225. top: 130rpx;
  226. right: 0;
  227. width: 140rpx;
  228. height: 50rpx;
  229. background: #ffffff;
  230. border-top-left-radius: 8rpx;
  231. border-bottom-left-radius: 8rpx;
  232. text-align: center;
  233. line-height: 50rpx;
  234. font-size: 26rpx;
  235. font-family: PingFang SC;
  236. font-weight: bold;
  237. color: #2e58ff;
  238. }
  239. }
  240. .btn {
  241. justify-content: center;
  242. align-items: center;
  243. position: relative;
  244. z-index: 10;
  245. .btn-item {
  246. margin: 0 15rpx;
  247. width: 330rpx;
  248. height: 100rpx;
  249. background: #ffffff;
  250. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  251. border-radius: 10rpx;
  252. text-align: center;
  253. line-height: 100rpx;
  254. font-size: 34rpx;
  255. font-family: PingFang SC;
  256. font-weight: bold;
  257. color: #3c77ff;
  258. margin-top: -50rpx;
  259. }
  260. }
  261. .money-box {
  262. position: relative;
  263. z-index: 10;
  264. padding-top: 150rpx;
  265. color: #ffffff;
  266. text-align: center;
  267. .money {
  268. font-size: 86rpx;
  269. font-family: PingFang SC;
  270. font-weight: bold;
  271. color: #ffffff;
  272. }
  273. }
  274. .navbar {
  275. margin-top: 20rpx;
  276. display: flex;
  277. height: 88rpx;
  278. padding: 0 5px;
  279. background: #fff;
  280. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  281. position: relative;
  282. z-index: 10;
  283. .nav-item {
  284. flex: 1;
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. height: 100%;
  289. font-size: 15px;
  290. color: $font-color-dark;
  291. position: relative;
  292. &.current {
  293. color: $base-color;
  294. &:after {
  295. content: '';
  296. position: absolute;
  297. left: 50%;
  298. bottom: 0;
  299. transform: translateX(-50%);
  300. width: 44px;
  301. height: 0;
  302. border-bottom: 2px solid $base-color;
  303. }
  304. }
  305. }
  306. }
  307. //列表
  308. .swiper-box {
  309. .order-item {
  310. padding: 20rpx 30rpx;
  311. line-height: 1.5;
  312. .title-box {
  313. .title {
  314. font-size: $font-lg;
  315. color: $font-color-base;
  316. }
  317. .time {
  318. font-size: $font-base;
  319. color: $font-color-light;
  320. }
  321. }
  322. .money {
  323. color: #fd5b23;
  324. font-size: $font-lg;
  325. }
  326. }
  327. }
  328. .list-scroll-content {
  329. background: #ffffff;
  330. height: 100%;
  331. }
  332. .content {
  333. height: 100%;
  334. .empty-content {
  335. background-color: #ffffff;
  336. }
  337. }
  338. .popup-box {
  339. background: #FFFFFF;
  340. border-radius: 10rpx;
  341. width: 580rpx;
  342. padding: 43rpx 60rpx 56rpx 34rpx;
  343. .popup-title {
  344. width: 100%;
  345. text-align: center;
  346. font-size: 36rpx;
  347. font-family: PingFang SC;
  348. font-weight: bold;
  349. color: #333333;
  350. }
  351. .popup-main {
  352. margin-top: 48rpx;
  353. .popup-little {
  354. padding-top: 18rpx;
  355. font-size: 30rpx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #333333;
  359. }
  360. .popup-text {
  361. padding-left: 60rpx;
  362. padding-top: 18rpx;
  363. font-size: 28rpx;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #666666;
  367. }
  368. }
  369. }
  370. .close {
  371. margin: 70rpx auto 0;
  372. width: 84rpx;
  373. height: 84rpx;
  374. image {
  375. width: 100%;
  376. height: 100%;
  377. }
  378. }
  379. .btn-box {
  380. width: 674rpx;
  381. height: 88rpx;
  382. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  383. border-radius: 44rpx;
  384. font-size: 36rpx;
  385. font-family: PingFang SC;
  386. font-weight: 500;
  387. color: #FFFFFF;
  388. text-align: center;
  389. line-height: 88rpx;
  390. position: fixed;
  391. bottom: 48rpx;
  392. left: 0;
  393. right: 0;
  394. margin: 0 auto;
  395. }
  396. </style>