Commit 89fa64fb authored by xulili's avatar xulili

推送

parent 6aed2285
...@@ -19,22 +19,15 @@ export default { ...@@ -19,22 +19,15 @@ export default {
}, },
mounted() { mounted() {
this.cleanUrl() this.cleanUrl()
this.getAcessToken(); // this.getAcessToken();
this.createCode(); this.createCode();
}, },
methods: { methods: {
cleanUrl() { cleanUrl() {
// alert(`!-->cleanUrl: IN.`) this.nowUrl = this.$route.query.Url
// alert(`!-->cleanUrl: url =${JSON.stringify(this.$route)}`) this.activeId = this.$route.query.activeId
// alert(`!-->cleanUrl: url =${JSON.stringify(this.$route.params)}`) this.voucherId = this.$route.query.voucherId
this.unionId = this.$route.query.unionId
const url = this.$route;
this.nowUrl = url.split("&")[0].slice(41);
this.activeId = url.split("&")[1].split("=")[1];
this.voucherId = url.split("&")[2].split("=")[1];
this.unionId = url.split("&")[3].split("=")[1];
}, },
getAcessToken() { getAcessToken() {
let _this = this; let _this = this;
...@@ -46,28 +39,52 @@ export default { ...@@ -46,28 +39,52 @@ export default {
_this.createCode(); _this.createCode();
}); });
}, },
// createCode() {
// let _this = this;
// let pageUrl = `/wxx/cgi-bin/wxaapp/createwxaqrcode?access_token=${_this.accessToken}`;
// $.ajax({
// type: "POST",
// url: pageUrl,
// data: JSON.stringify({ path: "pages/signIn/signIn" }),
// // data: JSON.stringify({ path: `${_this.nowUrl}&detailid=${_this.voucherId}&actionid=${_this.activeId}&unionid=${_this.unionId}` }),
// xhrFields: { responseType: "arraybuffer" },
// success: function(res) {
// alert('success' + JSON.stringify(res))
// let imgUrl =
// "data:image/png;base64," +
// btoa(
// new Uint8Array(res).reduce(
// (data, byte) => data + String.fromCharCode(byte),
// ""
// )
// );
// $("#image").attr("src", imgUrl);
// },
// error: function(data) {
// alert('error' + JSON.stringify(data))
// console.log(data);
// }
// });
// },
createCode() { createCode() {
let _this = this; let _this = this;
let pageUrl = `/wxx/cgi-bin/wxaapp/createwxaqrcode?access_token=${_this.accessToken}`; let nowUrl = _this.nowUrl? _this.nowUrl : ""
// alert(`!-->createCode: data: path: ${_this.nowUrl}&detailid=${_this.voucherId}&actionid=${_this.activeId}&unionid=${_this.unionId}`) let voucherId = _this.voucherId? _this.voucherId : ""
let activeId = _this.activeId? _this.activeId : ""
let unionId = _this.unionId? _this.unionId : ""
let pageUri = `${nowUrl}&detailid=${voucherId}&actionid=${activeId}&unionid=${unionId}`;
let pageUrl = `http://139.155.48.151:8085/workWx/auth/oauth2/wxMiniQrCode?pageUri=${pageUri}`;
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: pageUrl, url: pageUrl,
// data: JSON.stringify({ path: "pages/signIn/signIn" }), // data: JSON.stringify({ path: "pages/signIn/signIn" }),
data: JSON.stringify({ path: `${_this.nowUrl}&detailid=${_this.voucherId}&actionid=${_this.activeId}&unionid=${_this.unionId}` }), data: {},
xhrFields: { responseType: "arraybuffer" },
success: function(res) { success: function(res) {
let imgUrl = console.log(res)
"data:image/png;base64," + $('#image').attr('src',res.data)
btoa(
new Uint8Array(res).reduce(
(data, byte) => data + String.fromCharCode(byte),
""
)
);
$("#image").attr("src", imgUrl);
}, },
error: function(data) { error: function(data) {
alert('error' + JSON.stringify(data))
console.log(data); console.log(data);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment