Ver código fonte

人格测试前端页面搭建框架

wangxiaoming 5 anos atrás
pai
commit
69afec39be

Diferenças do arquivo suprimidas por serem muito extensas
+ 5 - 0
wechat_rg/css/mui.min.css


BIN
wechat_rg/fonts/mui.ttf


+ 90 - 0
wechat_rg/index.html

@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta charset="UTF-8">
+		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
+		<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="telphone=no, email=no" />
+		<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
+		<meta http-equiv="Pragma" content="no-cache" />
+		<meta http-equiv="Expires" content="0" />
+		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+		<meta http-equiv="X-UA-Compatible" content="IE=8">
+		<meta http-equiv="Cache" content="no-cache">
+		<title>WaterO官方商城</title>
+		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
+		<style>
+			.header { padding: 10px 0 7px 0; height: 65px; box-shadow: 0 0 0 #fff; background: #fff; } 
+			.header h6 { text-indent: 12px; color: #999; letter-spacing: 2px; } 
+			.go-index { width: 30%; margin-right: 1%; float: none; } 
+			.go-index img { width: 80%; padding-top: 5px; margin-left: 12px; max-width: 100px; } 
+			.swiper-container-horizontal>.swiper-pagination-bullets { bottom: 0; } 
+			.swiper-pagination-bullet-active { background: #63ccde; } 
+			.index-title { padding: 7px 12px 7px 12px; display: block; position: relative; } 
+			.index-title strong { font-size: 17px; } 
+			.index-title .mui-pull-right { color: #333; } 
+			.index-title font { display: inline-block; -webkit-transform: translateY(-1px); transform: translateY(-1px); }
+ 			.pro-list .mui-media-object { background: #eff5f7; border-radius: 5px; display: block; }
+			.pro-list:before,.pro-list:after {display: none;} 
+			.pro-list.mui-table-view.mui-grid-view>li:nth-child(odd) {padding: 10px 8px 0 14px;}
+			.pro-list.mui-table-view.mui-grid-view>li:nth-child(even) {padding: 10px 0 0 22px;}
+			.pro-list h6 {margin: 7px 0;color: #bbb;}
+			.pro-list .pro-price {font-size: 14px;margin-top: 8px;}
+			.pro-list .pro-price span {color: #db3f53;}
+			.pro-list .pro-price s {color: #bbb;margin-left: 15px;}
+ 			.pro-list2 .mui-media-object { background: #f2f2f2; border-radius: 5px; display: block; }
+			.pro-list2:before,.pro-list2:after {display: none;} 
+			.pro-list2.mui-table-view.mui-grid-view>li:nth-child(odd) {padding: 10px 8px 0 14px;}
+			.pro-list2.mui-table-view.mui-grid-view>li:nth-child(even) {padding: 10px 0 0 22px;}
+			.pro-list2 h6 {margin: 7px 0;color: #bbb;}
+			.pro-list2 .pro-price {font-size: 14px;margin-top: 8px;}
+			.pro-list2 .pro-price span {color: #db3f53;}
+			.pro-list2 .pro-price s {color: #bbb;margin-left: 15px;}
+		</style>
+	</head>
+	<body>
+		
+		<!--header 开始-->
+		<header class="mui-bar mui-bar-nav header">
+			<h6>Ta 是一种生活方式</h6>
+		</header>
+		<!--header 结束-->
+		<div class="mui-content" style="background: #fff;">
+<br>
+<br>
+<br>
+			<div class="index-title go_web_shop">
+				<strong>经典款净水机</strong><span class="mui-pull-right"><font>更多</font><span class="mui-icon mui-icon-arrowright"></span></span>
+			</div>
+		
+		</div>
+		<script src="js/mui.min.js"></script>
+		<script src="js/jquery-2.1.1.min.js"></script>
+		<script src="js/main.js"></script>
+		<!-- <script src="js/wechat-utils-1.0.js"></script> -->
+	</body>
+	<script>
+		//刷新用户信息
+		$.ajax(base_path + '/getUserInfo?dates=' + new Date().getTime(), {
+			dataType: 'json',
+			type: 'post',
+			timeout: 15000,
+			xhrFields: {
+				withCredentials: true
+			},
+			crossDomain: true,
+			success: function(dt) {
+				if(dt.isRedirect) {
+					location.href = dt.redirectURL;
+				} else {
+					console.log("用户信息刷新成功");
+				}
+			},
+			error: function(xhr, type, errorThrown) {
+				console.log(xhr)
+			}
+		});
+	</script>
+
+</html>

Diferenças do arquivo suprimidas por serem muito extensas
+ 4 - 0
wechat_rg/js/jquery-2.1.1.min.js


+ 238 - 0
wechat_rg/js/main.js

@@ -0,0 +1,238 @@
+var domanUrl = "//" + window.location.host,
+	path="//w.iamberry.com",
+    base_path= path +"/wechat_rg/wechat";
+
+
+function errorfn(xhr) {
+    if(xhr.readyState == 4 && xhr.status == 200) {} else {
+        var ref = location.href.split("#")[0],
+            src = '';
+        if(ref.indexOf('?') != -1) {
+            src = ref + "&date=" + new Date().getTime()
+        } else {
+            src = ref + "?date=" + new Date().getTime()
+        }
+        location.href = src;
+        return
+    }
+}
+
+function gotoTop(acceleration, stime) {
+    acceleration = acceleration || 0.1;
+    stime = stime || 10;
+    var x1 = 0,
+        y1 = 0,
+        x2 = 0,
+        y2 = 0,
+        x3 = 0,
+        y3 = 0;
+    if(document.documentElement) {
+        x1 = document.documentElement.scrollLeft || 0;
+        y1 = document.documentElement.scrollTop || 0
+    }
+    if(document.body) {
+        x2 = document.body.scrollLeft || 0;
+        y2 = document.body.scrollTop || 0
+    }
+    var x3 = window.scrollX || 0;
+    var y3 = window.scrollY || 0;
+    var x = Math.max(x1, Math.max(x2, x3));
+    var y = Math.max(y1, Math.max(y2, y3));
+    var speeding = 1 + acceleration;
+    window.scrollTo(Math.floor(x / speeding), Math.floor(y / speeding));
+    if(x > 0 || y > 0) {
+        var run = "gotoTop(" + acceleration + ", " + stime + ")";
+        window.setTimeout(run, stime)
+    }
+};
+
+function accDiv(arg1, arg2) {
+    var t1 = 0,
+        t2 = 0,
+        r1, r2;
+    try {
+        t1 = arg1.toString().split(".")[1].length
+    } catch(e) {}
+    try {
+        t2 = arg2.toString().split(".")[1].length
+    } catch(e) {}
+    with(Math) {
+        r1 = Number(arg1.toString().replace(".", ""));
+        r2 = Number(arg2.toString().replace(".", ""));
+        return(r1 / r2) * pow(10, t2 - t1)
+    }
+};
+Number.prototype.div = function(arg) {
+    return accDiv(this, arg)
+};
+
+function accAdd(arg1, arg2) {
+    var r1, r2, m, c;
+    try {
+        r1 = arg1.toString().split(".")[1].length
+    } catch(e) {
+        r1 = 0
+    }
+    try {
+        r2 = arg2.toString().split(".")[1].length
+    } catch(e) {
+        r2 = 0
+    }
+    c = Math.abs(r1 - r2);
+    m = Math.pow(10, Math.max(r1, r2));
+    if(c > 0) {
+        var cm = Math.pow(10, c);
+        if(r1 > r2) {
+            arg1 = Number(arg1.toString().replace(".", ""));
+            arg2 = Number(arg2.toString().replace(".", "")) * cm
+        } else {
+            arg1 = Number(arg1.toString().replace(".", "")) * cm;
+            arg2 = Number(arg2.toString().replace(".", ""))
+        }
+    } else {
+        arg1 = Number(arg1.toString().replace(".", ""));
+        arg2 = Number(arg2.toString().replace(".", ""))
+    }
+    return(arg1 + arg2) / m
+};
+Number.prototype.add = function(arg) {
+    return accAdd(arg, this)
+};
+
+function accSub(arg1, arg2) {
+    var r1, r2, m, n;
+    try {
+        r1 = arg1.toString().split(".")[1].length
+    } catch(e) {
+        r1 = 0
+    }
+    try {
+        r2 = arg2.toString().split(".")[1].length
+    } catch(e) {
+        r2 = 0
+    }
+    m = Math.pow(10, Math.max(r1, r2));
+    n = (r1 >= r2) ? r1 : r2;
+    return((arg1 * m - arg2 * m) / m).toFixed(n)
+};
+Number.prototype.sub = function(arg) {
+    return accMul(arg, this)
+};
+
+function accMul(arg1, arg2) {
+    var m = 0,
+        s1 = arg1.toString(),
+        s2 = arg2.toString();
+    try {
+        m += s1.split(".")[1].length
+    } catch(e) {}
+    try {
+        m += s2.split(".")[1].length
+    } catch(e) {}
+    return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
+};
+Number.prototype.mul = function(arg) {
+    return accMul(arg, this)
+};
+
+function getParam(paramName) {
+    paramValue = "", isFound = !1;
+    if(this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
+        arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
+        while(i < arrSource.length && !isFound) {
+            arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
+        }
+    }
+    return paramValue == "" && (paramValue = null), paramValue
+};
+
+function dc(objectid) {
+    if(document.getElementById && document.getElementById(objectid)) {
+        return document.getElementById(objectid)
+    } else if(document.all && document.all(objectid)) {
+        return document.all(objectid)
+    } else if(document.layers && document.layers[objectid]) {
+        return document.layers[objectid]
+    } else {
+        return false
+    }
+};
+
+function formatDate(now) {
+    now = new Date(now);
+    var year = now.getFullYear();
+    var month = now.getMonth() + 1;
+    var date = now.getDate();
+    var hour = now.getHours();
+    var minute = now.getMinutes();
+    var second = now.getSeconds();
+    return year + "-" + month + "-" + date + "   " + hour + ":" + minute + ":" + second
+};
+
+function springFestivalPop() {
+    if(getCookie("WATERO_WEB_") == null) {
+        maskspringFestival.show();
+        $(".mui-backdrop").append('<div style="position:relative;"><img src="//s.iamberry.com/watero/images/shop/springFestival_2017.png" style="width:80%;margin:10% 10% auto 10%;"/><button type="button" id="close-springFestival" class="mui-btn my-btn-red" style="position: absolute;bottom: 5%;left: 50%;-webkit-transform: translateX(-50%)">我知道了</button></div>');
+        mui('body').on('tap', '#close-springFestival', function(e) {
+            setCookie();
+            $(".mui-backdrop").hide();
+        });
+    }
+};
+
+function getCookie(name) {
+    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
+    if(arr = document.cookie.match(reg))
+        return unescape(arr[2]);
+    else
+        return null;
+};
+var maskspringFestival = mui.createMask(function() {
+    return false;
+}); //callback为用户点击蒙版时自动执行的回调;
+function setCookie() {
+    var Days = 30;
+    var exp = new Date();
+    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
+    document.cookie = "WATERO_WEB_=OK;Path=/;expires=" + exp.toGMTString();
+};
+
+
+/**
+ * 该方法用于将Undefined转换为空值
+ * @param val
+ */
+function convertUndefinedToEmpty(val) {
+    if (undefined == val || null == val||typeof val == undefined || typeof val == 'undefined'|| 'undefined' == val) {
+        val = "";
+    }
+    return val;
+}
+
+/**
+ * 该方法用于将Undefined转换为空值
+ * @param val
+ */
+function cufte(val) {
+    return convertUndefinedToEmpty(val);
+}
+
+/**
+ * 空值返回0,其他值返回原值
+ * @param val
+ */
+function cufteInt(val) {
+    if(convertUndefinedToEmpty(val) == "")
+        return 0;
+    return val;
+}
+
+/**
+ * 空值返回false
+ * @param val
+ */
+function isEmpty(val) {
+    if(convertUndefinedToEmpty(val) == "")
+        return false;
+    return true;
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 9 - 0
wechat_rg/js/mui.min.js


+ 269 - 0
wechat_rg/js/wechat-utils-1.0.js

@@ -0,0 +1,269 @@
+/**
+ * @author 何秀刚
+ * @description wechat 工具类,依赖JQuery,如果引入此文件,自动绑定分享事件。
+ * @version V.1.0
+ */
+// 获取绑定微信JSSDK的配置参数 
+var getConfigUrl = path +"/watero/config/get";
+// JSSDK是否绑定成功
+var jssdkSuccess = true;
+//是否隐藏全局菜单
+if (window.hiddenAllWechatMenu == null) {
+    window.hiddenAllWechatMenu = false;
+}
+// 分享信息全局变量
+window.wxFriend = null;
+if (window.repleFlag) {
+    // 自定义
+    window.wxFriend = window.repleWxData;
+} else {
+    // 使用全局默认
+    window.wxFriend = {
+        "appId": "",
+        "imgUrl":'https://s.iamberry.com/watero/images/shop/index.jpg',
+        "link":"https://s.iamberry.com/watero/wechat/index.html",
+        "desc":"Watero水时代商城,开启优雅生活",
+        "title":"Watero水时代商城,好水,好茶,生活不将就!",
+        "netError":"您的网络异常,请刷新重试!如多次刷新无效,请向我们反应 ~",
+        "shareTimeSuccess":"这里是分享朋友圈后调用的文字",
+        "shareTimeCancel":"这里是取消分享给朋友圈后调用的文字",
+        "shareAppSuccess":"这里是分享好友后调用的文字",
+        "shareAppCancel":"这里是取消分享给好友后调用的文字"
+    };
+}
+// 微信共享地址数据
+window.wechatAddr = {
+    "status":false, // 是否调用成功,true成功,false失败
+    "statusMsg":"失败时信息",
+    "detailInfo":"详细地址",
+    "postalCode":"邮编",
+    "userName":"收货人",
+    "userTel":"收货人电话",
+    "nationalCode":"收货地址国家码"
+};
+/** 引入JSSDK1.0基本组件,微信共享地址智能使用1.0版本,并且需要服务器返回参数支持 */
+//incoldeJSFile("//res.wx.qq.com/open/js/jweixin-1.0.0.js");
+/** 引入JSSDK1.1基本组件 ,支持摇一摇、微信共享地址 */
+incoldeJSFile("//res.wx.qq.com/open/js/jweixin-1.1.0.js");
+getConfig(); // 配置JSSDK组件
+
+
+/** 获取服务器JSSDK参数配置 */
+function getConfig(){
+	$.ajax({
+		type: 'get', url: getConfigUrl, data: {appid: "", url: location.href,"date":new Date().getTime()}, dataType: 'json', timeout: 10000, context: $('body'),
+		success: function(data){setConfig(data);},
+		error: function(xhr, type){
+			getConfig();
+			mui.alert('网络异常,请刷新重试,否则某些功能不能使用!')
+			}
+	});
+}
+
+/**配置JS-SDK*/
+function setConfig(config){
+    wx.config({
+        debug: false,
+        appId: config.appId,
+        timestamp: config.timestamp,
+        nonceStr: config.nonceStr,
+        signature: config.signature,
+        jsApiList: [
+            'checkJsApi',
+            'onMenuShareTimeline',
+            'onMenuShareAppMessage',
+            'hideMenuItems',
+            'showMenuItems'
+        ]
+    });
+    wx.ready(function(){ //JSSDK绑定成功
+        wxReadySuccess();
+    });
+    wx.error(function(res){ // JSSDK绑定失败的方法
+        wxReadyError();
+    });
+}
+
+/** JSSDK绑定成功调用事件 */
+function wxReadySuccess() {
+    window.jssdkSuccess = true;
+    shareMessage();
+    wx.getNetworkType({success: function (res) {}});
+    if (window.hiddenAllWechatMenu) {
+        wx.showMenuItems({
+            menuList: [
+            ] // 要显示的菜单项,所有menu项见附录3
+        });
+        wx.hideMenuItems({
+            menuList: [
+                "menuItem:copyUrl",
+                "menuItem:openWithSafari",
+                "menuItem:originPage",
+                "menuItem:share:email",
+                "menuItem:dayMode",
+                "menuItem:setFont",
+                "menuItem:nightMode",
+                "menuItem:share:qq",
+                "menuItem:dayMode",
+                "menuItem:exposeArticle",
+                "menuItem:nightMode",
+                "menuItem:openWithQQBrowser",
+                "menuItem:share:QZone",
+                "menuItem:favorite",
+                "menuItem:share:facebook",
+                "menuItem:share:appMessage",
+                "menuItem:share:timeline"
+            ] // 要隐藏的菜单项,所有menu项见附录3
+        });
+    } else {
+        wx.showMenuItems({
+            menuList: [
+                "menuItem:share:appMessage",
+                "menuItem:share:timeline"
+            ] // 要显示的菜单项,所有menu项见附录3
+        });
+        wx.hideMenuItems({
+            menuList: [
+                "menuItem:copyUrl",
+                "menuItem:openWithSafari",
+                "menuItem:originPage",
+                "menuItem:share:email",
+                "menuItem:dayMode",
+                "menuItem:setFont",
+                "menuItem:nightMode",
+                "menuItem:share:qq",
+                "menuItem:dayMode",
+                "menuItem:exposeArticle",
+                "menuItem:nightMode",
+                "menuItem:openWithQQBrowser",
+                "menuItem:share:QZone",
+                "menuItem:favorite",
+                "menuItem:share:facebook"
+            ] // 要隐藏的菜单项,所有menu项见附录3
+        });
+    }
+
+}
+
+/** JSSDK 绑定失败调用方法 */
+function wxReadyError() {
+    // alert(wxFriend.netError);
+}
+
+/** 分享时、分享后调用方法 */
+function shareMessage(title, message) {
+    title = title || wxFriend.title;
+    message = message || wxFriend.desc;
+    wx.onMenuShareTimeline({ //分享到朋友圈,只有标题、图标,没有内容简介
+        title: title, link: wxFriend.link, imgUrl: wxFriend.imgUrl,
+        success: function () {
+            if (wxFriend.shareAppSuccess != null && wxFriend.shareAppSuccess != "") {
+                // alert(wxFriend.shareAppSuccess);
+            }
+        },
+        cancel: function () {
+            if (wxFriend.shareTimeCancel != null && wxFriend.shareTimeCancel != "") {
+                // alert(wxFriend.shareTimeCancel);
+            }
+        }
+    });
+    wx.onMenuShareAppMessage({ // 分享给好友,有标题、内容简介、图标
+        title: title, desc: message, link: wxFriend.link, imgUrl: wxFriend.imgUrl,
+        success: function () {
+            if (wxFriend.shareAppSuccess != null && wxFriend.shareAppSuccess != "") {
+                // alert(wxFriend.shareAppSuccess);
+            }
+        },
+        cancel: function () {
+            if (wxFriend.shareTimeCancel != null && wxFriend.shareTimeCancel != "") {
+                // alert(wxFriend.shareTimeCancel);
+            }
+        }
+    });
+}
+
+/**
+ * 微信支付
+ * str:微信支付参数,字符串
+ * paySuccessCallBack:微信支付成功后回调方法,此方法必须为全局时,方可以回调成功
+ * payCancelCallBack:微信支付失败后回调方法,此方法必须为全局时,方可以回调成功
+ */
+function wechatPay(str, paySuccessCallBack, payCancelCallBack) {
+    if (typeof WeixinJSBridge == "undefined"){
+        alert("非微信浏览器!无法发起微信支付请求!");
+        return;
+    }
+    var obj = JSON.parse("{" + str + "}");
+    WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
+        if(res.err_msg=='get_brand_wcpay_request:ok'){
+            paySuccessCallBack
+        }else{
+            payCancelCallBack
+        }
+    });
+}
+if (typeof WeixinJSBridge == "undefined"){
+    if( document.addEventListener ){
+        document.addEventListener('WeixinJSBridgeReady', wechatPay, false);
+    }else if (document.attachEvent){
+        document.attachEvent('WeixinJSBridgeReady', wechatPay);
+        document.attachEvent('onWeixinJSBridgeReady', wechatPay);
+    }
+}
+/** 发起微信共享地址Version 1.0 */
+function editAddrV0(config) {
+    WeixinJSBridge.invoke('editAddress', {"appId" : config.appId, "scope" : "jsapi_address", "signType" : "SHA1", "addrSign" : config.addrSign, "timeStamp" : config.timestamp, "nonceStr" : config.nonceStr},
+        function(res) {
+            if ("edit_address:ok" == res.err_msg) {
+                var address = res.proviceFirstStageName + "-" + res.addressCitySecondStageName + "-" + res.addressCountiesThirdStageName + "-" + res.addressDetailInfo;
+                wechatAddr.status = true;
+                wechatAddr.detailInfo = address;
+                wechatAddr.postalCode = res.addressPostalCode;
+                wechatAddr.userName = res.userName;
+                wechatAddr.userTel = res.telNumber;
+                return wechatAddr;
+            } else if ("edit_address:fail" == res.err_msg) {// 没有选择
+                wechatAddr.statusMsg = "您没有选择收货地址!";
+                return wechatAddr;
+            } else { // 参数过时,请刷新
+                wechatAddr.statusMsg = "操作过时,请刷新重试!";
+                return wechatAddr;
+            }
+        }
+    );
+}
+/**
+ * 发起微信共享地址Version 1.1<br>
+ * {<br>
+ * 		status : 状态,true:请求成功,false:请求失败<br>
+ * 		errorInfo : 请求失败时的提示信息<br>
+ * 		res: { 请求成功时的地址信息,失败为空<br>
+ * 			userName : 收货人姓名。<br>
+ * 			postalCode : 邮编。<br>
+ * 			provinceName 国标收货地址第一级地址(省)。<br>
+ * 			cityName : 国标收货地址第二级地址(市)。<br>
+ * 			countryName : 国标收货地址第三级地址(区)。<br>
+ * 			detailInfo : 详细收货地址信息。<br>
+ * 			nationalCode : 收货地址国家码。<br>
+ * 			telNumber : 收货人电话<br>
+ * 		}
+ * }
+ */
+function editAddrV1(successCallback, errorCallback) {
+    if (!window.jssdkSuccess) {
+        mui.alert("错误啦 ~~ 请刷新重试!");
+        return;
+    }
+    wx.openAddress({
+        success: successCallback,
+        cancel: errorCallback
+    });
+}
+/** 动态引入wechat utils JavaScript */
+function incoldeJSFile(jsUrl) {
+    var typeHand = document.getElementsByTagName('head').item(0);
+    var typeScript= document.createElement("script");
+    typeScript.type = "text/javascript";
+    typeScript.src=jsUrl;
+    typeHand.appendChild(typeScript);
+}