parent
8e601e4735
commit
e0d6c2c19c
2 changed files with 171 additions and 2 deletions
@ -0,0 +1,149 @@ |
||||
<script setup> |
||||
import {ref, reactive, computed, watch, onMounted, onBeforeMount} from 'vue' |
||||
import {ec_api_set_user_data, ec_api_clear_user_data} from '@/apis/ec_api.js' |
||||
import {ElMessage} from "element-plus"; |
||||
|
||||
// 接收TabArea组件传递的参数 |
||||
const props = defineProps(['level', 'data', 'base_info']) |
||||
|
||||
// 定义用户选择的场次变量 |
||||
const selectLevel = ref('') |
||||
const levelList = reactive([]) |
||||
|
||||
// 处理用户选择的数据 |
||||
async function handle_set_user_data() { |
||||
let selectLevelData = {} |
||||
props.level.forEach((item) => { |
||||
if (item['levelId'] === selectLevel.value) { |
||||
selectLevelData = item |
||||
} |
||||
}) |
||||
const req_data = { |
||||
api: props.data.path, |
||||
member_type: props.data.type, |
||||
format: props.data.format, |
||||
user_data: JSON.stringify(selectLevelData), |
||||
env: props.base_info.env, |
||||
cid: props.base_info.cinema, |
||||
pid: props.base_info.channel, |
||||
} |
||||
console.log('handle_set_user_data', req_data) |
||||
await ec_api_set_user_data(req_data).then( |
||||
(req) => { |
||||
if (req['result'] === 'success') { |
||||
ElMessage({message: '选择的卡级别已做为后续测试数据!', type: 'success'}) |
||||
} else { |
||||
ElMessage({message: '设置用户选择卡级别数据失败!', type: 'error'}) |
||||
} |
||||
} |
||||
).catch( |
||||
(err) => { |
||||
console.log(err) |
||||
ElMessage({message: '设置用户选择卡级别数据失败!', type: 'error'}) |
||||
} |
||||
) |
||||
} |
||||
|
||||
async function handle_clear_user_data() { |
||||
const req_data = { |
||||
api: props.data.path, |
||||
member_type: props.data.type, |
||||
env: props.base_info.env, |
||||
cid: props.base_info.cinema, |
||||
pid: props.base_info.channel, |
||||
} |
||||
console.log('handle_clear_user_data', req_data) |
||||
await ec_api_clear_user_data(req_data).then( |
||||
(req) => { |
||||
if (req['result'] === 'success') { |
||||
ElMessage({message: '选择的联名卡级别已清除,推荐参数将使用随机值!', type: 'success'}) |
||||
} else { |
||||
ElMessage({message: '清除用户选择联名卡级别数据失败!', type: 'error'}) |
||||
} |
||||
} |
||||
).catch( |
||||
(err) => { |
||||
console.log(err) |
||||
ElMessage({message: '清除用户选择联名卡级别数据失败!', type: 'error'}) |
||||
} |
||||
) |
||||
} |
||||
|
||||
onBeforeMount(() => { |
||||
console.log('CardLevel onBeforeMount') |
||||
console.log(props.level) |
||||
// 挂载时生成用于展示的数据源 |
||||
props.level.forEach((item) => { |
||||
levelList.push({ |
||||
key: item['levelId'], |
||||
name: item['levelName'], |
||||
fee: item['initMoney'], |
||||
type: item['typeDesc'], |
||||
ticket_discount: `${item['ticketDiscount']}%`, |
||||
data: item |
||||
}) |
||||
}) |
||||
console.log(levelList) |
||||
}) |
||||
|
||||
|
||||
watch(() => selectLevel.value, () => { |
||||
console.log('selectLevel.value', selectLevel.value) |
||||
handle_set_user_data() |
||||
}) |
||||
|
||||
</script> |
||||
|
||||
<template> |
||||
<hr id="break_line"/> |
||||
<div style="font-size: 16px; font-weight: bold; color: #909399; text-align: left; margin-bottom: 10px">选择场次: |
||||
<el-tooltip |
||||
class="box-item" |
||||
effect="dark" |
||||
content="点击清除选择后会将后台服务器中记录的选择内容清空,其他接口将通过随机获取的方式从此接口返回的数据中模拟参数" |
||||
placement="right" |
||||
> |
||||
<el-button size="small" style="font-weight: bold;color: #909399" @click="handle_clear_user_data">清除选择 |
||||
</el-button> |
||||
</el-tooltip> |
||||
</div> |
||||
<el-form style="max-width: 600px; margin-left: 20px"> |
||||
<el-form-item> |
||||
<el-radio-group v-model="selectLevel"> |
||||
<el-radio-button v-for="s in levelList" :label="s.key" :value="s.key" :key="s.key"> |
||||
<div style="text-align: left"> |
||||
<div style="margin-top: 5px"><span>{{ s.key }}</span> -- <span style="font-weight: bold">{{ s.name }}</span> -- <span>{{s.type}}</span> |
||||
</div> |
||||
<div style="margin-top: 5px"><span>开卡费 {{ s.fee }} 元 </span><span>    {{s.renew}}</span></div> |
||||
</div> |
||||
</el-radio-button> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
</el-form> |
||||
</template> |
||||
|
||||
<style scoped> |
||||
#break_line { |
||||
margin-top: 30px; |
||||
margin-bottom: 30px; |
||||
background-color: rgba(144, 147, 153, 0.5); |
||||
height: 1px; |
||||
border: none |
||||
} |
||||
|
||||
:deep(.el-radio-button) { |
||||
margin-bottom: 10px; |
||||
margin-right: 15px; |
||||
|
||||
} |
||||
|
||||
:deep(.el-radio-button__inner) { |
||||
width: 400px; |
||||
height: 60px; |
||||
background: #ebebeb; |
||||
color: #333; |
||||
border: 0 !important; |
||||
border-radius: 10px !important; |
||||
} |
||||
|
||||
</style> |
Loading…
Reference in new issue