getIntegrate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <!-- 每日签到 -->
  3. <view>
  4. <view style="background-color: $color-white !important;">
  5. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
  6. :background="background" title-width="300" :title="i18n('getEveryDay')"></u-navbar>
  7. </view>
  8. <view class="content">
  9. <view class="top-pic">
  10. <view class="pic-text">
  11. <view class="big-text">{{$i18n.locale=='zh'?'立即签到':'Sign in immediately'}}</view>
  12. <view class="little-text">
  13. {{$i18n.locale=='zh'?'连续签到,奖励更丰富!':'Continuous check-in, more rich reward!'}}
  14. </view>
  15. </view>
  16. </view>
  17. <view class="body-day" v-if="flag==1">
  18. <view class="get-every">
  19. <view :class="index.charAt(index.length - 1)<=GetLength.length?'getDay1':'getDay'"
  20. v-for=" (item,index) in getSignIn" :key="index" @tap="getDailyIntetral(index)">
  21. <view :class="index.charAt(index.length - 1)<=GetLength.length?'dayImg1':'dayImg'">
  22. <view :class="index.charAt(index.length - 1)<=GetLength.length?'dayNum1':'dayNum'">
  23. {{$i18n.locale=='zh'?'第':'Day'}}{{index.charAt(index.length - 1)}}{{$i18n.locale=='zh'?'天':''}}
  24. </view>
  25. <image src="@/static/user-gave.png" class="img-pic" />
  26. <view :class="index.charAt(index.length - 1)<=GetLength.length?'imgText1':'imgText'">
  27. {{item}}{{$i18n.locale=='zh'?'积分':'Intetral'}}
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <u-button class="ntegrate-history" type="custom" shape="circle">
  33. {{$i18n.locale=='zh'?'积分签到获取历史':'Integral sign-in to obtain history'}}
  34. </u-button>
  35. </view>
  36. <view class="body-day" v-if="flag!=1">
  37. <view class="get-every">
  38. <view :class="index.charAt(index.length - 1)<=GetLength.length?'getDay1':'getDay'"
  39. v-for=" (item,index) in getSignIn" :key="index" @tap="getDailyIntetral(index)">
  40. <view :class="index.charAt(index.length - 1)<=GetLength.length?'dayImg1':'dayImg'">
  41. <view :class="index.charAt(index.length - 1)<=GetLength.length?'dayNum1':'dayNum'">
  42. {{$i18n.locale=='zh'?'第':'Day'}}{{index.charAt(index.length - 1)}}{{$i18n.locale=='zh'?'天':''}}
  43. </view>
  44. <image src="@/static/user-gave.png" class="img-pic" />
  45. <view :class="index.charAt(index.length - 1)<=GetLength.length?'imgText1':'imgText'">
  46. {{item}}{{$i18n.locale=='zh'?'积分':'Intetral'}}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <u-button class="ntegrate-history" type="custom" shape="circle">
  52. {{$i18n.locale=='zh'?'积分签到获取历史':'Integral sign-in to obtain history'}}
  53. </u-button>
  54. </view>
  55. <view class="kong-ui"></view>
  56. <view class="title">
  57. <view class="title-list">{{$i18n.locale=='zh'?'日期':'Date'}}</view>
  58. <view class="title-list">{{$i18n.locale=='zh'?'分数':'Score'}}</view>
  59. <view class="title-list">{{$i18n.locale=='zh'?'备注':'Remark'}}</view>
  60. </view>
  61. <view v-if="flag==1" class="detail-list" v-for="(getList,index) in getInfo" :key="index">
  62. <view class="list-time get-details">{{getList.updateDate|time('YYYY-MM-DD')}}</view>
  63. <view class="list-integrate get-details">+{{getList.point}}</view>
  64. <view class="list-info get-details">{{$i18n.locale=='zh'?getList.title:getList.titleEn}}</view>
  65. </view>
  66. <view v-if="flag!=1" class="detail-list" v-for="(getList,index) in getInfo" :key="index">
  67. <view class="list-time get-details">{{getList.updateDate|time('YYYY-MM-DD')}}</view>
  68. <view class="list-integrate get-details">+{{getList.point}}</view>
  69. <view class="list-info get-details">{{$i18n.locale=='zh'?getList.title:getList.titleEn}}</view>
  70. </view>
  71. <uni-load-more :status="status" v-show="this.total>10"></uni-load-more>
  72. </view>
  73. <uni-popup ref="message">
  74. <uni-popup-message style="border-radius: 10px;" :type="msgType" :message="messageText" :duration="1000">
  75. </uni-popup-message>
  76. </uni-popup>
  77. </view>
  78. </template>
  79. <script>
  80. import moment from "moment";
  81. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  82. import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
  83. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  84. import {
  85. addSignPointDetail
  86. } from '@/api/address'
  87. export default {
  88. components: {
  89. uniPopupDialog,
  90. uniPopupMessage,
  91. uniPopup
  92. },
  93. data() {
  94. return {
  95. flag: '1',
  96. background: {
  97. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  98. },
  99. backStyle: {
  100. color: '#FFFFFF',
  101. },
  102. // getBtnEd: true,
  103. getInfo: {},
  104. getSignIn: {},
  105. GetLength: {},
  106. msgType: 'success',
  107. messageText: `请稍后...`,
  108. pageSize: "10",
  109. pageNo: "1",
  110. total: null,
  111. status: 'more',
  112. index: '',
  113. };
  114. },
  115. onShow() {
  116. this.findBasicInfo();
  117. this.getEveryDays();
  118. console.log(this.flag, '判断');
  119. },
  120. onReachBottom() {
  121. let allTotal = this.pageNo * this.pageSize
  122. if (allTotal < this.total) {
  123. console.log(this.total);
  124. //当前条数小于总条数 则增加请求页数
  125. this.status = 'loading';
  126. this.pageSize++;
  127. this.getIntegrate() //调用加载数据方法
  128. } else {
  129. this.status = 'noMore';
  130. // console.log('已加载全部数据')
  131. }
  132. },
  133. onPullDownRefresh() {
  134. //调用获取数据方法
  135. this.getIntegrate()
  136. setTimeout(() => {
  137. uni.stopPullDownRefresh();
  138. }, 1000);
  139. },
  140. filters: {
  141. twoDecimal(value) {
  142. return parseFloat(string(value)).toFixed(2);
  143. },
  144. time(data, type) {
  145. return moment(data).format(type);
  146. }
  147. },
  148. methods: {
  149. i18n(data) {
  150. return this.$t('common.' + data);
  151. },
  152. change(e) {
  153. console.log('当前模式:' + e.type + ',状态:' + e.show);
  154. },
  155. async getDailyIntetral(index) {
  156. console.log(this.GetLength);
  157. //用户第一次签到
  158. if (this.GetLength.length === 0) {
  159. const tokendata = await this.$myRequest({
  160. url: '/sys/token',
  161. method: 'get'
  162. });
  163. addSignPointDetail({
  164. taskDict: "point_task_sign",
  165. point: this.getSignIn[`day${this.GetLength.length+1}`],
  166. },
  167. tokendata.data
  168. ).then(() => {
  169. this.$refs.message.open()
  170. if (this.$i18n.locale == 'zh') {
  171. this.messageText = `签到成功`
  172. this.findBasicInfo();
  173. this.getEveryDays();
  174. this.flag += '1'
  175. return this.flag
  176. } else {
  177. this.messageText = `Sign in successfully`
  178. this.findBasicInfo();
  179. this.getEveryDays();
  180. this.flag += '1'
  181. return this.flag
  182. }
  183. })
  184. }
  185. //用户非第一次签到
  186. else {
  187. let todayDate = moment(new Date()).format("YYYY-MM-DD");
  188. var length = this.GetLength.length;
  189. var data = parseInt(length - 1);
  190. let lastSingIn = moment(
  191. this.GetLength[data].updateDate
  192. ).format("YYYY-MM-DD");
  193. console.log(todayDate);
  194. console.log(lastSingIn);
  195. if (todayDate != lastSingIn) {
  196. const tokendata = await this.$myRequest({
  197. url: '/sys/token',
  198. method: 'get'
  199. });
  200. addSignPointDetail({
  201. taskDict: "point_task_sign",
  202. point: this.getSignIn[`day${this.GetLength.length+1}`],
  203. },
  204. tokendata.data
  205. ).then(() => {
  206. this.$refs.message.open()
  207. if (this.$i18n.locale == 'zh') {
  208. this.messageText = `签到成功!`
  209. this.findBasicInfo();
  210. this.getEveryDays();
  211. this.flag += '1'
  212. return this.flag
  213. } else {
  214. this.messageText = `Sign in successfully`
  215. this.findBasicInfo();
  216. this.getEveryDays();
  217. this.flag += '1'
  218. return this.flag
  219. }
  220. });
  221. } else {
  222. this.$refs.message.open()
  223. if (this.$i18n.locale == 'zh') {
  224. this.messageText = `今天已签到!`
  225. this.findBasicInfo();
  226. this.getEveryDays();
  227. this.flag += '1'
  228. return this.flag
  229. } else {
  230. this.messageText = `Have signed in today`
  231. this.findBasicInfo();
  232. this.getEveryDays();
  233. this.flag += '1'
  234. return this.flag
  235. }
  236. }
  237. }
  238. },
  239. async findBasicInfo() {
  240. const result = await this.$myRequest({
  241. url: '/uc/userCenter/findBasicInfo',
  242. data: {},
  243. });
  244. this.form = result.data;
  245. this.getIntegrate();
  246. },
  247. async getIntegrate() {
  248. const res = await this.$myRequest({
  249. url: '/uc/umsUserPointDetailss/getUserPointDetailsPage',
  250. data: {
  251. "pageSize": this.pageSize,
  252. "pageNo": this.pageNo,
  253. "taskDict": "point_task_sign"
  254. }
  255. });
  256. // console.log(res);
  257. this.getInfo = res.data.umsUserPointDetailss
  258. this.total = res.data.page.totalCount
  259. },
  260. async getEveryDays() {
  261. const res = await this.$myRequest({
  262. url: '/uc/umsUserTasks/getUserTaskComplete',
  263. data: {
  264. }
  265. });
  266. // console.log(res, '===========');
  267. this.GetLength = res.data.sign ? res.data.sign : [],
  268. console.log(this.GetLength, res.data.sign, '大数据');
  269. this.getSignIn = res.data.signTask.taskPoint
  270. },
  271. }
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. .content {
  276. // background-color: #4592FE;
  277. .top-pic {
  278. height: 400rpx;
  279. background-image: url('@/static/bgc-blue.jpg');
  280. background-size: 100% 400rpx;
  281. .pic-text {
  282. width: 64%;
  283. height: 64%;
  284. background: rgba(255, 255, 255, 0.3);
  285. margin-left: 50%;
  286. border: 1rpx solid #fff;
  287. transform: translateX(-50%) translateY(28%);
  288. .big-text {
  289. font-size: 38rpx;
  290. font-weight: 700;
  291. color: #fff;
  292. text-align: center;
  293. transform: translateY(46%);
  294. }
  295. .little-text {
  296. font-size: 28rpx;
  297. text-align: center;
  298. color: #fff;
  299. transform: translateY(110%);
  300. }
  301. }
  302. }
  303. .sign-in {
  304. height: 60rpx;
  305. line-height: 60rpx;
  306. background-color: #73d502ff;
  307. width: 150rpx;
  308. text-align: center;
  309. font-size: 30rpx;
  310. font-weight: 700;
  311. border-radius: 50rpx;
  312. margin-left: 75%;
  313. }
  314. .body-day {
  315. background-color: #fff;
  316. .get-every {
  317. width: 96%;
  318. margin-left: 2%;
  319. height: 360rpx;
  320. display: flex;
  321. flex-flow: wrap;
  322. justify-content: space-evenly;
  323. .getDay {
  324. width: 24%;
  325. height: 150rpx;
  326. border-radius: 20rpx;
  327. text-align: center;
  328. border: 1rpx solid #e566934d;
  329. background-color: #fef8ea;
  330. .dayImg {
  331. transform: translateY(-10rpx);
  332. .dayNum {
  333. border: 1rpx solid skyblue;
  334. border-radius: 50rpx;
  335. width: 100rpx;
  336. margin-left: 50%;
  337. transform: translateX(-50%);
  338. height: 45rpx;
  339. line-height: 45rpx;
  340. background-color: #fbb086ff;
  341. color: #fff;
  342. }
  343. .imgText {
  344. transform: translateY(-10rpx);
  345. font-size: 28rpx;
  346. color: #fbb086ff;
  347. }
  348. .img-pic {
  349. width: 70rpx;
  350. height: 70rpx;
  351. }
  352. }
  353. }
  354. .getDay:last-child {
  355. width: 49%;
  356. }
  357. .getDay1 {
  358. width: 24%;
  359. height: 150rpx;
  360. border-radius: 20rpx;
  361. text-align: center;
  362. border: 1rpx solid #00ff004d;
  363. background-color: #ccf6df;
  364. .dayImg1 {
  365. transform: translateY(-10rpx);
  366. .img-pic {
  367. width: 70rpx;
  368. height: 70rpx;
  369. }
  370. .dayNum1 {
  371. border: 1rpx solid skyblue;
  372. border-radius: 50rpx;
  373. width: 100rpx;
  374. margin-left: 50%;
  375. transform: translateX(-50%);
  376. height: 45rpx;
  377. line-height: 45rpx;
  378. background-color: #76d509ff;
  379. color: #fff;
  380. }
  381. .imgText1 {
  382. transform: translateY(-10rpx);
  383. font-size: 28rpx;
  384. color: #76d509ff;
  385. }
  386. }
  387. }
  388. .getDay1:last-child {
  389. width: 49%;
  390. }
  391. }
  392. .ntegrate-history {
  393. width: 60%;
  394. height: 80rpx;
  395. line-height: 80rpx;
  396. font-size: 30rpx;
  397. background-color: #4592fe;
  398. color: #fff;
  399. margin-top: 10rpx;
  400. }
  401. }
  402. .kong-ui {
  403. height: 35rpx;
  404. background-color: #ffffff;
  405. }
  406. .title {
  407. height: 60rpx;
  408. display: flex;
  409. justify-content: space-evenly;
  410. .title-list {
  411. width: 33%;
  412. line-height: 60rpx;
  413. text-align: center;
  414. }
  415. }
  416. .detail-list {
  417. display: flex;
  418. justify-content: space-evenly;
  419. height: 80rpx;
  420. background-color: #fff;
  421. .get-details {
  422. line-height: 80rpx;
  423. width: 33%;
  424. text-align: center;
  425. font-size: 28rpx;
  426. }
  427. .list-integrate {
  428. font-size: 32rpx;
  429. color: #E02020FF;
  430. font-weight: 700;
  431. }
  432. }
  433. }
  434. </style>