金诚优选前端代码
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.

322 lines
7.6 KiB

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