rechargeRecord.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="container">
  3. <view class="line"></view>
  4. <view class="uni-list-cell-db">
  5. <picker mode="date" :value="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
  6. <view class="uni-input">
  7. <text>{{date}}</text>
  8. <text class="iconfont icon-arrow-down"></text>
  9. </view>
  10. </picker>
  11. </view>
  12. <view class="line"></view>
  13. <scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
  14. @scrolltolower="scroll_to_lower">
  15. <view class="item-list" v-for="(item, i) in chongzhi_items" :key="i">
  16. <view class="item-left">
  17. <image src="../static/images/chongzhi-icon.png" mode=""></image>
  18. <view class="left-desc">
  19. <text class="item-list-title">{{item.desc}}</text>
  20. <text class="item-list-time">{{item.begin_time}}</text>
  21. </view>
  22. </view>
  23. <text class="item-right">{{numFilter(item.use_amount)}}</text>
  24. </view>
  25. </scroll-view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. ceshi: 'air',
  33. id_card: '', // 身份证号
  34. date: this.$getDate({
  35. format: true
  36. }),
  37. startDate: this.$getDate('start_date'),
  38. endDate: this.$getDate('end_date'),
  39. chongzhi_items: [], // 消费记录
  40. screenHeight: 0,
  41. }
  42. },
  43. onLoad(options) {
  44. // 获取身份证号
  45. this.get_base_info()
  46. },
  47. onShow() {
  48. // 从新计算高度
  49. setTimeout(() => {
  50. this.calc_screen_height()
  51. }, 1500)
  52. },
  53. methods: {
  54. /**
  55. * 滚动到顶部提示
  56. */
  57. scroll_to_upper() {
  58. uni.showToast({
  59. title: '到顶了!',
  60. icon: 'none',
  61. duration: 500
  62. })
  63. },
  64. /**
  65. * 滚动到底部提示
  66. */
  67. scroll_to_lower() {
  68. uni.showToast({
  69. title: '到底了!',
  70. icon: 'none',
  71. duration: 500
  72. })
  73. },
  74. /**
  75. * 保留小数点数值后两位,尾数四舍五入
  76. * @param {Object} value
  77. */
  78. numFilter(value) {
  79. // 截取当前数据到小数点后两位
  80. let realVal = parseFloat(value).toFixed(2)
  81. return realVal
  82. },
  83. /**
  84. * 获取身份证号
  85. */
  86. get_base_info() {
  87. try {
  88. if (this.id_card == '' || typeof(this.id_card) == 'undefined') {
  89. const userinfo = uni.getStorageSync('userinfo_storage_key')
  90. if (userinfo) {
  91. this.id_card = userinfo.id_card
  92. } else {
  93. uni.navigateTo({
  94. url: '../index/index?from=' + options.from
  95. })
  96. uni.showToast({
  97. icon: 'none',
  98. title: '身份证号为空,请进行授权',
  99. duration: 3000
  100. });
  101. return
  102. }
  103. }
  104. } catch (e) {
  105. console.log('获取基本信息:' + e.message);
  106. }
  107. this.getRechargeRecord()
  108. },
  109. /**
  110. * 请求服务器,获得充值记录
  111. */
  112. async getRechargeRecord() {
  113. const res = await this.$myRequest({
  114. host: this.ceshi,
  115. url: '/airManage/rechargequeryOwn.action',
  116. method: 'POST',
  117. header: {
  118. 'content-type': 'application/x-www-form-urlencoded'
  119. },
  120. data: {
  121. // sfzh: '36012325455222',
  122. sfzh: this.id_card,
  123. month: this.date
  124. }
  125. })
  126. // console.log(res.data);
  127. let data = res.data
  128. if (data.code == 200) {
  129. this.chongzhi_items = []
  130. if (typeof data.data != 'undefined' && data.data != '' && JSON.stringify(data.data) != '{}') {
  131. let tmp_items = []
  132. for (var i = 0; i < data.data.length; i++) {
  133. tmp_items.push({
  134. begin_time: data.data[i].time,
  135. // desc: data.data[i].order_num,
  136. desc: '空调充值',
  137. use_amount: data.data[i].account
  138. })
  139. }
  140. this.chongzhi_items = tmp_items
  141. } else {
  142. uni.showToast({
  143. title: '无充值记录!',
  144. icon: 'success'
  145. });
  146. }
  147. } else {
  148. uni.showToast({
  149. title: data.data.message
  150. })
  151. }
  152. },
  153. /**
  154. * 选择消费年月
  155. */
  156. bindDateChange(e) {
  157. this.date = e.detail.value
  158. // 请求选定的月份消费记录
  159. this.getRechargeRecord()
  160. },
  161. /**
  162. * 计算屏幕的高度
  163. */
  164. calc_screen_height() {
  165. uni.getSystemInfo({
  166. success: res => {
  167. let h = ((res.screenHeight * (750 / res.windowWidth)) - 280) //将px 转换rpx
  168. this.screenHeight = Math.floor(h) + 'rpx'
  169. }
  170. });
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .container {
  177. display: flex;
  178. flex-direction: column;
  179. font-size: 28rpx;
  180. font-family: "Microsoft YaHei-3970(82674968)";
  181. width: 730rpx;
  182. padding: 10rpx;
  183. .line {
  184. height: 20rpx;
  185. }
  186. .uni-list-cell-db {
  187. .uni-input {
  188. display: flex;
  189. justify-content: space-around;
  190. align-items: center;
  191. width: 200rpx;
  192. height: 60rpx;
  193. border: 2rpx solid #CCCCCC;
  194. border-radius: 6rpx;
  195. font-size: 32upx;
  196. }
  197. }
  198. .item-list {
  199. display: flex;
  200. justify-content: space-between;
  201. align-items: center;
  202. padding: 20rpx 10rpx;
  203. border-bottom: 1rpx solid #CCCCCC;
  204. .item-left {
  205. display: flex;
  206. align-items: center;
  207. image {
  208. width: 80rpx;
  209. height: 80rpx;
  210. }
  211. .left-desc {
  212. display: flex;
  213. flex-direction: column;
  214. justify-content: space-around;
  215. margin-left: 20rpx;
  216. .item-list-title {
  217. font-size: 32upx;
  218. font-weight: bold;
  219. }
  220. .item-list-time {
  221. color: #808080;
  222. }
  223. }
  224. }
  225. .item-right {
  226. font-size: 36upx;
  227. font-weight: bold;
  228. color: #333333;
  229. }
  230. }
  231. }
  232. </style>