integralGoodsList.vue 14 KB

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