<!DOCTYPE html>
|
<html>
|
|
<head>
|
<title>抖音一元限时秒</title>
|
<meta charset="UTF-8" />
|
<meta name="viewport"
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
|
<link rel="stylesheet" href="https://cdn.staticfile.org/minireset.css/0.0.2/minireset.css" />
|
<link rel="stylesheet" href="https://at.alicdn.com/t/font_1534407_039yhnv7evxo.css" />
|
<script src="https://cdn.staticfile.org/promise-polyfill/8.2.0/polyfill.min.js"></script>
|
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
|
<script src="https://cdn.staticfile.org/vue/3.0.11/vue.global.js"></script>
|
<script src="https://cdn.staticfile.org/vant/3.2.4/vant.min.js"></script>
|
<script src="https://img.bc.haodanku.com/cms/SpaUtils.min.js"></script>
|
<script src="https://img.bc.haodanku.com/cdn/vant-touch-emulator.js"></script>
|
<link href="https://cdn.staticfile.org/vant/3.2.4/index.min.css" rel="stylesheet" />
|
<link rel="stylesheet" href="https://img.bc.haodanku.com/cdn/locss.css" />
|
<script src="https://img.bc.haodanku.com/cdn/tsUtils.js"></script>
|
<script type="text/javascript" src="https://img.ushopvip.com/js/uni-webview-js.js"></script>
|
<meta name="referrer" content="no-referrer" />
|
<script
|
defer>document.write('<link rel="stylesheet" href="https://img.bc.haodanku.com/cms/dy_onebuy.css?t=' + (Date.now() - Date.now() % (60 * 1000 * 30)) + '"/>');</script>
|
</head>
|
|
<body>
|
<template id="c-card">
|
<div class="card row _ flex-c">
|
<img class="cover" v-lazy="item.itempic" v-if="item.itempic" />
|
<img class="cover" src="http://img.bc.fqapps.com/fudai13cae4ae6ef16739ed3b100a2ec39e97.gif" alt="" v-else />
|
<div class="detail">
|
<div class="title _ ellipsis-2">
|
<img src="https://img.bc.haodanku.com/cms/1666250839"
|
style="display: inline-block;width: 0.28rem;height: 0.28rem;margin-bottom: -0.04rem;">
|
{{ item.itemshorttitle || item.itemtitle }}
|
</div>
|
<div class="shop-name _ flex-c">
|
<img class="icon" src="https://img.bc.haodanku.com/cms/1655963255" :alt="item.shop_name" />
|
<span class="value">{{ item.shop_name }}</span>
|
</div>
|
<div class="price">
|
<div class="end-price">
|
<div class="label">抢购价</div>
|
<div class="value">
|
¥<strong>{{ Number(item.itemendprice) }}</strong>
|
</div>
|
</div>
|
</div>
|
<div class="btn-block">
|
<div class="_ btn btn-order" v-on:click.capture="buy">
|
<span>立即抢购</span>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
<template id="c-share">
|
<div class="footer-share _ lr-c">
|
<div id="share_href" v-on:click="handleShare">
|
<div class="share-content _ flex-c">
|
<i>
|
<svg xmlns="http://www.w3.org/2000/svg" id="svg-icon" data-name="图层 1" viewBox="0 0 18 19.11">
|
<title>分享</title>
|
<path class="cls-1" d="M17.5,8A2.5,2.5,0,1,0,15,5.5,2.5,2.5,0,0,0,17.5,8Z" transform="translate(-3 -2)" />
|
<path class="cls-1" d="M6.5,14.5A2.5,2.5,0,1,0,4,12,2.5,2.5,0,0,0,6.5,14.5Z"
|
transform="translate(-3 -2)" />
|
<path class="cls-2" d="M15,6.79,8.67,10.62" transform="translate(-3 -2)" />
|
<path class="cls-2" d="M8.67,13.28,13.27,16" transform="translate(-3 -2)" />
|
<path class="cls-1" d="M15.77,15.11a2.5,2.5,0,1,1-2.5,2.5A2.5,2.5,0,0,1,15.77,15.11Z"
|
transform="translate(-3 -2)" />
|
</svg>
|
</i>
|
<span>分享好友</span>
|
</div>
|
</div>
|
</div>
|
</template>
|
<template id="category">
|
<div class="c-category" v-on:click.stop>
|
<div class="tab-wrapper _ flex-c">
|
<div class="tabs _ flex-1">
|
<van-tabs
|
class="scroll-nav"
|
v-model:active="activeValue"
|
ref="tabsRef"
|
@click-tab="onTabChange"
|
background="none"
|
:ellipsis="false"
|
>
|
<van-tab
|
v-for="item in list"
|
v-bind:key="item[valueKey]"
|
v-bind:name="item[valueKey]"
|
v-bind:title="item[labelKey]"
|
></van-tab>
|
</van-tabs>
|
</div>
|
<div class="_ btn show-more" @click="toggleCateAllVisible">
|
<i class="iconfont hdk-paixu2" :class="{open:allCateVisible}"></i>
|
</div>
|
</div>
|
|
<div class="cate-all" toggle-status="hide" ref="cateAllRef">
|
<ul>
|
<li
|
class="_ btn"
|
v-for="(item,index) in list"
|
v-bind:class="{active:activeValue === item[valueKey]}"
|
v-on:click="onCateChange(item,index)"
|
>
|
<div class="ellipsis-single">{{item[labelKey]}}</div>
|
</li>
|
</ul>
|
</div>
|
</div>
|
</template>
|
|
<div id="single-page-app" v-cloak>
|
<van-pull-refresh v-model="refreshing" @refresh="reGetListData">
|
<van-list class="page-container" v-bind:loading="listData.loading" v-bind:finished="listData.finished"
|
v-on:load="getListData">
|
<!-- 底部提示 -->
|
<template v-slot:finished v-if="listData.list.length"><span class="list-item-loading">-优惠到底啦-</span></template>
|
<template v-slot:loading><span class="list-item-loading">数据正在赶来的路上...</span></template>
|
<div class="banner-wrapper" ref="bannerRef">
|
<img class="free-banner" v-bind:src="banner" alt="" />
|
</div>
|
<van-sticky class="fixed-box">
|
<van-search v-model="searchValue" show-action placeholder="请输入搜索关键词/链接" @search="onSearch"
|
@clear="onSearchClear">
|
<template v-slot:action>
|
<div class="_ flex-c-c" @click="onSearch">搜索</div>
|
</template>
|
</van-search>
|
<category
|
class="category"
|
:list="category.list"
|
:url-param-key="cateKey"
|
v-model:value="category.value"
|
@change="onCateChange"
|
value-key="cat_id"
|
label-key="cat_name"
|
></category>
|
</van-sticky>
|
<div class="page-content" ref="list" v-bind:class="{'empty-list':!listData.list.length}">
|
<div class="lists" ref="listsRef" v-if="listData.list.length || listData.finished">
|
<card v-for="(item, index) in listData.list" v-bind:item="item" v-bind:key="item.itemid"
|
v-on:transfer="handleGoodsTransfer"></card>
|
</div>
|
<div class="empty" v-show="!listData.list.length && !loading && listData.finished">
|
<div class="empty-box">
|
<img src="http://img.bc.haodanku.com/cms/1627883509" />
|
<div class="text">暂无数据~</div>
|
</div>
|
</div>
|
</div>
|
</van-list>
|
</van-pull-refresh>
|
<div class="back-top-wrap max-width" v-movable>
|
<div class="_ btn back-top" v-on:click="backTop" v-bind:class="{hide: scrollTop < 600}"></div>
|
</div>
|
<a class="back-link" v-if="fromLink" :href="fromLink"><i class="iconfont hdk-xiangyou"></i></a>
|
<share v-on:share="handleShare" v-bind:class="{hide:isScrollToDown}"></share>
|
<van-overlay v-bind:show="loading">
|
<van-loading color="#0094ff"></van-loading>
|
</van-overlay>
|
</div>
|
<script>
|
function useBase() {
|
const listDataStr = JSON.stringify({
|
list: [],
|
loading: false,
|
finished: false,
|
min_id: 1,
|
pageTotal: 1,
|
pageCurrent: 0,
|
});
|
|
const scrollTop = Vue.ref(0);
|
const listData = Vue.reactive(JSON.parse(listDataStr));
|
|
// 根据微信浏览器缩放比例设置rem缩放
|
if (SpaUtils.inWechat() && "ontouchstart" in window) {
|
const scale = SpaUtils.getFontScale(true);
|
document.documentElement.style.fontSize =
|
"calc(13.33333vw * " + scale + ")";
|
}
|
|
return {
|
listDataStr,
|
data: {
|
scrollTop,
|
listData,
|
},
|
useScrollEndMounted(onScrollEnd, onNotScrollEnd) {
|
Vue.onMounted(function () {
|
window.addEventListener("scroll", function (ev) {
|
scrollTop.value =
|
document.documentElement.scrollTop || document.body.scrollTop;
|
if (SpaUtils.isScrollEnd(this, "vertical", 40)) {
|
onScrollEnd && onScrollEnd();
|
} else {
|
onNotScrollEnd && onNotScrollEnd();
|
}
|
});
|
});
|
},
|
methods: {
|
backTop() {
|
$("html,body").animate({ scrollTop: 0 });
|
},
|
onScrollEnd() {
|
this.getListData();
|
},
|
handleShare() {
|
SpaUtils.copy(location.href, "复制成功,分享给身边好友吧~");
|
},
|
resetListData(isCleanList = true) {
|
Object.assign(
|
listData,
|
JSON.parse(listDataStr),
|
isCleanList ? undefined : { list: listData.list }
|
);
|
},
|
},
|
};
|
}
|
const Category = {
|
template: "#category",
|
props: {
|
list: {
|
type: Array,
|
required: true,
|
},
|
value: {
|
type: [String, Number],
|
required: true,
|
},
|
valueKey: {
|
type: String,
|
default: "value",
|
},
|
labelKey: {
|
type: String,
|
default: "label",
|
},
|
urlParamKey: {
|
type: String,
|
default: "",
|
},
|
},
|
emits: ["change", "update:value"],
|
setup(props, ctx) {
|
const propsRefs = Vue.toRefs(props);
|
const data = {
|
allCateVisible: Vue.ref(false),
|
activeValue: Vue.ref(""),
|
cateAllRef: Vue.ref(),
|
};
|
const methods = {
|
onTabChange() {
|
methods.closeAll();
|
Vue.nextTick(() => {
|
if (data.activeValue.value === props.value) return;
|
methods.emit(data.activeValue.value);
|
});
|
},
|
emit(value) {
|
if (props.urlParamKey) {
|
SpaUtils.historyReplaceState({
|
[props.urlParamKey]: data.activeValue.value,
|
});
|
}
|
ctx.emit("update:value", value);
|
ctx.emit("change", value);
|
},
|
onCateChange(item) {
|
methods.closeAll();
|
const value = item[props.valueKey];
|
data.activeValue.value = value;
|
methods.emit(value);
|
},
|
isHideAll() {
|
return (
|
data.cateAllRef.value.getAttribute("toggle-status") === "hide"
|
);
|
},
|
closeAll() {
|
data.allCateVisible.value = false;
|
!methods.isHideAll() && methods.toggleHeight();
|
},
|
showAll() {
|
data.allCateVisible.value = true;
|
methods.isHideAll() && methods.toggleHeight();
|
},
|
|
toggleHeight() {
|
tsUtils.toggleWidthOrHeight(data.cateAllRef.value, "height", {
|
duration: "300ms",
|
});
|
},
|
toggleCateAllVisible() {
|
data.allCateVisible.value = !data.allCateVisible.value;
|
methods.toggleHeight();
|
},
|
};
|
(function () {
|
Vue.onMounted(() => {
|
data.activeValue.value = props.value;
|
window.addEventListener("click", function () {
|
methods.closeAll();
|
});
|
});
|
|
Vue.watch(
|
propsRefs.value,
|
(n) => {
|
data.activeValue.value = n;
|
},
|
{ immediate: true }
|
);
|
})();
|
return { ...data, ...methods };
|
},
|
};
|
function getComponents() {
|
const Card = Vue.defineComponent({
|
template: "#c-card",
|
props: {
|
item: Object,
|
},
|
emits: ["transfer"],
|
setup(props, ctx) {
|
return {
|
buy(e, type = "buy") {
|
ctx.emit("transfer", { e, item: props.item, type });
|
},
|
getMoneyStr: SpaUtils.numWan,
|
};
|
},
|
});
|
const Share = Vue.defineComponent({
|
template: "#c-share",
|
emits: ["show-directer"],
|
setup(props, ctx) {
|
return {
|
handleShare() {
|
ctx.emit("share");
|
},
|
showDirecter() {
|
ctx.emit("show-directer");
|
},
|
};
|
},
|
});
|
return { card: Card, share: Share, category: Category };
|
}
|
</script>
|
<script>
|
window.onload = function () {
|
const stamp = Date.now() - (Date.now() % (60 * 1000 * 30));
|
const app = Vue.createApp({
|
name: "App",
|
directives: {
|
movable: SpaUtils.movable,
|
},
|
components: getComponents(),
|
setup() {
|
const cateKey = "ds_cate_id";
|
const {
|
data: baseData,
|
methods: baseMethods,
|
useScrollEndMounted,
|
} = useBase();
|
const customParams = useCustomParams();
|
const data = {
|
...baseData,
|
cateKey,
|
banner: "https://img.bc.haodanku.com/cms/1666341435?t=" + stamp,
|
top: 0,
|
loading: Vue.ref(true),
|
refreshing: Vue.ref(false),
|
isScrollToDown: Vue.ref(false),
|
searchValue: Vue.ref(""),
|
category: Vue.reactive({
|
list: [],
|
value: SpaUtils.parseSearch()[cateKey] || "",
|
}),
|
fromLink: decodeURIComponent(SpaUtils.parseSearch().from || ""),
|
...customParams,
|
};
|
const methods = {
|
...baseMethods,
|
backTop() {
|
$("html,body").animate({ scrollTop: 0 });
|
},
|
backTopAndReGetListData() {
|
methods.resetListData(false);
|
methods.backTop();
|
return methods.getListData(true);
|
},
|
reGetListData() {
|
methods.resetListData(false);
|
return methods.getListData(true);
|
},
|
onSearch() {
|
// 将默认选择第一个分类
|
if (data.category.list.length > 0) {
|
data.category.value = data.category.list[0].cat_id;
|
}
|
methods.backTopAndReGetListData();
|
},
|
onSearchClear() {
|
data.searchValue.value = "";
|
methods.backTopAndReGetListData();
|
},
|
onCateChange() {
|
// 清空搜索栏
|
data.searchValue.value = ""
|
SpaUtils.historyReplaceState({
|
[cateKey]: data.category.value,
|
});
|
methods.backTopAndReGetListData();
|
},
|
async getCategory() {
|
const url = "https://v2.api.haodanku.com/category_list";
|
const res = await SpaUtils.Request.get(url, {
|
type: 13,
|
is_has: 1,
|
}).promise;
|
const cateIdKey = "cat_id";
|
const cateList = res.data || [];
|
if (!cateList.length) return;
|
cateList.forEach((i) => (i[cateIdKey] = String(i[cateIdKey])));
|
const firstId = cateList[0][cateIdKey];
|
let cate = SpaUtils.parseSearch()[cateKey] || firstId;
|
const find = cateList.find((i) => cate === i[cateIdKey]);
|
if (!find) {
|
cate = firstId;
|
SpaUtils.historyReplaceState({ [cateKey]: cate });
|
}
|
data.loading.value = false;
|
data.category.list = cateList;
|
data.category.value = cate;
|
methods.reGetListData();
|
},
|
async getListData(clean) {
|
const loading = data.loading;
|
const listData = data.listData;
|
if (loading.value || listData.loading || listData.finished)
|
return;
|
listData.loading = true;
|
if (clean) {
|
loading.value = true;
|
}
|
try {
|
const min_size = 10;
|
const param = {
|
...customParams.getListDataParams(),
|
keyword: data.searchValue.value,
|
cate_id: data.category.value,
|
min_id: data.listData.min_id,
|
back: min_size,
|
};
|
const url =
|
"https://v3.api.haodanku.com/dy_onebuy";
|
const res = await SpaUtils.Request.get(url, param).promise;
|
const list = res.data || [];
|
|
setTimeout(() => {
|
listData.list = clean ? list : listData.list.concat(list);
|
listData.finished =
|
listData.min_id == res.min_id ||
|
!list.length ||
|
list.length < min_size;
|
listData.min_id = res.min_id || listData.min_id;
|
}, 200);
|
return res;
|
} catch (e) {
|
listData.list = [];
|
listData.finished = true;
|
} finally {
|
setTimeout(() => {
|
listData.loading = false;
|
loading.value = false;
|
data.refreshing.value = false;
|
}, 200);
|
}
|
},
|
/**
|
* 商品转链
|
* @param e {MouseEvent}
|
* @param item
|
*/
|
async handleGoodsTransfer({ e, item }) {
|
const param = {
|
itemid: item.product_id,
|
...customParams.getTransferParams(),
|
};
|
|
try {
|
const params = {
|
// sync: true,
|
platformType: "dy",
|
itemData: item,
|
url: "https://v2.api.haodanku.com/get_dyitem_link",
|
el: e.target,
|
data: param,
|
copySuccessMsg: "复制抖口令成功,请打开抖音APP下单",
|
getCopyTarget(res) {
|
return res.data.dy_password;
|
},
|
};
|
await SpaUtils.conversionLink(params);
|
} catch (e) {
|
SpaUtils.toast(e.msg || "转链失败");
|
}
|
},
|
};
|
|
function init() {
|
methods.getCategory();
|
useScrollEndMounted();
|
Vue.watch(baseData.scrollTop, (n, o) => {
|
data.isScrollToDown.value = n > o;
|
});
|
}
|
|
init();
|
return { ...data, ...methods };
|
},
|
});
|
app.use(vant);
|
app.use(vant.Lazyload, {
|
lazyComponent: true,
|
preLoad: 1.3,
|
error: "http://img.bc.haodanku.com/haodanku/1595237918",
|
loading:
|
"http://img.bc.fqapps.com/fudai13cae4ae6ef16739ed3b100a2ec39e97.gif",
|
attempt: 1,
|
});
|
app.mount("#single-page-app");
|
};
|
</script>
|
<script>
|
function useCustomParams() {
|
const customParams = {
|
apikey: "0F92EBA7AADA", //必填
|
channel: "", //选填
|
};
|
return {
|
customParams,
|
// 获取列表数据参数
|
getListDataParams() {
|
return { apikey: customParams.apikey };
|
},
|
// 转链参数
|
getTransferParams(item) {
|
return { ...customParams };
|
},
|
};
|
}
|
</script>
|
</body>
|
|
</html>
|