| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- <template>
- <view class="container u-f es-ver es-fx">
- <view class="top-box">
- <view class="my-integral">
- <view class="left">
- <view class="label">我的福币</view>
- <view style="margin-top: 30rpx;display: flex;align-items: baseline;">
- <view class="integral">{{integral}}</view>
- <view class="integralbtn" @click="goIntegral">获取福币</view>
- </view>
- </view>
- <view class="btn-box">
- <view class="btn" @click="navTo('/pages/user/integral/integralLogsList')">获得记录</view>
- <view class="btn" @click="navTo('/pages/user/integral/integralOrderList')">兑换记录</view>
- </view>
- </view>
- <!-- 搜索 -->
- <view class="search-box">
- <uni-search-bar class="search" bgColor="#eee" radius="34" v-model="keyword" placeholder="搜索商品"
- clearButton="auto" cancelButton="none" @confirm="refreshList">
- <template v-slot:searchIcon>
- <image src="@/static/image/hall/search_gray_icon.png" mode="aspectFill"></image>
- </template>
- </uni-search-bar>
- </view>
- <view class="tabs" v-if="tabs.length>0">
- <u-tabs :current="tabIndex" :scrollable="true" :list="tabs" lineColor="#FF5C03" @change="tabChange">
- </u-tabs>
- </view>
- </view>
- <view class="es-fx">
- <mescroll-body bottom="0" :top="top +'px'" ref="mescrollRef" @init="mescrollInit" @down="downCallback"
- @up="upCallback" :down="downOption" :up="upOption">
- <view class="integral-box">
- <view class="item" @click="navTo('/pages/user/integral/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 class="integral-box" v-if="false">
- <view class="item" @click="navTo('/pages/user/integral/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>
- <view class="x-ac" v-if="dataList&&dataList.length==0">
- <u-empty style="padding-top: 20px" mode="data"
- icon="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png"
- text="暂无数据"></u-empty>
- </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],
- props: {
- i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
- index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
- type: Number,
- default () {
- return 0
- }
- },
- height: [Number, String] // mescroll的高度
- },
- data() {
- return {
- integral: 0,
- type: null,
- 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://zkzh-2025.oss-cn-beijing.aliyuncs.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
- tip: '暂无数据'
- }
- },
- dataList: [],
- total: 0,
- pageNum: 1,
- pageSize: 10,
- keyword: "",
- }
- },
- mounted() {
- this.getDictByKey("sys_integral_goods_type");
- this.getUserInfo();
- this.refreshList()
- },
- methods: {
- tabChange(item) {
- this.type = item.index == 0 ? null : this.typeOptions[item.index - 1].dictValue;
- this.mescroll.resetUpScroll()
- },
- search() {
- this.mescroll.resetUpScroll()
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- let that = this;
- let data = {
- pageNum: page.num,
- pageSize: page.size,
- keyword: this.keyword
- };
- 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();
- }
- });
- },
- async getUserInfo() {
- const res = await getUserInfo()
- if (res.code == 200) {
- if (res.user != null) {
- this.integral = res.user.integral;
- }
- } else {
- uni.showToast({
- icon: 'none',
- title: "请求失败",
- });
- }
- },
- navTo(url) {
- uni.navigateTo({
- url: url
- })
- },
- goIntegral() {
- let pages = getCurrentPages();
- let url = pages[pages.length - 2];
- if (pages.length > 1 && url && url.route == 'pages/user/integral/points') {
- uni.navigateBack()
- } else {
- uni.navigateTo({
- url: '/pages/user/integral/points'
- })
- }
- },
- getDictByKey(key) {
- let data = {
- key: key
- }
- let that = this;
- getDictByKey(data).then(
- res => {
- if (res.code == 200) {
- this.typeOptions = res.data;
- this.typeOptions.forEach(function(item, index) {
- let data = {
- name: item.dictLabel
- };
- that.tabs.push(data);
- })
- this.tabs.unshift({
- name: '全部'
- })
- if (this.tabs.length > 0) {
- this.tabIndex = 0
- }
- }
- },
- err => {}
- );
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .container {
- // min-height: 100vh;
- // height: 100%;
- // width: 100vw;
- }
- .yAuto {
- overflow-y: auto;
- }
- .top-box {
- padding: 0 30rpx 0 30rpx;
- width: 100%;
- .my-integral {
- height: 200rpx;
- box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
- background: linear-gradient(#FF5C03, #E2C99E);
- border-radius: 30rpx;
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- padding: 30rpx;
- .integralbtn {
- font-size: 24rpx;
- font-family: PingFang SC;
- color: #fff;
- margin-left: 16rpx;
- text-decoration: underline;
- }
- .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: #FF5C03;
- }
- .left {
- .label {
- font-size: 28upx;
- font-family: PingFang SC;
- color: #fff;
- }
- .integral {
- 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;
- }
- }
- .tabs {
- height: 88rpx;
- }
- }
- .integral-box {
- padding: 0 30rpx 30rpx 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: #FF5C03;
- border-radius: 30rpx;
- font-size: 20upx;
- font-family: PingFang SC;
- color: #ffffff;
- }
- .count {
- font-size: 24upx;
- font-family: PingFang SC;
- color: #333333;
- }
- }
- }
- }
- }
- .search-box {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-top: 22rpx;
- .search {
- padding: 0;
- flex: 1;
- image {
- width: 28rpx;
- height: 28rpx;
- padding-left: 16rpx;
- }
- }
- }
- </style>
|