This commit is contained in:
ylj20011123 2025-12-02 18:35:40 +08:00
parent 328d8a2f2c
commit caba7797f1
5 changed files with 215 additions and 116 deletions

View File

@ -7,6 +7,10 @@
<view class="pointsLabel">我的ETC积分</view> <view class="pointsLabel">我的ETC积分</view>
<view class="pointsValue">{{ userPoints || 0 }}</view> <view class="pointsValue">{{ userPoints || 0 }}</view>
</view> </view>
<view class="pointsInfo platformPointsInfo">
<view class="pointsLabel">我的彩云驿积分</view>
<view class="pointsValue">{{ platformUserPoints || 0 }}</view>
</view>
</view> </view>
</view> </view>
@ -15,22 +19,26 @@
<view class="boxTitle">积分兑换</view> <view class="boxTitle">积分兑换</view>
<view class="exchangeContent"> <view class="exchangeContent">
<!-- ETC积分输入 --> <!-- 积分输入 -->
<view class="inputBox"> <view class="inputBox">
<view class="inputLabel">ETC积分</view> <view class="inputLabel">{{ conversionDirection === 'etcToPlatform' ? 'ETC积分' : '彩云驿积分' }}</view>
<input class="inputField" type="digit" v-model="etcPoints" placeholder="请输入兑换积分" <input class="inputField" type="digit" v-model="sourcePointsInput" :placeholder="sourcePlaceholder"
@input="handleCalculate" /> @input="handleCalculate" />
<view class="balanceText">可用余额: {{ conversionDirection === 'etcToPlatform' ? userPoints :
platformUserPoints }}</view>
</view> </view>
<!-- 兑换比例显示 --> <!-- 兑换方向切换 -->
<view class="exchangeRate"> <view class="iconBox" @click="toggleConversion">
<text class="exchangeTextIcon"></text>
<view class="rateText">兑换比例 {{ exchangeRate }}:1</view> <view class="rateText">兑换比例 {{ exchangeRate }}:1</view>
</view> </view>
<!-- 彩云驿积分显示 -->
<!-- 目标积分显示 -->
<view class="resultBox"> <view class="resultBox">
<view class="resultLabel">彩云驿积分</view> <view class="resultLabel">{{ conversionDirection === 'etcToPlatform' ? '彩云驿积分' : 'ETC积分' }}</view>
<view class="resultValue">{{ platformPoints }}</view> <view class="resultValue">{{ destinationPointsOutput }}</view>
</view> </view>
</view> </view>
@ -82,25 +90,29 @@
</template> </template>
<script> <script>
import { mapGetters } from "vuex"; import {
mapGetters
} from "vuex";
export default { export default {
data() { data() {
return { return {
userPoints: 0, // ETC userPoints: 0, // ETC
etcPoints: '', // ETC platformUserPoints: 0, // 驿
platformPoints: 0, // 驿 sourcePointsInput: '', //
destinationPointsOutput: 0, //
exchangeRate: 1, // 1:1 exchangeRate: 1, // 1:1
conversionDirection: 'etcToPlatform', // etcToPlatform(ETC) | platformToEtc(ETC)
userInfo: {},
// //
rules: [ rules: [
'1个ETC积分可兑换1个彩云驿积分', '1个ETC积分可兑换1个彩云驿积分',
'1个彩云驿积分可兑换1个ETC积分',
'兑换后不可撤销,请谨慎操作', '兑换后不可撤销,请谨慎操作',
], ],
// () // ()
productList: [ productList: [{
{
id: 1, id: 1,
name: '10元优惠券', name: '10元优惠券',
points: 100, points: 100,
@ -132,16 +144,82 @@ export default {
...mapGetters({ ...mapGetters({
user: "user", 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() { onLoad() {
this.getUserPoints(); this.getUserPoints();
this.handleGetUserDetail()
}, },
computed: {
onShow() { ...mapGetters({
user: "user",
}),
}, },
methods: { 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() { async getUserPoints() {
uni.showLoading({ uni.showLoading({
title: "获取积分中..." title: "获取积分中..."
@ -152,12 +230,9 @@ export default {
type: "encryption" type: "encryption"
} }
const data = await this.$api.$post('/MemberApi/ThirdInterface/GetYTSLMemberPoint', req) const data = await this.$api.$post('/MemberApi/ThirdInterface/GetYTSLMemberPoint', req)
console.log('datadatadatadata321', data);
uni.hideLoading() uni.hideLoading()
if (data.Result_Code === 100) { if (data.Result_Code === 100) {
let res = data.Result_Data this.userPoints = data.Result_Data.balance;
console.log('resresresres', res);
this.userPoints = res.balance
} else { } else {
uni.showToast({ uni.showToast({
title: data.Result_Desc, title: data.Result_Desc,
@ -166,73 +241,93 @@ export default {
} }
}, },
// //
handleCalculate(e) { handleCalculate(e) {
const value = e.detail.value; const value = e.detail.value;
if (value && !isNaN(value)) { if (value && !isNaN(value)) {
// 驿 this.destinationPointsOutput = Math.floor(Number(value) / this.exchangeRate);
this.platformPoints = Math.floor(Number(value) / this.exchangeRate);
} else { } else {
this.platformPoints = 0; this.destinationPointsOutput = 0;
} }
}, },
// //
handleExchange() { handleExchange() {
// if (!this.etcPoints || this.etcPoints <= 0) { uni.showToast({ title: '', icon: 'none' }); return; } if if (!this.sourcePointsInput) {
// (Number(this.etcPoints) > this.userPoints) { uni.showToast({
// uni.showToast({ title: '请输入要兑换的积分!',
// title: 'ETC', icon: 'none'
// icon: 'none' });
// }); return
// return; }
// }
if (this.etcPoints > this.userPoints) { if (this.sourcePointsInput > 0) {
} else {
uni.showToast({
title: '请输入要兑换的积分!',
icon: 'none'
});
return
}
if (this.conversionDirection === 'etcToPlatform') {
// ETC
if (this.sourcePointsInput > this.userPoints) {
uni.showToast({ uni.showToast({
title: 'ETC积分不足', title: 'ETC积分不足',
icon: 'none' icon: 'none'
}); });
return; return;
} }
} else {
// ETC
if (this.sourcePointsInput > this.platformUserPoints) {
uni.showToast({
title: '彩云驿积分不足',
icon: 'none'
});
return;
}
}
let _this = this
uni.showModal({ uni.showModal({
title: '确认兑换', title: '确认兑换',
content: `确定使用${this.etcPoints}个ETC积分兑换${this.platformPoints}个彩云驿积分吗?`, content: `确定使用${this.sourcePointsInput}${this.conversionDirection === 'etcToPlatform' ? 'ETC积分' : '彩云驿积分'}兑换${this.destinationPointsOutput}${this.conversionDirection === 'etcToPlatform' ? '彩云驿积分' : 'ETC积分'}吗?`,
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this.doExchange(); _this.doExchange()
} }
} }
}); });
}, },
//
async 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 = { const req = {
orderno: `535001-${time}-${new Date().getTime()}`, orderno: `535001-${new Date().getFullYear()}-${new Date().getTime()}`,
outUserId: this.user.MEMBERSHIP_ID, outUserId: this.user.MEMBERSHIP_ID,
changePoint: this.platformPoints, changePoint: this.conversionDirection === 'etcToPlatform' ? this.destinationPointsOutput : -this.destinationPointsOutput,
memo: "积分兑换", memo: "ETC积分兑换彩云驿积分",
type: "encryption" type: "encryption"
} }
console.log('reqreq', JSON.parse(JSON.stringify(req)));
const data = await this.$api.$post('/MemberApi/ThirdInterface/ChangeYTSLMemberPoint', req) const data = await this.$api.$post('/MemberApi/ThirdInterface/ChangeYTSLMemberPoint', req)
console.log('datadatadatadata321', data); uni.hideLoading();
if (data.Result_Code === 100) { if (data.Result_Code === 100) {
uni.showToast({ uni.showToast({
title: '兑换成功', title: '兑换成功',
icon: 'none' icon: 'none'
}); });
this.etcPoints = '' this.sourcePointsInput = '';
this.getUserPoints(); this.destinationPointsOutput = 0;
this.getUserPoints(); // ETC
this.handleGetUserDetail(); // 驿
} else { } else {
uni.showToast({ uni.showToast({
title: data.Result_Desc, title: data.Result_Desc,
@ -247,10 +342,6 @@ export default {
title: `查看${product.name}详情`, title: `查看${product.name}详情`,
icon: 'none' icon: 'none'
}); });
// TODO:
// uni.navigateTo({
// url: `/pages/productDetail/index?id=${product.id}`
// });
}, },
// //
@ -259,10 +350,6 @@ export default {
title: '查看更多商品', title: '查看更多商品',
icon: 'none' icon: 'none'
}); });
// TODO:
// uni.navigateTo({
// url: '/pages/productList/index'
// });
} }
} }
} }
@ -281,15 +368,17 @@ export default {
.pointsHeader { .pointsHeader {
width: 100%; width: 100%;
background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%); background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
padding: 60rpx 32rpx 80rpx; padding: 40rpx 32rpx 80rpx;
box-sizing: border-box; box-sizing: border-box;
.headerContent { .headerContent {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-around;
.pointsInfo { .pointsInfo {
text-align: center;
.pointsLabel { .pointsLabel {
font-size: 28rpx; font-size: 28rpx;
color: rgba(255, 255, 255, 0.8); color: rgba(255, 255, 255, 0.8);
@ -297,18 +386,12 @@ export default {
} }
.pointsValue { .pointsValue {
font-size: 72rpx; font-size: 60rpx;
font-weight: bold; font-weight: bold;
color: #FFFFFF; color: #FFFFFF;
line-height: 1; line-height: 1;
} }
} }
.headerIcon {
width: 120rpx;
height: 120rpx;
opacity: 0.3;
}
} }
} }
@ -326,7 +409,7 @@ export default {
font-size: 28rpx; font-size: 28rpx;
font-weight: 600; font-weight: 600;
color: #222222; color: #222222;
margin-bottom: 24rpx; margin-bottom: 32rpx;
} }
.exchangeContent { .exchangeContent {
@ -341,36 +424,51 @@ export default {
.inputField { .inputField {
width: 100%; width: 100%;
height: 68rpx; height: 80rpx;
background: #F7F8FA; background: #F7F8FA;
border-radius: 12rpx; border-radius: 12rpx;
padding: 0 24rpx; padding: 0 24rpx;
font-size: 28rpx; font-size: 32rpx;
color: #222222; color: #222222;
box-sizing: border-box; box-sizing: border-box;
} }
.balanceText {
font-size: 24rpx;
color: #999999;
margin-top: 12rpx;
text-align: right;
}
} }
.exchangeRate { .iconBox {
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
text-align: center; margin: 24rpx 0;
margin-bottom: 12rpx;
.exchangeIcon { &:active {
width: 48rpx; opacity: 0.7;
height: 48rpx; }
margin-right: 12rpx;
.exchangeTextIcon {
font-size: 56rpx;
// Adjust color to match existing design, or a neutral one
color: #667EEA;
font-weight: bold;
line-height: 1;
} }
.rateText { .rateText {
font-size: 24rpx; font-size: 24rpx;
color: #667EEA; color: #667EEA;
font-weight: 500; font-weight: 500;
margin-top: 8rpx;
} }
} }
.resultBox { .resultBox {
.resultLabel { .resultLabel {
font-size: 28rpx; font-size: 28rpx;
@ -380,11 +478,11 @@ export default {
.resultValue { .resultValue {
width: 100%; width: 100%;
height: 68rpx; height: 80rpx;
background: #F7F8FA; background: #F7F8FA;
border-radius: 12rpx; border-radius: 12rpx;
padding: 0 24rpx; padding: 0 24rpx;
font-size: 28rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
color: #667EEA; color: #667EEA;
display: flex; display: flex;
@ -396,13 +494,13 @@ export default {
.exchangeBtn { .exchangeBtn {
width: 100%; width: 100%;
height: 68rpx; height: 80rpx;
background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%); background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
border-radius: 12rpx; border-radius: 12rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 28rpx; font-size: 32rpx;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #FFFFFF;
margin-top: 40rpx; margin-top: 40rpx;
@ -429,12 +527,6 @@ export default {
font-weight: 600; font-weight: 600;
color: #222222; color: #222222;
margin-bottom: 24rpx; margin-bottom: 24rpx;
.titleIcon {
width: 40rpx;
height: 40rpx;
margin-right: 12rpx;
}
} }
.rulesList { .rulesList {

View File

@ -449,7 +449,7 @@ export default {
// //
this.handleGetYNUserInfo() // this.handleGetYNUserInfo()
// //

File diff suppressed because one or more lines are too long

View File

@ -302,7 +302,7 @@ var _default = {
// } // }
// 请求一下云南那边的积分信息 // 请求一下云南那边的积分信息
_this2.handleGetYNUserInfo(); // this.handleGetYNUserInfo()
// 拿到订单信息 // 拿到订单信息
// await this.handleGetOrderDetail() // await this.handleGetOrderDetail()
@ -340,7 +340,7 @@ var _default = {
_this2.$utils.addUserBehaviorNew({ _this2.$utils.addUserBehaviorNew({
behaviorRecordDesc: "进入了我的页面" behaviorRecordDesc: "进入了我的页面"
}); });
case 16: case 15:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }

View File

@ -8,6 +8,13 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "pages/user/index",
"pathName": "pages/user/index",
"query": "",
"scene": null,
"launchMode": "default"
},
{ {
"name": "pages/pointsRedemption/index", "name": "pages/pointsRedemption/index",
"pathName": "pages/pointsRedemption/index", "pathName": "pages/pointsRedemption/index",