checkInRecord.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="checkInRecord">
  3. <view class="timeData">
  4. <picker mode="date" fields="month" @change="selectDataTime">
  5. <view class="time" v-if="isShowYeer" style="display: flex;align-items: center;">
  6. <text>{{queryForm.dayTime | getYMFilter}}</text>
  7. <image src="../../static/triangle.png" mode="widthFix" class="triangle"></image>
  8. </view>
  9. <view class="time" v-else>
  10. <text style="font-size: 48rpx;margin-right: 10rpx;">{{queryForm.dayTime | getDateFilter}}</text>
  11. <text>月</text>
  12. <image src="../../static/triangle.png" mode="widthFix" class="triangle"></image>
  13. </view>
  14. </picker>
  15. </view>
  16. <scroll-view scroll-y="true" class="checkInList" lower-threshold="80" @scrolltolower="scrolltolower" >
  17. <template v-if="signList.length > 0">
  18. <view v-for="item in signList" :key="item.id" class="item">
  19. <view class="left">
  20. <view class="title">{{item.describe}}</view>
  21. <view class="data">{{item.longCreateTime | getTimerFilter}}</view>
  22. </view>
  23. <view class="right">
  24. <text v-if="item.rechargeStatus === 1">已发放</text>
  25. <view class="error" v-else @click="setAgainReceive(item)">
  26. 失败重领
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <view class="baseline" v-if="this.total === this.signList.length">
  32. —— 我是有底线的 ——
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </template>
  37. <script>
  38. import { config ,getSignList, setReClaim } from '@/api/api.js'
  39. export default {
  40. data() {
  41. return {
  42. queryForm: {
  43. page: 1,
  44. pageSize: 20,
  45. dayTime: '',
  46. appId: config.appid
  47. },
  48. isShowYeer: false, //是否展示年月
  49. signList: [],
  50. total: 0
  51. };
  52. },
  53. onLoad(options) {
  54. if (Object.keys(options).length > 0) {
  55. let { mpName , ...option } = options
  56. this.queryForm = {...this.queryForm, ...option}
  57. this.queryForm.dayTime = this.getDate()
  58. this.getList()
  59. }
  60. },
  61. filters: {
  62. getYMFilter(value) {
  63. if(!value) return ''
  64. let data = value.split('-')
  65. if (data.length > 1) {
  66. return data[0] + '-' + data[1]
  67. }else {
  68. return value
  69. }
  70. },
  71. getDateFilter(value) { // 获取月
  72. if(!value) return ''
  73. let data = value.split('-')
  74. if (data.length > 1) {
  75. return Number(data[1])
  76. }else {
  77. return value
  78. }
  79. },
  80. getTimerFilter(value) { // 获取年月日时分秒
  81. if(!value) return ""
  82. let timestamp = Date.parse(new Date(value))
  83. let date = new Date(timestamp)
  84. let Y = date.getFullYear()
  85. let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  86. let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  87. let H = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  88. let minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  89. let S = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  90. return `${Y}-${M}-${D} ${H}:${minute}:${S}`
  91. }
  92. },
  93. methods: {
  94. // 重新领取
  95. setAgainReceive(item) {
  96. setReClaim({id: item.id, createTime: item.longCreateTime}).then(res => {
  97. if (res.data === 1) {
  98. uni.showToast({
  99. title: '重领成功',
  100. icon: 'success'
  101. })
  102. this.signList = this.signList.map(item => {
  103. if (item.id === id) {
  104. return {
  105. ...item,
  106. rechargeStatus: res.data
  107. }
  108. } else {
  109. return item
  110. }
  111. })
  112. } else {
  113. uni.showToast({
  114. title: '重新领取失败,请稍后再来',
  115. icon: 'none',
  116. duration: 2000
  117. })
  118. }
  119. })
  120. },
  121. getList() {
  122. getSignList({...this.queryForm, dayTime: this.queryForm.dayTime + '-01'}).then(res => {
  123. this.signList = this.signList.concat(res.data.luckDrawLogEsDtoList)
  124. this.total = res.data.total
  125. })
  126. },
  127. // 滚动到底部去获取数据
  128. scrolltolower() {
  129. if ( this.signList.length !== this.total ) {
  130. this.$set(this.queryForm, 'page', this.queryForm.page + 1)
  131. this.getList()
  132. }
  133. },
  134. // 选择时间
  135. selectDataTime(e) {
  136. this.isShowYeer = true
  137. this.signList = []
  138. this.$set(this.queryForm, 'page', 1)
  139. this.$set(this.queryForm, 'dayTime', e.target.value)
  140. this.getList()
  141. },
  142. // 获取年月
  143. getDate() {
  144. let timestamp = Date.parse(new Date())
  145. let date = new Date(timestamp)
  146. let Y = date.getFullYear()
  147. let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  148. let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  149. return Y + '-' + M
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss">
  155. .checkInRecord {
  156. display: flex;
  157. flex-direction: column;
  158. justify-content: flex-start;
  159. width: 100%;
  160. height: 100vh;
  161. }
  162. .timeData {
  163. width: 100%;
  164. height: 104rpx;
  165. line-height: 104rpx;
  166. padding: 0 30rpx;
  167. box-sizing: border-box;
  168. border-bottom: 1rpx solid #efefef;
  169. }
  170. .time {
  171. font-size: 24rpx;
  172. .triangle {
  173. margin-left: 5rpx;
  174. width: 15rpx;
  175. height: 10rpx;
  176. }
  177. }
  178. .checkInList{
  179. height: calc(100vh - 100rpx);
  180. padding-bottom: 40rpx;
  181. box-sizing: border-box;
  182. overflow: hidden;
  183. .item {
  184. padding: 10rpx 0;
  185. margin: 0 30rpx;
  186. border-bottom: 1rpx solid #efefef;
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. }
  191. .title {
  192. font-size: 28rpx;
  193. font-weight: 500;
  194. color: #000000;
  195. }
  196. .data {
  197. font-size: 24rpx;
  198. margin-top: 8rpx;
  199. color: #808080;
  200. }
  201. .right {
  202. &>text {
  203. font-size: 28rpx;
  204. }
  205. .error {
  206. font-size: 24rpx;
  207. background-color: #FC6E53;
  208. width: 140rpx;
  209. height: 55rpx;
  210. box-sizing: border-box;
  211. color: #FFFFFF;
  212. text-align: center;
  213. line-height: 55rpx;
  214. border-radius: 30rpx;
  215. }
  216. }
  217. }
  218. .baseline {
  219. text-align: center;
  220. padding: 30rpx 0;
  221. font-size: 24rpx;
  222. color: #999999;
  223. }
  224. </style>