checkInRecord.vue 6.3 KB

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