function getsip() {
return "http://www.cnemsd.com/"; //正式
//return "http://183.60.143.97:7777/"; //備用
// return "http://test.cnemsd.com/"; //測試
//return "http://183.60.143.97:7788/"; //測試備用
// return "http://localhost:2000/"; //本地調(diào) 地址
// return "http://localhost:7777/";
}
function isnull_(value) {
if ((typeof (value) == "undefined") || (value == "") || (value == null)) {
return true;
} else { return false; }
}
//檢查IMG的圖片源是否為BASE64,為BASE64時返回去除頭部信息的值,否則返回空值
function checkimgurl_(url) {
if (url.indexOf("data:image/jpeg;base64") >= 0) {
return url.replace("data:image/jpeg;base64,", "");
} else { return ""; }
}
//得到日期 “yyyy-MM-dd HH:MM:SS”
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes() + seperator2 + date.getSeconds();
return currentdate;
}
//時間戳轉(zhuǎn)換為日期
function getLocalTime(nS) {
//return new Date(parseInt(nS) ).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
var tmp = new Date(parseInt(nS));
var newdate = tmp.getTime()//+(tmp.getTimezoneOffset() * 60000);
var nd = new Date(newdate + (3600000 * 8));
var result = nd.toLocaleString();
return result;//.replace(/年|月/g, "-").replace(/日/g, " ");
}
function selectColor(num, classname) {
var buttons = document.querySelectorAll(".listbuttons button");
for (var i = 0; i < buttons.length; i++) {
if (i == num) {
buttons[i].classList.add(classname);
}
else {
buttons[i].classList.remove(classname);
}
}
}
function selectColorTwo(num, classname) {
var buttons = document.querySelectorAll(".listbutton button");
for (var i = 0; i < buttons.length; i++) {
if (i == num) {
buttons[i].childNodes[0].src = "img/kefu/" + (i + 1).toString() + (i + 1).toString() + ".png";
buttons[i].classList.add(classname);
}
else {
buttons[i].childNodes[0].src = "img/kefu/" + (i + 1).toString() + ".png";
buttons[i].classList.remove(classname);
}
}
}
function addnum() {
var el = document.getElementById("xmnum");
el.value = el.value * 1 + 1;
}
function getljtjurl() {
var el = document.getElementById("xmnum");
var yuyueurl = document.getElementById("lijiyuyueurl");
var url = yuyueurl.href;
var indexOfnum = url.indexOf("pCount");
var newurl = url.substring(0, indexOfnum);
yuyueurl.href = newurl + "pCount=" + el.value;
}
function minusnum() {
var el = document.getElementById("xmnum");
if (el.value * 1 == 0) {
el.value = 0;
return;
}
el.value = el.value * 1 - 1;
}
function encodeUTF8(str) {
var temp = "", rs = "";
for (var i = 0, len = str.length; i < len; i++) {
temp = str.charCodeAt(i).toString(16);
rs += "\\u" + new Array(5 - temp.length).join("0") + temp;
}
return rs;
}
function decodeUTF8(str) {
return str.replace(/(\\u)(\w{4}|\w{2})/gi, function ($0, $1, $2) {
return String.fromCharCode(parseInt($2, 16));
});
}
function selectPhoto(num, classname) {
var buttons = document.querySelectorAll(".listbuttons button");
for (var i = 0; i < buttons.length; i++) {
if (i == num) {
buttons[i].childNodes[0].src = "img/yimeisay/" + (i + 1).toString() + (i + 1).toString() + ".png";
buttons[i].classList.add(classname);
}
else {
buttons[i].childNodes[0].src = "img/yimeisay/" + (i + 1).toString() + ".png";
buttons[i].classList.remove(classname);
}
}
}
function selectAA(num, classname) {
var buttons = document.querySelectorAll(".listbuttonsaa button");
for (var i = 0; i < buttons.length; i++) {
if (i == num) {
buttons[i].classList.add(classname);
}
else {
buttons[i].classList.remove(classname);
}
}
}
function getDataById(countId) {
return document.getElementById(countId).value;
}
//頁面控制按鈕高度控制
function changeheight() {
var new_box1 = document.getElementById("list_01");
var list_news1 = new_box1.getElementsByTagName("div");
var new_box2 = document.getElementById("list_02");
var list_news2 = new_box2.getElementsByTagName("div");
var bod_height = document.documentElement.clientHeight;
var bod_widht = document.documentElement.clientWidth;
// var btn_footer=document.getElementById("btn_footer").offsetHeight;
// alert(btn_footer);
var img_height = (bod_widht * 370) / 600;
var box_height = bod_height - img_height;
var list_height = (box_height / 2) - 64 + "px";
for (var i = 0; i < list_news1.length; i++) {
list_news1[i].style.height = list_height;
};
for (var i = 0; i < list_news2.length; i++) {
list_news2[i].style.height = list_height;
};
}
//張力 2015/9/23 17:38:24
function wap_pay(channel) {
var amount = 1 * 100;
var pay_url = getsip() + '/pingpp_api/GetCharge?orderId=12345678900';
alert(pay_url);
var xhr = new XMLHttpRequest();
xhr.open("POST", pay_url, true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.send(JSON.stringify({
channel: channel,
amount: amount
}));
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
pingpp.createPayment(xhr.responseText, function (result, err) {
if (result == "success") {
// 只有微信公眾賬號 wx_pub 支付成功的結(jié)果會在這里返回,其他的 wap 支付結(jié)果都是在 extra 中對應(yīng)的 URL 跳轉(zhuǎn)。
} else if (result == "fail") {
// charge 不正確或者微信公眾賬號支付失敗時會在此處返回
} else if (result == "cancel") {
// 微信公眾賬號支付取消支付
}
console.log(result);
console.log(err);
});
}
}
}
// app_pay 需要配合 example-webview 的 iOS 或者 Android 項(xiàng)目使用。
function app_pay(channel) {
var amount = 1 * 100;
alert(amount);
if (typeof PINGPP_IOS_SDK !== 'undefined') {
alert("iosSdk");
PINGPP_IOS_SDK.callPay(channel, amount);
} else if (typeof PINGPP_ANDROID_SDK !== 'undefined') {
alert("androidSdk");
PINGPP_ANDROID_SDK.callPay(channel, amount);
}
}
function pingxxInit(orderNo, amount) {
alert(1111);
pingpp_one.init({
app_id: 'sk_test_f9S8O4Wfn5i9uTK8K4zbHiH0', //該應(yīng)用在ping++的應(yīng)用ID
order_no: orderNo, //訂單在商戶系統(tǒng)中的訂單號
amount: amount, //訂單價格,單位:人民幣 分
// 壹收款頁面上需要展示的渠道,數(shù)組,數(shù)組順序即頁面展示出的渠道的順序
// upmp_wap 渠道在微信內(nèi)部無法使用,若用戶未安裝銀聯(lián)手機(jī)支付控件,則無法調(diào)起支付
channel: ['alipay_wap', 'wx_pub', 'upacp_wap', 'yeepay_wap', 'jdpay_wap', 'bfb_wap'],
charge_url: getsip() + '/pingpp_api/PaySuccess', //商戶服務(wù)端創(chuàng)建訂單的url
charge_param: { a: 1, b: 2 }, //(可選,用戶自定義參數(shù),若存在自定義參數(shù)則壹收款會通過 POST 方法透傳給 charge_url)
open_id: 'Openid' //(可選,使用微信公眾號支付時必須傳入)
}, function (res) {
if (!res.status) {
//處理錯誤
alert(res.msg);
}
else {
pingpp_one.success(function (res) {
if (!res.status) {
alert(res.msg);
}
}, function () {
//這里處理支付成功頁面點(diǎn)擊“繼續(xù)購物”按鈕觸發(fā)的方法,例如:若你需要點(diǎn)擊“繼續(xù)購物”按鈕跳轉(zhuǎn)到你的購買頁,則在該方法內(nèi)寫入 window.location.href = "你的購買頁面 url"
alert("繼續(xù)購物");
// window.location.;//示例
});
}
});
}