oil-station/gasStation-uni/pagesHome/PointsRedemption/details.vue
2024-09-26 13:45:57 +08:00

264 lines
6.2 KiB
Vue

<template>
<view class="centenr">
<view class="Candywrapper">
<view class="bai-bs">
<view class="">
<image v-if="giftInfo.coverImage" :src="baseUrl+giftInfo.coverImage" mode="aspectFit"
style="width: 60px; height: 60px; "></image>
<image v-else src="../../static/logo.png" style="width: 60px; height: 60px; "></image>
</view>
<view class="rr-box">
<view class="title_">{{giftInfo.giftName}}</view>
<view style="font-size: 12px;color: #666666;">{{giftInfo.goodsName || ''}}</view>
<view style="width: 100%;display: flex;justify-content: space-between; ">
<view class="red-size">{{giftInfo.giftType}}</view>
<view class="red-size">剩余3张</view>
</view>
</view>
</view>
<view class="bai-bs">
<view class="title_">兑换数量</view>
<u-number-box v-model="value" @change="valChange"></u-number-box>
</view>
<view class="bai-box">
<view class="title_">兑换内容</view>
<view class="si_">{{giftInfo.exchangeInstructions || '--'}}</view>
</view>
<view class="bai-box">
<view class="title_">使用须知</view>
<view class="si_">{{giftInfo.useInstructions || '--'}}</view>
</view>
<view class="bai-box">
<view class="title_">兑换方式</view>
<view class="si_">{{giftInfo.exchangeMethod || '--'}}</view>
</view>
<view class="bai-box">
<view style="width: 100%; display: flex;align-items: center;justify-content: space-between; ">
<view class="title_">适用门店</view>
<view class="d-s" style="font-size: 14px;color: #FF2828;" @click="goGoGo()">
<image src="../../static/icon/reddh.png" style="width: 18px; height: 18px; "></image>
导航
</view>
</view>
<view class="si">{{store.name}}</view>
<view class="si">{{store.address}} | {{distance}}km</view>
</view>
</view>
<view class="bottom-box">
<view class="or-num">
<span v-if="giftInfo.exchangeMethod == '积分' || giftInfo.exchangeMethod == '积分+金额'
|| giftInfo.exchangeMethod == '积分+加钱购'">{{giftInfo.exchangePoints}}积分</span>
<span v-if="giftInfo.exchangeMethod == '积分+金额'">+</span>
<span
v-if="giftInfo.exchangeMethod == '金额' || giftInfo.exchangeMethod == '积分+金额'">¥{{giftInfo.exchangeAmount}}</span>
</view>
<view class="anniu">立即兑换</view>
</view>
</view>
</template>
<script>
import config from '@/config'
import request from '../../utils/request'
export default {
data() {
return {
baseUrl: config.baseUrl,
value: 0,
giftId: '',
giftInfo: {},
AppToken: uni.getStorageSync("App-Token"),
// 当前经度信息
longitude: "",
// 当前纬度信息
latitude: "",
// 店铺经度信息
lon: "",
// 店铺纬度信息
lat: "",
// 店铺信息
store: {
name: "测试油站",
description: "济南分店",
address: "济南槐荫区"
},
distance: 0,
}
},
onLoad(e) {
this.giftId = e.giftId
this.getInfo()
this.getAddress(uni.getStorageSync("storeId"))
},
methods: {
goGoGo() {
let lat = Number(this.lat)
let lon = Number(this.lon)
uni.openLocation({
latitude: lat,
longitude: lon,
name: this.store.name,
address: this.store.address,
success: function() {
console.log('success');
},
complete: function(res) {
console.log(res);
}
});
},
// 获取当前位置
getAddress(storeId) {
let _this = this;
uni.getLocation({
// 谷歌使用wgs84 其他使用gcj02
type: 'gcj02', // 使用国测局坐标系
success: function(res) {
if (_this.longitude == "" && _this.latitude == "") {
_this.longitude = res.longitude;
_this.latitude = res.latitude
}
console.log('经度: ' + _this.longitude);
console.log('纬度: ' + _this.latitude);
request({
url: 'business/storeInformation/store/recentlyStore',
method: 'post',
data: {
"lon": _this.longitude,
"lat": _this.latitude,
"storeId": storeId,
"isLogin": _this.AppToken ? "0" : "1", // 0为登录
},
}).then((response) => {
if (response.data.store) {
_this.distance = (Math.ceil(response.data.distance))
.toFixed(1)
_this.store = response.data.store
_this.lon = _this.store.longitude
_this.lat = _this.store.latitude
console.log(_this.store, 129);
} else {
uni.showToast({
title: "当前店铺已关闭!!!",
icon: "none"
})
}
}).catch(err => {})
},
fail: function(err) {
console.log('获取位置信息失败: ' + err.errMsg);
}
});
},
getInfo() {
request({
url: '/business/integral/integralGift/' + this.giftId,
method: 'get',
}).then(res => {
if (res.code == 200) {
this.giftInfo = res.data
}
})
},
valChange(e) {
console.log('当前值为: ' + e.value)
}
}
}
</script>
<style scoped lang="scss">
.centenr {
width: 100%;
height: 100vh;
background: #F9F9F9;
}
.Candywrapper {
background: #F9F9F9;
box-sizing: border-box;
padding: 10px;
}
.bottom-box {
width: 100%;
background: #fff;
box-sizing: border-box;
padding: 15px 10px;
display: flex;
align-items: center;
justify-content: space-between;
position: fixed;
left: 0px;
bottom: 0px;
}
.or-num {
font-weight: 600;
font-size: 20px;
color: #FA6400;
}
.bai-box {
background-color: #fff;
box-sizing: border-box;
padding: 10px;
width: 100%;
margin: 10px auto;
}
.bai-bs {
background-color: #fff;
box-sizing: border-box;
padding: 10px;
width: 100%;
margin: 10px auto;
display: flex;
align-items: center;
justify-content: space-between;
}
.title_ {
font-weight: 600;
font-size: 16px;
margin-bottom: 5px;
}
.anniu {
width: 90px;
height: 30px;
background: #FA6400;
border-radius: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
}
.rr-box {
width: 80%;
}
.red-size {
font-size: 12px;
color: #E02020;
}
.si_ {
font-size: 14px;
color: #333333;
}
.d-s {
display: flex;
align-items: center;
}
</style>