123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
- <link rel="icon" href="//static.hoolihome.com/www/assets/images/hooli.ico">
- <title>海外租房_留学生租房_留学生公寓 - hooli官网</title>
- <meta name="keywords" contect="留学生公寓,留学租房,留学买房,海外租房价格,海外租房多少钱,海外租房,海外购房,海外买房,海外生活服务">
- <meta name="description" contect="hooli,出国留学租房买房首选平台,房源遍布全球热门留学国家500+城市,提供200000+房间,覆盖各大海外高校,实时更新最新留学租房买房、留学生公寓、海外房产等房源信息,信息真实有效,欢迎免费咨询。">
- <script type="text/javascript" src="//unpkg.com/vue@2.6.6/dist/vue.min.js"></script>
- <!-- <script type="text/javascript" src="//unpkg.com/axios@0.18.0/dist/axios.min.js"></script> -->
- <script type="text/javascript" src="//unpkg.com/crypto-js@3.1.9-1/crypto-js.js"></script>
- <script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
- <script type="text/javascript" src="//unpkg.com/qs@6.6.0/dist/qs.js"></script>
- <style type="text/css">
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- html,body {
- width: 100%;
- height: 100%;
- }
- .van-nav-bar{
- height: 44px;
- position: relative;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- text-align: center;
- line-height: 44px;
- background-color: #fff;
- border-bottom: 1px solid #eaeaea;
- }
- .van-nav-bar .van-nav-bar__left{
- bottom: 0;
- font-size: 14px;
- position: absolute;
- width: 33px;
- left: 15px;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .goback{
- width: 20px;
- }
- .van-nav-bar__title {
- margin: 0 auto;
- max-width: 60%;
- font-size: 17px;
- font-weight: 500;
- color: #000;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- #pay-btn {
- position: fixed;
- bottom: 30px;
- width: 100%;
- }
- #pay-btn div{
- display: flex;
- align-items: center;
- justify-content: center;
- height: 45px;
- font-size: 18px;
- background: #ff523d;
- border-radius: 25px;
- color: #fff;
- border: 0;
- margin: 15px 20px;
- }
- #pay-btn[disabled] div {
- background: #ffbfab;
- }
- .wrap .info {
- height: 100px;
- background: #fff;
- margin-bottom: 10px;
- display: flex;
- align-items: baseline;
- padding: 50px 0 0;
- justify-content: center;
- }
- .wrap .info span {
- font-size: 18px;
- color: #222;
- }
- .wrap .info p {
- font-size: 40px;
- line-height: 45px;
- color: #222;
- }
- </style>
- </head>
- <body onload="bodyOnLoad()">
- <div id="app">
- <div class="van-hairline--bottom van-nav-bar">
- <div class="van-nav-bar__left" @click="handleBack">
- <img class="goback" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABq0lEQVRYR+3Wv2sUURTF8U9QFIQIQbQSEdIGrAx2lhYWgoJYmEK0SJPKwqQRGxFUUBDBSistLBTUJo29f4CFhUVILYgkWPmDA29hXCX7dmbcbXKbLebNnu875753Z8aUa2bK+nYB/ocDe3AXV/EQt3aKuW+AObzG6SK6iWOTAljAWxwvgj9xDc8mAXAOL3CgiH3FBbwfdcq6RpD3bw7l/BFnsTFKPM+7AGS32XV2P6hXuIzvNeJdAJJz8k7uqR9Yxf1a4cG6Ng6kw9Pp6fhUdd7/ghsXYAUPkLOeGivvLgD78ARXuuTdFuAI3uFk17zbAnzAYh959wHwBRdrLpja01DThIfxBqcaEazhXq3ITutqAPL+XjzF0jSasLmBZTwqQBM9hk2IRJFTcajRmJew3iaS2giG//togThRHmT0ZijdHheiLUB09pdhdL4hGmfixnYtSBeAgcYN3GlM1k9lHH+ugegDIDpn8BIHi+i3cl+M7Iu+AKI7Xxoxv6lfyPB63Mc9UONm1sSBOBFHUluYnSRAtOJqPsuv4/nQ5fUXS58R1Lr0x7pdgKk78BuNnUQhl5vndwAAAABJRU5ErkJggg==" alt="">
- </div>
- <div class="van-ellipsis van-nav-bar__title">微信支付</div>
- </div>
- <div class="wrap">
- <div class="info" v-if="dataObj.moneySymbol && isRequest">
- <span>{{dataObj.moneySymbol}}</span>
- <p>{{dataObj.otPrice}}</p>
- </div>
- <div class="info" v-if="!dataObj.moneySymbol && isRequest">数据加载失败</div>
- </div>
- <div id="pay-btn" @click="handleGoPay" :disabled="!isRequest">
- <div>立即支付</div>
- </div>
- </div>
- <script>
- var js_api_param = null;
- var jsWxPay = new function(){
- var me = this,
- app = null;
- me.init = function(){
- app = new Vue({
- el: '#app',
- data: function() {
- return {
- query: {},
- dataObj: {
- moneySymbol: ''
- },
- isRequest: false,
- paramsObj: {}
- }
- },
- created: function() {
- var query = GetRequest();
- this.query = query;
- var paramsObj = decrypt(this.query.paramsObj);
- this.paramsObj = JSON.parse(paramsObj)
- window.alert = function (name) {
- var iframe = document.createElement('IFRAME');
- iframe.style.display = 'none';
- iframe.setAttribute('src', 'data:text/plain,');
- document.documentElement.appendChild(iframe);
- window.frames[0].window.alert(name);
- iframe.parentNode.removeChild(iframe);
- };
- },
- mounted() {
- this.loadData();
- },
- methods: {
- loadData: function(){
- var that = this;
- $.ajax({
- type: "POST",
- url: "https://api.hoolihome.com/hpay/wiseCashier/weChatPay.do",
- data: this.paramsObj,
- dataType: "json",
- success: function(res){
- if (res.code == 0) {
- that.dataObj = res.data;
- that.isRequest = true;
- var dom = document.getElementById('pay-btn');
- dom.click();
- }else{
- that.isRequest = true;
- alert('微信支付失败,'+code);
- }
- },
- error: function(e){
- that.isRequest = true;
- alert('微信支付失败,请返回上一页继续支付。')
- }
- });
- // axios({
- // url: apiUrl,
- // method: 'post',
- // headers: {
- // // 'X-Requested-With': 'XMLHttpRequest',
- // // "Content-Type": "application/x-www-form-urlencoded"
- // },
- // responseType: "json",
- // data: this.paramsObj,
- // // transformRequest: [
- // // function(data) {
- // // return Qs.stringify(data, {
- // // arrayFormat: "brackets"
- // // });
- // // }
- // // ]
- // }).then(function(response){
- // alert(JSON.stringify(response))
- // var data = response.data,
- // status = response.status;
- // if (status === 200) {
- // var code = data.code;
- // code = parseInt(code);
- // if (code === 0) {
- // that.dataObj = data;
- // that.isRequest = true;
- // var dom = document.getElementById('pay-btn');
- // dom.click();
- // }else{
- // alert('微信支付失败,'+code);
- // }
- // }else{
- // alert('微信支付失败');
- // }
- // }).catch(function(e){
- // that.msg = JSON.stringify(e)
- // alert('微信支付失败,请返回上一页继续支付。' + JSON.stringify(e))
- // })
- },
- handleGoPay: function() {
- if(js_api_param){
- jsApiCall();
- return;
- }
- var that = this;
- var params = {
- merchant_no: that.dataObj.merchantNo,
- amount: that.dataObj.otPrice,
- openid: that.dataObj.openId,
- currency: that.query.currency,
- product_info: that.dataObj.productInfo,
- agent_order_id: that.dataObj.agentOrderId,
- notify_url: that.dataObj.notifyUrl
- }
- that.isRequest = false;
- $.ajax({
- type: "POST",
- url: "/mp_pay",
- data: params,
- dataType: "json",
- headers: {
- 'Version': '1.0'
- },
- success: function(r){
- // alert('微信支付success,'+JSON.stringify(r))
- that.isRequest = true;
- if (r.meta.success) {
- js_api_param = r.data.js_param;
- if (typeof WeixinJSBridge == "undefined") {
- if (document.addEventListener) {
- document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
- } else if (document.attachEvent) {
- document.attachEvent('WeixinJSBridgeReady', jsApiCall);
- document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
- }
- } else {
- jsApiCall();
- }
- }
- },
- error: function(e){
- that.isRequest = true;
- alert('微信支付失败,请返回上一页继续支付。')
- }
- });
- // var that = this;
- // var apiUrl = '/mp_pay';
- // var params = {
- // merchant_no: that.dataObj.data.merchantNo,
- // amount: that.dataObj.data.otPrice,
- // openid: that.dataObj.data.openId,
- // currency: that.query.currency,
- // product_info: that.dataObj.data.productInfo,
- // agent_order_id: that.dataObj.data.agentOrderId,
- // notify_url: that.dataObj.data.notifyUrl
- // }
- // axios({
- // url: apiUrl,
- // method: 'post',
- // headers: {
- // 'Version': '1.0'
- // },
- // responseType: "json",
- // data: params,
- // transformRequest: [
- // function(data) {
- // return Qs.stringify(data, {
- // arrayFormat: "brackets"
- // });
- // }
- // ]
- // })
- // .then(function (r) {
- // var data = r.data;
- // if (data.meta.success) {
- // js_api_param = data.data.js_param;
- // if (typeof WeixinJSBridge == "undefined") {
- // if (document.addEventListener) {
- // document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
- // } else if (document.attachEvent) {
- // document.attachEvent('WeixinJSBridgeReady', jsApiCall);
- // document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
- // }
- // } else {
- // jsApiCall();
- // }
- // }
- // })
- // .catch(function (e) {
- // console.log(e);
- // });
- },
- handleBack: function(){
- window.history.go(-1);
- }
- }
- });
- };
- }
- //调用微信JS api 支付
- function jsApiCall() {
- WeixinJSBridge.invoke('getBrandWCPayRequest', js_api_param, function (res) {
- var originHost = GetRequest().originHost || 'm.hoolihome.com'
- if (res.err_msg == "get_brand_wcpay_request:ok") {
- window.location.href = originHost+'/success'
- }
- if (res.err_msg == "get_brand_wcpay_request:fail") {
- alert('支付失败');
- window.history.go(-1);
- }
- });
- }
- function decrypt(word) {
- const CryptoJSKey = CryptoJS.enc.Utf8.parse("1234123412ABCDEF"); //十六位十六进制数作为密钥
- const CryptoJSiv = CryptoJS.enc.Utf8.parse("ABCDEF1234123412"); //十六位十六进制数作为密钥偏移量
- var encryptedHexStr = CryptoJS.enc.Hex.parse(word);
- var srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
- var decrypt = CryptoJS.AES.decrypt(srcs, CryptoJSKey, {
- iv: CryptoJSiv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
- return decryptedStr.toString();
- }
- function getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- }
- function GetRequest() {
- var url = location.search; //获取url中"?"符后的字串
- var theRequest = {};
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- strs = str.split("&");
- for(var i = 0; i < strs.length; i ++) {
- theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
- }
- }
- return theRequest;
- }
-
- function bodyOnLoad(){
- jsWxPay.init();
- }
- </script>
- </body>
- </html>
|