balance.vue 7.7 KB

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