balance.vue 8.1 KB

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