memberSign.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="memberCenter">
  3. <global-loading />
  4. <view class="avatarTop">
  5. <view class="avatarBox">
  6. <image :src="memberData.headImage"></image>
  7. </view>
  8. <view class="nameBox">
  9. <view class="name fs36">{{ memberData.name }}</view>
  10. <view class="level">
  11. <image :src="levelInfo.memberLevelIcon"></image>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="signInfoBox">
  16. <view class="accumulate flex-items flex-sp-between">
  17. <view class="accumulateTit">
  18. <label class="fs6">已累计签到</label>
  19. <text class="fs6">{{ signDate }}天</text>
  20. </view>
  21. <view class="toSignBtn fs24" :class="{ active: currentData === upDate }" @click="signInFn">
  22. {{ currentData === upDate ? '已签到' : '立即签到' }}
  23. </view>
  24. </view>
  25. <view class="points">
  26. <label>
  27. {{ currentData === upDate ? '明' : '今' }}日签到可获得<text>
  28. {{ recordList.length === 0 ? '10积分' : '' }}
  29. </text>
  30. </label>
  31. <text v-if="recordList.length === 1">20积分</text>
  32. <text v-if="recordList.length === 2">30积分</text>
  33. <text v-if="recordList.length === 3">40积分</text>
  34. <text v-if="recordList.length === 4">50积分</text>
  35. <text v-if="recordList.length === 5">60积分</text>
  36. <text v-if="recordList.length === 6">100积分</text>
  37. </view>
  38. <view class="signDateList">
  39. <view v-for="(item, index) in recordList" :key="item.signinId" class="signItem">
  40. <view class="topIcon">
  41. <image src="../../static/images/origin/signIcon.png"></image>
  42. </view>
  43. <view class="dateInfo">{{ index + 1 }}天</view>
  44. </view>
  45. <view v-for="index in noSign" :key="index" class="signItem">
  46. <view class="topIcon">
  47. <image src="../../static/images/origin/signIcon2.png"></image>
  48. </view>
  49. <!-- #ifdef MP-WEIXIN -->
  50. <view class="dateInfo">{{ recordList.length + index + 1 }}天</view>
  51. <!-- #endif -->
  52. <!-- #ifdef H5 -->
  53. <view class="dateInfo">{{ recordList.length + index }}天</view>
  54. <!-- <view class="dateInfo">{{index+1}}天</view> -->
  55. <!-- #endif -->
  56. </view>
  57. </view>
  58. <view class="fs24 font-color-71521B">连续签到可获得超额奖励哦~</view>
  59. </view>
  60. <view class="signInList">
  61. <view class="signTit fs30 font-color-333">签到明细</view>
  62. <view v-if="historyList.length !== 0" class="signInBox">
  63. <view v-for="item in historyList" :key="item.signinId" class="signItem flex-items flex-sp-between">
  64. <view class="itemLeft flex-items">
  65. <view class="leftInfo">
  66. <label class="fs28 font-color-333">签到</label>
  67. <view class="fs24 font-color-999">{{ item.createTime }}</view>
  68. </view>
  69. </view>
  70. <view class="rightBtn">+{{ item.growth }}</view>
  71. </view>
  72. </view>
  73. <view v-if="historyList.length === 0" class="fs24 noHistory">暂无签到记录~</view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import NET from '../../utils/request'
  79. import API from '../../config/api'
  80. export default {
  81. name: 'Index',
  82. data() {
  83. return {
  84. growingValue: 80,
  85. growingMax: 3500,
  86. memberData: {},
  87. recordList: {},
  88. historyList: [],
  89. page: 1,
  90. pageSize: 5,
  91. levelInfo: {},
  92. noSign: 7,
  93. signDate: 0,
  94. currentData: '',
  95. upDate: '',
  96. loadingType: false // 判断是否触发onReachBottom
  97. }
  98. },
  99. onLoad() {
  100. this.getDate()
  101. this.memberData = uni.getStorageSync('storage_userInfo')
  102. this.levelInfo = uni.getStorageSync('storage_levelInfo')
  103. this.getSelectSigninRecordList()
  104. this.getSelectSigninHistory()
  105. },
  106. onReachBottom() {
  107. if (this.loadingType) {
  108. uni.stopPullDownRefresh()
  109. } else {
  110. this.page = this.page + 1
  111. this.getSelectSigninHistory()
  112. }
  113. },
  114. methods: {
  115. getSelectSigninRecordList() {
  116. this.noSign = 7
  117. this.signDate = 0
  118. // 获取签到
  119. // uni.showLoading({
  120. // mask: true,
  121. // title: '加载中...',
  122. // })
  123. NET.request(API.selectSigninRecordList, {}, 'GET').then((res) => {
  124. uni.hideLoading()
  125. this.recordList = res.data
  126. this.noSign = this.noSign - this.recordList.length
  127. // this.signDate = this.recordList.length
  128. const newDate = this.recordList[this.recordList.length - 1]
  129. this.upDate = newDate.createTime.slice(0, 10)
  130. })
  131. .catch((res) => { })
  132. },
  133. getSelectSigninHistory() {
  134. // 获取签到历史
  135. let param = ''
  136. param = {
  137. page: this.page,
  138. pageSize: this.pageSize
  139. }
  140. // uni.showLoading({
  141. // mask: true,
  142. // title: '加载中...',
  143. // })
  144. NET.request(API.selectSigninHistory, param, 'GET').then((res) => {
  145. if (res.data.list.length === 0) {
  146. this.loadingType = true
  147. this.page = this.page
  148. }
  149. uni.hideLoading()
  150. this.historyList = this.historyList.concat(res.data.list)
  151. this.signDate = res.data.total
  152. })
  153. .catch((res) => {
  154. uni.hideLoading()
  155. })
  156. },
  157. // 签到
  158. signInFn() {
  159. if (this.upDate !== this.currentData) {
  160. // uni.showLoading({
  161. // mask: true,
  162. // title: '请稍等...',
  163. // })
  164. NET.request(API.signIn, {}, 'POST').then((res) => {
  165. uni.hideLoading()
  166. uni.showToast({
  167. title: '签到成功!',
  168. icon: 'none'
  169. })
  170. this.getSelectSigninRecordList()
  171. this.getSelectSigninHistory()
  172. })
  173. .catch((res) => { })
  174. }
  175. },
  176. getDate() {
  177. const year = new Date().getFullYear()
  178. const month = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() +
  179. 1
  180. const date = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
  181. this.currentData = year + '-' + month + '-' + date
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. page {
  188. background: #F8F8F8;
  189. }
  190. .memberCenter {
  191. border-top: 2rpx solid #4b4b4b;
  192. background: url("../../static/images/origin/memberSignBg.png") no-repeat left top;
  193. background-size: contain;
  194. min-height: 900rpx;
  195. padding: 0 20rpx;
  196. .avatarTop {
  197. text-align: center;
  198. margin-top: 30rpx;
  199. }
  200. .avatarBox {
  201. margin-bottom: 20rpx;
  202. image {
  203. width: 110rpx;
  204. height: 110rpx;
  205. border: 5rpx solid #FFFFFF;
  206. border-radius: 50%;
  207. }
  208. }
  209. .nameBox {
  210. .name {
  211. font-size: 36rpx;
  212. color: #FFFFFF;
  213. font-weight: bold;
  214. }
  215. .level {
  216. image {
  217. width: 172rpx;
  218. height: 50rpx;
  219. }
  220. }
  221. }
  222. .signInList {
  223. background: #FFFFFF;
  224. border-radius: 20rpx;
  225. padding: 30rpx;
  226. .signTit {
  227. font-weight: bold;
  228. height: 92rpx;
  229. line-height: 92rpx;
  230. }
  231. .signInBox {
  232. .signItem {
  233. border-top: 2rpx solid #F3F4F5;
  234. padding: 30rpx 0;
  235. .itemLeft {
  236. image {
  237. width: 92rpx;
  238. height: 92rpx;
  239. margin-right: 30rpx;
  240. }
  241. }
  242. }
  243. .rightBtn {
  244. width: 160rpx;
  245. height: 58rpx;
  246. line-height: 58rpx;
  247. background: #F6EEDB;
  248. border-radius: 10rpx;
  249. color: #C5AA7B;
  250. text-align: center;
  251. }
  252. }
  253. }
  254. .signInfoBox {
  255. height: 366rpx;
  256. border: 2rpx solid rgba(0, 0, 0, 0);
  257. background: linear-gradient(88deg, #D8BD8D 0%, #EFD8AB 100%);
  258. border-radius: 10rpx;
  259. margin-top: 40rpx;
  260. padding: 30rpx 40rpx;
  261. box-sizing: border-box;
  262. .accumulate {
  263. .points {
  264. margin-top: 15rpx;
  265. margin-bottom: 30rpx;
  266. }
  267. label {
  268. color: #71521B;
  269. }
  270. text {
  271. color: #C83732;
  272. margin-left: 20rpx
  273. }
  274. .toSignBtn {
  275. width: 160rpx;
  276. height: 58rpx;
  277. line-height: 58rpx;
  278. background: #333333;
  279. border-radius: 10rpx;
  280. color: #FFEBC4;
  281. text-align: center;
  282. }
  283. .active {
  284. opacity: 0.8;
  285. }
  286. .accumulateTit {
  287. font-weight: bold;
  288. }
  289. }
  290. .signDateList {
  291. display: flex;
  292. flex-flow: wrap;
  293. justify-content: space-around;
  294. margin: 20rpx 0;
  295. .signItem {
  296. text-align: center;
  297. .topIcon {
  298. image {
  299. width: 60rpx;
  300. height: 60rpx;
  301. }
  302. }
  303. }
  304. .active {}
  305. }
  306. }
  307. .noHistory {
  308. color: #999999;
  309. height: 100rpx;
  310. line-height: 100rpx;
  311. border-top: 2rpx solid #F3F4F5;
  312. }
  313. }
  314. </style>