金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

318 lines
7.4 KiB

4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="余额" :showIcon="true" :spreadOut="false" bgColor="transparent" titleColor="#fff"></lf-nav>
  4. <view class="head">
  5. <view class="bg-left"></view>
  6. <view class="bg-right"></view>
  7. <view class="head-content">
  8. <view>
  9. <text class="lf-iconfont icon-yuebao lf-font-50"></text>
  10. </view>
  11. <view class="point">
  12. <text>{{ num || 0 }}</text>
  13. <text class="label">()</text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="main">
  18. <view class="lf-row-between lf-m-b-30">
  19. <view class="lf-font-32 lf-color-black lf-font-bold">余额变动明细</view>
  20. <picker mode='date' :value="date" @change="dateChange">
  21. <view style="width: 440rpx; text-align: right;">
  22. <text>{{ date || getDay }}</text>
  23. <text class="lf-iconfont icon-xiangyou lf-font-24 lf-m-l-10"></text>
  24. </view>
  25. </picker>
  26. </view>
  27. <view class="item" v-for="(item, index) in list" :key="index">
  28. <view class="lf-row-between">
  29. <view class="lf-font-36 lf-color-black lf-font-bold"
  30. :class="{'lf-color-price': item.value < 0}"
  31. style="width: 70%;">{{ item.balance }}
  32. </view>
  33. <view class="lf-font-24 lf-color-555">{{ item.note }}</view>
  34. </view>
  35. <view class="lf-row-between lf-m-t-20">
  36. <view class="lf-font-24 lf-color-555">¥{{ item.current }}</view>
  37. <view class="lf-font-24 lf-color-777">{{ item.created_at }}</view>
  38. </view>
  39. </view>
  40. <lf-nocontent src="/static/images/empty.png" v-if="list.length <= 0"></lf-nocontent>
  41. </view>
  42. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  43. </view>
  44. </template>
  45. <script>
  46. import { pageLogin, getUrl, config, is } from '@/common/js/utils.js';
  47. export default {
  48. data(){
  49. return {
  50. date: '',
  51. // activeIndex: 0,
  52. // tabList: [{
  53. // id: 0,
  54. // name: "收入",
  55. // init: false,
  56. // page: 0,
  57. // more: true,
  58. // show: false
  59. // }, {
  60. // id: 1,
  61. // name: "支出",
  62. // init: false,
  63. // page: 0,
  64. // more: true,
  65. // show: false
  66. // }],
  67. // dataList: {
  68. // 0: [],
  69. // 1: []
  70. // },
  71. list: [],
  72. show: false,
  73. page: 0,
  74. more: true,
  75. token: '',
  76. num: "",
  77. showText: '正在加载下一页数据',
  78. config: ''
  79. }
  80. },
  81. computed: {
  82. getDay(){
  83. return this.$shared.recordTime(new Date(), '-', 'date');
  84. }
  85. },
  86. onLoad(e){
  87. // TODO 将list数据渲染到页面上,,根据date请求筛选
  88. // 第三方平台配置颜色
  89. var bgConfig = this.$cookieStorage.get('globalConfig') || '';
  90. this.setData({
  91. config: bgConfig
  92. }); // var status=0,page=1;
  93. // this.queryBalanceList(token);
  94. // var status = e.type ? e.type : 0;
  95. // var page = this.tabList[status].page;
  96. pageLogin(getUrl(), token => {
  97. this.setData({
  98. 'token': token
  99. });
  100. this.queryBalanceList();
  101. this.queryUserSum(token);
  102. });
  103. // this.queryBalanceList(token, status, page);
  104. // this.queryUserSum(this.token);
  105. },
  106. methods: {
  107. dateChange(event){
  108. this.date = event.detail.value;
  109. this.page = 0;
  110. this.more = true;
  111. this.show = false;
  112. this.showText = '正在加载下一页数据';
  113. this.queryBalanceList();
  114. },
  115. queryBalanceList() {
  116. // var type = status ? 'consume' : 'recharge';
  117. // var params = type ? {
  118. // type
  119. // } : {};
  120. // params.page = page;
  121. uni.showLoading({
  122. title: '正在获取中'
  123. })
  124. let token = this.token;
  125. let params = {
  126. page: this.page
  127. };
  128. if(this.date){
  129. params.day = this.date;
  130. }
  131. this.$http.get({
  132. api: 'api/users/balance/list',
  133. header: {
  134. Authorization: token
  135. },
  136. data: params
  137. }).then(res => {
  138. if (res.statusCode == 200) {
  139. res = res.data;
  140. // this.result(res, status);
  141. var page = res.meta.pagination;
  142. this.page = page.current_page;
  143. this.more = page.current_page < page.total_pages;
  144. this.show = false;
  145. console.log("page", page);
  146. if(page.current_page == 1){
  147. this.list = res.data;
  148. }else{
  149. this.list.push(...res.data);
  150. }
  151. console.log("res.data", this.list);
  152. } else {
  153. uni.showModal({
  154. title: '提示',
  155. content: '数据请求失败',
  156. success: res => {}
  157. });
  158. }
  159. uni.hideLoading();
  160. }).catch(rej => {
  161. uni.showToast({
  162. title: "请求失败",
  163. image: '../../../static/error.png'
  164. });
  165. uni.hideLoading();
  166. });
  167. },
  168. // 获取总余额
  169. queryUserSum(token) {
  170. this.$http.get({
  171. api: "api/users/balance/sum",
  172. header: {
  173. Authorization: token
  174. }
  175. }).then(res => {
  176. if (res.statusCode == 200) {
  177. res = res.data;
  178. this.setData({
  179. "num": res.data.sum
  180. });
  181. } else {
  182. wx.showModal({
  183. title: '提示',
  184. content: '数据请求失败',
  185. success: res => {}
  186. });
  187. }
  188. });
  189. },
  190. setData: function (obj) {
  191. let that = this;
  192. let keys = [];
  193. let val, data;
  194. Object.keys(obj).forEach(function (key) {
  195. keys = key.split('.');
  196. val = obj[key];
  197. data = that.$data;
  198. keys.forEach(function (key2, index) {
  199. if (index + 1 == keys.length) {
  200. that.$set(data, key2, val);
  201. } else {
  202. if (!data[key2]) {
  203. that.$set(data, key2, {});
  204. }
  205. }
  206. data = data[key2];
  207. });
  208. });
  209. }
  210. },
  211. onReachBottom(e) {
  212. // var status = this.activeIndex;
  213. // var page = this.tabList[status].page + 1;
  214. // var tabList = `tabList[${status}]`;
  215. if (this.more) {
  216. this.page++;
  217. this.show = true;
  218. this.queryBalanceList();
  219. // this.setData({
  220. // [`${tabList}.show`]: true
  221. // });
  222. // var token = this.token;
  223. // this.queryBalanceList(token, status, page);
  224. } else {
  225. wx.showToast({
  226. icon: 'error',
  227. title: '再拉也没有啦'
  228. });
  229. }
  230. }
  231. }
  232. </script>
  233. <style>
  234. page{
  235. overflow-x: hidden;
  236. }
  237. </style>
  238. <style lang="scss" scoped>
  239. .head{
  240. width: 750rpx;
  241. // height: 512rpx;
  242. height: 429rpx;
  243. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  244. position: relative;
  245. overflow: hidden;
  246. display: flex;
  247. align-items: flex-end;
  248. box-sizing: border-box;
  249. padding: 60rpx 32rpx;
  250. color: #FFFFFF;
  251. .bg-left{
  252. position: absolute;
  253. width: 196rpx;
  254. height: 196rpx;
  255. border-radius: 50%;
  256. background-color: rgba(255,255,255,0.04);
  257. left: -92rpx;
  258. bottom: 60rpx;
  259. }
  260. .bg-right{
  261. position: absolute;
  262. width: 520rpx;
  263. height: 520rpx;
  264. border-radius: 50%;
  265. background-color: rgba(255,255,255,0.04);
  266. right: -168rpx;
  267. top: -122rpx;
  268. }
  269. .head-content{
  270. width: 100%;
  271. display: flex;
  272. flex-direction: column;
  273. justify-content: center;
  274. align-items: center;
  275. &>view{
  276. width: 100%;
  277. text-align: center;
  278. }
  279. .point{
  280. font-size: 72rpx;
  281. letter-spacing: 2rpx;
  282. font-weight: bold;
  283. word-break: break-all;
  284. line-height: 1;
  285. margin-top: 10rpx;
  286. .label{
  287. font-size: 36rpx;
  288. font-weight: initial;
  289. }
  290. }
  291. }
  292. }
  293. .main{
  294. padding: 30rpx 32rpx;
  295. width: 750rpx;
  296. height: max-content;
  297. box-sizing: border-box;
  298. .item{
  299. width: 686rpx;
  300. height: max-content;
  301. background: #F4F8F8;
  302. border-radius: 10rpx;
  303. margin-bottom: 26rpx;
  304. padding: 30rpx;
  305. box-sizing: border-box;
  306. line-height: 1;
  307. }
  308. }
  309. </style>