123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- <template>
- <view class="content">
-
- <view class="cont-box">
- <view class="top-box">
- <view class="my-integral">
- <view class="left">
- <view class="label">我的积分</view>
- <view class="integral">{{integral}}</view>
- </view>
- <view class="btn-box">
- <view class="btn" @click="navTo('/pages_user/integralLogsList')">积分记录</view>
- <view class="btn" @click="navTo('/pages_user/integralOrderList')">兑换记录</view>
- </view>
- </view>
- <view class="tabs" v-if="tabs.length>0">
- <u-tabs
- :current="tabIndex"
- :scrollable="true"
- :list="tabs"
- lineColor="#C39A58"
- @change="tabChange">
- </u-tabs>
- </view>
- </view>
- <mescroll-body top="288rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="integral-box" >
- <view class="item" @click="navTo('/pages_user/integralGoodsDetails?goodsId='+item.goodsId)" v-for="(item,index) in dataList">
- <view class="top">
- <image :src="item.imgUrl"></image>
- </view>
- <view class="bottom">
- <view class="title ellipsis2">
- {{item.goodsName}}
- </view>
- <view class="price-box">
- <view class="price">{{item.integral}}积分</view>
- <view class="count">原价:{{item.otPrice.toFixed(2)}}元</view>
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
-
- </view>
- </template>
- <script>
- import {getDictByKey} from '@/api/common.js'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- import {getIntegralGoodsList} from '@/api/integral.js'
- import {getUserInfo} from '@/api/user'
- export default {
- mixins: [MescrollMixin],
- data() {
- return {
- integral:0,
- type:"0",
- typeOptions:[],
- tabIndex:0,
- tabs: [],
- mescroll:null,
- downOption: { //下拉刷新
- use:true,
- auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
- },
- upOption: {
- onScroll:false,
- use: true, // 是否启用上拉加载; 默认true
- page: {
- pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 10 // 每页数据的数量,默认10
- },
- noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- textNoMore:"已经到底了",
- empty: {
- icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
- tip: '暂无数据'
- }
- },
- dataList: []
- }
- },
- onLoad() {
- this.getDictByKey("sys_integral_goods_type");
- this.getUserInfo();
- },
- methods: {
- getUserInfo(){
- getUserInfo().then(
- res => {
- if(res.code==200){
- if(res.user!=null){
- this.integral=res.user.integral;
- }
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- }
- },
- rej => {}
- );
- },
- navTo(url) {
- uni.navigateTo({
- url: url
- })
- },
- getDictByKey(key){
- var data={key:key}
- var that=this;
- getDictByKey(data).then(
- res => {
- if(res.code==200){
- this.typeOptions=res.data;
- this.typeOptions.forEach(function(item,index){
- var data={name:item.dictLabel};
- that.tabs.push(data);
- })
- if(this.tabs.length>0){
- this.tabIndex=0
- }
-
- }
- },
- err => {
- }
- );
-
- },
- tabChange(item){
- console.log(item.index)
- this.type=this.typeOptions[item.index].dictValue;
- this.mescroll.resetUpScroll()
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- //联网加载数据
- var that = this;
- var data = {
- pageNum: page.num,
- pageSize: page.size
- };
- if(this.type!=null){
- data.goodsType=this.type
- }
- getIntegralGoodsList(data).then(res => {
- if(res.code==200){
- //设置列表数据
- if (page.num == 1) {
- that.dataList = res.data.list;
-
- } else {
- that.dataList = that.dataList.concat(res.data.list);
-
- }
- that.mescroll.endBySize(res.data.list.length, res.data.total);
-
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- that.dataList = null;
- that.mescroll.endErr();
- }
- });
- }
-
- }
- }
-
-
- </script>
- <style scoped lang="scss">
- page{
- height: 100%;
- background-color: #f5f5f5;
- }
- .content{
- height: 100%;
- .cont-box{
- .top-box{
- z-index: 999;
- padding: 30rpx;
- width: 100%;
- position: fixed;
- top: 0rpx;
- left: 0rpx;
- .my-integral{
- height: 200rpx;
- box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
- background: linear-gradient(#C39A58, #E2C99E);
- border-radius: 30rpx;
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- padding: 30rpx;
- .left{
- .label{
- font-size: 28upx;
- font-family: PingFang SC;
- color: #fff;
- }
- .integral{
- margin-top: 30rpx;
- font-weight: bold;
- font-size: 40upx;
- font-family: PingFang SC;
- color: #fff;
- }
- }
- .btn-box{
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- .btn{
- margin-bottom: 30rpx;
- background-color: #fff;
- border-radius: 30rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 10rpx 15rpx;
- font-size: 20upx;
- font-family: PingFang SC;
- color: #C39A58;
- }
- }
- }
- .tabs{
- height: 88rpx;
- }
- }
- .integral-box{
- padding: 30rpx;
- display: flex;
- align-items: flex-start;
- justify-content: flex-start;
- flex-wrap: wrap;
- .item{
- box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
- background-color: #fff;
- width: calc(50% - 20rpx);
- border-radius: 15rpx;
- margin: 10rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- &:last-child{
- }
- .top{
- width:100%;
- height:300rpx;
- image{
- border-radius: 15rpx 15rpx 0rpx 0rpx;
- width:100%;
- height:300rpx;
- }
-
- }
- .bottom{
- width: 100%;
- padding: 15rpx;
- .title{
- font-weight: bold;
- font-size: 28upx;
- font-family: PingFang SC;
- color: #111111;
- }
- .price-box{
- margin-top: 10rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- .price{
- padding: 5rpx 10rpx;
- background-color: #C39A58;
- border-radius: 30rpx;
- font-size: 20upx;
- font-family: PingFang SC;
- color: #ffffff;
- }
- .count{
- font-size: 24upx;
- font-family: PingFang SC;
- color: #333333;
- }
-
- }
- }
- }
- }
- }
- }
-
- </style>
|