多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
7.9 KiB

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