integral.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <view>
  3. <view class="top-cont">
  4. <!-- 背景图片 -->
  5. <image class="bg"
  6. src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/ed4a8ff0406747a68e40988b210d1c78.png"
  7. mode=""></image>
  8. <view class="top-inner">
  9. <!-- 这里是状态栏 -->
  10. <view class="fixed-top-box" :style="{ background: bg }">
  11. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  12. <view class="back-box" @click="back">
  13. <text class="title">我的积分</text>
  14. <text></text>
  15. </view>
  16. </view>
  17. <!-- 顶部固定后站位元素 -->
  18. <view style="padding-bottom: 88upx;">
  19. <view :style="{height: statusBarHeight}"></view>
  20. </view>
  21. <!-- 可用积分 -->
  22. <view class="available-points">
  23. <text class="label">可用积分</text>
  24. <text class="num">{{integral}}</text>
  25. </view>
  26. <!-- 签到 -->
  27. <!-- <view class="singn-content">
  28. <view class="sign-in-box">
  29. <view class="inner">
  30. <view class="title-box">已连续签到<text class="num">{{totalDays}}</text>天</view>
  31. <view class="sign-list">
  32. <view v-for="(item,index) in records" :key="index"
  33. :class="totalDays >= index+ 1?'item active':'item'">
  34. <view class="line"></view>
  35. <view class="right">
  36. <image v-if="totalDays >= index+ 1"
  37. src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/f3bdd5d388854e9a8f365904840c3b32.png"
  38. mode=""></image>
  39. <image v-else
  40. src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/c593e551e4b246b981aaa58deb1fe725.png"
  41. mode=""></image>
  42. <text class="text">第{{ item.continuousDays}}天</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="sign-btn-box">
  48. <view class="btn" v-if="isDaySign==false" @click="doSign()">
  49. <image
  50. src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/295aa046433d4feb95b467c83f8b4096.png"
  51. mode=""></image>
  52. <text class="text">签到</text>
  53. </view>
  54. <view class="btn" v-else>
  55. <image
  56. src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/295aa046433d4feb95b467c83f8b4096.png"
  57. mode=""></image>
  58. <text class="text">签到</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view> -->
  63. <view class="content">
  64. <!-- 积分列表 -->
  65. <view class="points-cont">
  66. <!-- tab切换 -->
  67. <!-- <view class="pub-tab-box">
  68. <view class="tab-inner">
  69. <view
  70. v-for="(item,index) in tags"
  71. :key="index"
  72. :class="tabIndex == item.value?'item active':'item'"
  73. @click="tabChange(item)">
  74. <view class="text">
  75. {{ item.lable }}
  76. <image v-show="tabIndex == item.value" class="tab-bg" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/1828ea6b3b124b5f84e3556267a8d9ef.png" mode=""></image>
  77. </view>
  78. </view>
  79. </view>
  80. </view> -->
  81. <!-- 列表 -->
  82. <view class="point-list">
  83. <view v-for="(item,index) in list" :key="index" class="item">
  84. <view class="left">
  85. <text class="title">
  86. <!-- {{item.logTypeName}} -->
  87. 直播间完课积分
  88. </text>
  89. <view class="time">{{item.createTime}}</view>
  90. </view>
  91. <view class="right">
  92. <text v-if="item.integral<0" class="less">{{item.integral}}</text>
  93. <text v-else class="add">+{{item.pointsAwarded}}</text>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. getUserIntegralInfo
  106. } from '@/api/living.js' // 积分
  107. import {
  108. completionRecords,
  109. completionInfo,doSign
  110. } from '@/api/integral.js'
  111. // import {getDictByKey} from '@/api/common.js'
  112. // import {getUserSign,getUserIntegralLogsList,doSign} from '@/api/integral';
  113. // import {
  114. // doSign
  115. // } from '@/api/integral';
  116. export default {
  117. comments() {
  118. Loading
  119. },
  120. data() {
  121. return {
  122. totalDays: null,
  123. records: null,
  124. liveId: 712,
  125. signNum: 0,
  126. typeOptions: [],
  127. top: 0,
  128. integral: 0,
  129. sign: [],
  130. // 状态栏的高度
  131. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  132. // tab切换
  133. // {lable:'获得',value:1},{lable:'消耗',value:2}
  134. // tags: [{lable:'最近十条',value:0},],
  135. // 选中的tab
  136. tabIndex: 0,
  137. current: 0,
  138. page: {
  139. type: 0,
  140. page: 1,
  141. pageSize: 10
  142. },
  143. list: [],
  144. loaded: false,
  145. loading: false
  146. };
  147. },
  148. onLoad(option) {
  149. if (option.liveId) {
  150. this.liveId = option.liveId
  151. }
  152. console.log("进入积分页面了")
  153. // this.getUserIntegralInfo()
  154. this.completionRecords()
  155. this.completionInfo()
  156. },
  157. computed: {
  158. // 计算属性的 getter
  159. bg: function() {
  160. return 'rgba(255,142,60, ' + this.top / 30 + ')';
  161. },
  162. },
  163. methods: {
  164. // 查询用户积分领取记录
  165. completionRecords() {
  166. if (!this.liveId) return;
  167. const data = {
  168. liveId: this.liveId
  169. }
  170. completionRecords(data).then((res) => {
  171. if (res.code == 200) {
  172. this.list = res.data
  173. console.log("查询用户积分领取记录", res)
  174. }
  175. }).catch((error) => {
  176. });
  177. },
  178. //查询用户积分余额和看直播信息统计
  179. completionInfo() {
  180. if (!this.liveId) return;
  181. const data = {
  182. liveId: this.liveId
  183. }
  184. completionInfo(data).then((res) => {
  185. if (res.code == 200) {
  186. this.integral = res.data.integral
  187. this.records = res.data.records
  188. this.totalDays = res.data.totalDays
  189. console.log("查询用户积分余额和看直播信息统计", res)
  190. }
  191. }).catch((error) => {
  192. });
  193. },
  194. doSign() {
  195. var data = {};
  196. // uni.showLoading({
  197. // title:"正在加载中..."
  198. // })
  199. doSign(data).then(
  200. res => {
  201. // uni.hideLoading()
  202. if (res.code == 200) {
  203. uni.showToast({
  204. icon: 'success',
  205. title: res.msg,
  206. });
  207. this.list = [];
  208. this.page.page = 1;
  209. this.list = [];
  210. this.loaded = false;
  211. this.loading = false;
  212. this.getUserIntegralLogsList();
  213. this.getUserSign();
  214. } else {
  215. uni.showToast({
  216. icon: 'none',
  217. title: res.msg,
  218. });
  219. }
  220. },
  221. rej => {}
  222. );
  223. },
  224. getUserSign() {
  225. getUserSign().then(
  226. res => {
  227. if (res.code == 200) {
  228. this.data = res.member;
  229. this.signNum = res.signNum;
  230. this.isDaySign = res.isDaySign;
  231. this.integral = res.integral;
  232. this.sign = JSON.parse(res.sign);
  233. } else {
  234. uni.showToast({
  235. icon: 'none',
  236. title: "请求失败",
  237. });
  238. }
  239. },
  240. rej => {}
  241. );
  242. },
  243. // 积分
  244. getUserIntegralInfo() {
  245. uni.showLoading({
  246. title: "正在加载中..."
  247. })
  248. getUserIntegralInfo().then(res => {
  249. uni.hideLoading()
  250. if (res.code == 200) {
  251. console.log("积分>>", res)
  252. // 处理列表数据,将"积分"替换为"积分"
  253. this.list = res.data.logs.map(item => {
  254. return {
  255. ...item,
  256. logTypeName: item.logTypeName ? item.logTypeName.replace(/积分/g, '积分') :
  257. item.logTypeName
  258. }
  259. })
  260. this.integral = res.data.integral
  261. }
  262. }).catch(error => {
  263. console.error("获取积分数据失败:", error);
  264. });
  265. },
  266. getDictByKey(key) {
  267. var data = {
  268. key: key
  269. }
  270. getDictByKey(data).then(
  271. res => {
  272. if (res.code == 200) {
  273. this.typeOptions = res.data;
  274. }
  275. },
  276. err => {}
  277. );
  278. },
  279. getUserIntegralLogsList() {
  280. let that = this;
  281. if (that.loaded == true || that.loading == true) return;
  282. that.loading = true;
  283. uni.showLoading({
  284. title: "加载中..."
  285. })
  286. getUserIntegralLogsList(that.page).then(
  287. res => {
  288. that.loading = false;
  289. that.loaded = res.data.list.length < that.page.pageSize;
  290. that.page.page = that.page.page + 1;
  291. that.list.push.apply(that.list, res.data.list);
  292. uni.hideLoading()
  293. },
  294. err => {
  295. uni.hideLoading()
  296. uni.showToast({
  297. title: err.msg,
  298. icon: 'none',
  299. duration: 2000
  300. });
  301. }
  302. );
  303. },
  304. // 返回上一页
  305. back() {
  306. uni.navigateBack()
  307. },
  308. // tab选择
  309. // tabChange(item) {
  310. // console.log(item)
  311. // this.tabIndex = item.value
  312. // this.page.type=this.tabIndex;
  313. // this.page.page=1;
  314. // this.list=[];
  315. // this.loaded=false;
  316. // this.loading=false;
  317. // this.getUserIntegralLogsList();
  318. // }
  319. }
  320. }
  321. </script>
  322. <style lang="scss">
  323. .fixed-top-box {
  324. width: 100%;
  325. position: fixed;
  326. top: 0;
  327. left: 0;
  328. z-index: 1000;
  329. transition: all 0.5s;
  330. }
  331. .top-cont {
  332. width: 100%;
  333. height: 654upx;
  334. position: relative;
  335. .bg {
  336. width: 100%;
  337. height: 100%;
  338. position: absolute;
  339. top: 0;
  340. left: 0;
  341. z-index: 1;
  342. }
  343. .top-inner {
  344. width: 100%;
  345. height: 100%;
  346. position: absolute;
  347. top: 0;
  348. left: 0;
  349. z-index: 2;
  350. .back-box {
  351. height: 88upx;
  352. padding-left: 22upx;
  353. display: flex;
  354. align-items: center;
  355. justify-content: space-between;
  356. padding: 0 20upx;
  357. image {
  358. width: 40upx;
  359. height: 40upx;
  360. }
  361. .title {
  362. font-size: 36upx;
  363. font-family: PingFang SC;
  364. font-weight: 500;
  365. color: #FFFFFF;
  366. }
  367. }
  368. .available-points {
  369. margin-top: 140upx;
  370. display: flex;
  371. flex-direction: column;
  372. align-items: center;
  373. justify-content: center;
  374. .label {
  375. font-size: 30upx;
  376. font-family: PingFang SC;
  377. font-weight: bold;
  378. color: #FFFFFF;
  379. line-height: 1;
  380. }
  381. .num {
  382. font-size: 80upx;
  383. font-family: Gilroy;
  384. font-weight: 500;
  385. color: #FFFFFF;
  386. line-height: 1;
  387. margin-top: 28upx;
  388. }
  389. }
  390. .singn-content {
  391. padding: 0 20upx;
  392. margin-top: 50upx;
  393. }
  394. .sign-in-box {
  395. height: 380upx;
  396. background: #FFFFFF;
  397. border-radius: 16upx;
  398. .inner {
  399. padding: 40upx 30upx;
  400. .title-box {
  401. font-size: 26upx;
  402. font-family: PingFang SC;
  403. font-weight: 500;
  404. color: #666666;
  405. line-height: 1;
  406. .num {
  407. font-size: 32upx;
  408. font-family: PingFang SC;
  409. font-weight: Bold;
  410. color: #FF7511;
  411. margin: 0 10upx;
  412. line-height: 1;
  413. }
  414. }
  415. .sign-list {
  416. display: flex;
  417. align-items: center;
  418. justify-content: space-between;
  419. margin-top: 40upx;
  420. .item {
  421. display: flex;
  422. justify-content: center;
  423. .right {
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. justify-content: center;
  428. image {
  429. width: 44upx;
  430. height: 44upx;
  431. margin-bottom: 20upx;
  432. }
  433. .text {
  434. font-size: 24upx;
  435. font-family: PingFang SC;
  436. font-weight: 500;
  437. color: #FF7511;
  438. line-height: 1;
  439. white-space: nowrap;
  440. }
  441. }
  442. .line {
  443. width: 34upx;
  444. height: 4upx;
  445. background: #F6CDA7;
  446. border-radius: 2upx;
  447. margin-top: 22upx;
  448. }
  449. &:first-child {
  450. .line {
  451. display: none;
  452. }
  453. }
  454. &.active {
  455. .line {
  456. background: #FF8E3C;
  457. }
  458. }
  459. }
  460. }
  461. }
  462. .sign-btn-box {
  463. padding: 0 14upx;
  464. .btn {
  465. width: 100%;
  466. height: 88upx;
  467. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  468. background-color: #FF7511;
  469. border-radius: 44rpx;
  470. display: flex;
  471. justify-content: center;
  472. align-items: center;
  473. image {
  474. width: 32upx;
  475. height: 32upx;
  476. }
  477. .text {
  478. font-size: 30upx;
  479. font-family: PingFang SC;
  480. font-weight: bold;
  481. color: #FFFFFF;
  482. line-height: 1;
  483. }
  484. }
  485. }
  486. }
  487. }
  488. }
  489. .content {
  490. margin-top: 20upx;
  491. padding: 0 20upx 40upx;
  492. .points-cont {
  493. background-color: #FFFFFF;
  494. border-radius: 16upx;
  495. .pub-tab-box {
  496. padding: 0 80upx;
  497. .tab-inner {
  498. height: 88upx;
  499. line-height: 88upx;
  500. display: flex;
  501. align-items: center;
  502. justify-content: space-between;
  503. }
  504. .item {
  505. font-size: 28upx;
  506. white-space: nowrap;
  507. line-height: 1;
  508. font-family: PingFang SC;
  509. font-weight: 500;
  510. color: #666666;
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. &.active {
  515. font-weight: bold;
  516. color: #333333;
  517. }
  518. .text {
  519. position: relative;
  520. z-index: 1;
  521. }
  522. .tab-bg {
  523. width: 72upx;
  524. height: 28upx;
  525. position: absolute;
  526. top: 17upx;
  527. left: 50%;
  528. transform: translateX(-36upx);
  529. z-index: -1;
  530. }
  531. }
  532. }
  533. .point-list {
  534. padding: 0 30upx;
  535. .item {
  536. padding: 30upx 0;
  537. display: flex;
  538. align-items: center;
  539. justify-content: space-between;
  540. border-bottom: 1px solid #F0F0F0;
  541. &:last-child {
  542. border-bottom: none;
  543. }
  544. .left {
  545. .title {
  546. font-size: 28upx;
  547. font-family: PingFang SC;
  548. font-weight: 500;
  549. color: #111111;
  550. line-height: 1;
  551. }
  552. .time {
  553. font-size: 24upx;
  554. font-family: PingFang SC;
  555. font-weight: 500;
  556. color: #999999;
  557. line-height: 1;
  558. margin-top: 22upx;
  559. }
  560. }
  561. .right {
  562. .add {
  563. font-size: 28upx;
  564. font-family: PingFang SC;
  565. font-weight: 500;
  566. color: #111111;
  567. }
  568. .less {
  569. font-size: 28upx;
  570. font-family: PingFang SC;
  571. font-weight: 500;
  572. color: #F56C6C;
  573. }
  574. }
  575. }
  576. }
  577. }
  578. }
  579. </style>