memberSign.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view class="memberCenter">
  3. <JHeader title="会员签到" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="avatarTop">
  5. <view class="avatarBox">
  6. <image :src="common.seamingImgUrl($store.getters.userInfo.headImage)"></image>
  7. </view>
  8. <view class="nameBox">
  9. <view class="name fs36">{{ $store.getters.userInfo.name }}</view>
  10. <view class="level">
  11. <image :src="common.seamingImgUrl(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">{{ historyTotal }}天</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. <tui-icon name="member-fill" :size="60" unit="upx" color="#fdbc3d"></tui-icon>
  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. <tui-icon name="circle-selected" :size="60" unit="upx" color="#b0b0b0"></tui-icon>
  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 && historyList.length" 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 style="padding-bottom: 45upx;">
  74. <LoadingMore
  75. :status="!isEmpty && !historyList.length
  76. ? 'loading' : !isEmpty && historyList.length && (historyList.length >= historyTotal) ? 'no-more' : ''"
  77. >
  78. </LoadingMore>
  79. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无签到记录~</tui-no-data>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import { getMemberByMemberLevelIdApi, getSelectSigninRecordListApi, getSelectSigninHistoryApi, updateMemberSignInApi } from '../../../api/anotherTFInterface'
  86. export default {
  87. name: 'MemberSign',
  88. data() {
  89. return {
  90. levelInfo: {},
  91. recordList: {},
  92. noSign: 7,
  93. currentData: '',
  94. upDate: '',
  95. isEmpty: false,
  96. historyList: [],
  97. historyTotal: 0,
  98. queryInfo: {
  99. page: 1,
  100. pageSize: 20
  101. }
  102. }
  103. },
  104. onLoad() {
  105. this.getDate()
  106. this.$store.dispatch('auth/refrshUserInfoAction', () => {
  107. getMemberByMemberLevelIdApi({ memberLevelId: this.$store.getters.userInfo.memberLevelId })
  108. .then((res) => {
  109. this.levelInfo = res.data
  110. })
  111. })
  112. this.getSelectSigninRecordList()
  113. this.getSelectSigninHistory()
  114. },
  115. methods: {
  116. getDate() {
  117. const year = new Date().getFullYear()
  118. const month = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
  119. const date = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
  120. this.currentData = year + '-' + month + '-' + date
  121. },
  122. getSelectSigninRecordList() {
  123. this.noSign = 7
  124. uni.showLoading({
  125. mask: true,
  126. title: '加载中...'
  127. })
  128. getSelectSigninRecordListApi({}).then((res) => {
  129. uni.hideLoading()
  130. this.recordList = res.data
  131. this.noSign = this.noSign - this.recordList.length
  132. const newDate = this.recordList[this.recordList.length - 1]
  133. this.upDate = newDate.createTime.slice(0, 10)
  134. })
  135. },
  136. getSelectSigninHistory(isLoadmore) {
  137. uni.showLoading()
  138. getSelectSigninHistoryApi(this.queryInfo).then((res) => {
  139. this.historyTotal = res.data.total
  140. if (isLoadmore) {
  141. this.historyList.push(...res.data.list)
  142. } else {
  143. this.historyList = res.data.list
  144. }
  145. this.isEmpty = this.historyList.length === 0
  146. uni.hideLoading()
  147. })
  148. .catch((e) => {
  149. uni.hideLoading()
  150. })
  151. },
  152. // 签到
  153. signInFn() {
  154. if (this.upDate !== this.currentData) {
  155. uni.showLoading({
  156. mask: true,
  157. title: '请稍等...'
  158. })
  159. updateMemberSignInApi({}).then((res) => {
  160. uni.hideLoading()
  161. uni.showToast({
  162. title: '签到成功!',
  163. icon: 'none'
  164. })
  165. this.getSelectSigninRecordList()
  166. this.getSelectSigninHistory()
  167. })
  168. }
  169. }
  170. },
  171. onReachBottom() {
  172. if (this.historyList.length < this.historyTotal) {
  173. ++this.queryInfo.page
  174. this.getSelectSigninHistory(true)
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="less" scoped>
  180. .memberCenter {
  181. min-height: 100vh;
  182. padding: 0 20rpx;
  183. background: #F8F8F8;
  184. background-size: contain;
  185. box-sizing: border-box;
  186. .avatarTop {
  187. text-align: center;
  188. margin-top: 30rpx;
  189. }
  190. .avatarBox {
  191. margin-bottom: 20rpx;
  192. image {
  193. width: 110rpx;
  194. height: 110rpx;
  195. border: 5rpx solid #FFFFFF;
  196. border-radius: 50%;
  197. }
  198. }
  199. .nameBox {
  200. .name {
  201. font-size: 36rpx;
  202. color: #FFFFFF;
  203. font-weight: bold;
  204. }
  205. .level {
  206. image {
  207. width: 172rpx;
  208. height: 50rpx;
  209. }
  210. }
  211. }
  212. .signInList {
  213. background: #FFFFFF;
  214. border-radius: 20rpx;
  215. padding: 30rpx;
  216. .signTit {
  217. font-weight: bold;
  218. height: 92rpx;
  219. line-height: 92rpx;
  220. }
  221. .signInBox {
  222. .signItem {
  223. border-top: 2rpx solid #F3F4F5;
  224. padding: 30rpx 0;
  225. .itemLeft {
  226. image {
  227. width: 92rpx;
  228. height: 92rpx;
  229. margin-right: 30rpx;
  230. }
  231. }
  232. }
  233. .rightBtn {
  234. width: 160rpx;
  235. height: 58rpx;
  236. line-height: 58rpx;
  237. background: #F6EEDB;
  238. border-radius: 10rpx;
  239. color: #C5AA7B;
  240. text-align: center;
  241. }
  242. }
  243. }
  244. .signInfoBox {
  245. height: 366rpx;
  246. border: 2rpx solid rgba(0, 0, 0, 0);
  247. background: linear-gradient(88deg, #D8BD8D 0%, #EFD8AB 100%);
  248. border-radius: 10rpx;
  249. margin-top: 40rpx;
  250. padding: 30rpx 40rpx;
  251. box-sizing: border-box;
  252. .accumulate {
  253. .points {
  254. margin-top: 15rpx;
  255. margin-bottom: 30rpx;
  256. }
  257. label {
  258. color: #71521B;
  259. }
  260. text {
  261. color: #C83732;
  262. margin-left: 20rpx
  263. }
  264. .toSignBtn {
  265. width: 160rpx;
  266. height: 58rpx;
  267. line-height: 58rpx;
  268. background: #333333;
  269. border-radius: 10rpx;
  270. color: #FFEBC4;
  271. text-align: center;
  272. }
  273. .active {
  274. opacity: 0.8;
  275. }
  276. .accumulateTit {
  277. font-weight: bold;
  278. }
  279. }
  280. .signDateList {
  281. display: flex;
  282. flex-flow: wrap;
  283. justify-content: space-around;
  284. margin: 20rpx 0;
  285. .signItem {
  286. text-align: center;
  287. }
  288. }
  289. }
  290. }
  291. </style>