You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
268 lines
8.6 KiB
268 lines
8.6 KiB
5 years ago
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
||
|
<title>微信设置</title>
|
||
|
<!--REM自适应布局JS-->
|
||
|
<script src="../../../js/base/rem-layout.js"></script>
|
||
|
<link rel="stylesheet" type="text/css" href="../../../../lib/css/mui.min.css">
|
||
|
<link href="../../../../lib/css/basic.css" rel="stylesheet" />
|
||
|
<link rel="stylesheet" type="text/css" href="../../../css/base.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="../../../css/dom-flex.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="../../../css/user_pay_base.css" />
|
||
|
<script src="../../../../lib/js/mui.min.js"></script>
|
||
|
<script src="../../../../lib/js/vue.js"></script>
|
||
|
<script src="../../../../lib/js/app.js"></script>
|
||
|
<script src="../../../../lib/js/jsencrypt.min.js">
|
||
|
</script>
|
||
|
<script src="../../../js/my/my_ajax.js"></script>
|
||
|
<script src="../../../js/user/user_language.js"></script>
|
||
|
<script src="../../../js/user/user_ajax.js"></script>
|
||
|
<script src="../../../../html/wakuang/js/eth/ajax/eth.ajaxApi.js"></script>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
|
||
|
<div id="data-info">
|
||
|
<header class="mui-bar mui-bar-nav app-header">
|
||
|
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
|
||
|
<h1 class="mui-title">{{dataBase.c2cSaveUserPayWXTitle}}</h1>
|
||
|
</header>
|
||
|
<div class="mui-content" style="display: none;">
|
||
|
<div id="contents">
|
||
|
<div class="app-input-group app-input-group-darkly">
|
||
|
<div class="app-input-row-list">
|
||
|
<label>{{dataBase.c2cSaveUserPayWXNickNameText}} :</label>
|
||
|
<input class="app-input" type="text" :placeholder="dataBase.c2cSaveUserPayWXNickNamePlaceholder" v-model.trim="data.accountInfo" onkeyup="this.value = this.value.replace(/^ +| +$/g, '')">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="pay-code-content">
|
||
|
<p id="pay-code-title">{{dataBase.c2cSaveUserPayWXCodeText}} :</p>
|
||
|
<div id="pay-code-img" class="dom-flex-column flex-cell-center">
|
||
|
<span class="mui-icon mui-icon-plusempty"></span>
|
||
|
</div>
|
||
|
</div>
|
||
|
<button id="save" class="app-btn-darkly">{{dataBase.c2cBtnSaveText}}</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="backdrop" class="transfer-backdrop mui-backdrop mui-active"></div>
|
||
|
<div id="footer-div-bottom" class="footer-div-bottom">
|
||
|
<div class="transfer-footer-header">
|
||
|
<a id="transfer-cancel" class="transfer-footer-left mui-icon mui-icon-closeempty mui-pull-left"></a>
|
||
|
<h1 class="transfer-footer-title">确认</h1>
|
||
|
</div>
|
||
|
<div class="transfer-password-group transfer-input-group mui-input-group">
|
||
|
<div class="transfer-password-row transfer-input-row mui-input-row">
|
||
|
<label>请输入密码</label>
|
||
|
<input value="" type="password" id="password" onkeyup="this.value = this.value.replace(/^ +| +$/g, '')">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="transfer-next-group">
|
||
|
<input id="order_submit" type="button" value="确认">
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
|
||
|
</html>
|
||
|
<script type="text/javascript">
|
||
|
setTimeout(function() {
|
||
|
document.querySelector(".mui-content").style.display = "block";
|
||
|
}, 300)
|
||
|
/**
|
||
|
* 对象克隆
|
||
|
*
|
||
|
* @param {Object} obj
|
||
|
*/
|
||
|
var cloneObj = function(obj) {
|
||
|
var newObj = {};
|
||
|
if(obj instanceof Array) {
|
||
|
newObj = [];
|
||
|
}
|
||
|
for(var key in obj) {
|
||
|
var val = obj[key];
|
||
|
//newObj[key] = typeof val === 'object' ? arguments.callee(val) : val; //arguments.callee 在哪一个函数中运行,它就代表哪个函数, 一般用在匿名函数中。
|
||
|
newObj[key] = typeof val === 'object' ? cloneObj(val) : val;
|
||
|
}
|
||
|
return newObj;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* 图片压缩
|
||
|
*
|
||
|
* @param {Object} src 图片路径
|
||
|
*/
|
||
|
function resizeImage(imgSrc) {
|
||
|
plus.zip.compressImage({
|
||
|
src: imgSrc,
|
||
|
dst: '_doc/a' + new Date().getTime() + '.jpg',
|
||
|
overwrite: true,
|
||
|
width: '500px', //这里指定了宽度,同样可以修改
|
||
|
format: 'jpg',
|
||
|
quality: 100 //图片质量不再修改,以免失真
|
||
|
},
|
||
|
function(e) {
|
||
|
plus.nativeUI.closeWaiting();
|
||
|
//添加图片
|
||
|
addImg(e.target);
|
||
|
uploadAppealFile(e.target.toString()); //上传图片, e.target存的是本地路径!
|
||
|
},
|
||
|
function(err) {
|
||
|
mui.alert(dataBase.c2cUploadError)
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 图片上传
|
||
|
*
|
||
|
* @param {Object} imgSrc 图片路径
|
||
|
*/
|
||
|
function uploadAppealFile(imgSrc) {
|
||
|
var loading = plus.nativeUI.showWaiting(dataBase.c2cNativeUIText);
|
||
|
var task = plus.uploader.createUpload(ajaxJs.AJAX_SAVE_UPLOAD_USERPAYWX.getUrl, {
|
||
|
method: ajaxJs.AJAX_SAVE_UPLOAD_USERPAYWX.getType
|
||
|
},
|
||
|
function(t, status) { //上传完成
|
||
|
if(status == 200) {
|
||
|
var path = JSON.parse(t.responseText);
|
||
|
console.log(ajaxJs.AJAX_SAVE_UPLOAD_USERPAYWX.getUrl);
|
||
|
bodyData.data.collectionCodeUrl = path.data;
|
||
|
console.log(bodyData.data.collectionCodeUrl);
|
||
|
loading.close();
|
||
|
} else {
|
||
|
mui.alert("图片上传失败,请刷新重试!");
|
||
|
loading.close();
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
//添加其他参数
|
||
|
task.addFile(imgSrc, {
|
||
|
key: "userPayFile"
|
||
|
});
|
||
|
task.start();
|
||
|
}
|
||
|
|
||
|
//数据验证
|
||
|
function verifyData() {
|
||
|
console.log(2);
|
||
|
var imga = document.getElementById("pay-code-img").firstElementChild;
|
||
|
if(bodyData.data.accountInfo == "") {
|
||
|
mui.alert(dataBase.c2cSaveUserPayWXMsgNickNameNullError);
|
||
|
} else if(bodyData.data.collectionCodeUrl == "" || bodyData.data.collectionCodeUrl == null) {
|
||
|
console.log(2);
|
||
|
mui.alert(dataBase.c2cSaveUserPayWXMsgCodeNullError);
|
||
|
} else if(bodyData.oldData == null || bodyData.data.accountInfo != bodyData.oldData.accountInfo || bodyData.data.collectionCodeUrl != bodyData.oldData.collectionCodeUrl) {
|
||
|
return true;
|
||
|
} else {
|
||
|
mui.alert(dataBase.c2cSaveUserPayWXError);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var bodyData = new Vue({
|
||
|
el: '#data-info',
|
||
|
data: {
|
||
|
dataBase: dataBase, // 页面文字渲染
|
||
|
data: {
|
||
|
accountInfo: "",
|
||
|
collectionCodeUrl: ""
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// 数据请求
|
||
|
ajaxJs.ajaxUtil({
|
||
|
obj: ajaxJs.AJAX_SELECT_USERLPAY,
|
||
|
isNotMsg: true,
|
||
|
data: {
|
||
|
payType: 0
|
||
|
},
|
||
|
end: function(data) {
|
||
|
bodyData.data = data.data;
|
||
|
addImg(app.walletFileUrl + data.data.collectionCodeUrl);
|
||
|
bodyData.oldData = cloneObj(data.data);
|
||
|
}
|
||
|
})
|
||
|
|
||
|
//显示图片
|
||
|
function addImg(imgSrc) {
|
||
|
//初始化图片路径和格式
|
||
|
var image = document.createElement("img");
|
||
|
image.src = imgSrc;
|
||
|
image.style.width = '100%';
|
||
|
//添加两个自定义属性,用作图片预览
|
||
|
image.setAttribute("data-preview-group", "1");
|
||
|
image.setAttribute("data-preview-src", "");
|
||
|
//将图片添加到框中
|
||
|
var pay_code_img = document.getElementById("pay-code-img");
|
||
|
pay_code_img.innerHTML = "";
|
||
|
pay_code_img.appendChild(image);
|
||
|
//清除添加框的边框线
|
||
|
pay_code_img.style.border = '0';
|
||
|
}
|
||
|
|
||
|
//点击图片框选择图片
|
||
|
document.getElementById("pay-code-img").addEventListener("tap", function() {
|
||
|
plus.gallery.pick(function(path) {
|
||
|
resizeImage(path);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// 设置 / 更改
|
||
|
document.getElementById("save").addEventListener("tap", function() {
|
||
|
console.log("保存操作");
|
||
|
if(verifyData()) {
|
||
|
//弹出交易密码
|
||
|
document.getElementById("backdrop").style.display = "block";
|
||
|
document.getElementById("footer-div-bottom").style.display = "block";
|
||
|
document.activeElement.blur();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
<script type="text/javascript">
|
||
|
//交易密码,底部遮罩
|
||
|
document.getElementById("backdrop").addEventListener("tap", function() {
|
||
|
document.getElementById("backdrop").style.display = "none";
|
||
|
document.getElementById("footer-div-bottom").style.display = "none";
|
||
|
});
|
||
|
document.getElementById("transfer-cancel").addEventListener("tap", function() {
|
||
|
document.getElementById("backdrop").style.display = "none";
|
||
|
document.getElementById("footer-div-bottom").style.display = "none";
|
||
|
});
|
||
|
|
||
|
document.getElementById('order_submit').addEventListener('tap', function() {
|
||
|
plus.nativeUI.showWaiting("等待中...");
|
||
|
var _pass = document.getElementById("password").value;
|
||
|
if(_pass == "" || _pass == null) {
|
||
|
mui.alert("密码不能为空!");
|
||
|
} else {
|
||
|
ethCommonFun.getPublicKey(_pass, function(data) { // 获取公钥加密密码,生成秘钥
|
||
|
if(data.code == "200") {
|
||
|
var ajaxObj = bodyData.oldData == null ? ajaxJs.AJAX_INSERT_USERPAYWX : ajaxJs.AJAX_UPDATE_USERPAYWX;
|
||
|
bodyData.data.password = data.data;
|
||
|
ajaxJs.ajaxUtil({
|
||
|
obj: ajaxObj,
|
||
|
data: bodyData.data,
|
||
|
end: function(data) {
|
||
|
plus.nativeUI.closeWaiting();
|
||
|
//更新父窗口数据
|
||
|
var userPayView = plus.webview.getWebviewById("mine/html/user/pay/user_pay.html");
|
||
|
userPayView.evalJS("saveUserPayData();");
|
||
|
app.toast(dataBase.c2cMsgSuccess);
|
||
|
mui.back();
|
||
|
}
|
||
|
})
|
||
|
} else {
|
||
|
mui.toast(data.msg);
|
||
|
}
|
||
|
plus.nativeUI.closeWaiting();
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
</script>
|