Files
g.hnyhua.cn/Mtxfw.VipSite/mobile/yydd_lqcp.html
2026-02-07 15:48:27 +08:00

621 lines
24 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>领取产品</title>
<link rel="stylesheet" type="text/css" href="/css/api.css" />
<link rel="stylesheet" type="text/css" href="/css/content.css" />
<script type="text/javascript" src="/scripts/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.cookie.min.js"></script>
<!--<script type="text/javascript" src="/scripts/iscroll.js"></script>-->
<script type="text/javascript" src="/script/main.js?t=0"></script>
<script type="text/javascript" src="/layer/layer.js"></script>
<script type="text/javascript" src="/Scripts/long.js"></script>
<script type="text/javascript" src="/script/moment.js"></script>
<script type="text/javascript" src="/script/area.js?t=0"></script>
<script type="text/javascript" src="/script/api.js"></script>
<style type="text/css">
html, body {
overflow: hidden;
}
#wrapper {
flex: 1;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.pullDown {
position: absolute;
top: -1.25rem;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
display: none;
}
.pullUp {
position: absolute;
bottom: -1.25rem;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
display: none;
}
.pullDown.loading, .pullUp.loading, .pullDown.refresh, .pullUp.refresh {
display: block;
}
.dbtnbox {
margin: 0 auto;
width: 100%;
text-align: center;
padding: 0;
box-sizing: border-box;
}
.dbtnbox input[type='button'] {
height: 3.5em;
line-height: 3.5em;
border-radius: 0;
}
.uploadpic_btn {
position: absolute;
width: 5em;
height: 5em;
right: 0;
top: 0;
opacity: 0;
filter: alpha(opacity=0);
}
</style>
<script type="text/javascript">
var userId = null;
var LoginId = null;
var CartId = null;
var opentimes = null;
var products = null;
var guiges = null;
var showpics = null;
var showpic = "";
var yshowpic = "";
var id = 0, viewId = 0;
var myScroll = null;
var pullDown = 1; // 下拉刷新避免多次执行
var pullUp = 1; // 上拉加载避免多次执行
var downHeight = 0;
var upHeight = 0;
var isload = true;//设置是否终止滚动加载
var curScrollHeight = 0;//当前滚动位置
var curCount = 1;//计数器,防止滚动时重复执行加载下一页
$(document).ready(function () {
userId = getlocalStorage("userId");
LoginId = getlocalStorage("LoginId");
CartId = getlocalStorage("CartId");
var dParam = $.getUrlParam("id");
if (dParam != null) {
id = dParam;
}
rdata(1);
});
function onScroll() {
if (myScroll != null) {
myScroll.destroy();
myScroll = null;
}
myScroll = new IScroll('#wrapper', {
probeType: 2,
fadeScrollbars: false
});
myScroll.on('scroll', function () {
var y = myScroll.y;
downHeight = $(".pullDown").height();
upHeight = $(".pullUp").height();
// 下拉加载
if (y >= downHeight && pullDown) {
$(".pullDown").addClass("refresh").html("松开刷新...");
myScroll.minScrollY = downHeight;
pullDown = 0;
}
if (y <= downHeight && y >= 0 && !pullDown) {
$(".pullDown").removeClass("refresh").html("下拉刷新...");
pullDown = 1;
myScroll.minScrollY = 0;
}
// 上拉刷新
var maxHeight = myScroll.maxScrollY;
if (y < (maxHeight - upHeight) && pullUp) {
$(".pullUp").addClass("loading").html("松开加载...");
myScroll.maxScrollY = maxHeight - upHeight;
pullUp = 0;
}
if (y > maxHeight && y < (maxHeight + upHeight) && !pullUp) {
$(".pullUp").removeClass("loading").html("上拉加载...");
myScroll.maxScrollY = maxHeight + upHeight;
pullUp = 1;
}
});
myScroll.on('scrollEnd', function () {
if ($(".pullDown").hasClass("refresh")) {
$(".pullDown").text("正在刷新...");
opentimes = setTimeout(function () {
clearInterval(opentimes);
rdata();
$(".pullDown").removeClass("refresh").html("下拉刷新...");
pullDown = 1;
myScroll.refresh();
}, 2000);
}
});
myScroll.on('refresh', function () {
$(".pullUp").removeClass("loading").html("上拉加载...");
pullUp = 1;
});
}
function onScroll0() {
isload = true;//设置是否终止滚动加载
curScrollHeight = 0;//当前滚动位置
curCount = 1;//计数器,防止滚动时重复执行加载下一页
$("#wrapper").scroll(function () {
var pageHeight = $("#sysnew").height();
var showHeight = $("#wrapper").height();
var scrollHeight = $("#wrapper").scrollTop();
if (curScrollHeight - scrollHeight < 10 && curScrollHeight > 0) {
if (curCount == 1 && isload) {
rdata(0);
}
curCount++; //加载下一页后计数器+1
}
if (curScrollHeight < scrollHeight) {
curScrollHeight = pageHeight - showHeight;//滚动到页面底部时,重设当前滚动位置
curCount = 1;
}
});
}
function rdata(ag) {
userId = getlocalStorage("userId");
LoginId = getlocalStorage("LoginId");
var Start = $("#sysnew .databox").length;
if (ag == 1) {
Start = 0;
}
$(".ajaxLoader").removeClass("uhide");
$.ajax({
type: 'GET',
url: "/apiajax.ashx",
data: "&action=gettihuosp&ifweb=1&Start=" + Start + "&userId=" + (userId != null ? userId : "") + "&LoginId=" + (LoginId != null ? LoginId : ""),
dataType: "JSON",
error: function (xhr, type) {
tishi3("发生错误:" + JSON.stringify(xhr));
},
success: function (data) {
if (data) {
if (data.status == 1) {
products = data.productlist;
var html = "";
if (data.productlist.length > 0) {
var html = "";
for (i = 0; i < data.productlist.length; i++) {
var bifshow = 0;
if (ag == 0) {
if ($("#databox_" + data.productlist[i].id).length == 0) {
bifshow = 1;
}
} else {
bifshow = 1;
}
if (bifshow == 1) {
html += addMsg(data.productlist[i], i);
}
}
if (ag == 1 || ag == 2) {
$("#sysnew").html(html);
if (ag == 1) {
onScroll0();
}
} else {
$("#sysnew").append(html);
}
$(".more_box").html("");
} else {
if (Start > 0) {
if (Start > 10) {
$(".more_box").html("亲!找不到更多了");
}
} else {
$('#sysnew').html("");
$(".more_box").html("亲,暂无信息!");
}
}
$(".ajaxLoader").addClass("uhide");
} else {
tishi3(data.msg);
$(".ajaxLoader").addClass("uhide");
if (data.msg == "您未登录") {
$api.rmStorage("userId");
$api.rmStorage("LoginId");
onlink("/");
}
}
} else {
tishi3("网络错误!");
$(".ajaxLoader").addClass("uhide");
}
}
});
}
function addMsg(param, i) {
var html = '<div class="products_item" onclick="ondetail(' + param._id + ',' + i + ')">';
html += '<div class="products_image"><img src="' + param.image + '" /></div>';
html += '<div class="products_title">';
html += '<div>' + param.name + '</div>';
html += '<div class="right">零售价:<span>¥' + param.scje + '</span></div>';
html += '</div>';
html += '<div class="products_hyje">';
html += '<div class="right">会员价:<span>0元领取</span></div>';
html += '</div>';
html += '<div class="products_button" onclick="stopPropagation(event)">';
html += '<div class="gm" onclick="ondetail(' + param._id + ',' + i + ',\'' + param.image + '\')"><div><div>立即领取</div><img src="../image/addcart.png" /></div></div>';
html += '</div>';
html += '</div>';
return html;
}
function ondetail(id, j, image) {
viewId = id;
showpic = image;
yshowpic = image;
$(".select_box_pic").html("<img src=\"" + yshowpic + "\" />");
var zkc = 0;
guiges = products[j].guige;
if (guiges.length > 0) {
var html = '';
for (var i = 0; i < guiges.length; i++) {
if (guiges[i].kc > 0) {
zkc += parseInt(guiges[i].kc);
}
html += '<div class="selguige_item ' + (guiges[i].selectednum > 0 ? 'hover' : '') + '" id="selguige_item_' + i + '">';
html += '<div class="select_name">' + guiges[i].gg + '</div>';//<div>¥'+ guiges[i].jg + '</div>
if (guiges[i].colors.length > 0) {
html += '<div class="select_colors" onclick="showcolor(' + i + ')">';
html += '<div>选择颜色</div>';
html += '</div>';
}
html += '<div class="select_box_selnum">';
html += '<div class="select_box_selnum_box">';
html += '<div class="num">数量</div>';
html += '<div class="addcart_input">';
html += '<span class="num_del" onclick="decrement(' + i + ')" ></span>';
html += '<input name="product_amount" id="product_amount" type="text" class="input_text" onbur="inputOnlyNum(' + i + ')" value="' + guiges[i].selectednum + '"/>';
html += '<span class="num_add" onclick="increment(' + i + ')"></span>';
html += '</div>';
html += '</div>';
html += '<div class="productkc">库存:<span>' + guiges[i].kc + '</span></div>';
html += '</div>';
html += '</div>';
}
$(".select_box_bg").css("display", "block");
$("#guiges").html(html);
}
}
function stopPropagation(e) {
if (e.stopPropagation)
e.stopPropagation();
else
e.cancelBubble = true;
}
function onselectout(event) {
if ($(".select_box_bg").css("display") != "none") {
$(".select_box_bg").css("display", "none");
//$("body").css("overflow-y","auto");
}
}
function closeselect() {
$(".select_box_bg").css("display", "none");
//$("body").css("overflow-y","auto");
}
function showcolor(index) {
var html = "";
var colors = guiges[index].colors;
if (colors.length > 0) {
for (var i = 0; i < colors.length; i++) {
var selcolor = guiges[index].selectedcolor;
var sclass = "";
if (selcolor != "") {
if (selcolor == colors[i].color) {
sclass = "selected";
}
}
html += '<div onclick="selcolor(' + j + '' + index + ',' + i + ')" class="selguige_item ' + sclass + '" id="selcolor_item_' + i + '">';
html += '<span></span>';
html += '<div class="guigetit">' + colors[i].color + '</div>';
html += '</div>';
}
}
$("#color_box .select_box_selcolor").html(html);
$("#color_box").css("display", "flex");
}
function selcolor(j, index, index0) {
var acolor = guiges[index].colors[index0];
guiges[index].selectedcolor = acolor.color;
$("#selguige_item_" + index + " .select_colors div").html(acolor.color);
$("#selguige_item_" + index + " .productkc span").html(acolor.kc);
$("#color_box .select_box_selcolor .selguige_item.selected").removeClass("selected");
$("#color_box .select_box_selcolor .selguige_item#selcolor_item_" + index0 + "").addClass("selected");
topics();
closecolor();
}
function closecolor() {
$("#color_box").css("display", "none");
}
function topics() {
var strguiges = "";
for (var i = 0; i < guiges.length; i++) {
var color = guiges[i].selectedcolor;
var num = parseInt(guiges[i].selectednum);
if (num > 0) {
if (strguiges == "") {
strguiges = (guiges[i].gg + color + ":" + num);
} else {
strguiges += ("\n" + guiges[i].gg + color + ":" + num);
}
}
}
if (strguiges != "") {
$(".select_box_title .selguige_font").html("已选择:");
$(".select_box_title .selguige_title").html(strguiges);
} else {
$(".select_box_title .selguige_font").html("请选择:");
$(".select_box_title .selguige_title").html("规格或颜色");
}
}
function increment(index) {
var kc = $("#selguige_item_" + index + " .productkc span").html();
var num = $("#selguige_item_" + index + " #product_amount").val();
var c = /^[0-9]*$/;
if (!c.test(num)) {
tishi3("输入的数量有误", 3000);
} else {
kc = parseInt(kc);
num = parseInt(num);
var b = num + 1;
if (b > 1) {
tishi3("只能选择一件", 3000);
b = num
}
for (var i = 0; i < guiges.length; i++) {
var num0 = parseInt(guiges[i].selectednum);
if (num0 > 0) {
tishi3("只能选择一件", 3000);
b = num
}
}
guiges[index].selectednum = b;
$("#selguige_item_" + index + " #product_amount").val(b);
if (b > 0) {
$("#selguige_item_" + index + "").addClass("hover");
} else {
$("#selguige_item_" + index + "").removeClass("hover");
}
}
topics();
}
function decrement(index) {
var kc = $("#selguige_item_" + index + " .productkc span").html();
var num = $("#selguige_item_" + index + " #product_amount").val();
var c = /^[0-9]*$/;
if (!c.test(num)) {
tishi3("输入的数量有误", 3000);
} else {
kc = parseInt(kc);
num = parseInt(num);
var b = num - 1;
if (b < 0) {
tishi3("不能小于0", 3000);
b = num
}
guiges[index].selectednum = b;
$("#selguige_item_" + index + " #product_amount").val(b);
if (b < 1) {
$("#selguige_item_" + index + "").removeClass("hover");
}
}
topics();
}
function inputOnlyNum(c, b) {
var kc = $("#selguige_item_" + index + " .productkc span").html();
var num = $("#selguige_item_" + index + " #product_amount").val();
var c = /^[0-9]*$/;
if (!c.test(num)) {
tishi3("输入的数量有误", 3000);
} else {
kc = parseInt(kc);
num = parseInt(num);
var b = num;
if (b > kc) {
ifb = false;
b = kc;
tishi3("库存不足", 3000);
}
for (var i = 0; i < guiges.length; i++) {
var num0 = parseInt(guiges[i].selectednum);
if (num0 > 0) {
tishi3("只能选择一件", 3000);
b = num
}
}
if (b < 0) {
ifb = false;
b = 1;
tishi3("不能小于0", 3000);
}
guiges[index].selectednum = b;
$("#selguige_item_" + index + " #product_amount").val(b);
if (b > 0) {
$("#selguige_item_" + index + "").addClass("hover");
} else {
$("#selguige_item_" + index + "").removeClass("hover");
}
}
topics();
}
function qyaddcart() {
var strguiges = "";
var aguige = guiges;
var bb = true;
for (var i = 0; i < aguige.length; i++) {
var color = aguige[i].selectedcolor;
var num = parseInt(aguige[i].selectednum);
if (num > 0) {
if (aguige[i].colors.length > 0) {
if (color == "") {
tishi3(aguige[i].gg + "的颜色必须选择")
bb = false;
}
}
if (bb) {
if (strguiges == "") {
strguiges = (aguige[i].id + "|" + color + "|" + num);
} else {
strguiges += ("," + aguige[i].id + "|" + color + "|" + num);
}
}
}
}
if (strguiges != "") {
closeselect();
setlocalStorage("strguiges", strguiges);
onlink("yydd_lqcp0.html?id=" + id + "&viewId=" + viewId);
}
}
</script>
</head>
<body class="wrap">
<header>
<div class="ub">
<div class="nav-btn" id="nav-left" style=" margin:0; padding:0; padding-top:0.2em; min-width:3em" onclick="closeWin()">
<img src="../image/faifei.png" style="margin-left:0; margin-top:0em; height:1.2em;width:1.2em;" />
</div>
<h1 class="ub-f1">
领取产品
</h1>
<div class="nav-btn blue" id="nav-right" style=" margin:0; padding:0; min-width:3em; ">
</div>
</div>
</header>
<section class="ub-f1" id="wrapper">
<div id="wrapper_content">
<p class="pullDown">下拉刷新...</p>
<div class="clear"></div>
<div style="padding:0.8em;">
<div class="products_list" id="sysnew">
</div>
<div class="clear"></div>
<div class="more_box"></div>
</div>
<div class="clear"></div>
<p class="pullUp">上拉加载...</p>
</div>
</section>
<div class="ajaxLoader ub ub-ac uhide" onclick="reload()">
<div class="ub ub-ac ub-ver"><img src="image/load.gif" /><br>正在加载...</div>
</div>
<!-- 选择规格框 -->
<div class="select_box_bg" onclick="onselectout()">
<div class="select_box" onclick="stopPropagation(event)">
<div class="select_box_to">
<div class="select_box_pic"></div>
<div class="select_box_title">
<div class="selguige">
<span class="selguige_font">请选择:</span>
<span class="selguige_title">规格或颜色</span>
</div>
</div>
<div class="close" onclick='closeselect()'><img src="../image/close.png" /></div>
<div class="clear"></div>
<div class="select_box_selguige" style="padding-bottom:4em;" onmousewheel="return scroll(event,this)">
<div class="selguige_box" id="guiges">
</div>
</div>
<div class="clear"></div>
<div class="select_box_btn">
<input id="qybtn" type="button" onclick="qyaddcart();" value="确认" class="mybtn" />
</div>
<input id="addtype" type="hidden" value="" />
</div>
</div>
</div>
<div class="Hidden_box" id="color_box" onclick="closecolor()">
<div class="Hidden_box_to" onclick="stopPropagation(event)">
<div class="title">点击下面颜色</div>
<div class="close" onclick="closecolor()"><img src="../image/close.png" /></div>
<div class="body">
<div class="select_box_selcolor">
</div>
</div>
</div>
</div>
</body>
</html>