anticipate.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view>
  3. <view class="app-bg">
  4. <image src="/static/img/detail_bg.png"></image>
  5. <view class="body fx-h fx-bc fx-ac">
  6. <view class="count">{{ user.anticipate || 0 }}</view>
  7. <view class="label">我的余额</view>
  8. </view>
  9. <view class="transfer fx-r fx-bc" @tap="tapTransfer">
  10. <image src="/static/img/ic_transfer.png"></image>
  11. 余额转账
  12. </view>
  13. </view>
  14. <uni-nav-bar color="#fff" :border="false" statusBar backgroundColor="transparent" left-icon="left"
  15. @clickLeft="utils.navigateBack()" fixed title="我的易趣卷"></uni-nav-bar>
  16. <view class="htop" :style="'height:calc(61vw - ' + statusBarHeight + 'px - 44px);'"></view>
  17. <view class="app-body">
  18. <!--列表数据-->
  19. <view class="nav-list fx-r fx-bc">
  20. <view class="item fx-h fx-bc" @tap="tapNav(item.code)" :class="form.type == item.code ? 'active' : ''"
  21. v-for="(item,index) in navList">
  22. <view class="label">{{ item.name }}</view>
  23. <image class="icon" v-if="form.type == item.code" src="/static/img/detail_d.png"></image>
  24. </view>
  25. <view class="fx-g1"></view>
  26. <view class="time fx-r fx-bc" @tap="openDateTimeU()">
  27. <view class="count">{{ form.dateStr || "" }}</view>
  28. <image class="icon" src="/static/img/detail_next.png"></image>
  29. </view>
  30. </view>
  31. <scroll-view scroll-y class="scroll" :style="'height: calc(100vh - 61vw - 100rpx);'"
  32. @scrolltolower="loadMoreData">
  33. <view class="sc-body">
  34. <view class="detail-list" v-if="data.length > 0">
  35. <view class="top fx-r">
  36. <view class="label">{{ this.form.dateStr }}</view>
  37. <view class="fx-g1"></view>
  38. <view class="label">收入:{{ this.total.inMoney || '0.00' }}
  39. 支出:{{ this.total.outMoney || '0.00' }}</view>
  40. </view>
  41. <view class="item fx-r fx-bc" v-for="(item,index) in data">
  42. <image class="icon" v-if="item.type == 0" src="/static/img/detail_in.png"></image>
  43. <image class="icon" v-if="item.type == 1" src="/static/img/detail_in.png"></image>
  44. <image class="icon" v-if="item.type == 2" src="/static/img/detail_out.png"></image>
  45. <view class="info">
  46. <view class="title">{{ item.title }}</view>
  47. <view class="tag">{{ item.content }}</view>
  48. <view class="time">{{ item.time }}</view>
  49. </view>
  50. <view class="fx-g1"></view>
  51. <view class="right fx-h">
  52. <view class="money" style="color:#e2a622;" v-if="item.type == 1">+{{item.v}}</view>
  53. <view class="money" v-if="item.type == 2">-{{item.v}}</view>
  54. <view class="fx-g1"></view>
  55. <view class="balance">余额:{{ item.money }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="data.length > 0">
  60. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  61. <image src="/static/img/xloading.png"></image>
  62. <text>正在载入更多...</text>
  63. </view>
  64. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  65. </view>
  66. <uv-empty v-if="data.length == 0 && isFirst" mode="data" icon="/static/img/no-empty.png"></uv-empty>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. <uv-datetime-picker ref='dateTimeU' v-model="datetime" @confirm="tapConfirm" @cancel="closedateTimeU()"
  71. @close="closedateTimeU()" mode="year-month"></uv-datetime-picker>
  72. </view>
  73. </view>
  74. </template>
  75. <style lang="scss">
  76. .app-bg {
  77. position: absolute;
  78. image {
  79. width: 100vw;
  80. height: 61vw;
  81. }
  82. .body {
  83. position: absolute;
  84. height: 61vw;
  85. width: 100vw;
  86. top: 0;
  87. .count {
  88. font-weight: 500;
  89. font-size: 64rpx;
  90. color: #fff;
  91. }
  92. .label {
  93. margin-top: 4px;
  94. color: #fff;
  95. }
  96. }
  97. .transfer {
  98. position: absolute;
  99. bottom: 80rpx;
  100. right: 20rpx;
  101. color: #FFFFFF;
  102. image {
  103. width: 25px;
  104. height: 19px;
  105. margin-right: 10px;
  106. }
  107. }
  108. }
  109. .app-body {
  110. padding: 0px 20rpx;
  111. }
  112. .nav-list {
  113. height: 100rpx;
  114. .item {
  115. margin-right: 50rpx;
  116. .label {
  117. font-weight: bold;
  118. font-size: 30rpx;
  119. color: #5C5C5C;
  120. }
  121. &.active {
  122. .label {
  123. font-weight: bold;
  124. font-size: 36rpx;
  125. color: #2C2C2C;
  126. }
  127. .icon {
  128. width: 36rpx;
  129. height: 14rpx;
  130. margin-top: 4rpx;
  131. }
  132. }
  133. }
  134. .time {
  135. .count {
  136. font-weight: bold;
  137. font-size: 28rpx;
  138. color: #2C2C2C;
  139. }
  140. .label {
  141. font-weight: bold;
  142. font-size: 30rpx;
  143. color: #2C2C2C;
  144. margin-left: 6rpx;
  145. }
  146. .icon {
  147. margin-left: 10rpx;
  148. width: 20rpx;
  149. height: 12rpx;
  150. }
  151. }
  152. }
  153. .detail-list {
  154. background: #FFFFFF;
  155. border-radius: 20rpx;
  156. padding: 40rpx 30rpx;
  157. .top {
  158. margin-bottom: 40rpx;
  159. .label {
  160. font-weight: 500;
  161. font-size: 25rpx;
  162. color: #979797;
  163. }
  164. }
  165. .item {
  166. margin-bottom: 40rpx;
  167. .icon {
  168. width: 84rpx;
  169. height: 84rpx;
  170. }
  171. .info {
  172. width: calc(100% - 280rpx);
  173. margin-left: 16rpx;
  174. .title {
  175. font-weight: bold;
  176. font-size: 28rpx;
  177. color: #333333;
  178. }
  179. .tag {
  180. font-size: 24rpx;
  181. color: #979797;
  182. margin-top: 6rpx;
  183. }
  184. .time {
  185. font-size: 24rpx;
  186. color: #979797;
  187. }
  188. }
  189. .right {
  190. text-align: right;
  191. width: 160rpx;
  192. .money {
  193. font-weight: bold;
  194. font-size: 34rpx;
  195. color: #FF4C4C;
  196. }
  197. .balance {
  198. font-weight: 500;
  199. font-size: 24rpx;
  200. color: #979797;
  201. }
  202. }
  203. }
  204. }
  205. </style>
  206. <script>
  207. import {
  208. mapState,
  209. mapMutations
  210. } from 'vuex';
  211. export default {
  212. computed: mapState(['user']),
  213. data() {
  214. return {
  215. statusBarHeight: 20,
  216. isFirst: false,
  217. datetime: "",
  218. total: {},
  219. data: [],
  220. page: {
  221. isFirst: false,
  222. isLoad: false,
  223. isFoot: false,
  224. page: 1
  225. },
  226. form: {
  227. dateStr: "",
  228. date: "",
  229. type: "all"
  230. },
  231. navList: [{
  232. "name": "全部",
  233. "code": "all"
  234. },
  235. {
  236. "name": "收入",
  237. "code": "income"
  238. },
  239. {
  240. "name": "支出",
  241. "code": "disburse"
  242. }
  243. ]
  244. }
  245. },
  246. onLoad(options) {
  247. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  248. this.form.dateStr = this.utils.date('Y年m月');
  249. this.form.date = this.utils.date('Y-m');
  250. this.datetime = this.utils.strtotime() * 1000;
  251. },
  252. onShow() {
  253. this.initView();
  254. },
  255. methods: {
  256. ...mapMutations(['checkUserLogin']),
  257. /**
  258. * 加载基础配置
  259. */
  260. initView: function() {
  261. this.totalData();
  262. this.getData(true);
  263. },
  264. /**
  265. * 获取数据
  266. */
  267. getData: function(isPull = false) {
  268. if (this.page.isLoad) return;
  269. this.page.isLoad = true;
  270. if (isPull) {
  271. this.page.page = 1;
  272. this.page.isLoad = false;
  273. this.page.isFoot = false;
  274. }
  275. uni.showLoading({
  276. title: '获取数据中..'
  277. });
  278. var post = {};
  279. post.page = this.page.page;
  280. this
  281. .request
  282. .post("userAnticipate", {
  283. ...this.form,
  284. page: this.page.page
  285. })
  286. .then(res => {
  287. uni.hideLoading();
  288. this.page.isFirst = true;
  289. this.page.isLoad = false;
  290. this.isFirst = true;
  291. if (isPull) {
  292. this.data = res.data.list;
  293. } else {
  294. this.data = this.data.concat(res.data.list);
  295. }
  296. //是否到底
  297. if (res.data.list.length != res.data.pageSize) {
  298. this.page.isFoot = true;
  299. }
  300. })
  301. .catch((res) => {
  302. console.log(res);
  303. uni.hideLoading();
  304. uni.showModal({
  305. title: '系统提示',
  306. content: '加载失败,返回在尝试',
  307. showCancel: false
  308. });
  309. });
  310. },
  311. totalData: function() {
  312. this
  313. .request
  314. .post("userAnticipateTotal", {
  315. ...this.form
  316. })
  317. .then(res => {
  318. if (res.code == 200) {
  319. this.total = res.data;
  320. }
  321. })
  322. },
  323. loadMoreData: function() {
  324. if (this.page.isFoot || this.page.isLoad) {
  325. return;
  326. }
  327. this.page.page++;
  328. this.getData();
  329. },
  330. tapNav: function(ev) {
  331. this.form.type = ev;
  332. this.getData(true);
  333. },
  334. tapConfirm: function(ev) {
  335. this.form.dateStr = this.utils.date('Y年m月', ev.value / 1000);
  336. this.form.date = this.utils.date('Y-m', ev.value / 1000);
  337. this.$refs.dateTimeU.close()
  338. this.totalData();
  339. this.getData(true);
  340. },
  341. openDateTimeU(){
  342. this.$refs.dateTimeU.open()
  343. },
  344. closedateTimeU(){
  345. this.$refs.dateTimeU.close()
  346. },
  347. tapTransfer: function() {
  348. uni.navigateTo({
  349. url: "anticipate_gift"
  350. })
  351. }
  352. },
  353. }
  354. </script>
  355. <style>
  356. </style>