mobileclient/packkey-back/demo/goods-exchange.html

264 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<!-- A11Y注意设置页面的 lang 属性 -->
<html lang="zh">
<head>
<meta charset="utf-8" />
<!-- A11Y打开页面时屏幕阅读器会首先阅读 title 的内容,确保 title 准确描述页面 -->
<title>兑换详情</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no, email=no" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<!-- A11Y如果有无障碍方面的需求建议使用下面的 viewport 设置,不要禁止页面缩放 -->
<!--<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />-->
<script>
var docEl = document.documentElement;
docEl.style.fontSize = 100 / 375 * docEl.clientWidth + 'px';
window.addEventListener('resize', function () {
docEl.style.fontSize = 100 / 375 * docEl.clientWidth + 'px';
});
</script>
<link rel="stylesheet"
href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/libs/antui/swiper.min.css">
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/libs/antui/swiper.min.js"></script>
<link rel="stylesheet"
href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/libs/antui/antui-all.css" />
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/libs/antui/antui.js"></script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/libs/vue.global.js"></script>
<script type="text/javascript" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322">
</script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js"></script>
<link rel="stylesheet" href="./style.css">
</head>
<body ontouchstart="">
<div id="app">
<!-- 轮播 -->
<div class="swiper-container am-carousel demo-swiper" id="J-swiper">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="item in state.describeUrl">
<img :src="item" alt="">
</div>
</div>
<div class="swiper-pagination"></div>
</div>
<!-- 直充 -->
<div class="main" v-if="state.goodsType === 1">
<div class="main-input">
<div class="input-style">
<span>账 号:</span>
<input type="text" :placeholder="state.placeholder" style="padding-left: 0.42rem;"
v-model="state.account" @input="inputChange" :maxlength="state.maxLen">
</div>
<div class="input-style">
<span>再次输入:</span>
<input type="text" :placeholder="state.placeholder" style="padding-left: 0.15rem;"
v-model="state.reAccount" @input="inputChange" :maxlength="state.maxLen">
</div>
</div>
</div>
<!-- 说明 -->
<div class="use-mark">
<img :src="state.useMarkUrl" alt="">
</div>
<!-- 底部 -->
<footer class="footer">
<button type="button" class="footer-btn" :disabled="state.isDisabled" @click="submitBtn">立即兑换</button>
</footer>
<div class="am-toast text" v-show="state.showToast">
<div class="am-toast-text">
{{state.toastTip}}
</div>
</div>
</div>
</body>
<script>
// 获取 包码结算数据
const bm_obj_data = sessionStorage.getItem("bm_auth") ? JSON.parse(sessionStorage.getItem("bm_auth")) : null;
const { createApp, ref, reactive, onMounted } = Vue;
createApp({
setup() {
const state = reactive({
goodsInfo: {}, // 商品数据
goodsType: 1, // 1直充 2卡密 0无
describeUrl: [], // 商品列表图片
useMarkUrl: "",
placeholder: "",
maxLen: 50,
isDisabled: false,
account: "",
reAccount: "",
bmAuth: {},
toastTip: "",
showToast: false
})
onMounted(() => {
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 5) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
// 1.获取 商品数据
let goodsInfo = JSON.parse(sessionStorage.getItem("bm_goodsInfo"));
state.goodsInfo = goodsInfo;
state.describeUrl = goodsInfo.entity.describe_url;
state.useMarkUrl = goodsInfo.entity.detail_url;
// 2.判断商品类型 1直充 2卡密 0无
state.goodsType = goodsInfo.entity.product_type;
state.isDisabled = goodsInfo.entity.product_type === 1 ? true : false;
// 3.input placeholder
findPlaceholderText(goodsInfo.entity.account_type);
// 4.授权
let bm_data = sessionStorage.getItem("bm_auth");
if (bm_data) {
state.bmAuth = JSON.parse(bm_data)
}
// swiper
const swiper = new Swiper('.swiper', {
loop: true,
pagination: {
el: '.swiper-pagination',
}
});
})
const openToast = (msg) => {
if (state.showToast) return
state.toastTip = msg;
state.showToast = true;
setTimeout(() => {
state.showToast = false;
}, 1500);
}
const findPlaceholderText = (accountType) => {
if (accountType == 0) {
state.placeholder = "请输入账号";
} else if (accountType == 1) {
state.placeholder = "请输入手机号";
state.maxLen = 11;
} else if (accountType == 2) {
state.placeholder = "请输入邮箱";
} else if (accountType == 3) {
state.placeholder = "请输入手机号或邮箱";
} else if (accountType == 4) {
state.placeholder = "请输入QQ号";
state.maxLen = 10;
} else if (accountType == 5) {
state.placeholder = "请输入手机号或QQ号";
state.maxLen = 11;
} else if (accountType == 6) {
state.placeholder = "请输入邮箱或QQ号";
} else if (accountType == 7) {
state.placeholder = "请输入手机号/邮箱/QQ号";
} else if (accountType == 8) {
state.placeholder = "请输入微信号";
state.maxLen = 20;
} else if (accountType == 9) {
state.placeholder = "请输入手机号或微信";
state.maxLen = 20;
} else if (accountType == 10) {
state.placeholder = "请输入邮箱或微信号";
} else if (accountType == 11) {
state.placeholder = "请输入手机号/邮箱/微信号";
} else if (accountType == 12) {
state.placeholder = "请输入QQ号或微信号";
state.maxLen = 20;
} else if (accountType == 13) {
state.placeholder = "请输入手机号/QQ号/微信号";
state.maxLen = 20;
} else if (accountType == 14) {
state.placeholder = "请输入邮箱/QQ号/微信号";
} else if (accountType == 99) {
state.placeholder = "请输入昵称";
} else {
state.placeholder = "请输入手机号/邮箱/QQ号/微信号";
}
}
const inputChange = (e) => {
if (state.account !== "" && state.reAccount !== "" && state.account === state.reAccount) {
state.isDisabled = false;
} else {
state.isDisabled = true;
}
}
// 提交
const submitBtn = () => {
state.isDisabled = true;
setTimeout(() => {
state.isDisabled = false;
}, 300);
let params = {
goods_id: state.goodsInfo.entity.goods_id,
account: state.account,
code_batch_id: state.goodsInfo.code_batch_id,
key: state.goodsInfo.key,
token: state.bmAuth.token
};
req.axiosPost('/key/usage', params).then(res => {
// 使用结算7
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 6) {
if (state.goodsInfo.product_type !== 2) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_type);
}
}
if (res.code === 200) {
sessionStorage.setItem('orderNumber', res.data.order_number);
/* product_type:2 卡密
* card_show:2 线上查看卡密信息
* backAble是否多个商品
*/
const clr = setTimeout(() => {
state.account = "";
state.reAccount = "";
if (state.goodsInfo.product_type === 2) {
window.location.href = '../orderDetails/cardOrder.html';
} else {
window.location.href = '../orderDetails/chargerOrder.html';
}
clearTimeout(clr);
}, 1000);
} else {
openToast(res.message);
if (res.code == 403) {
/*跳转起始页面*/
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, 3000);
}
}
})
}
return {
state,
submitBtn,
inputChange
}
}
}).mount('#app')
</script>
</html>