update
This commit is contained in:
parent
328d8a2f2c
commit
caba7797f1
@ -7,6 +7,10 @@
|
||||
<view class="pointsLabel">我的ETC积分</view>
|
||||
<view class="pointsValue">{{ userPoints || 0 }}</view>
|
||||
</view>
|
||||
<view class="pointsInfo platformPointsInfo">
|
||||
<view class="pointsLabel">我的彩云驿积分</view>
|
||||
<view class="pointsValue">{{ platformUserPoints || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -15,22 +19,26 @@
|
||||
<view class="boxTitle">积分兑换</view>
|
||||
|
||||
<view class="exchangeContent">
|
||||
<!-- ETC积分输入 -->
|
||||
<!-- 源积分输入 -->
|
||||
<view class="inputBox">
|
||||
<view class="inputLabel">ETC积分</view>
|
||||
<input class="inputField" type="digit" v-model="etcPoints" placeholder="请输入兑换积分"
|
||||
<view class="inputLabel">{{ conversionDirection === 'etcToPlatform' ? 'ETC积分' : '彩云驿积分' }}</view>
|
||||
<input class="inputField" type="digit" v-model="sourcePointsInput" :placeholder="sourcePlaceholder"
|
||||
@input="handleCalculate" />
|
||||
<view class="balanceText">可用余额: {{ conversionDirection === 'etcToPlatform' ? userPoints :
|
||||
platformUserPoints }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 兑换比例显示 -->
|
||||
<view class="exchangeRate">
|
||||
<!-- 兑换方向切换 -->
|
||||
<view class="iconBox" @click="toggleConversion">
|
||||
<text class="exchangeTextIcon">⇅</text>
|
||||
<view class="rateText">兑换比例 {{ exchangeRate }}:1</view>
|
||||
</view>
|
||||
|
||||
<!-- 彩云驿积分显示 -->
|
||||
|
||||
<!-- 目标积分显示 -->
|
||||
<view class="resultBox">
|
||||
<view class="resultLabel">彩云驿积分</view>
|
||||
<view class="resultValue">{{ platformPoints }}</view>
|
||||
<view class="resultLabel">{{ conversionDirection === 'etcToPlatform' ? '彩云驿积分' : 'ETC积分' }}</view>
|
||||
<view class="resultValue">{{ destinationPointsOutput }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -82,48 +90,52 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import {
|
||||
mapGetters
|
||||
} from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userPoints: 0, // 用户当前ETC积分
|
||||
etcPoints: '', // 用户输入的ETC积分
|
||||
platformPoints: 0, // 计算后的彩云驿积分
|
||||
platformUserPoints: 0, // 用户当前彩云驿积分
|
||||
sourcePointsInput: '', // 用户输入的源积分
|
||||
destinationPointsOutput: 0, // 计算后的目标积分
|
||||
exchangeRate: 1, // 兑换比例 1:1
|
||||
|
||||
conversionDirection: 'etcToPlatform', // etcToPlatform(ETC积分换平台积分) | platformToEtc(平台积分换ETC积分)
|
||||
userInfo: {},
|
||||
// 兑换规则
|
||||
rules: [
|
||||
'1个ETC积分可兑换1个彩云驿积分',
|
||||
'1个彩云驿积分可兑换1个ETC积分',
|
||||
'兑换后不可撤销,请谨慎操作',
|
||||
],
|
||||
|
||||
// 积分商品列表(示例数据)
|
||||
productList: [
|
||||
{
|
||||
id: 1,
|
||||
name: '10元优惠券',
|
||||
points: 100,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product1.png'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '20元优惠券',
|
||||
points: 200,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product2.png'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '50元优惠券',
|
||||
points: 500,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product3.png'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '100元优惠券',
|
||||
points: 1000,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product4.png'
|
||||
}
|
||||
productList: [{
|
||||
id: 1,
|
||||
name: '10元优惠券',
|
||||
points: 100,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product1.png'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '20元优惠券',
|
||||
points: 200,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product2.png'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '50元优惠券',
|
||||
points: 500,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product3.png'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '100元优惠券',
|
||||
points: 1000,
|
||||
image: 'https://eshangtech.com/caiyunyiImg/product4.png'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -132,16 +144,82 @@ export default {
|
||||
...mapGetters({
|
||||
user: "user",
|
||||
}),
|
||||
sourcePointName() {
|
||||
return this.conversionDirection === 'etcToPlatform' ? 'ETC积分' : '彩云驿积分';
|
||||
},
|
||||
destinationPointName() {
|
||||
return this.conversionDirection === 'etcToPlatform' ? '彩云驿积分' : 'ETC积分';
|
||||
},
|
||||
sourcePointBalance() {
|
||||
return this.conversionDirection === 'etcToPlatform' ? this.userPoints : this.platformUserPoints;
|
||||
},
|
||||
sourcePlaceholder() {
|
||||
return `请输入兑换${this.sourcePointName}`;
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.getUserPoints();
|
||||
this.handleGetUserDetail()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
computed: {
|
||||
...mapGetters({
|
||||
user: "user",
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
// 获取用户积分
|
||||
// 拿到用户详情
|
||||
async handleGetUserDetail() {
|
||||
let _this = this;
|
||||
_this.$api
|
||||
.getCoop({
|
||||
action_type: "GetMembershipInfo",
|
||||
WechatUserId: _this.user.WechatUserId,
|
||||
noLoading: true,
|
||||
})
|
||||
.then(function (data) {
|
||||
if (data.ResultCode === "100") {
|
||||
let _data = data;
|
||||
_this.userInfo = _data.Data
|
||||
_this.user.MEMBERSHIP_ID = _data.Data.MEMBERSHIP_ID || "";
|
||||
_this.user.MEMBERSHIP_NAME = _data.Data.MEMBERSHIP_NAME || "";
|
||||
_this.user.MEMBERSHIP_LEVEL_TEXT =
|
||||
_data.Data.MEMBERSHIP_LEVEL_TEXT || "";
|
||||
_this.user.COUPON_COUNT = _data.Data.COUPON_COUNT || "";
|
||||
_this.user.PENDORDER_COUNT = _data.Data.PENDORDER_COUNT || "";
|
||||
_this.user.RESERVATION_COUNT = _data.Data.RESERVATION_COUNT || "";
|
||||
_this.user.ACCOUNT_BALANCE = _data.Data.ACCOUNT_BALANCE || "";
|
||||
_this.user.ISPLUS = _data.Data.ISPLUS || "";
|
||||
_this.user.INDUSTRY_MEMBERSHIP_ID =
|
||||
_data.Data.INDUSTRY_MEMBERSHIP_ID || "";
|
||||
_this.user.MEMBERSHIP_TYPE = _data.Data.MEMBERSHIP_TYPE || "";
|
||||
_this.user.MEMBERSHIP_LEVEL = _data.Data.MEMBERSHIP_LEVEL || "";
|
||||
_this.user.InviteCode = _data.Data.InviteCode || "";
|
||||
_this.user.MEMBERSHIP_POINT = _data.Data.MEMBERSHIP_POINT || "";
|
||||
_this.user.MEMBERSHIP_MOBILEPHONE =
|
||||
_data.Data.MEMBERSHIP_MOBILEPHONE || "";
|
||||
_this.WXProfile = _data.Data.MEMBERSHIP_HEADIMAGEURL;
|
||||
_this.user.TEST_MEMBER = _data.Data.TEST_MEMBER || "";
|
||||
_this.$store.commit("setUser", _this.user);
|
||||
|
||||
_this.platformUserPoints = _data.Data.MEMBERSHIP_POINT
|
||||
|
||||
_this.$forceUpdate()
|
||||
} else {
|
||||
// _this.setUser({});
|
||||
_this.$store.commit("setUser", user);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 切换兑换方向
|
||||
toggleConversion() {
|
||||
this.conversionDirection = this.conversionDirection === 'etcToPlatform' ? 'platformToEtc' : 'etcToPlatform';
|
||||
this.sourcePointsInput = '';
|
||||
this.destinationPointsOutput = 0;
|
||||
},
|
||||
|
||||
// 获取用户ETC积分
|
||||
async getUserPoints() {
|
||||
uni.showLoading({
|
||||
title: "获取积分中..."
|
||||
@ -152,12 +230,9 @@ export default {
|
||||
type: "encryption"
|
||||
}
|
||||
const data = await this.$api.$post('/MemberApi/ThirdInterface/GetYTSLMemberPoint', req)
|
||||
console.log('datadatadatadata321', data);
|
||||
uni.hideLoading()
|
||||
if (data.Result_Code === 100) {
|
||||
let res = data.Result_Data
|
||||
console.log('resresresres', res);
|
||||
this.userPoints = res.balance
|
||||
this.userPoints = data.Result_Data.balance;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.Result_Desc,
|
||||
@ -166,73 +241,93 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 计算兑换积分
|
||||
handleCalculate(e) {
|
||||
const value = e.detail.value;
|
||||
if (value && !isNaN(value)) {
|
||||
// 按照兑换比例计算彩云驿积分
|
||||
this.platformPoints = Math.floor(Number(value) / this.exchangeRate);
|
||||
this.destinationPointsOutput = Math.floor(Number(value) / this.exchangeRate);
|
||||
} else {
|
||||
this.platformPoints = 0;
|
||||
this.destinationPointsOutput = 0;
|
||||
}
|
||||
},
|
||||
|
||||
// 执行兑换
|
||||
handleExchange() {
|
||||
// if (!this.etcPoints || this.etcPoints <= 0) { uni.showToast({ title: '请输入兑换积分', icon: 'none' }); return; } if
|
||||
// (Number(this.etcPoints) > this.userPoints) {
|
||||
// uni.showToast({
|
||||
// title: 'ETC积分不足',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
if (this.etcPoints > this.userPoints) {
|
||||
if (!this.sourcePointsInput) {
|
||||
uni.showToast({
|
||||
title: 'ETC积分不足',
|
||||
title: '请输入要兑换的积分!',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (this.sourcePointsInput > 0) {
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请输入要兑换的积分!',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (this.conversionDirection === 'etcToPlatform') {
|
||||
// ETC 换 平台
|
||||
if (this.sourcePointsInput > this.userPoints) {
|
||||
uni.showToast({
|
||||
title: 'ETC积分不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 平台 换 ETC积分
|
||||
if (this.sourcePointsInput > this.platformUserPoints) {
|
||||
uni.showToast({
|
||||
title: '彩云驿积分不足',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
let _this = this
|
||||
uni.showModal({
|
||||
title: '确认兑换',
|
||||
content: `确定使用${this.etcPoints}个ETC积分兑换${this.platformPoints}个彩云驿积分吗?`,
|
||||
content: `确定使用${this.sourcePointsInput}个${this.conversionDirection === 'etcToPlatform' ? 'ETC积分' : '彩云驿积分'}兑换${this.destinationPointsOutput}个${this.conversionDirection === 'etcToPlatform' ? '彩云驿积分' : 'ETC积分'}吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.doExchange();
|
||||
_this.doExchange()
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 调用兑换接口
|
||||
async doExchange() {
|
||||
uni.showLoading({ title: '兑换中...' });
|
||||
|
||||
// 创建一个时间的订单
|
||||
// let time = this.$moment.now().format("YYYYMMDDHHmmss")
|
||||
let time = this.$moment.now().format("YYYY")
|
||||
console.log('platformPointsplatformPoints', this.platformPoints);
|
||||
|
||||
|
||||
uni.showLoading({
|
||||
title: '兑换中...'
|
||||
});
|
||||
const req = {
|
||||
orderno: `535001-${time}-${new Date().getTime()}`,
|
||||
orderno: `535001-${new Date().getFullYear()}-${new Date().getTime()}`,
|
||||
outUserId: this.user.MEMBERSHIP_ID,
|
||||
changePoint: this.platformPoints,
|
||||
memo: "积分兑换",
|
||||
changePoint: this.conversionDirection === 'etcToPlatform' ? this.destinationPointsOutput : -this.destinationPointsOutput,
|
||||
memo: "ETC积分兑换彩云驿积分",
|
||||
type: "encryption"
|
||||
}
|
||||
console.log('reqreq', JSON.parse(JSON.stringify(req)));
|
||||
|
||||
const data = await this.$api.$post('/MemberApi/ThirdInterface/ChangeYTSLMemberPoint', req)
|
||||
console.log('datadatadatadata321', data);
|
||||
uni.hideLoading();
|
||||
if (data.Result_Code === 100) {
|
||||
uni.showToast({
|
||||
title: '兑换成功',
|
||||
icon: 'none'
|
||||
});
|
||||
this.etcPoints = ''
|
||||
this.getUserPoints();
|
||||
this.sourcePointsInput = '';
|
||||
this.destinationPointsOutput = 0;
|
||||
this.getUserPoints(); // 刷新ETC积分
|
||||
this.handleGetUserDetail(); // 刷新彩云驿积分
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.Result_Desc,
|
||||
@ -247,10 +342,6 @@ export default {
|
||||
title: `查看${product.name}详情`,
|
||||
icon: 'none'
|
||||
});
|
||||
// TODO: 跳转到商品详情页
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/productDetail/index?id=${product.id}`
|
||||
// });
|
||||
},
|
||||
|
||||
// 查看更多商品
|
||||
@ -259,10 +350,6 @@ export default {
|
||||
title: '查看更多商品',
|
||||
icon: 'none'
|
||||
});
|
||||
// TODO: 跳转到商品列表页
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/productList/index'
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,15 +368,17 @@ export default {
|
||||
.pointsHeader {
|
||||
width: 100%;
|
||||
background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
|
||||
padding: 60rpx 32rpx 80rpx;
|
||||
padding: 40rpx 32rpx 80rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
.headerContent {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
justify-content: space-around;
|
||||
|
||||
.pointsInfo {
|
||||
text-align: center;
|
||||
|
||||
.pointsLabel {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
@ -297,18 +386,12 @@ export default {
|
||||
}
|
||||
|
||||
.pointsValue {
|
||||
font-size: 72rpx;
|
||||
font-size: 60rpx;
|
||||
font-weight: bold;
|
||||
color: #FFFFFF;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.headerIcon {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,7 +409,7 @@ export default {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #222222;
|
||||
margin-bottom: 24rpx;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.exchangeContent {
|
||||
@ -341,36 +424,51 @@ export default {
|
||||
|
||||
.inputField {
|
||||
width: 100%;
|
||||
height: 68rpx;
|
||||
height: 80rpx;
|
||||
background: #F7F8FA;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 24rpx;
|
||||
font-size: 28rpx;
|
||||
font-size: 32rpx;
|
||||
color: #222222;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.balanceText {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
margin-top: 12rpx;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
.exchangeRate {
|
||||
.iconBox {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
margin-bottom: 12rpx;
|
||||
margin: 24rpx 0;
|
||||
|
||||
.exchangeIcon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
margin-right: 12rpx;
|
||||
&:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.exchangeTextIcon {
|
||||
font-size: 56rpx;
|
||||
// Adjust color to match existing design, or a neutral one
|
||||
color: #667EEA;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.rateText {
|
||||
font-size: 24rpx;
|
||||
color: #667EEA;
|
||||
font-weight: 500;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.resultBox {
|
||||
.resultLabel {
|
||||
font-size: 28rpx;
|
||||
@ -380,11 +478,11 @@ export default {
|
||||
|
||||
.resultValue {
|
||||
width: 100%;
|
||||
height: 68rpx;
|
||||
height: 80rpx;
|
||||
background: #F7F8FA;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 24rpx;
|
||||
font-size: 28rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #667EEA;
|
||||
display: flex;
|
||||
@ -396,13 +494,13 @@ export default {
|
||||
|
||||
.exchangeBtn {
|
||||
width: 100%;
|
||||
height: 68rpx;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 400;
|
||||
color: #FFFFFF;
|
||||
margin-top: 40rpx;
|
||||
@ -429,12 +527,6 @@ export default {
|
||||
font-weight: 600;
|
||||
color: #222222;
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
.titleIcon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.rulesList {
|
||||
|
||||
@ -449,7 +449,7 @@ export default {
|
||||
|
||||
|
||||
// 请求一下云南那边的积分信息
|
||||
this.handleGetYNUserInfo()
|
||||
// this.handleGetYNUserInfo()
|
||||
|
||||
|
||||
// 拿到订单信息
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -302,7 +302,7 @@ var _default = {
|
||||
// }
|
||||
|
||||
// 请求一下云南那边的积分信息
|
||||
_this2.handleGetYNUserInfo();
|
||||
// this.handleGetYNUserInfo()
|
||||
|
||||
// 拿到订单信息
|
||||
// await this.handleGetOrderDetail()
|
||||
@ -340,7 +340,7 @@ var _default = {
|
||||
_this2.$utils.addUserBehaviorNew({
|
||||
behaviorRecordDesc: "进入了我的页面"
|
||||
});
|
||||
case 16:
|
||||
case 15:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
|
||||
@ -8,6 +8,13 @@
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "pages/user/index",
|
||||
"pathName": "pages/user/index",
|
||||
"query": "",
|
||||
"scene": null,
|
||||
"launchMode": "default"
|
||||
},
|
||||
{
|
||||
"name": "pages/pointsRedemption/index",
|
||||
"pathName": "pages/pointsRedemption/index",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user