1
0

balance.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <app-layout>
  3. <view class="balance-head dir-top-nowrap cross-center" style="background-color:#F84469;">
  4. <!-- <view class="" :style="{'background-image': `url(${setting.bj_pic_url.url})`}"></view> -->
  5. <image @click="getRules" class="balance-legend" :src="setting.re_pic_url.url ? setting.re_pic_url.url : `/static/image/icon/question.png`"></image>
  6. <view class="account">账户余额(元)</view>
  7. <view class="balance">{{balance}}</view>
  8. <view class="app-button">
  9. <app-form-id>
  10. <app-button @click="recharge" background="rgba(255,255,255,0)" color="#FFFFFF" round height="56">{{setting.re_name}}
  11. </app-button>
  12. </app-form-id>
  13. </view>
  14. </view>
  15. <!-- 仅跳转 -->
  16. <app-jump-button v-if="setting.ad_pic_url" :open_type="setting.open_type" :url="setting.page_url" :params="setting.params">
  17. <image class="balance-ad" :src="setting.ad_pic_url.url"></image>
  18. </app-jump-button>
  19. <view class="balance-date main-center cross-center">
  20. <view class="icon-view cross-center main-center" @click="dateLess">
  21. <image class="balance-icon" src="/static/image/icon/arrow-left.png"></image>
  22. </view>
  23. <picker mode="date" :value="date" fields="month" @change="dateChange">
  24. <view>{{date_a}}</view>
  25. </picker>
  26. <view class="icon-view cross-center main-center" @click="datePlus">
  27. <image class="balance-icon" src="/static/image/icon/arrow-right.png"></image>
  28. </view>
  29. </view>
  30. <block v-for="(item,index) in logs" :key="index">
  31. <app-form-id @click="detail(item)" open-type="navigate">
  32. <view class="dir-left-nowrap cross-center balance-list">
  33. <view class="box-grow-1 dir-top-nowrap">
  34. <view class="balance-desc dir-left-nowrap t-omit">{{item.desc}}</view>
  35. <view class="balance-time">{{item.created_at}}</view>
  36. </view>
  37. <view v-if="item.type == 1" class="box-grow-0 balance-plus">+{{item.money}}</view>
  38. <view v-if="item.type == 2" class="box-grow-0 balance-less">-{{item.money}}</view>
  39. </view>
  40. </app-form-id>
  41. </block>
  42. </app-layout>
  43. </template>
  44. <script>
  45. export default {
  46. name: "balance",
  47. onShow: function() {
  48. this.getSetting();
  49. this.getNowTime(new Date());
  50. },
  51. onReachBottom: function() {
  52. const self = this;
  53. if (self.args || self.load)
  54. return;
  55. self.load = true;
  56. let page = self.page + 1;
  57. this.$request({
  58. url: self.$api.balance.logs,
  59. data: {
  60. page: page,
  61. date: self.date,
  62. }
  63. }).then(info => {
  64. if (info.code === 0) {
  65. [self.page, self.args, self.logs] = [page, info.data.list.length === 0, self.logs.concat(info.data.list)];
  66. }
  67. self.load = false;
  68. });
  69. },
  70. data() {
  71. return {
  72. balance: 0,
  73. setting: null,
  74. logs: null,
  75. page: 1,
  76. load: false,
  77. args: false,
  78. showHidden: false,
  79. date: '',
  80. date_a: '',
  81. }
  82. },
  83. methods: {
  84. recharge: function() {
  85. uni.navigateTo({
  86. url: `/pages/balance/recharge`
  87. });
  88. },
  89. detail: function(row) {
  90. uni.navigateTo({
  91. url: `/pages/balance/detail?id=` + row.id
  92. });
  93. },
  94. getRules: function() {
  95. uni.navigateTo({
  96. url: `/pages/rules/index?url=${encodeURIComponent(this.$api.balance.index)}&keys=${JSON.stringify(['setting', 'explain'])}`,
  97. });
  98. },
  99. getSetting: function() {
  100. const self = this;
  101. self.$request({
  102. url: self.$api.balance.index,
  103. }).then(info => {
  104. if (info.code === 0) {
  105. this.setting = info.data.setting;
  106. this.balance = info.data.balance;
  107. }
  108. });
  109. },
  110. getLog: function() {
  111. const self = this;
  112. self.$showLoading({
  113. title: `加载中`
  114. });
  115. this.$request({
  116. url: self.$api.balance.logs,
  117. data: {
  118. date: self.date
  119. }
  120. }).then(info => {
  121. self.$hideLoading();
  122. if (info.code === 0) {
  123. self.logs = info.data.list;
  124. }
  125. }).catch(() => {
  126. self.$hideLoading();
  127. })
  128. },
  129. dateLess: function() {
  130. let date = this.date;
  131. let d = new Date(date);
  132. d.setMonth(d.getMonth() - 1);
  133. this.getNowTime(d);
  134. },
  135. datePlus: function() {
  136. let date = this.date;
  137. let d = new Date(date);
  138. d.setMonth(d.getMonth() + 1);
  139. this.getNowTime(d);
  140. },
  141. dateChange: function(e) {
  142. let date = e.detail.value;
  143. let d = new Date(date);
  144. this.getNowTime(d);
  145. },
  146. getNowTime(date) {
  147. let year = date.getFullYear();
  148. let month = date.getMonth() + 1;
  149. date = [year, month].map((n) => {
  150. n = n.toString()
  151. return n[1] ? n : '0' + n
  152. }).join('-');
  153. let date_a = date.replace('-', '年') + '月';
  154. [this.date, this.date_a, this.page, this.args] = [date, date_a, 1, false];
  155. this.getLog();
  156. },
  157. }
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. .balance-head {
  162. height: #{324rpx};
  163. width: #{100%};
  164. color: #FFFFFF;
  165. .account {
  166. font-size: #{26rpx};
  167. margin-top: #{48rpx};
  168. }
  169. .balance {
  170. font-size: #{88rpx};
  171. margin: #{20rpx} auto;
  172. }
  173. .app-button {
  174. margin-bottom: #{48rpx};
  175. }
  176. }
  177. .balance-legend {
  178. height: #{36rpx};
  179. width: #{36rpx};
  180. align-self: flex-end;
  181. position: absolute;
  182. top: #{32rpx};
  183. right: #{24rpx};
  184. }
  185. .balance-ad {
  186. height: #{180rpx};
  187. width: #{750rpx};
  188. margin: #{20rpx} 0;
  189. }
  190. .balance-date {
  191. width: #{100%};
  192. height: #{80rpx};
  193. background: #FFFFFF;
  194. .icon-view {
  195. width: #{84rpx + 84rpx + 12rpx};
  196. height: 100%;
  197. }
  198. .balance-icon {
  199. height: #{20rpx};
  200. width: #{12rpx};
  201. }
  202. }
  203. .balance-list {
  204. height: #{140rpx};
  205. border-top: #{1px} solid #e2e2e2;
  206. padding: 0 #{24rpx};
  207. background: #FFFFFF;
  208. .balance-desc {
  209. font-size: #{28rpx};
  210. color: #353535;
  211. padding-right: #{24rpx};
  212. }
  213. .balance-time {
  214. font-size: #{24rpx};
  215. margin-top: #{30rpx};
  216. color: #666666;
  217. }
  218. .balance-plus {
  219. font-weight: bold;
  220. font-size: #{48rpx};
  221. color: #ff4544;
  222. }
  223. .balance-less {
  224. font-weight: bold;
  225. font-size: #{48rpx};
  226. color: #3fc24c;
  227. }
  228. }
  229. </style>