integral.vue 12 KB

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