wallet.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <view class="content">
  3. <view class="top-bg"></view>
  4. <view class="yue-wrap flex">
  5. <view class="yue-tit flex">
  6. <view class="yue-left">总资产(CNY)</view>
  7. <view class="yue-left">
  8. <view class="cz" @click="open()">
  9. 发红包
  10. <image src="../../static/icon/dz.png" mode="widthFix"></image>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="yue-num flex">
  15. <view class="yue">{{ userInfo.now_money || '0.00' }}</view>
  16. <view class="">
  17. <view class="cz" @click="navto('/pages/money/recharge')">
  18. 充值
  19. <image src="../../static/icon/dz.png" mode="widthFix"></image>
  20. </view>
  21. <view class="tx" @click="navto('/pages/money/withdrawal')">
  22. 提现
  23. <image src="../../static/icon/dz.png" mode="widthFix"></image>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="lj-wrap flex">
  28. <view class="">累计消费:¥{{ userInfo.orderStatusSum || '0' }}</view>
  29. <view class="">累计充值:¥{{ userInfo.recharge || '0' }}</view>
  30. </view>
  31. </view>
  32. <scroll-view scroll-y="true" class="jl-wrap" :style="{ height: maxheight }" @scrolltolower="loadData">
  33. <view>
  34. <empty v-if="navList[tabCurrentIndex].orderList.length == 0 && navList[tabCurrentIndex].loaded"></empty>
  35. <view class="jl " v-for="item in navList[tabCurrentIndex].orderList">
  36. <view class="jl-tit flex">
  37. <view class="clamp2 tit">{{ item.title }}</view>
  38. <view class="price" :class="{ add: item.pm == 1, jian: item.pm == 0 }">{{ item.number * 1 }}</view>
  39. </view>
  40. <view class="jl-mark flex">
  41. <!-- <view class="mark">
  42. {{item.mark}}
  43. </view> -->
  44. <view class="" v-if="item.status == 1">{{ item.add_time }}</view>
  45. <view class="" v-if="item.status == 0">等待下级确认收货</view>
  46. </view>
  47. </view>
  48. <uni-load-more :status="navList[tabCurrentIndex].loadingType"></uni-load-more>
  49. </view>
  50. </scroll-view>
  51. <uni-popup ref="popuphx" class="agree-wrapper">
  52. <view class="hx-wrapper">
  53. <view class="hx-img"><image src="../../static/img/hxbg.png" mode=""></image></view>
  54. <view class="hx-body">
  55. <view class="hx-title">输入红包金额</view>
  56. <input type="text" v-model="num" placeholder="请输入红包金额" placeholder-class="hx-placeholder" />
  57. <view class="hx-btn" @click="qhx">立即发送</view>
  58. </view>
  59. <view class="hx-close" @click="close"><image src="../../static/icon/close.png" mode=""></image></view>
  60. </view>
  61. </uni-popup>
  62. </view>
  63. </template>
  64. <script>
  65. import { mapState, mapMutations } from 'vuex';
  66. import { spreadCommission, userBalance } from '@/api/wallet.js';
  67. import { getMoneyStyle } from '@/utils/rocessor.js';
  68. import { getUserInfo, getUser, redbag } from '@/api/user.js';
  69. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  70. import empty from '@/components/empty';
  71. export default {
  72. filters: {
  73. getMoneyStyle
  74. },
  75. components: {
  76. empty,
  77. uniLoadMore
  78. },
  79. onReady() {
  80. // 初始化获取页面宽度
  81. var obj = this;
  82. uni.getSystemInfo({
  83. success: resu => {
  84. const query = uni.createSelectorQuery();
  85. query.select('.jl-wrap').boundingClientRect();
  86. query.exec(function(res) {
  87. obj.maxheight = resu.windowHeight - res[0].top + 'px';
  88. });
  89. },
  90. fail: res => {}
  91. });
  92. },
  93. data() {
  94. return {
  95. // 头部图高度
  96. maxheight: '',
  97. tabCurrentIndex: 0,
  98. num: '',
  99. navList: [
  100. {
  101. state: 0,
  102. text: '收入',
  103. loadingType: 'more',
  104. orderList: [],
  105. page: 1, //当前页数
  106. limit: 10, //每次信息条数
  107. loaded: false
  108. },
  109. {
  110. state: 2,
  111. text: '收入',
  112. loadingType: 'more',
  113. orderList: [],
  114. page: 1, //当前页数
  115. limit: 10, //每次信息条数
  116. loaded: false
  117. },
  118. {
  119. state: 1,
  120. text: '支出',
  121. loadingType: 'more',
  122. orderList: [],
  123. page: 1, //当前页数
  124. limit: 10, //每次信息条数
  125. loaded: false
  126. }
  127. ],
  128. money: '',
  129. userInfo: {}
  130. };
  131. },
  132. onLoad(options) {},
  133. onShow() {
  134. this.loadData();
  135. this.getUserInfo();
  136. },
  137. methods: {
  138. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  139. getUserInfo() {
  140. getUser({}).then(({ data }) => {
  141. this.userInfo = data;
  142. });
  143. },
  144. // 页面跳转
  145. navto(e) {
  146. uni.navigateTo({
  147. url: e
  148. });
  149. },
  150. open() {
  151. this.$refs.popuphx.open();
  152. },
  153. close() {
  154. this.$refs.popuphx.close();
  155. },
  156. qhx() {
  157. const obj = this;
  158. redbag({ num: this.num }).then(e => {
  159. console.log(e);
  160. uni.navigateTo({
  161. url:
  162. '/pages/user/shareEx?shareid=' +
  163. e.data.uni +
  164. '&scene=' +
  165. obj.userInfo.uid +
  166. '&num=' +
  167. obj.num +
  168. '&logo=' +
  169. obj.userInfo.avatar +
  170. '&nickname=' +
  171. obj.userInfo.nickname +
  172. '&type=1'
  173. });
  174. });
  175. },
  176. //获取收入支出信息
  177. async loadData(source) {
  178. //这里是将订单挂载到tab列表下
  179. let index = this.tabCurrentIndex;
  180. let navItem = this.navList[index];
  181. let state = navItem.state;
  182. if (source === 'tabChange' && navItem.loaded === true) {
  183. //tab切换只有第一次需要加载数据
  184. return;
  185. }
  186. if (navItem.loadingType === 'loading') {
  187. //防止重复加载
  188. return;
  189. }
  190. // 修改当前对象状态为加载中
  191. navItem.loadingType = 'loading';
  192. spreadCommission(
  193. {
  194. page: navItem.page,
  195. limit: navItem.limit
  196. },
  197. state
  198. )
  199. .then(({ data }) => {
  200. console.log(data, '获取数据');
  201. // if (data.count > 0) {
  202. // navItem.orderList = navItem.orderList.concat(data.list);
  203. // console.log(navItem.orderList);
  204. // navItem.page++;
  205. // }
  206. if (data.length > 0) {
  207. data.forEach(item => {
  208. console.log(item.list, '内部列表');
  209. navItem.orderList = navItem.orderList.concat(item.list);
  210. });
  211. // navItem.orderList = navItem.orderList.concat(data[0].list);
  212. console.log(navItem.orderList);
  213. navItem.page++;
  214. }
  215. if (navItem.limit == data.length) {
  216. //判断是否还有数据, 有改为 more, 没有改为noMore
  217. navItem.loadingType = 'more';
  218. return;
  219. } else {
  220. //判断是否还有数据, 有改为 more, 没有改为noMore
  221. navItem.loadingType = 'noMore';
  222. }
  223. uni.hideLoading();
  224. this.$set(navItem, 'loaded', true);
  225. })
  226. .catch(e => {
  227. console.log(e);
  228. });
  229. },
  230. //swiper 切换
  231. changeTab(e) {
  232. this.tabCurrentIndex = e.target.current;
  233. this.loadData('tabChange');
  234. },
  235. //顶部tab点击
  236. tabClick(index) {
  237. this.tabCurrentIndex = index;
  238. },
  239. addmoney() {
  240. uni.navigateTo({
  241. url: '/pages/money/recharge'
  242. });
  243. }
  244. }
  245. };
  246. </script>
  247. <style lang="scss">
  248. page {
  249. background-color: #fff;
  250. height: auto;
  251. min-height: 100%;
  252. }
  253. .top-bg {
  254. background-color: #ee2f72;
  255. height: 180rpx;
  256. width: 750rpx;
  257. }
  258. .yue-wrap {
  259. width: 670rpx;
  260. height: 320rpx;
  261. margin: -160rpx auto 30rpx;
  262. background: linear-gradient(-70deg, #ff77a7, #ff4a8a);
  263. box-shadow: 0px 15rpx 22rpx 6rpx rgba(238, 47, 114, 0.1);
  264. border-radius: 25rpx;
  265. color: #fff;
  266. font-size: 26rpx;
  267. padding: 50rpx 75rpx;
  268. flex-direction: column;
  269. justify-content: space-between;
  270. align-items: flex-start;
  271. .yue-tit {
  272. width: 100%;
  273. }
  274. .cz {
  275. image {
  276. width: 13rpx;
  277. margin-left: 10rpx;
  278. }
  279. }
  280. .tx {
  281. image {
  282. width: 13rpx;
  283. margin-left: 10rpx;
  284. }
  285. }
  286. .yue-num {
  287. width: 100%;
  288. justify-content: space-between;
  289. .yue {
  290. font-size: 76rpx;
  291. font-weight: bold;
  292. }
  293. .cz {
  294. image {
  295. width: 13rpx;
  296. margin-left: 10rpx;
  297. }
  298. }
  299. }
  300. .lj-wrap {
  301. width: 100%;
  302. justify-content: space-between;
  303. font-size: 24rpx;
  304. }
  305. }
  306. .jl {
  307. width: 670rpx;
  308. margin: 0 auto 20rpx;
  309. padding: 35rpx 30rpx;
  310. background: #ffffff;
  311. box-shadow: 0px 0px 28px 0px rgba(48, 48, 48, 0.1);
  312. border-radius: 8px;
  313. .jl-tit {
  314. width: 100%;
  315. font-size: 28rpx;
  316. font-weight: bold;
  317. color: #333333;
  318. .tit {
  319. max-width: 450rpx;
  320. }
  321. .price {
  322. font-size: 38rpx;
  323. font-weight: bold;
  324. }
  325. .add {
  326. color: #ee2f72;
  327. &::before {
  328. content: '+';
  329. font-size: 28rpx;
  330. color: #ee2f72;
  331. }
  332. }
  333. .jian {
  334. color: #808080;
  335. &::before {
  336. content: '-';
  337. font-size: 28rpx;
  338. }
  339. }
  340. }
  341. .jl-mark {
  342. padding-top: 20rpx;
  343. width: 100%;
  344. font-size: 24rpx;
  345. font-weight: 500;
  346. color: #808080;
  347. align-items: flex-start;
  348. // justify-content: flex-end;
  349. .mark {
  350. max-width: 470rpx;
  351. }
  352. }
  353. }
  354. .hx-wrapper {
  355. width: 536rpx;
  356. height: 630rpx;
  357. position: relative;
  358. // background-color: #fff;
  359. .hx-img {
  360. width: 536rpx;
  361. height: 281rpx;
  362. image {
  363. width: 536rpx;
  364. height: 281rpx;
  365. }
  366. }
  367. .hx-close {
  368. position: absolute;
  369. left: 243rpx;
  370. bottom: -80rpx;
  371. width: 52rpx;
  372. height: 52rpx;
  373. image {
  374. width: 52rpx;
  375. height: 52rpx;
  376. }
  377. }
  378. .hx-body {
  379. width: 536rpx;
  380. height: 349rpx;
  381. background-color: #fff;
  382. border-radius: 0 0 10rpx 10rpx;
  383. .hx-title {
  384. width: 536rpx;
  385. font-size: 36rpx;
  386. font-weight: 500;
  387. color: #333333;
  388. line-height: 1;
  389. padding-top: 42rpx;
  390. text-align: center;
  391. }
  392. input {
  393. width: 439rpx;
  394. height: 68rpx;
  395. background: #eeddde;
  396. border-radius: 10rpx;
  397. margin: 39rpx auto 0;
  398. padding-left: 26rpx;
  399. .hx-placeholder {
  400. font-size: 26rpx;
  401. font-weight: 500;
  402. color: #ee2f72;
  403. }
  404. }
  405. .hx-btn {
  406. margin: 44rpx auto 0;
  407. width: 353rpx;
  408. height: 71rpx;
  409. background: #ee2f72;
  410. border-radius: 34rpx;
  411. font-size: 36rpx;
  412. font-weight: 500;
  413. color: #f8f9f9;
  414. line-height: 71rpx;
  415. text-align: center;
  416. }
  417. }
  418. }
  419. </style>