points.vue 14 KB

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