ldDetailed.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="ldDetailed-container">
  3. <!-- 筛选菜单 -->
  4. <u-dropdown ref="uDropdown" class="filter-dropdown">
  5. <u-dropdown-item v-model="queryParam.changeType" :title="titType" :options="optionsType" @change="searchHandle()"></u-dropdown-item>
  6. <u-dropdown-item v-model="timeScope" :title="titScope" :options="optionsScope" @change="searchHandle()"></u-dropdown-item>
  7. </u-dropdown>
  8. <scroll-view class="scroll-con" scroll-y @scrolltolower="onreachBottom">
  9. <!-- 列表数据 -->
  10. <view class="cell-item-con">
  11. <view class="cell-item" v-for="(item, index) in listdata" :key="index">
  12. <text class="cell-item-month" v-if="timeScope == 'threeMonth'">{{item.month}}</text>
  13. <view class="cell-item-main" v-for="(subItem, ind) in item.monthDataList" :key="ind">
  14. <view :class="['cell-item-pic']">
  15. <u-image mode="scaleToFill" v-if="subItem.changeType == 'ADD'" shape="circle" width="90rpx" height="90rpx" src="/static/tudi.png"></u-image>
  16. <u-image mode="scaleToFill" v-else shape="circle" width="90rpx" height="90rpx" src="/static/bued.png"></u-image>
  17. </view>
  18. <view class="cell-item-c">
  19. <text class="cell-item-des">{{subItem.remarks||'--'}}</text>
  20. <text class="cell-item-date">{{subItem.createDate}}</text>
  21. </view>
  22. <view :class="['cell-item-score', subItem.changeType == 'ADD' ? 'black' : 'red']">
  23. <text>{{subItem.changeType == 'ADD' ? '+'+subItem.changeNum : '-'+subItem.changeNum}}</text>
  24. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  25. </view>
  26. </view>
  27. <view class="nodata" v-if="item.monthDataList.length==0 && status!='loading'">
  28. <u-empty :text="noDataText" mode="list"></u-empty>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="nodata" v-if="listdata.length==0 && status!='loading'">
  33. <u-empty :text="noDataText" mode="list"></u-empty>
  34. </view>
  35. <view class="loadmore">
  36. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  37. </view>
  38. </scroll-view>
  39. </view>
  40. </template>
  41. <script>
  42. import {ldUsedQuery} from '@/api/user.js'
  43. import getDate from '@/libs/getDate'
  44. import moment from 'moment'
  45. export default {
  46. data() {
  47. return {
  48. listdata: [],
  49. pageNo: 1, // 当前页码
  50. pageSize: 10, // 每页条数
  51. total: 0, // 数据总条数
  52. noDataText: '暂无数据', // 列表请求状态提示语
  53. status: 'loadmore', // 加载中状态
  54. timeScope: 'threeMonth', // 时间类别 1:近三个月 2:本月 3:本月前一月 4:本月前2月
  55. queryParam: { // 过滤条件
  56. changeType: '', // 金币变更类型
  57. },
  58. optionsType: [
  59. { label: '所有记录', value: '', },
  60. { label: '获取记录', value: 'ADD', },
  61. { label: '使用记录', value: 'SUB', }
  62. ]
  63. }
  64. },
  65. onShow() {
  66. this.searchHandle()
  67. },
  68. onLoad() {
  69. this.timeScope = 'threeMonth'
  70. this.queryParam.changeType = ''
  71. },
  72. computed: {
  73. // 时间过滤条件
  74. optionsScope(){ // 过滤条件 近3个月
  75. let arr = [
  76. { label: '近3个月', value: 'threeMonth' },
  77. { label: '本月', value: 'thisMonth' }
  78. ]
  79. arr[2] = { label: new Date().getMonth() + '月', value: 'lastMonth' }
  80. arr[3] = { label: new Date().getMonth()-1 + '月', value: 'lastTwoMonth' }
  81. return arr
  82. },
  83. titType(){ // 过滤条件 所有记录 title
  84. const row = this.optionsType.find(item => item.value == this.queryParam.changeType)
  85. return row ? row.label : this.optionsType[0].label
  86. },
  87. titScope(){ // 过滤条件 近3个月 title
  88. const row = this.optionsScope.find(item => item.value == this.timeScope)
  89. return row ? row.label : this.optionsScope[0].label
  90. },
  91. // 查询时间段
  92. queryDate() {
  93. var dt = new Date();
  94. const threeTime = dt.setMonth( dt.getMonth()-2 )
  95. const quickType = {
  96. threeMonth: [moment(getDate.getThreeMonthDays().starttime), moment(getDate.getThreeMonthDays().endtime)],
  97. lastMonth: [moment(getDate.getLastMonthDays().starttime), moment(getDate.getLastMonthDays().endtime)],
  98. thisMonth: [moment(getDate.getCurrMonthDays().starttime), moment(getDate.getCurrMonthDays().endtime)],
  99. lastTwoMonth: [moment(getDate.getLastTwoMonthDays().starttime), moment(getDate.getLastTwoMonthDays().endtime)],
  100. }
  101. let queryTime = {
  102. beginDate: quickType[this.timeScope][0].format('YYYY-MM-DD'),
  103. endDate: quickType[this.timeScope][1].format('YYYY-MM-DD')
  104. }
  105. return queryTime
  106. },
  107. },
  108. methods:{
  109. // 搜索查询
  110. searchHandle () {
  111. this.status = "loading"
  112. let params = Object.assign(this.queryParam,this.queryDate)
  113. console.log(params,'pppppppp')
  114. ldUsedQuery(params).then(res => {
  115. console.log(res,'pppppppp')
  116. if (res.status == 200) {
  117. let list = res.data
  118. // 查询3个月时 数据处理
  119. if (this.timeScope == 'threeMonth') {
  120. list.map(item=>{
  121. let m = moment(item.month).month()+1
  122. item.month = (m == moment().month()+1) ? '本月' : m+'月'
  123. })
  124. }
  125. this.listdata = list
  126. } else {
  127. this.noDataText = res.message
  128. this.listdata = []
  129. this.total = 0
  130. }
  131. this.status = "loadmore"
  132. })
  133. },
  134. // scroll-view到底部加载更多
  135. onreachBottom() {
  136. if(this.listdata.length < this.total){
  137. this.pageNo += 1
  138. this.searchHandle()
  139. }else{
  140. uni.showToast({ title: '已经到底了', icon: 'none' })
  141. this.status = "nomore"
  142. }
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="less">
  148. page{
  149. height: 100%;
  150. background-color: #fff;
  151. }
  152. .ldDetailed-container{
  153. width: 100%;
  154. height: 100%;
  155. .nodata{
  156. margin: 50upx 0;
  157. }
  158. // 筛选菜单
  159. .filter-dropdown{
  160. background-color: #fff!important;
  161. .u-dropdown__menu__item{
  162. background-color: #fff!important;
  163. }
  164. }
  165. // 列表
  166. .scroll-con{
  167. height: calc(100% - 40);
  168. overflow: auto;
  169. }
  170. // 列表样式
  171. .cell-item-con{
  172. .cell-item{
  173. background-color: #fff;
  174. color: #606266;
  175. .cell-item-month{
  176. display: block;
  177. color: #909399;
  178. font-size: 26rpx;
  179. padding: 16rpx 30rpx;
  180. background-color: #f8f8f8;
  181. }
  182. .cell-item-main{
  183. display: flex;
  184. align-items: center;
  185. padding: 20rpx 30rpx;
  186. border-bottom: 1rpx solid #e9e9e9;
  187. .cell-item-pic{
  188. flex-shrink: 0;
  189. margin-right: 20rpx;
  190. width: 90rpx;
  191. height: 90rpx;
  192. line-height: 90rpx;
  193. background-color: #FFFFFF;
  194. border-radius: 50%;
  195. text-align: center;
  196. }
  197. .cell-item-c{
  198. flex-grow: 1;
  199. .cell-item-des{
  200. display: block;
  201. color: #606266;
  202. font-size: 30rpx;
  203. margin-bottom: 10rpx;
  204. }
  205. .cell-item-date{
  206. display: block;
  207. color: #909399;
  208. font-size: 24rpx;
  209. }
  210. }
  211. .cell-item-score{
  212. flex-shrink: 0;
  213. font-size: 40rpx;
  214. display: flex;
  215. align-items: center;
  216. }
  217. .black{
  218. color: #01c9b2;
  219. }
  220. .red{
  221. color: red;
  222. }
  223. .orange{
  224. background-color: #fcbd71;
  225. color: #fff;
  226. }
  227. }
  228. .cell-item-main:last-child{
  229. border: none;
  230. }
  231. }
  232. }
  233. }
  234. </style>