前端vue开发连续签到功能

╰半夏微凉° 2022-09-04 03:52 402阅读 0赞

话不多说 直接上代码

在这里插入图片描述

  1. <template>
  2. <div class="signBox">
  3. <div class="tips">
  4. <span>Signed in for </span> <span>{ { days }}</span>
  5. <span>consecutive days</span>
  6. </div>
  7. <p class="history" @click="goToHistory">View score history ></p>
  8. <ul class="signBtnBox">
  9. <li class="signBtnOne" v-for="(item, key, index) in list" :key="index">
  10. <div
  11. v-if="Number(days) == index + 1 || Number(days) > index + 1"
  12. style=" width: 100%; height: 100%; border-radius: 4px; background-color: #ff9400; ">
  13. <img src="./image/2.png" />
  14. <p>{ { item.gift_num }}</p>
  15. </div>
  16. <div v-else @click="signInToday">
  17. <img src="./image/3.png" />
  18. <p>{ { item.gift_num }}</p>
  19. </div>
  20. </li>
  21. </ul>
  22. <p class="signResetTime">Check-in reset time: daily 18:00:00</p>
  23. <div class="pointJump">
  24. <div class="pointShop" @click="gotoPointsStore">
  25. <P>Points</P>
  26. <p>Shop</p>
  27. </div>
  28. <div class="textCenter">
  29. <P>Task</P>
  30. <p>Center</p>
  31. </div>
  32. <div class="myWallet" @click="gotoWallet">
  33. <P>My</P>
  34. <p>Wallet</p>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import { assetsVersionDir } from "../../../hrefs";
  41. export default {
  42. data() {
  43. return {
  44. list: [],
  45. res: "",
  46. /* 签到的总天数 */
  47. days: "",
  48. signOK:""
  49. };
  50. },
  51. methods: {
  52. // 跳转到积分历史页面
  53. goToHistory() {
  54. this.$openUrl(assetsVersionDir + "index.html?#/profile/wallet/points",1);
  55. },
  56. // 打开积分商城页面
  57. gotoPointsStore() {
  58. this.$openUrl();
  59. },
  60. // 打开我的钱包页面
  61. gotoWallet() {
  62. this.$openUrl(assetsVersionDir + "index.html?#/other/getPoints", 1);
  63. },
  64. todaySignIn() {
  65. this.$http.get(window.apis.sign_in_today).then((res) => {
  66. this.getSignIn();
  67. console.log(res);
  68. let signOK = res;
  69. this.signOK = signOK
  70. console.log(signOK);
  71. });
  72. },
  73. // 点击签到
  74. signInToday() {
  75. console.log(this.res.data.today);
  76. if (this.res.data.today == 0) {
  77. this.todaySignIn()
  78. console.log(this.res.code);
  79. if(this.res.code !== 0){
  80. this.$message.success("签到失败");
  81. }else{
  82. this.$message.error("签到成功");
  83. }
  84. } else {
  85. this.$message.error("今日已签到");
  86. }
  87. },
  88. getSignIn() {
  89. this.$http.get(window.apis.check_in_query).then((res) => {
  90. // console.log(res);
  91. this.res = res;
  92. console.log(this.res);
  93. //传值发给list[]
  94. let list = res.data.conf;
  95. this.list = list;
  96. let days = this.res.data.days_num;
  97. this.days = days;
  98. console.log(days);
  99. console.log(this.res.data.today);
  100. // console.log(this.list);
  101. });
  102. },
  103. },
  104. components: { },
  105. created() {
  106. this.getSignIn();
  107. },
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. * {
  112. padding: 0;
  113. margin: 0;
  114. box-sizing: border-box;
  115. }
  116. .signBox {
  117. width: 398px;
  118. height: 276px;
  119. background: #2d3949;
  120. border-radius: 10px;
  121. padding: 1.4% 2.3%;
  122. margin: 0 auto;
  123. .tips {
  124. margin-top: 3%;
  125. span {
  126. color: #ffffff;
  127. font-size: 16px;
  128. font-family: PingFang SC;
  129. letter-spacing: -0.1px;
  130. line-height: 22px;
  131. font-weight: 500;
  132. }
  133. :nth-of-type(2) {
  134. color: #fe9300;
  135. letter-spacing: -0.1px;
  136. }
  137. }
  138. .history {
  139. opacity: 0.5;
  140. font-family: PingFangSC-Regular;
  141. font-size: 14px;
  142. color: #ffffff;
  143. letter-spacing: 0;
  144. font-weight: 400;
  145. cursor: pointer;
  146. margin: 3% 0 6% 0;
  147. }
  148. .signBtnBox {
  149. display: flex;
  150. justify-content: space-between;
  151. & > li {
  152. cursor: pointer;
  153. width: 42px;
  154. height: 52px;
  155. background: #28313e;
  156. border-radius: 4px;
  157. img {
  158. margin: 6px 0 0 10px;
  159. }
  160. p {
  161. text-align: center;
  162. opacity: 0.6;
  163. font-family: PingFangSC-Medium;
  164. font-size: 14px;
  165. color: #ffffff;
  166. letter-spacing: 0;
  167. font-weight: 500;
  168. }
  169. }
  170. .signed {
  171. background: #ff9400;
  172. color: #ffffff;
  173. p {
  174. opacity: 1 !important;
  175. }
  176. }
  177. }
  178. .signResetTime {
  179. text-align: center;
  180. opacity: 0.5;
  181. font-family: PingFangSC-Regular;
  182. font-size: 14px;
  183. color: #ffffff;
  184. letter-spacing: 0;
  185. font-weight: 400;
  186. margin: 3% 0;
  187. }
  188. .pointJump {
  189. display: flex;
  190. justify-content: space-between;
  191. .pointShop {
  192. width: 110px;
  193. height: 76px;
  194. background-image: url(./image/积分商城.png);
  195. }
  196. .textCenter {
  197. width: 110px;
  198. height: 76px;
  199. background-image: url(./image/任务中心.png);
  200. }
  201. .myWallet {
  202. width: 110px;
  203. height: 76px;
  204. background-image: url(./image/我的钱包.png);
  205. }
  206. .pointShop,
  207. .textCenter,
  208. .myWallet {
  209. padding: 20px 10px;
  210. line-height: 20px;
  211. font-family: PingFangSC-Medium;
  212. font-size: 16px;
  213. color: #ffffff;
  214. letter-spacing: 0;
  215. font-weight: 500;
  216. cursor: pointer;
  217. p {
  218. opacity: 0.9;
  219. }
  220. }
  221. }
  222. }
  223. </style>

发表评论

表情:
评论列表 (有 0 条评论,402人围观)

还没有评论,来说两句吧...

相关阅读

    相关 使用redis bitmap实现签到功能

    1.签到功能的实现思路 最近有研究到用户的签到功能,对功能进行设计的时候想到使用msyql存储用户的签到记录,将用户的每日签到记录存储到表中,然后又想到每次签到就往表里面

    相关 利用redis实现每日签到功能

    今天给大家介绍一个简单的应用场景,我们迷你喵小程序最近新增了一个签到功能,但是每天只能签到一次,我们如何实现每日只签到一次呢? 想学习分布式、微服务、JVM、多线程、架构、j