rechargeRecord.vue 5.4 KB

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