points.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. <template>
  2. <view class="content">
  3. <view class="cont-box">
  4. <u-sticky offsetTop="0" customNavHeight="0">
  5. <image class="home_top_bg" src="@/static/images/integral/coin_points_mall_top_bg_blue.png"
  6. mode="widthFix"></image>
  7. <view class="top-box" :style="{ paddingTop: paddingTop + 'px' }">
  8. <view class="top-title">
  9. <image class="title-img" src="/static/images/integral/fanghua_coin_mall_title.png"></image>
  10. </view>
  11. <!-- <view class="my-integral">
  12. <view class="left">
  13. <view class="x-ac">
  14. <view class="label">我的健康币</view>
  15. <view class="x-ac" style="margin-left: 20rpx;" @click="goCart()">
  16. <u-icon name="shopping-cart" color="#fff" size="28"></u-icon>
  17. <view class="label">购物车</view>
  18. </view>
  19. </view>
  20. <view style="display: flex;align-items: baseline;">
  21. <view class="integral">{{integral}}</view>
  22. <view class="integralbtn" @click="goIntegral">获取健康币</view>
  23. </view>
  24. </view>
  25. <view class="btn-box">
  26. <view class="btn" @click="navTo('/pages/user/integral/integralLogsList')">获得记录</view>
  27. <view class="btn" @click="navTo('/pages/user/integral/integralOrderList')">健康币订单</view>
  28. </view>
  29. </view> -->
  30. <view class="inner-box">
  31. <view class="topbox">
  32. <view class="left">
  33. <view class="align-center">
  34. <image class="points-icon" src="@/static/images/integral/my_points_icon.png"
  35. mode=""></image>
  36. <text class="points-title">我的健康币</text>
  37. </view>
  38. <view class="num">{{ integral }}</view>
  39. </view>
  40. <view class="guize" @click="goIntegral">获取健康币</view>
  41. </view>
  42. <view class="bottom-box">
  43. <view class="ttbg"></view>
  44. <view class="x-bc" style="height: 100rpx;">
  45. <view class="t-left" @click="navTo('/pages/user/integral/integralLogsList')">
  46. <image src="@/static/images/integral/points_details_icon_blue.png" mode=""></image>
  47. <view>获得记录</view>
  48. </view>
  49. <view class="t-right" @click="navTo('/pages/user/integral/integralOrderList')">
  50. <image src="@/static/images/integral/exchange_records_icon_blue.png" mode="">
  51. </image>
  52. <view>健康币订单</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 搜索 -->
  58. <view class="search-box">
  59. <uni-search-bar class="search" bgColor="#FFFFFF" radius="34" v-model="keyword"
  60. placeholder="搜索商品" clearButton="auto" cancelButton="none" @confirm="search"
  61. @clear="handleClear">
  62. <template v-slot:searchIcon>
  63. <image src="@/static/image/hall/search_gray_icon.png" mode="aspectFill"></image>
  64. </template>
  65. </uni-search-bar>
  66. </view>
  67. <view class="tabs" v-if="tabs.length > 0">
  68. <u-tabs :current="tabIndex" :scrollable="true" :list="tabs" :lineWidth="40" :lineHeight="8"
  69. :lineColor="'linear-gradient(64deg, #5DADFF 0%, #FF5030100%)'"
  70. :activeStyle="{ fontSize: '32rpx', fontWeight: 'bold', color: '#222222' }"
  71. @change="tabChange">
  72. </u-tabs>
  73. </view>
  74. </view>
  75. </u-sticky>
  76. <mescroll-body bottom="0" :top="top2 + 'px'" ref="mescrollRef" @init="mescrollInit" @down="downCallback"
  77. @up="upCallback" :down="downOption" :up="upOption">
  78. <view class="integral-box">
  79. <view class="item" @click="navTo('/pages/user/integral/integralGoodsDetails?goodsId=' + item.goodsId)"
  80. v-for="(item, index) in dataList">
  81. <view class="top">
  82. <image :src="item.imgUrl"></image>
  83. </view>
  84. <view class="bottom">
  85. <view class="title ellipsis">
  86. {{ item.goodsName }}
  87. </view>
  88. <view class="price-box">
  89. <view class="count">标准价¥{{ item.otPrice.toFixed(2) }}</view>
  90. <view class="price">
  91. <image src="@/static/images/integral/my_points_icon.png" class="icon"></image><text
  92. class="bold">{{ item.integral }}</text>健康币
  93. </view>
  94. </view>
  95. <view class="exchange">兑换</view>
  96. </view>
  97. </view>
  98. </view>
  99. </mescroll-body>
  100. </view>
  101. <view class="slide-cart" @click="goCart()">
  102. <view class="cart-box">
  103. <view class="badge-box">
  104. <u-badge type="error" max="99" :value="cartNum" bgColor="#FF5030"></u-badge>
  105. </view>
  106. <image class="shop-cart" src="@/static/images/integral/orange_shopping_car_icon.png"></image>
  107. </view>
  108. <text>购物车</text>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import {
  114. getDictByKey
  115. } from '@/api/common.js'
  116. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  117. import {
  118. getIntegralGoodsList,
  119. getFsIntegralCartList
  120. } from '@/api/integral.js'
  121. import {
  122. getUserInfo
  123. } from '@/api/user'
  124. export default {
  125. mixins: [MescrollMixin],
  126. data() {
  127. return {
  128. integral: 0,
  129. type: null,
  130. typeOptions: [],
  131. tabIndex: 0,
  132. tabs: [],
  133. mescroll: null,
  134. downOption: { //下拉刷新
  135. use: true,
  136. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  137. },
  138. upOption: {
  139. onScroll: false,
  140. use: true, // 是否启用上拉加载; 默认true
  141. page: {
  142. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  143. size: 10 // 每页数据的数量,默认10
  144. },
  145. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  146. textNoMore: "已经到底了",
  147. empty: {
  148. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  149. tip: '暂无数据'
  150. }
  151. },
  152. dataList: [],
  153. keyword: "",
  154. top2: uni.upx2px(432),
  155. paddingTop: uni.getSystemInfoSync().statusBarHeight + 12,
  156. cartNum: 0
  157. }
  158. },
  159. onLoad() {
  160. this.getDictByKey("sys_integral_goods_type");
  161. },
  162. onShow() {
  163. this.getUserInfo();
  164. this.getcartNum()
  165. },
  166. onReady() {
  167. this.getTop()
  168. },
  169. methods: {
  170. goCart() {
  171. uni.navigateTo({
  172. url: '/pages/user/integral/cart'
  173. })
  174. },
  175. getcartNum() {
  176. getFsIntegralCartList().then(res => {
  177. if (res.code == 200) {
  178. this.cartNum = res.data.total || 0
  179. }
  180. })
  181. },
  182. getTop() {
  183. const query = uni.createSelectorQuery().in(this);
  184. query
  185. .select(".top-box")
  186. .boundingClientRect((data) => {
  187. if (data) {
  188. this.top2 = data.height + uni.upx2px(88)
  189. }
  190. })
  191. .exec();
  192. },
  193. handleClear() {
  194. // 清除搜索关键词后刷新列表
  195. this.keyword = '';
  196. this.mescroll.resetUpScroll()
  197. },
  198. getUserInfo() {
  199. getUserInfo().then(
  200. res => {
  201. if (res.code == 200) {
  202. if (res.user != null) {
  203. this.integral = res.user.integral;
  204. this.mescroll.resetUpScroll()
  205. }
  206. } else {
  207. uni.showToast({
  208. icon: 'none',
  209. title: "请求失败",
  210. });
  211. }
  212. },
  213. rej => { }
  214. );
  215. },
  216. navTo(url) {
  217. uni.navigateTo({
  218. url: url
  219. })
  220. },
  221. goCart() {
  222. if (this.$isLogin()) {
  223. uni.navigateTo({
  224. url: '/pages/user/integral/cart'
  225. })
  226. } else {
  227. uni.navigateTo({
  228. url: '/pages/auth/loginIndex'
  229. })
  230. }
  231. },
  232. goIntegral() {
  233. let pages = getCurrentPages();
  234. let url = pages[pages.length - 2];
  235. if (pages.length > 1 && url && url.route == 'pages/user/integral/points') {
  236. uni.navigateBack()
  237. } else {
  238. uni.navigateTo({
  239. url: '/pages/user/integral/points'
  240. })
  241. }
  242. },
  243. getDictByKey(key) {
  244. var data = {
  245. key: key
  246. }
  247. var that = this;
  248. getDictByKey(data).then(
  249. res => {
  250. if (res.code == 200) {
  251. this.typeOptions = res.data;
  252. this.typeOptions.forEach(function (item, index) {
  253. var data = {
  254. name: item.dictLabel
  255. };
  256. that.tabs.push(data);
  257. })
  258. this.tabs.unshift({
  259. name: '全部'
  260. })
  261. if (this.tabs.length > 0) {
  262. this.tabIndex = 0
  263. }
  264. }
  265. },
  266. err => { }
  267. );
  268. },
  269. tabChange(item) {
  270. this.type = item.index == 0 ? null : this.typeOptions[item.index - 1].dictValue;
  271. this.mescroll.resetUpScroll()
  272. },
  273. search() {
  274. this.mescroll.resetUpScroll()
  275. },
  276. mescrollInit(mescroll) {
  277. this.mescroll = mescroll;
  278. },
  279. /*下拉刷新的回调 */
  280. downCallback(mescroll) {
  281. mescroll.resetUpScroll()
  282. },
  283. upCallback(page) {
  284. //联网加载数据
  285. var that = this;
  286. var data = {
  287. pageNum: page.num,
  288. pageSize: page.size,
  289. keyword: this.keyword
  290. };
  291. if (this.type != null) {
  292. data.goodsType = this.type
  293. }
  294. getIntegralGoodsList(data).then(res => {
  295. if (res.code == 200) {
  296. //设置列表数据
  297. if (page.num == 1) {
  298. that.dataList = res.data.list;
  299. } else {
  300. that.dataList = that.dataList.concat(res.data.list);
  301. }
  302. that.mescroll.endBySize(res.data.list.length, res.data.total);
  303. } else {
  304. uni.showToast({
  305. icon: 'none',
  306. title: "请求失败",
  307. });
  308. that.dataList = null;
  309. that.mescroll.endErr();
  310. }
  311. });
  312. }
  313. }
  314. }
  315. </script>
  316. <style scoped lang="scss">
  317. page {
  318. height: 100%;
  319. background: #F5F7FA !important;
  320. }
  321. // .cartbox {
  322. // position: fixed;
  323. // bottom: 50rpx;
  324. // right: 20rpx;
  325. // z-index: 99;
  326. // background-color: #fff;
  327. // box-shadow: 0 2px 4px rgba(150, 150, 150, 0.6);
  328. // padding: 10rpx;
  329. // border-radius: 50%;
  330. // .box {
  331. // position: absolute;
  332. // top: -10rpx;
  333. // right: 0;
  334. // z-index: 99;
  335. // }
  336. // }
  337. .content {
  338. height: 100%;
  339. .slide-cart {
  340. position: fixed;
  341. right: 0;
  342. display: flex;
  343. flex-direction: column;
  344. justify-content: center;
  345. align-items: center;
  346. top: 70%;
  347. width: 136rpx;
  348. height: 136rpx;
  349. background: #FFFFFF;
  350. border-radius: 16rpx 16rpx 16rpx 16rpx;
  351. border: 1rpx solid #EEEEEE;
  352. font-weight: 500;
  353. font-size: 24rpx;
  354. color: #222222;
  355. .cart-box {
  356. position: relative;
  357. }
  358. .badge-box {
  359. position: absolute;
  360. top: -10rpx;
  361. right: 0rpx;
  362. z-index: 99;
  363. }
  364. .shop-cart {
  365. width: 56rpx;
  366. height: 56rpx;
  367. margin-bottom: 10rpx;
  368. }
  369. }
  370. .home_top_bg {
  371. width: 100%;
  372. height: auto;
  373. position: absolute;
  374. top: 0;
  375. left: 0;
  376. z-index: -1;
  377. }
  378. .cont-box {
  379. .top-title {
  380. text-align: center;
  381. }
  382. .top-box {
  383. box-sizing: border-box;
  384. padding: 30rpx 30rpx 0 30rpx;
  385. width: 100%;
  386. z-index: 998;
  387. //background-color: #f5f5f5;
  388. position: absolute;
  389. top: 0;
  390. left: 0;
  391. width: 100%;
  392. .top-title {
  393. width: 100%;
  394. height: 88rpx;
  395. line-height: 88rpx;
  396. .title-img {
  397. width: 200rpx;
  398. height: 40rpx;
  399. }
  400. }
  401. .my-integral {
  402. height: 200rpx;
  403. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  404. background: linear-gradient(#FF5030, #E2C99E);
  405. border-radius: 30rpx;
  406. display: flex;
  407. align-items: flex-start;
  408. justify-content: space-between;
  409. padding: 30rpx;
  410. box-sizing: border-box;
  411. .integralbtn {
  412. font-size: 30rpx;
  413. font-weight: bold;
  414. font-family: PingFang SC;
  415. color: #fff;
  416. margin-left: 16rpx;
  417. //text-decoration: underline;
  418. background-color: #F5533C;
  419. padding: 8rpx 15rpx;
  420. border-radius: 30rpx;
  421. }
  422. .btn {
  423. width: 100%;
  424. //margin-bottom: 30rpx;
  425. background-color: #fff;
  426. border-radius: 30rpx;
  427. display: flex;
  428. align-items: center;
  429. justify-content: center;
  430. padding: 10rpx 15rpx;
  431. font-size: 24upx;
  432. font-family: PingFang SC;
  433. color: #FF5030;
  434. }
  435. .left {
  436. height: 100%;
  437. display: flex;
  438. flex-direction: column;
  439. align-items: flex-start;
  440. justify-content: space-around;
  441. .label {
  442. font-size: 28upx;
  443. font-family: PingFang SC;
  444. color: #fff;
  445. }
  446. .integral {
  447. font-weight: bold;
  448. font-size: 40upx;
  449. font-family: PingFang SC;
  450. color: #fff;
  451. }
  452. }
  453. .btn-box {
  454. height: 100%;
  455. display: flex;
  456. flex-direction: column;
  457. align-items: flex-start;
  458. justify-content: space-around;
  459. }
  460. }
  461. .tabs {
  462. height: 88rpx;
  463. background-color: #F5F7FA;
  464. //z-index: 999;
  465. .u-tabs__wrapper__nav__line {
  466. border-radius: 8rpx !important;
  467. opacity: 0.8 !important;
  468. bottom: 10rpx !important;
  469. }
  470. .u-tabs__wrapper__nav__item {
  471. padding: 0 16rpx;
  472. }
  473. .u-tabs__wrapper__nav__item__text {
  474. font-size: 28rpx;
  475. }
  476. }
  477. }
  478. .inner-box {
  479. z-index: 9;
  480. position: relative;
  481. // padding: 40upx 30upx;
  482. .topbox {
  483. padding: 30rpx;
  484. margin: 0 30rpx;
  485. display: flex;
  486. align-items: center;
  487. justify-content: space-between;
  488. background: #FFFFFF;
  489. border-radius: 24rpx 24rpx 0rpx 0rpx;
  490. .left {
  491. display: flex;
  492. flex-direction: column;
  493. align-items: flex-start;
  494. text {
  495. margin-left: 12rpx;
  496. font-family: PingFang SC, PingFang SC;
  497. font-weight: 400;
  498. font-size: 26rpx;
  499. color: #626468;
  500. text-align: left;
  501. }
  502. .num {
  503. font-family: Roboto, Roboto;
  504. font-weight: 500;
  505. font-size: 64rpx;
  506. color: #222426;
  507. text-align: left;
  508. }
  509. .points-icon {
  510. width: 40rpx;
  511. height: 40rpx;
  512. }
  513. .points-title {
  514. font-size: 32rpx;
  515. color: #222222;
  516. }
  517. }
  518. .guize {
  519. width: 220rpx;
  520. height: 72rpx;
  521. display: flex;
  522. align-items: center;
  523. justify-content: center;
  524. background: linear-gradient(280deg, #FD7600 0%, #FD4015 100%);
  525. border-radius: 36rpx 36rpx 36rpx 36rpx;
  526. font-family: PingFang SC, PingFang SC;
  527. font-weight: 500;
  528. font-size: 28rpx;
  529. color: #FFFFFF;
  530. }
  531. }
  532. .bottom-box {
  533. font-size: 28rpx;
  534. color: #222222;
  535. background: #DFEEFC;
  536. border-radius: 24rpx 24rpx 24rpx 24rpx;
  537. height: 150rpx;
  538. z-index: -1;
  539. position: relative;
  540. margin-top: -50rpx;
  541. .ttbg {
  542. width: 100%;
  543. height: 50rpx;
  544. background: #0372FD;
  545. border-radius: 24rpx 24rpx 24rpx 24rpx;
  546. }
  547. .t-left {
  548. flex: 1;
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. font-family: PingFang SC, PingFang SC;
  553. font-weight: 400;
  554. font-size: 28rpx;
  555. color: #222222;
  556. border-right: 2rpx solid rgba(0, 112, 253, 0.2);
  557. image {
  558. width: 40rpx;
  559. height: 40rpx;
  560. margin-right: 12rpx;
  561. }
  562. }
  563. .t-right {
  564. flex: 1;
  565. display: flex;
  566. align-items: center;
  567. justify-content: center;
  568. font-family: PingFang SC, PingFang SC;
  569. font-weight: 400;
  570. font-size: 28rpx;
  571. color: #222222;
  572. image {
  573. width: 32rpx;
  574. height: 32rpx;
  575. margin-right: 12rpx;
  576. }
  577. }
  578. }
  579. }
  580. .integral-box {
  581. padding: 0 30rpx 30rpx 30rpx;
  582. display: flex;
  583. align-items: flex-start;
  584. justify-content: flex-start;
  585. flex-wrap: wrap;
  586. .item {
  587. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  588. background-color: #fff;
  589. width: calc(50% - 20rpx);
  590. border-radius: 15rpx;
  591. margin: 10rpx;
  592. display: flex;
  593. flex-direction: column;
  594. align-items: flex-start;
  595. justify-content: flex-start;
  596. &:last-child {}
  597. .top {
  598. width: 100%;
  599. height: 300rpx;
  600. image {
  601. border-radius: 15rpx 15rpx 0rpx 0rpx;
  602. width: 100%;
  603. height: 300rpx;
  604. }
  605. }
  606. .bottom {
  607. width: 100%;
  608. padding: 15rpx;
  609. .title {
  610. font-weight: 500;
  611. font-size: 32rpx;
  612. color: #222222;
  613. }
  614. .price-box {
  615. display: flex;
  616. flex-direction: column;
  617. width: 100%;
  618. font-size: 24rpx;
  619. .price {
  620. display: flex;
  621. align-items: center;
  622. border-radius: 30rpx;
  623. color: #FF5030;
  624. margin: 18rpx 0;
  625. .icon {
  626. width: 32rpx;
  627. height: 32rpx;
  628. margin-right: 8rpx;
  629. }
  630. .bold {
  631. font-family: Roboto, Roboto;
  632. font-weight: 600;
  633. font-size: 32rpx;
  634. margin-right: 4rpx;
  635. }
  636. }
  637. .count {
  638. margin-top: 18rpx;
  639. color: #999999;
  640. }
  641. }
  642. .exchange {
  643. text-align: center;
  644. width: 100%;
  645. padding: 8rpx 0;
  646. font-weight: 500;
  647. font-size: 28rpx;
  648. color: #FFFFFF;
  649. box-sizing: border-box;
  650. background: linear-gradient(280deg, #FD7600 0%, #FD4015 100%);
  651. border-radius: 16rpx 16rpx 16rpx 16rpx;
  652. }
  653. }
  654. }
  655. }
  656. }
  657. }
  658. .search-box {
  659. display: flex;
  660. align-items: center;
  661. justify-content: space-between;
  662. padding-top: 22rpx;
  663. font-size: 28rpx;
  664. .search {
  665. padding: 0;
  666. flex: 1;
  667. image {
  668. width: 28rpx;
  669. height: 28rpx;
  670. padding-left: 16rpx;
  671. }
  672. }
  673. }
  674. </style>