sign.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. a<template>
  2. <view class="sign">
  3. <view class="header bg-color-green">
  4. <view class="headerCon acea-row row-between-wrapper">
  5. <view class="left acea-row row-between-wrapper">
  6. <view class="pictrue">
  7. <image :src="userInfo.avatar?userInfo.avatar:'/static/user/touxiang-@2x.png'" />
  8. </view>
  9. <view class="text">
  10. <view class="line1">{{ userInfo.nickname || '' }}</view>
  11. <view class="integral acea-row">
  12. <text>积分: {{ userInfo.integral || 0 }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <view @click="goSignRecord()" class="right acea-row row-middle">
  17. <view class="iconfont icon-caidan"></view>
  18. <view>明细</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="wrapper">
  23. <view class="list acea-row row-between-wrapper">
  24. <view class="item" v-for="(item, signSystemListIndex) in signSystemList" :key="signSystemListIndex">
  25. <view :class="signSystemListIndex + 1 === signSystemList.length ? 'rewardTxt' : ''">{{ item.dictLabel }}</view>
  26. <view class="venus" :class=" (signSystemListIndex + 1 === signSystemList.length ? 'reward' : '') +' ' + (sign_index >= signSystemListIndex + 1 ? 'venusSelect' : '')"></view>
  27. <view class="num" :class="sign_index >= signSystemListIndex + 1 ? 'on' : ''">+{{ item.dictValue }}</view>
  28. </view>
  29. </view>
  30. <!--加在 but 上 on 为已签到-->
  31. <view class="but bg-color-green" :class="userInfo.is_day_sgin ? 'on' : ''" @click="goSign">{{ userInfo.isDaySign ? "已签到" : "立即签到" }}</view>
  32. <!-- <view class="lock"></view>-->
  33. </view>
  34. <view class="wrapper wrapper2">
  35. <view class="tip">已累计签到</view>
  36. <view class="list2 acea-row row-center row-bottom">
  37. <view class="item" v-for="(item, signCountIndex) in signCount" :key="signCountIndex">{{ item || 0 }}</view>
  38. <view class="data">天</view>
  39. </view>
  40. <view class="tip2">据说连续签到第{{ day }}天可获得超额积分,一定要坚持签到哦~~~</view>
  41. <view class="list3">
  42. <view class="item acea-row row-between-wrapper" v-for="(item, signListIndex) in signList" :key="signListIndex">
  43. <view>
  44. <view class="name line1">{{ item.title }}</view>
  45. <view class="data">{{ item.createTime }}</view>
  46. </view>
  47. <view class="num font-color-red">+{{ item.number }}</view>
  48. </view>
  49. <view @click="goSignRecord()" class="Loads acea-row row-center-wrapper" v-if="signList.length > 0">
  50. 点击加载更多
  51. <view class="iconfont icon-xiangyou acea-row row-center-wrapper"></view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="signTip acea-row row-center-wrapper" :class="active === true ? 'on' : ''">
  56. <view class="signTipLight loadingpic">
  57. <image :src="`${$VUE_APP_RESOURCES_URL}/images/light.png`" />
  58. </view>
  59. <view class="signTipCon">
  60. <view class="state">签到成功</view>
  61. <view class="integral">获得{{ integral }}积分</view>
  62. <view class="signTipBnt" @click="close">好的</view>
  63. </view>
  64. </view>
  65. <view class="mask" @touchmove.prevent :hidden="active === false"></view>
  66. </view>
  67. </template>
  68. <style scoped lang="less">
  69. .Loads .iconfont {
  70. font-size: 0.25*100rpx;
  71. margin: 0.02*100rpx 0 0 0.1*100rpx;
  72. }
  73. </style>
  74. <script>
  75. import {
  76. add
  77. } from "@/util/bc";
  78. export default {
  79. name: "Sign",
  80. components: {},
  81. props: {},
  82. data: function() {
  83. return {
  84. userInfo: {},
  85. integral: 0,
  86. signCount: [],
  87. sign_index: 0,
  88. signSystemList: [],
  89. signList: [],
  90. pageNum: 1,
  91. pageSize: 3,
  92. active: false,
  93. day: ""
  94. };
  95. },
  96. mounted: function() {
  97. uni.showLoading({ title: "加载中", mask: true });
  98. this.signUser();
  99. this.signConfig();
  100. this.getSignList();
  101. },
  102. methods: {
  103. goSignRecord() {
  104. uni.redirectTo({
  105. url: '/pages/user/integral'
  106. })
  107. },
  108. // js给数字补0;num:需要补0的数字,length:长度(补到多少位);
  109. PrefixInteger: function(num, length) {
  110. return (Array(length).join("0") + num).slice(-length).split("");
  111. },
  112. //数字转中文
  113. Rp: function(n) {
  114. var cnum = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
  115. var s = "";
  116. n = "" + n; // 数字转为字符串
  117. for (var i = 0; i < n.length; i++) {
  118. s += cnum[parseInt(n.charAt(i))];
  119. }
  120. return s;
  121. },
  122. // 获取用户信息
  123. signUser: function() {
  124. let that = this;
  125. this.$api.request('get', 'user/app/userSign/getSignInUser').then(res => {
  126. uni.hideLoading();
  127. res.data.integral = parseInt(res.data.integral);
  128. var sumSginDay = res.data.sumSignDay;
  129. that.userInfo = res.data;
  130. that.signCount = that.PrefixInteger(sumSginDay, 4);
  131. that.sign_index = parseInt(res.data.signNum);
  132. });
  133. },
  134. // 签到配置
  135. signConfig: function() {
  136. let that = this;
  137. this.$api.request('get', 'system/app/dict/data/type/sgin_rule').then(res => {
  138. that.signSystemList = res.data;
  139. that.day = that.Rp(that.signSystemList.length);
  140. });
  141. },
  142. // 用户签到
  143. goSign: function() {
  144. let that = this,
  145. sumSginDay = that.userInfo.sumSignDay;
  146. if (that.userInfo.is_day_sgin) {
  147. uni.showToast({
  148. title: "您今日已签到!",
  149. icon: "none",
  150. duration: 2000
  151. });
  152. return
  153. }
  154. this.$api.request('get', 'user/app/userSign/sign/integral').then(res => {
  155. that.active = true;
  156. that.integral = res.data.integral;
  157. let sign_index = parseInt(that.sign_index + 1);
  158. that.sign_index =
  159. sign_index > that.signSystemList.length ? 1 : sign_index;
  160. that.signCount = that.PrefixInteger(sumSginDay + 1, 4);
  161. that.userInfo.is_day_sgin = true;
  162. that.userInfo.integral = add(that.userInfo.integral, res.data.integral);
  163. that.getSignList();
  164. });
  165. },
  166. // 获取签到列表;
  167. getSignList: function() {
  168. let that = this;
  169. this.$api.request('get', 'user/app/userSign/list',
  170. {pageNum:that.pageNum,pageSize:that.pageSize}).then(res => {
  171. that.signList = res.rows;
  172. });
  173. },
  174. close: function() {
  175. this.active = false;
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="less">
  181. /*签到*/
  182. .sign .header {
  183. width: 100%;
  184. height: 3.1 * 100rpx;
  185. }
  186. .sign .header .headerCon {
  187. padding: 0 0 0 0.3 * 100rpx;
  188. height: 2.34 * 100rpx;
  189. }
  190. .sign .header .headerCon .left {
  191. width: 5.3 * 100rpx;
  192. font-size: 0.32 * 100rpx;
  193. color: #fff;
  194. font-weight: bold;
  195. }
  196. .sign .header .headerCon .left .integral text {
  197. font-size: 0.24 * 100rpx;
  198. margin-top: 0.19 * 100rpx;
  199. background-color: #ff9000;
  200. text-align: center;
  201. border-radius: 0.06 * 100rpx;
  202. font-weight: normal;
  203. padding: 0.06 * 100rpx 0.15 * 100rpx;
  204. }
  205. .sign .header .headerCon .text {
  206. width: 4.1 * 100rpx;
  207. }
  208. .sign .header .headerCon .left .pictrue {
  209. width: 0.86 * 100rpx;
  210. height: 0.86 * 100rpx;
  211. border-radius: 50%;
  212. border: 0.04 * 100rpx solid #fff;
  213. }
  214. .sign .header .headerCon .left .pictrue image {
  215. width: 100%;
  216. height: 100%;
  217. border-radius: 50%;
  218. }
  219. .sign .header .headerCon .right {
  220. width: 1.42 * 100rpx;
  221. height: 0.66 * 100rpx;
  222. background-color: #fff;
  223. border-radius: 0.5 * 100rpx 0 0 0.5 * 100rpx;
  224. font-size: 0.24 * 100rpx;
  225. }
  226. .sign .header .headerCon .right .iconfont {
  227. font-size: 0.33 * 100rpx;
  228. padding: 0 0.1 * 100rpx 0 0.3 * 100rpx;
  229. height: 0.35 * 100rpx;
  230. line-height: 0.35 * 100rpx;
  231. }
  232. .sign .wrapper {
  233. background-color: #fff;
  234. margin: -0.8 * 100rpx 0.2 * 100rpx 0 0.2 * 100rpx;
  235. border-radius: 0.15 * 100rpx;
  236. padding-bottom: 0.8 * 100rpx;
  237. position: relative;
  238. }
  239. .sign .wrapper .list {
  240. padding: 0 0.3 * 100rpx;
  241. height: 2.4 * 100rpx;
  242. }
  243. .sign .wrapper .list .item {
  244. font-size: 0.22 * 100rpx;
  245. color: #8a8886;
  246. text-align: center;
  247. }
  248. .sign .wrapper .list .item .rewardTxt {
  249. width: 0.74 * 100rpx;
  250. height: 0.32 * 100rpx;
  251. background-color: #f4b409;
  252. border-radius: 0.16 * 100rpx;
  253. font-size: 0.2 * 100rpx;
  254. color: #a57d3f;
  255. line-height: 0.32 * 100rpx;
  256. }
  257. .sign .wrapper .list .item .num {
  258. font-size: 0.3 * 100rpx;
  259. color: #999;
  260. }
  261. .sign .wrapper .list .item .num.on {
  262. color: #ff9000;
  263. }
  264. .sign .wrapper .list .item .venus {
  265. background-image: url('https://wx.yixiang.co/static/images/stars2.png');
  266. background-repeat: no-repeat;
  267. background-size: 100% 100%;
  268. width: 0.56 * 100rpx;
  269. height: 0.56 * 100rpx;
  270. margin: 0.1 * 100rpx 0;
  271. }
  272. .sign .wrapper .list .item .venus.venusSelect {
  273. background-image: url('https://wx.yixiang.co/static/images/stars1.png');
  274. }
  275. .sign .wrapper .list .item .venus.reward {
  276. background-image: url('https://wx.yixiang.co/static/images/stars3.png');
  277. width: 0.75 * 100rpx;
  278. height: 0.56 * 100rpx;
  279. }
  280. .sign .wrapper .but {
  281. width: 4 * 100rpx;
  282. height: 0.76 * 100rpx;
  283. font-size: 0.3 * 100rpx;
  284. line-height: 0.76 * 100rpx;
  285. color: #fff;
  286. border-radius: 0.5 * 100rpx;
  287. text-align: center;
  288. margin: 0 auto;
  289. }
  290. .sign .wrapper .but.on {
  291. background-color: #999 !important;
  292. }
  293. .sign .wrapper .lock {
  294. background-image: url('https://wx.yixiang.co/static/images/lock2.png');
  295. background-repeat: no-repeat;
  296. background-size: 100% 100%;
  297. width: 5.58 * 100rpx;
  298. height: 0.68 * 100rpx;
  299. position: absolute;
  300. left: 50%;
  301. transform: translateX(-50%);
  302. bottom: -0.41 * 100rpx;
  303. z-index: 9;
  304. }
  305. .sign .wrapper2 {
  306. margin-top: 0.15 * 100rpx;
  307. padding: 0.73 * 100rpx 0 0 0;
  308. }
  309. .sign .wrapper2 .tip {
  310. font-size: 0.3 * 100rpx;
  311. color: #666;
  312. text-align: center;
  313. }
  314. .sign .wrapper2 .list2 {
  315. margin: 0.45 * 100rpx 0 0.49 * 100rpx 0;
  316. }
  317. .sign .wrapper2 .list2 .item {
  318. width: 0.8 * 100rpx;
  319. height: 1.16 * 100rpx;
  320. background-repeat: no-repeat;
  321. background-size: 100% 100%;
  322. color: #fff;
  323. font-size: 0.72 * 100rpx;
  324. text-align: center;
  325. line-height: 1.16 * 100rpx;
  326. margin-right: 0.19 * 100rpx;
  327. background-image: url('../../static/redBg.png');
  328. }
  329. .sign .wrapper2 .list2 .data {
  330. font-size: 0.3 * 100rpx;
  331. color: #232323;
  332. }
  333. .sign .wrapper2 .tip2 {
  334. font-size: 0.3 * 100rpx;
  335. color: #999999;
  336. padding: 0 0.55 * 100rpx;
  337. text-align: center;
  338. line-height: 1.5;
  339. }
  340. .sign .list3 {
  341. margin: 0.45 * 100rpx 0.37 * 100rpx 0 0.37 * 100rpx;
  342. border-top: 1px dashed #eee;
  343. }
  344. .sign .list3 .item {
  345. border-bottom: 1px solid #eee;
  346. height: 1.3 * 100rpx;
  347. }
  348. .sign .list3 .item .name {
  349. color: #232323;
  350. font-size: 0.3 * 100rpx;
  351. width: 4 * 100rpx;
  352. }
  353. .sign .list3 .item .data {
  354. font-size: 0.24 * 100rpx;
  355. color: #bbbbbb;
  356. margin-top: 0.09 * 100rpx;
  357. }
  358. .sign .list3 .item .num {
  359. font-size: 0.36 * 100rpx;
  360. font-family: 'GuildfordProBook 5';
  361. }
  362. .sign .signTip {
  363. width: 6.44 * 100rpx;
  364. height: 6.45 * 100rpx;
  365. position: fixed;
  366. top: 50%;
  367. left: 50%;
  368. margin-left: -3.22 * 100rpx;
  369. margin-top: -3.225 * 100rpx;
  370. z-index: 99;
  371. text-align: center;
  372. transition: all 0.3s ease-in-out 0s;
  373. opacity: 0;
  374. transform: scale(0);
  375. }
  376. .sign .signTip .signTipLight {
  377. background-repeat: no-repeat;
  378. background-size: 100% 100%;
  379. width: 100%;
  380. height: 100%;
  381. }
  382. .sign .signTip.on {
  383. opacity: 1;
  384. transform: scale(1);
  385. }
  386. .sign .signTip .signTipCon {
  387. background-image: url('https://wx.yixiang.co/static/images/register.png');
  388. background-repeat: no-repeat;
  389. background-size: 100% 100%;
  390. width: 4.2 * 100rpx;
  391. height: 4.2 * 100rpx;
  392. margin-top: -7 * 100rpx;
  393. position: relative;
  394. }
  395. .sign .signTip .signTipCon .state {
  396. font-size: 0.34 * 100rpx;
  397. color: #fff;
  398. margin-top: 1.5 * 100rpx;
  399. }
  400. .sign .signTip .signTipCon .integral {
  401. font-size: 0.3 * 100rpx;
  402. color: rgba(255, 255, 255, 0.6);
  403. margin-top: 0.09 * 100rpx;
  404. }
  405. .sign .signTip .signTipCon .signTipBnt {
  406. font-size: 0.3 * 100rpx;
  407. color: #eb4331;
  408. width: 2.6 * 100rpx;
  409. height: 0.76 * 100rpx;
  410. background-color: #f8d168;
  411. border-radius: 0.38 * 100rpx;
  412. line-height: 0.76 * 100rpx;
  413. margin: 0.48 * 100rpx auto 0 auto;
  414. }
  415. /*签到记录、账单明细列表*/
  416. .sign-record .list .item .data {
  417. height: 0.8 * 100rpx;
  418. line-height: 0.8 * 100rpx;
  419. padding: 0 0.3 * 100rpx;
  420. font-size: 0.24 * 100rpx;
  421. color: #666;
  422. }
  423. .sign-record .list .item .listn {
  424. background-color: #fff;
  425. font-size: 0.24 * 100rpx;
  426. color: #999;
  427. }
  428. .sign-record .list .item .listn .itemn {
  429. height: 1.2 * 100rpx;
  430. border-bottom: 1px solid #eee;
  431. padding-right: 0.3 * 100rpx;
  432. margin-left: 0.3 * 100rpx;
  433. }
  434. .sign-record .list .item .listn .itemn .name {
  435. width: 3.9 * 100rpx;
  436. font-size: 0.28 * 100rpx;
  437. color: #282828;
  438. margin-bottom: 0.06 * 100rpx;
  439. }
  440. .sign-record .list .item .listn .itemn .num {
  441. font-size: 0.36 * 100rpx;
  442. font-family: 'GuildfordProBook 5';
  443. color: #16ac57;
  444. }
  445. .bg-color-red {
  446. background-color: #eb3729 !important;
  447. }
  448. .bg-color-green {
  449. background-color: #75be1d !important;
  450. }
  451. .acea-row {
  452. display: flex;
  453. flex-wrap: wrap /* 辅助类 */;
  454. }
  455. .acea-row.row-center-wrapper{
  456. align-items: center;
  457. justify-content: center;
  458. }
  459. .acea-row.row-between-wrapper {
  460. align-items: center;
  461. justify-content: space-between;
  462. }
  463. .acea-row.row-middle {
  464. align-items: center;
  465. }
  466. .acea-row.row-center {
  467. justify-content: center;
  468. }
  469. .font-color-red {
  470. color: #eb3729!important;
  471. }
  472. </style>