index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <!-- 我的钱包 -->
  2. <template>
  3. <view class="wallet-wrap">
  4. <!-- 钱包卡片 -->
  5. <view class="head_box u-flex u-row-center u-col-center">
  6. <view class="card-box">
  7. <view class="card-head u-flex u-col-center">
  8. <view class="card-title u-m-r-10">可提现金额(元)</view>
  9. <view @tap="showMoney = !showMoney" class="u-iconfont"
  10. :class="showMoney ? 'uicon-eye' : 'uicon-eye-off'" style="color: #fff;font-size: 46rpx;"></view>
  11. </view>
  12. <view class="money-num u-p-t-50">{{ showMoney ? userInfo.money || '0.00' : '*****' }}</view>
  13. <button v-if="initRecharge.enable ==='1'" class="u-reset-button topup-btn"
  14. @tap="$Router.push('/pages/user/wallet/top-up')">充值</button>
  15. <button class="u-reset-button withdraw-btn"
  16. @tap="$Router.push('/pages/user/wallet/withdraw')">提现</button>
  17. </view>
  18. </view>
  19. <!-- 筛选 -->
  20. <u-sticky offset-top="0" :enable="true">
  21. <view class="filter-box u-flex u-row-between">
  22. <button class="u-reset-button date-btn u-flex" @tap="showCalendar = true">
  23. {{ selDateText }}
  24. <text class="u-iconfont uicon-arrow-down-fill u-m-l-20" style="color: #e5e5e5"></text>
  25. </button>
  26. <view class="total-box">收入¥{{ incomeMoney || '0.00' }} 支出¥{{ expendMoney || '0.00' }}</view>
  27. </view>
  28. <!-- 状态分类 -->
  29. <view class="u-flex nav-box">
  30. <view class="state-item u-flex-1 " v-for="(state, index) in statusList" :key="state.value"
  31. @tap="onTab(state.value)">
  32. <text class="state-title"
  33. :class="{ 'title-active': stateCurrent === state.value }">{{ state.name }}</text>
  34. <text class="underline" :class="{ 'underline-active': stateCurrent === state.value }"></text>
  35. </view>
  36. </view>
  37. </u-sticky>
  38. <!-- 钱包记录 -->
  39. <view class="wallet-list u-flex" v-for="item in walletLog" :key="item.id">
  40. <image class="head-img u-m-r-20" :src="item.avatar" mode=""></image>
  41. <view class="list-content">
  42. <view class="title-box u-flex u-row-between">
  43. <text class="title u-ellipsis-1">{{ item.type_name }}{{ item.title ? '-' + item.title : '' }}</text>
  44. <view class="money">
  45. <text v-if="item.wallet >= 0" class="add font-OPPOSANS">+{{ item.wallet }}</text>
  46. <text v-else class="minus font-OPPOSANS">{{ item.wallet }}</text>
  47. </view>
  48. </view>
  49. <text class="time">{{ $u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM') }}</text>
  50. </view>
  51. </view>
  52. <!-- 空置页 -->
  53. <shopro-empty v-if="isEmpty" marginTop="200rpx" :image="$IMG_URL + '/imgs/empty/no_data.png'" tipText="暂无数据~">
  54. </shopro-empty>
  55. <!-- 更多 -->
  56. <u-loadmore v-if="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
  57. <!-- 日期选择 -->
  58. <u-calendar v-model="showCalendar" ref="uCalendar" safeAreaInsetBottom mode="range" start-text="开始"
  59. end-text="结束" active-bg-color="#7063d2" active-color="#fff" range-bg-color="#e5e2ff" range-color="#7063d2"
  60. :customStyle="{ background: 'linear-gradient(90deg, #A36FFF, #5336FF)', boxShadow: '0 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34)' }"
  61. @change="selDate"></u-calendar>
  62. </view>
  63. </template>
  64. <script>
  65. import { mapState, mapActions, mapGetters } from 'vuex';
  66. export default {
  67. components: {},
  68. data() {
  69. return {
  70. isEmpty: false,
  71. stateCurrent: 'all', //默认
  72. statusList: [{
  73. name: '全部',
  74. value: 'all'
  75. },
  76. {
  77. name: '收入',
  78. value: 'add'
  79. },
  80. {
  81. name: '支出',
  82. value: 'reduce'
  83. }
  84. ],
  85. showMoney: true,
  86. //日期选择
  87. showCalendar: false,
  88. selDateText: '',
  89. walletLog: [], //钱包记录
  90. propsDate: '', //日期参数
  91. incomeMoney: '', //收入
  92. expendMoney: '', //支出
  93. loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
  94. currentPage: 1,
  95. lastPage: 1
  96. };
  97. },
  98. computed: {
  99. ...mapGetters(['isLogin', 'userInfo', 'initRecharge'])
  100. },
  101. onShow() {
  102. this.isLogin && this.getUserInfo();
  103. this.getToday();
  104. this.currentPage = 1;
  105. this.lastPage = 1;
  106. this.walletLog = [];
  107. this.getWalletLog();
  108. },
  109. // 触底加载更多
  110. onReachBottom() {
  111. if (this.currentPage < this.lastPage) {
  112. this.currentPage += 1;
  113. this.getWalletLog();
  114. }
  115. },
  116. methods: {
  117. ...mapActions(['getUserInfo']),
  118. // 今日
  119. getToday() {
  120. let now = new Date();
  121. let dateText = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}`;
  122. this.selDateText = `${now.getFullYear()}.${now.getMonth() + 1}.${now.getDate()}`;
  123. this.propsDate = `${dateText}-${dateText}`;
  124. },
  125. // tab切换
  126. onTab(state) {
  127. if (this.stateCurrent !== state) {
  128. this.stateCurrent = state;
  129. this.currentPage = 1;
  130. this.lastPage = 1;
  131. this.walletLog = [];
  132. this.getWalletLog();
  133. }
  134. },
  135. // 日期选择
  136. selDate(e) {
  137. this.walletLog = [];
  138. this.currentPage = 1;
  139. this.lastPage = 1;
  140. this.selDateText = `${e.startYear}.${e.startMonth}.${e.startDay}-${e.endYear}.${e.endMonth}.${e.endDay}`;
  141. let dateText = `${e.startYear}/${e.startMonth}/${e.startDay}-${e.endYear}/${e.endMonth}/${e.endDay}`;
  142. this.propsDate = dateText;
  143. this.getWalletLog();
  144. this.$refs.uCalendar.init();
  145. },
  146. // 钱包明细
  147. getWalletLog() {
  148. let that = this;
  149. that.loadStatus = 'loading';
  150. that.$http('money.walletLog', {
  151. wallet_type: 'money',
  152. status: that.stateCurrent,
  153. date: that.propsDate,
  154. page: that.currentPage
  155. }).then(res => {
  156. if (res.code === 1) {
  157. that.walletLog = [...that.walletLog, ...res.data.wallet_logs.data];
  158. that.incomeMoney = res.data.income;
  159. that.expendMoney = Math.abs(res.data.expend);
  160. that.isEmpty = !that.walletLog.length;
  161. that.lastPage = res.data.wallet_logs.last_page;
  162. that.loadStatus = that.currentPage < res.data.wallet_logs.last_page ? 'loadmore' :
  163. 'nomore';
  164. }
  165. });
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="scss">
  171. // 钱包记录
  172. .wallet-list {
  173. width: 750rpx;
  174. padding: 30rpx;
  175. background-color: #ffff;
  176. border-bottom: 1rpx solid #eeeeee;
  177. .head-img {
  178. width: 70rpx;
  179. height: 70rpx;
  180. border-radius: 50%;
  181. background: #ccc;
  182. }
  183. .list-content {
  184. justify-content: space-between;
  185. align-items: flex-start;
  186. flex: 1;
  187. .title {
  188. font-size: 28rpx;
  189. color: #333;
  190. width: 400rpx;
  191. }
  192. .time {
  193. color: #c0c0c0;
  194. font-size: 22rpx;
  195. }
  196. }
  197. .money {
  198. font-size: 28rpx;
  199. font-weight: bold;
  200. .add {
  201. color: #7063d2;
  202. }
  203. .minus {
  204. color: #333333;
  205. }
  206. }
  207. }
  208. // 钱包
  209. .head_box {
  210. width: 750rpx;
  211. background-color: #fff;
  212. padding: 30rpx 0;
  213. .card-box {
  214. width: 690rpx;
  215. min-height: 300rpx;
  216. padding: 40rpx;
  217. background: url($IMG_URL+'/imgs/user/money_wallet_bg.png') no-repeat;
  218. background-size: 100% 100%;
  219. box-shadow: 1rpx 5rpx 16rpx 0 rgba(94, 73, 195, 0.81);
  220. border-radius: 30rpx;
  221. overflow: hidden;
  222. position: relative;
  223. .card-head {
  224. color: #fff;
  225. font-size: 30rpx;
  226. }
  227. .money-num {
  228. font-size: 70rpx;
  229. line-height: 70rpx;
  230. font-weight: 500;
  231. color: #ffffff;
  232. }
  233. .reduce-num {
  234. font-size: 26rpx;
  235. font-weight: 400;
  236. color: #ffffff;
  237. }
  238. .withdraw-btn {
  239. width: 120rpx;
  240. height: 60rpx;
  241. line-height: 60rpx;
  242. background: #ffffff;
  243. border-radius: 30px;
  244. font-size: 24rpx;
  245. font-weight: 500;
  246. color: #5848c4;
  247. position: absolute;
  248. right: 30rpx;
  249. top: 40rpx;
  250. }
  251. .topup-btn {
  252. width: 120rpx;
  253. height: 60rpx;
  254. line-height: 60rpx;
  255. border-radius: 30px;
  256. font-size: 24rpx;
  257. font-weight: 500;
  258. color: #fff;
  259. border: 1px solid #fff;
  260. position: absolute;
  261. right: 180rpx;
  262. top: 40rpx;
  263. }
  264. }
  265. }
  266. // 筛选
  267. .filter-box {
  268. height: 120rpx;
  269. padding: 0 30rpx;
  270. background-color: #f6f6f6;
  271. .date-btn {
  272. background-color: #fff;
  273. line-height: 54rpx;
  274. border-radius: 27rpx;
  275. padding: 0 20rpx;
  276. font-size: 24rpx;
  277. font-weight: 500;
  278. color: #666666;
  279. }
  280. .total-box {
  281. font-size: 24rpx;
  282. font-weight: 500;
  283. color: #999999;
  284. }
  285. }
  286. // 分类
  287. .state-item {
  288. height: 100%;
  289. display: flex;
  290. flex-direction: column;
  291. align-items: center;
  292. justify-content: center;
  293. background-color: #fff;
  294. border-bottom: 1rpx solid rgba(#999, 0.5);
  295. .state-title {
  296. color: #666;
  297. font-weight: 500;
  298. font-size: 28rpx;
  299. line-height: 90rpx;
  300. }
  301. .title-active {
  302. color: #333;
  303. }
  304. .underline {
  305. display: block;
  306. width: 68rpx;
  307. height: 4rpx;
  308. background: #fff;
  309. border-radius: 2rpx;
  310. }
  311. .underline-active {
  312. background: #5e49c3;
  313. display: block;
  314. width: 68rpx;
  315. height: 4rpx;
  316. border-radius: 2rpx;
  317. }
  318. }
  319. </style>