oil-station/gasStation-uni/pagesMy/VIP/vip.vue

517 lines
14 KiB
Vue
Raw Normal View History

2023-11-28 14:43:36 +08:00
<template>
2023-12-15 14:00:09 +08:00
<view class="content">
2024-01-03 18:40:21 +08:00
<view class="container" v-if="isExist">
2023-12-15 14:00:09 +08:00
<view class="my-header">
2023-12-18 18:44:02 +08:00
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
2023-12-15 14:00:09 +08:00
<view class="my-text">会员</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
<uni-swiper-dot class="uni-swiper-dot-box" @clickItem=clickItem :info="info" :current="current" :mode="mode"
:dots-styles="dotsStyles" field="content">
<swiper class="swiper-box" @change="change" :current="swiperDotIndex">
2023-12-18 18:44:02 +08:00
<swiper-item v-for="(item, index) in userGradeList" :key="index">
2024-02-29 18:06:34 +08:00
<view>
<view class="top-box">
2023-12-15 14:00:09 +08:00
2024-02-29 18:06:34 +08:00
<view class="b-top">
<view style="width: 70%;">
<view class="title-size">
{{item.name}}
<span v-if="member.gradeId==item.id">(当前等级)</span>
</view>
<view class="min-size" style="margin-bottom: 20px;">升级会员享更多特权</view>
<!-- <view class="min-size" style="margin-bottom: 10px;" v-if="userBalance.gradeId == item.id && index < (userGradeList.length-1)">
在获得{{item.growthValue - userBalance.growthValue}}可升级至{{userGradeList[index+1].name}}
</view>
<view class="min-size" style="margin-bottom: 10px;" v-else-if="userBalance.gradeId == item.id && index == (userGradeList.length-1)">
已达到最高等级
</view> -->
<view class="min-size" style="margin-bottom: 10px;" >
达到当前等级所需成长值为{{item.growthValue}}
</view>
<u-line-progress :percentage="percentage" activeColor="#2F72F7"></u-line-progress>
2024-01-06 18:04:36 +08:00
</view>
2024-02-29 18:06:34 +08:00
<view class="right-img">
<image src="../../static/imgs/vipxz.png" mode="aspectFit"></image>
2023-12-18 18:44:02 +08:00
</view>
2023-12-15 14:00:09 +08:00
</view>
</view>
2024-02-29 18:06:34 +08:00
<!-- qy -->
<view class="c-box">
<!-- <view class="title-bai">会员权益</view> -->
<view class="wrap-box">
2023-12-15 15:11:42 +08:00
2024-02-29 18:06:34 +08:00
<view class="box-ba" v-for="(item,index) in oilNameList" :key="index">
<view class="min-box">
<image :src="item.imgurl" mode="aspectFit"></image>
</view>
<view class="mu_">{{item.name}}</view>
2023-12-15 14:00:09 +08:00
</view>
</view>
</view>
</view>
</swiper-item>
</swiper>
</uni-swiper-dot>
2023-12-18 18:44:02 +08:00
<!-- <view style="height: 300px; width: 100%;"></view> -->
2023-12-15 14:00:09 +08:00
<view class="bottom-box">
2023-12-18 18:44:02 +08:00
<!-- <scroll-view scroll-y="true" class="scroll-Y"> -->
<view class="bottom-bai-box">
<view class="b-top-bt">
<view class="title">汽油优惠信息</view>
<!-- <view class="times">每天04:00更新</view> -->
</view>
<view class="b-center" v-if="userGrade.preferential!='自定义优惠'">无优惠</view>
<view v-else>
<view class="b-center" v-if="userGrade.gasolineDiscount=='满减优惠'">
满减优惠:
<view class="b-center-spn" v-for="(item,index) in gasolineRule" :key="index">
消费满{{item.gasolineRule1}},立减{{item.gasolineRule2}}
</view>
</view>
<view class="b-center" v-else-if="userGrade.gasolineDiscount=='每升优惠'">
每升优惠:
<view class="b-center-spn" v-for="(item,index) in gasolineRule" :key="index">
消费满{{item.gasolineRule1}},每升优惠{{item.gasolineRule3}}
</view>
</view>
<view class="b-center" v-else>{{userGrade.gasolineDiscount}}</view>
</view>
<view class="title">成长规则每消费<text style=" margin: 0px 5px; color:#ff5c28 ;">1</text> 元加<text
style="margin: 0px 5px;color:#2c62cd ;">{{chainStoreConfig.gasGrowthValue}}</text>成长值</view>
</view>
<view class="bottom-bai-box">
<view class="b-top-bt">
<view class="title">柴油优惠信息</view>
<!-- <view class="times">每天04:00更新</view> -->
</view>
<view class="b-center" v-if="userGrade.preferential!='自定义优惠'">无优惠</view>
<view v-else>
<view class="b-center" v-if="userGrade.dieselDiscount=='满减优惠'">
满减优惠:
<view class="b-center-spn" v-for="(item,index) in dieselRule" :key="index">
消费满{{item.dieselRule1}},立减{{item.dieselRule2}}
</view>
</view>
<view class="b-center" v-else-if="userGrade.dieselDiscount=='每升优惠'">
每升优惠:
<view class="b-center-spn" v-for="(item,index) in dieselRule" :key="index">
消费满{{item.dieselRule1}},每升优惠{{item.dieselRule3}}
</view>
</view>
<view class="b-center" v-else>{{userGrade.dieselDiscount}}</view>
</view>
<view class="title">成长规则每消费<text style=" margin: 0px 5px; color:#ff5c28 ;">1</text> 元加<text
style="margin: 0px 5px;color:#2c62cd ;">{{chainStoreConfig.dieselGrowthValue}}</text>成长值</view>
</view>
<view class="bottom-bai-box">
<view class="b-top-bt">
<view class="title">天然气优惠信息</view>
<!-- <view class="times">每天04:00更新</view> -->
</view>
<view class="b-center" v-if="userGrade.preferential!='自定义优惠'">无优惠</view>
<view v-else>
<view class="b-center" v-if="userGrade.naturalGasDiscount=='满减优惠'">
满减优惠:
<view class="b-center-spn" v-for="(item,index) in naturalGasRule" :key="index">
消费满{{item.naturalGas1}},立减{{item.naturalGas2}}
</view>
</view>
<view class="b-center" v-else-if="userGrade.naturalGasDiscount=='每升优惠'">
每升优惠:
<view class="b-center-spn" v-for="(item,index) in naturalGasRule" :key="index">
消费满{{item.naturalGas1}},每升优惠{{item.naturalGas3}}
</view>
</view>
<view class="b-center" v-else>{{userGrade.naturalGasDiscount}}</view>
</view>
<view class="title">成长规则每消费<text style=" margin: 0px 5px; color:#ff5c28 ;">1</text> 元加<text
style="margin: 0px 5px;color:#2c62cd ;">{{chainStoreConfig.naturalGrowthValue}}</text>成长值</view>
2023-12-15 14:00:09 +08:00
</view>
2023-12-18 18:44:02 +08:00
<!-- <view class="bottom-bai-box">
<view class="title">每消费<text style=" margin: 0px 5px; color:#ff5c28 ;">200</text> 元加<text
style="margin: 0px 5px;color:#2c62cd ;">1%</text>成长值</view>
2023-12-15 14:00:09 +08:00
2023-12-18 18:44:02 +08:00
</view> -->
<!-- </scroll-view> -->
2023-12-15 14:00:09 +08:00
</view>
</view>
2024-01-03 18:40:21 +08:00
<view class="container" v-else>
<view class="my-header">
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">会员</view>
<view class="my-icons"></view>
</view>
<view style="width:100%;height: 90vh;background-color: white;text-align: center;">当前店铺不存在会员等级信息</view>
</view>
2023-12-15 14:00:09 +08:00
</view>
2023-11-28 14:43:36 +08:00
</template>
<script>
2023-12-18 18:44:02 +08:00
import request from '../../utils/request'
2023-12-15 14:00:09 +08:00
export default {
data() {
return {
2024-01-27 09:05:50 +08:00
percentage:0,
2023-12-15 14:00:09 +08:00
title: '',
info: [{
colorClass: 'uni-bg-red',
url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
content: '内容 A'
},
{
colorClass: 'uni-bg-green',
url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
content: '内容 B'
},
{
colorClass: 'uni-bg-blue',
url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
content: '内容 C'
}
],
2023-12-15 15:11:42 +08:00
oilNameList: [
2023-12-18 18:44:02 +08:00
{name:"汽油",imgurl:"../../static/imgs/gasoline.png"},
{name:"柴油",imgurl:"../../static/imgs/diesel_oil.png"},
{name:"天然气",imgurl:"../../static/imgs/natural_gas.png"},
2023-12-15 15:11:42 +08:00
],
2023-12-15 14:00:09 +08:00
modeIndex: -1,
styleIndex: -1,
current: 0,
mode: 'default',
dotsStyles: {},
2023-12-18 18:44:02 +08:00
swiperDotIndex: 0,
// 会员等级列表信息
userGradeList:[],
2024-01-06 18:04:36 +08:00
storeId:uni.getStorageSync("storeId"),
2023-12-18 18:44:02 +08:00
userId:"",
userBalance:{},
userGrade:{},
// 汽油优惠
gasolineRule:[],
// 柴油优惠
dieselRule:[],
// 天然气优惠
naturalGasRule:[],
// 连锁店配置信息
chainStoreConfig: {},
2024-01-03 18:40:21 +08:00
// 当前店铺是否存在会员等级信息
isExist:false,
2024-01-06 18:04:36 +08:00
// 当前用户的会员信息
member:{},
2023-12-15 14:00:09 +08:00
}
},
2023-12-18 18:44:02 +08:00
onLoad() {
this.storeId = uni.getStorageSync("storeId")
this.getList(this.storeId)
this.getChainConfig(this.storeId)
this.getUserBalance()
2024-01-06 18:04:36 +08:00
this.getMember()
2023-12-15 14:00:09 +08:00
},
methods: {
2024-01-27 09:05:50 +08:00
getPercentage(id){
let grade = {}
2024-01-27 11:35:35 +08:00
request({
url: "business/userManager/userGrade/" + this.member.gradeId,
method: 'get',
}).then((res) => {
grade = res.data
this.userGradeList.forEach(item => {
if (item.id == id){
if (grade.grade > item.grade){
this.percentage = 100
}
if (grade.grade < item.grade){
this.percentage = 0
}
if (grade.grade == item.grade){
this.percentage = ((this.member.growthValue / item.growthValue) * 100).toFixed(0)
}
}
})
2024-01-27 09:05:50 +08:00
})
2024-01-27 11:35:35 +08:00
2024-01-27 09:05:50 +08:00
},
2024-01-06 18:04:36 +08:00
// 获取当前登入用户的等级信息
getMember(){
request({
2024-01-12 13:55:40 +08:00
url: "business/userManager/user/storeUserInfo/" + this.storeId,
2024-01-06 18:04:36 +08:00
method: 'get',
}).then((res) => {
this.member = res.data
2024-01-27 11:35:35 +08:00
this.getPercentage(this.userGrade.id)
2024-01-06 18:04:36 +08:00
})
},
2023-12-18 18:44:02 +08:00
getChainConfig(storeId){
let _this = this;
request({
url: "business/userManager/chainStoreConfig/" + storeId,
method: 'get',
}).then((res) => {
_this.chainStoreConfig = res.data
})
},
// 获取用户余额信息
getUserBalance(){
let _this = this;
request({
url: "business/userManager/user/userBalanceByUserId",
method: 'get',
}).then((res) => {
_this.userBalance = res.data
})
},
// 获取会员等级列表信息
getList(storeId){
let _this = this;
request({
url: "business/userManager/userGrade/getGradeList/"+storeId,
method: 'get',
}).then((res) => {
2024-01-03 18:40:21 +08:00
if (res.data){
this.isExist = true
this.userGradeList = res.data
this.userGrade = res.data[0]
if (res.data[0].preferential == '自定义优惠'){
this.gasolineRule = JSON.parse(res.data[0].gasolineRule)
this.dieselRule = JSON.parse(res.data[0].dieselRule)
this.naturalGasRule = JSON.parse(res.data[0].naturalGasRule)
}
2024-01-27 11:35:35 +08:00
// this.getPercentage(res.data[0].id)
2024-01-03 18:40:21 +08:00
}else{
this.isExist = false
2023-12-18 18:44:02 +08:00
}
})
},
2023-12-15 14:00:09 +08:00
change(e) {
this.current = e.detail.current
2023-12-18 18:44:02 +08:00
this.userGrade = this.userGradeList[this.current]
if (this.userGradeList[this.current].preferential == '自定义优惠'){
this.gasolineRule = JSON.parse(this.userGradeList[this.current].gasolineRule)
this.dieselRule = JSON.parse(this.userGradeList[this.current].dieselRule)
this.naturalGasRule = JSON.parse(this.userGradeList[this.current].naturalGasRule)
}
2024-01-27 11:35:35 +08:00
this.getPercentage(this.userGrade.id)
2023-12-15 14:00:09 +08:00
},
2023-12-18 18:44:02 +08:00
goBack() {
2023-12-15 14:00:09 +08:00
uni.navigateBack()
}
}
}
2023-11-28 14:43:36 +08:00
</script>
2023-12-09 09:16:50 +08:00
<style scoped lang="scss">
2023-12-18 18:44:02 +08:00
.b-center{
line-height: 25px;
margin: 10px 0;
margin-left: 10px;
font-size: 15px;
}
.b-center-spn{
margin-left: 20px;
}
2023-12-15 14:00:09 +08:00
.swiper-box {
2024-02-29 18:06:34 +08:00
height: 50vh;
2023-12-15 14:00:09 +08:00
}
.content {
background: #2F3648;
height: 100vh;
}
.container {
width: 100%;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.top-box {
width: 90%;
border-radius: 8px;
box-sizing: border-box;
padding: 20px;
background: linear-gradient(90deg, #EEF4FF 0%, #AEC9FF 100%);
margin: 10px auto;
}
.b-top {
color: #2F72F7;
display: flex;
justify-content: space-between;
}
.right-img {
width: 80px;
height: 80px;
image {
width: 100%;
height: 100%;
}
}
.title-size {
font-weight: bold;
font-size: 18px;
}
.min-size {
font-size: 12px;
}
.c-box {
width: 90%;
box-sizing: border-box;
padding: 15px;
margin: 20px auto;
height: 188px;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
border-radius: 8px;
}
.title-bai {
font-size: 18px;
font-weight: bold;
color: #ffffff;
}
.wrap-box {
width: 100%;
display: flex;
2023-12-15 15:11:42 +08:00
justify-content: space-between;
align-items: center;
2023-12-15 14:00:09 +08:00
}
.box-ba {
2023-12-15 15:11:42 +08:00
width: 33%;
2023-12-15 14:00:09 +08:00
text-align: center;
margin: 10px auto;
color: #ffffff;
font-size: 12px;
}
.min-box {
2023-12-15 15:11:42 +08:00
width: 90%;
height: 90px;
2023-12-15 14:00:09 +08:00
margin: 5px auto;
image {
width: 100%;
height: 100%;
}
}
.bottom-box {
background: #F3F5F9;
width: 100%;
border-radius: 16px 16px 0px 0px;
box-sizing: border-box;
padding: 15px;
position: fixed;
bottom: 0px;
2023-12-18 18:44:02 +08:00
height: 390px;
overflow-y: scroll;
2023-12-15 14:00:09 +08:00
}
.bottom-bai-box {
width: 100%;
border-radius: 8px;
background: #ffffff;
box-sizing: border-box;
padding: 10px;
2023-12-15 15:11:42 +08:00
margin: 15px auto;
2023-12-15 14:00:09 +08:00
}
.b-top-bt {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.title {
font-size: 16px;
font-weight: bold;
color: #333333;
}
.times {
font-size: 12px;
color: #999999;
}
.btimg {
image {
width: 44px;
height: 44px;
}
}
.anniu {
width: 70px;
height: 30px;
background: #EB3E67;
border-radius: 15px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 14px;
font-weight: bold;
}
.disa {
display: flex;
align-items: center;
justify-content: center;
}
.an-title {
font-size: 16px;
font-weight: bold;
color: #333333;
margin-left: 5px;
}
2023-12-15 15:11:42 +08:00
.mu_ {
font-size: 18px;
font-weight: bold;
margin: 15px auto;
}
2023-12-15 14:00:09 +08:00
</style>