sign.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view class="center">
  3. <view class="status_bar"><!-- 这里是状态栏 --></view>
  4. <view class="content-money">
  5. <view class="body-title">
  6. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  7. <view class="header">每日签到</view>
  8. </view>
  9. <view class="content-bg"><image src="../../static/img/sign-bg.png" mode=""></image></view>
  10. <view class="sign" @click="integral()">
  11. <image class="sign-bg" src="../../static/img/sign-main.png" mode=""></image>
  12. <view class="sign-font">{{ signTrue ? '已签到' : '签到' }}</view>
  13. </view>
  14. <view class="sign-tip">今日签到可得10购物积分</view>
  15. </view>
  16. <view class="nav">
  17. <view class="nav-item">
  18. <view class="num">{{ sum_integral }}</view>
  19. <view class="font">获得金额</view>
  20. </view>
  21. <view class="xian"></view>
  22. <view class="nav-item">
  23. <view class="num">{{ allSign }}</view>
  24. <view class="font">签到天数</view>
  25. </view>
  26. </view>
  27. <view class="rili"><calendar class="sign-date-box" :checks="signList" checksClass="" :checkTextShow="true"></calendar></view>
  28. <!-- <view class="explain">
  29. <view class="explain-left">
  30. 签到说明
  31. </view>
  32. <view class="explain-right">
  33. </view>
  34. </view> -->
  35. <uni-popup ref="popup" type="center">
  36. <view class="popup">
  37. <view class="popup-dox"><image class="popup-logo" src="../../static/img/sign-popup.png"></image></view>
  38. <view class="popup-title">
  39. 获得¥
  40. <text>10</text>
  41. 现金
  42. </view>
  43. <view class="popup-tip">
  44. 明天签到可得¥
  45. <text>10</text>
  46. 现金
  47. </view>
  48. <view class="popup-btn" @click="close">知道了</view>
  49. </view>
  50. <view class="close_icon" @click="close"><image src="../../static/img/Close.png"></image></view>
  51. </uni-popup>
  52. </view>
  53. </template>
  54. <script>
  55. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  56. import calendar from '../../components/ss-calendar/ss-calendar.vue';
  57. import { signList, integral, signUser } from '@/api/functionalUnit.js';
  58. export default {
  59. components: {
  60. calendar,
  61. uniPopup
  62. },
  63. data() {
  64. return {
  65. money: '', //保存当前月份
  66. year: '', //保存当前年份
  67. day: '', //保存当前日期
  68. signList: [], //签到日子列表
  69. actionDay: 0, //连续签到天数
  70. allSign: 0, //累计签到
  71. sum_integral: 0, //累计获得积分
  72. signTrue: false
  73. };
  74. },
  75. onLoad() {
  76. this.signUser();
  77. this.getData();
  78. this.loadList();
  79. },
  80. methods: {
  81. // 点击返回 我的页面
  82. toBack() {
  83. uni.navigateBack({});
  84. },
  85. integral() {
  86. integral({})
  87. .then(e => {
  88. this.$refs.popup.open();
  89. // 改为已签到
  90. this.signTrue = true;
  91. this.actionDay++;
  92. // 保存签到成功
  93. this.signList.push(this.day);
  94. })
  95. .catch(e => {
  96. this.$refs.popup.open();
  97. console.log(e);
  98. });
  99. },
  100. close() {
  101. this.$refs.popup.close();
  102. },
  103. // 获取签到列表
  104. loadList() {
  105. let obj = this;
  106. let present = this.day; //保存当前天数用于后续计算
  107. let actionDay = 0; //用于计算活跃天数
  108. let arr = []; //保存返回数组;
  109. signList({
  110. page: 1,
  111. limit: 31
  112. }).then(e => {
  113. arr = e.data.map((e, ind) => {
  114. let time = e.add_time.split('-');
  115. let day = parseInt(time[2].replace(/^0/i, ''));
  116. let year = time[0];
  117. let month = +time[1];
  118. if (obj.year == year && obj.month == month) {
  119. return day;
  120. }
  121. });
  122. this.signList = arr;
  123. // 判断今天是否已经签到
  124. if (arr[0] == this.day) {
  125. this.signTrue = true;
  126. }
  127. });
  128. }, // 获取当前时间
  129. getData(current) {
  130. const date = current ? new Date(current) : new Date();
  131. this.year = date.getFullYear(); //保存当前年份
  132. this.month = date.getMonth() + 1; //保存当前月份
  133. this.day = date.getDate(); //保存当前日期
  134. },
  135. //获取签到用户信息
  136. signUser() {
  137. signUser({ all: 1 }).then(({ data }) => {
  138. this.actionDay = data.sign_num; //连续签到天数
  139. this.allSign = data.sum_sgin_day; //累计签到天数
  140. this.sum_integral = data.sum_integral; //累计总积分
  141. });
  142. }
  143. }
  144. };
  145. </script>
  146. <style lang="scss">
  147. .center,
  148. page {
  149. padding-bottom: 20rpx;
  150. }
  151. .status_bar {
  152. height: var(--status-bar-height);
  153. width: 100%;
  154. }
  155. .content-money {
  156. padding-bottom: 30rpx;
  157. position: relative;
  158. height: 526rpx;
  159. .content-bg {
  160. position: absolute;
  161. top: 0;
  162. left: 0;
  163. right: 0;
  164. width: 750rpx;
  165. height: 526rpx;
  166. image {
  167. width: 100%;
  168. height: 100%;
  169. }
  170. }
  171. .body-title {
  172. height: 80rpx;
  173. text-align: center;
  174. font-size: 35rpx;
  175. position: relative;
  176. .header {
  177. position: absolute;
  178. left: 0;
  179. top: 0;
  180. width: 100%;
  181. font-size: 36rpx;
  182. font-family: PingFang SC;
  183. font-weight: bold;
  184. color: #fffeff;
  185. height: 80rpx;
  186. font-size: 36rpx;
  187. font-weight: 700;
  188. z-index: 9;
  189. display: flex;
  190. justify-content: center;
  191. align-items: center;
  192. }
  193. .goback-box {
  194. position: absolute;
  195. left: 18rpx;
  196. top: 0;
  197. height: 80rpx;
  198. display: flex;
  199. align-items: center;
  200. }
  201. .goback {
  202. z-index: 100;
  203. width: 34rpx;
  204. height: 34rpx;
  205. }
  206. }
  207. .sign {
  208. width: 200rpx;
  209. height: 200rpx;
  210. margin: 40rpx auto 0;
  211. text-align: center;
  212. position: relative;
  213. z-index: 10;
  214. .sign-bg {
  215. position: absolute;
  216. top: 0;
  217. left: 0;
  218. right: 0;
  219. width: 100%;
  220. height: 100%;
  221. }
  222. .sign-font {
  223. position: relative;
  224. z-index: 11;
  225. line-height: 200rpx;
  226. font-size: 46rpx;
  227. font-family: PingFang SC;
  228. font-weight: 500;
  229. color: #ffffff;
  230. }
  231. }
  232. .sign-tip {
  233. margin: 14rpx auto 0;
  234. font-size: 32rpx;
  235. font-family: PingFang SC;
  236. font-weight: 500;
  237. color: #ffffff;
  238. position: relative;
  239. z-index: 10;
  240. text-align: center;
  241. }
  242. }
  243. .nav {
  244. position: relative;
  245. z-index: 10;
  246. width: 710rpx;
  247. height: 192rpx;
  248. display: flex;
  249. align-items: center;
  250. background: #ffffff;
  251. border-radius: 10rpx;
  252. margin: -86rpx auto 0;
  253. .nav-item {
  254. width: 50%;
  255. display: flex;
  256. flex-direction: column;
  257. align-items: center;
  258. justify-content: center;
  259. line-height: 1;
  260. .num {
  261. font-size: 56rpx;
  262. font-family: PingFang SC;
  263. font-weight: bold;
  264. color: #666666;
  265. }
  266. .font {
  267. margin-top: 28rpx;
  268. font-size: 30rpx;
  269. font-family: PingFang SC;
  270. font-weight: 500;
  271. color: #333333;
  272. opacity: 0.6;
  273. }
  274. }
  275. .xian {
  276. width: 2rpx;
  277. height: 152rpx;
  278. background-color: #efefef;
  279. }
  280. }
  281. .explain {
  282. margin: 20rpx auto 0;
  283. padding: 24rpx 28rpx;
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-between;
  287. width: 694rpx;
  288. background: #ffffff;
  289. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  290. border-radius: 20rpx;
  291. .explain-left {
  292. font-size: 28rpx;
  293. font-family: PingFang SC;
  294. font-weight: bold;
  295. color: #333333;
  296. }
  297. .explain-right {
  298. position: relative;
  299. bottom: 14rpx;
  300. right: 28rpx;
  301. }
  302. .explain-right:after,
  303. .explain-right:before {
  304. border: 12rpx solid transparent;
  305. border-left: 12rpx solid #fff;
  306. width: 0;
  307. height: 0;
  308. position: absolute;
  309. top: 0;
  310. right: -20px;
  311. content: ' ';
  312. }
  313. .explain-right:before {
  314. border-left-color: #333333;
  315. right: -21px;
  316. }
  317. }
  318. .popup {
  319. width: 560rpx;
  320. padding-bottom: 45rpx;
  321. background-color: #ffffff;
  322. border-radius: 15rpx;
  323. text-align: center;
  324. line-height: 1;
  325. .popup-dox {
  326. position: relative;
  327. .popup-logo {
  328. margin: -160rpx auto 0;
  329. width: 400rpx;
  330. height: 200rpx;
  331. }
  332. }
  333. .popup-title {
  334. margin-top: 85rpx;
  335. font-size: 40rpx;
  336. font-family: PingFang SC;
  337. font-weight: bold;
  338. color: #2a2a2a;
  339. text {
  340. font-size: 56rpx;
  341. color: #e83f30;
  342. }
  343. }
  344. .popup-tip {
  345. margin-top: 20rpx;
  346. font-size: 28rpx;
  347. font-family: PingFang SC;
  348. font-weight: 500;
  349. color: #8c8c8c;
  350. text {
  351. color: #e83f30;
  352. }
  353. }
  354. .popup-btn {
  355. margin: 58rpx auto 0;
  356. width: 270rpx;
  357. height: 66rpx;
  358. background: #f0c838;
  359. border-radius: 34rpx;
  360. text-align: center;
  361. line-height: 66rpx;
  362. font-size: 36rpx;
  363. font-family: Source Han Sans CN;
  364. font-weight: 500;
  365. color: #ffffff;
  366. }
  367. }
  368. .close_icon {
  369. width: 60rpx;
  370. height: 60rpx;
  371. margin: 88rpx auto 0;
  372. image {
  373. width: 100%;
  374. height: 100%;
  375. }
  376. }
  377. .rili {
  378. margin-top: 20rpx;
  379. padding: 0 20rpx;
  380. }
  381. </style>