Browse Source

2

pull/1/head
pengda 8 months ago
parent
commit
48dc8ae8cf
  1. 42
      src/components/cardSecretBuy.vue
  2. 4
      src/components/cardSecretQuery.vue
  3. 40
      src/components/common/Login.vue
  4. 42
      src/main.js

42
src/components/cardSecretBuy.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="cardSecretBuy"> <div class="cardSecretBuy">
<login :page="login_page" :mckey="mckey" @loaded="loginLoaded"></login> <login :page="login_page"></login>
<div v-if="prompt" class="prompt-alert">{{ prompt }}</div> <div v-if="prompt" class="prompt-alert">{{ prompt }}</div>
@ -23,7 +23,7 @@
<div @click="toOrderSample()" class="card-order">订单编号指引</div> <div @click="toOrderSample()" class="card-order">订单编号指引</div>
</div> </div>
<div class="search-input"> <div class="search-input">
<input type="text" placeholder="请输入订单编号" v-model="inputValue"> <input type="text" placeholder="请输入订单编号" v-model="inputValue" @keyup.enter="search()">
<div @click="search()">搜索</div> <div @click="search()">搜索</div>
</div> </div>
</div> </div>
@ -51,12 +51,10 @@ import Login from './common/Login.vue'
export default { export default {
data() { data() {
return { return {
prompt: '',
agent_url: "",
islogin:false,
login_page: "cardSecretBuy", login_page: "cardSecretBuy",
mckey: this.$route.query.mckey,
prompt: '',
agent_url: localStorage.getItem('agent_url'),
tab: 0, tab: 0,
card_type_list: [], card_type_list: [],
@ -66,9 +64,6 @@ export default {
}; };
}, },
methods: { methods: {
loginLoaded(){
this.islogin = true
},
promptshow(content) { promptshow(content) {
this.prompt = content; this.prompt = content;
setTimeout(() => { setTimeout(() => {
@ -89,21 +84,18 @@ export default {
}, },
toTab: function (tab) { toTab: function (tab) {
this.tab = tab; this.tab = tab;
localStorage.setItem('cardSecretBuyTab', tab)
}, },
search: function () { search: function () {
this.tid = this.inputValue; if (this.inputValue == '') {
if (this.tid == '') {
this.promptshow('请输入订单编号'); this.promptshow('请输入订单编号');
return; return;
} }
this.$http.post(this.agent_url + "/h5_get_card_secret", { this.$http.post(this.agent_url + "/h5_get_card_secret", {
orderid: this.tid, orderid: this.inputValue,
}).then(response => { }).then(response => {
if (response.data.status) { if (response.data.status) {
this.is_buy = false; localStorage.setItem('cardSecretBuyTab', 1)
this.inputValue = ""; this.toCardSecretQuery(this.inputValue);
this.toCardSecretQuery();
} else { } else {
this.promptshow(response.data.info); this.promptshow(response.data.info);
} }
@ -162,9 +154,9 @@ export default {
"paySign": data.paySign "paySign": data.paySign
}, (res) => { }, (res) => {
// //
if (res.errMsg.indexOf('ok') > -1) { if (res.err_msg.indexOf('ok') > -1) {
this.checkpayresult(); this.checkpayresult();
} else if (res.errMsg.indexOf('cancel') > -1) { } else if (res.err_msg.indexOf('cancel') > -1) {
} else { } else {
this.promptshow('支付失败'); this.promptshow('支付失败');
@ -178,7 +170,7 @@ export default {
pay_type: paytype pay_type: paytype
}).then(response => { }).then(response => {
if (response.data.status) { if (response.data.status) {
this.toCardSecretQuery(); this.toCardSecretQuery(this.tid);
} else { } else {
this.promptshow(response.data.info); this.promptshow(response.data.info);
} }
@ -187,20 +179,18 @@ export default {
this.promptshow("网络错误,请重试"); this.promptshow("网络错误,请重试");
}); });
}, },
toCardSecretQuery() { toCardSecretQuery(orderid) {
location.href = "#/cardSecretQuery/?orderid=" + this.tid; location.href = "#/cardSecretQuery/?orderid=" + orderid;
} }
}, },
components: { components: {
Login Login
}, },
mounted() { mounted() {
if(this.islogin){
this.agent_url = localStorage.getItem('agent_url');
this.getCardSecretTypes(); this.getCardSecretTypes();
} if (localStorage.getItem('cardSecretBuyTab') >=0 ) {
if(localStorage.getItem('cardSecretBuyTab') != null){
this.tab = localStorage.getItem('cardSecretBuyTab') this.tab = localStorage.getItem('cardSecretBuyTab')
localStorage.setItem('cardSecretBuyTab', 0)
} }
} }
}; };

4
src/components/cardSecretQuery.vue

@ -155,13 +155,13 @@ export default {
.detail-info div:first-child { .detail-info div:first-child {
text-align: left; text-align: left;
width: 50%; width: 30%;
color: #828897; color: #828897;
} }
.detail-info div:last-child { .detail-info div:last-child {
text-align: right; text-align: right;
width: 50%; width: 70%;
color: #071432; color: #071432;
} }

40
src/components/common/Login.vue

@ -3,13 +3,12 @@
</template> </template>
<script> <script>
import _global from "../utils/Global.vue";
export default { export default {
name: 'Login', name: 'Login',
data() { data() {
return { return {
query_url:"", mckey: this.$route.query.mckey,
query_url:localStorage.getItem('query_url'),
agent_url: localStorage.getItem('agent_url'), agent_url: localStorage.getItem('agent_url'),
} }
}, },
@ -17,11 +16,7 @@ export default {
page: { page: {
type: String, type: String,
default: "" default: ""
}, }
mckey: {
type: String,
default: ""
},
}, },
methods: { methods: {
tologin: function () { tologin: function () {
@ -40,35 +35,6 @@ export default {
} }
}, },
mounted() { mounted() {
this.query_url = this.$route.query.url
if(!this.query_url){
let error = {
title_error:"商家尚未开通手机访问功能",
detail_error_one:"商家尚未开通手机访问功能",
}
localStorage.setItem('H5OpenError', JSON.stringify(error));
location.href = _global.hostname + '/index.html#/h5OpenError';
}
const parsedUrl = new URL(decodeURIComponent(this.query_url));
this.agent_url = parsedUrl.origin
localStorage.setItem('agent_url', this.agent_url);
this.$emit('loaded');
let isweixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1;
isweixin = true
if (!isweixin) {
let error = {
title_error:"只支持在微信中访问",
detail_error_one:"移动端只能在微信浏览器中访问",
detail_error_two:"请复制链接发送到手机微信端或者电脑端访问",
device:"手机微信端或者电脑端",
}
localStorage.setItem('H5OpenError', JSON.stringify(error));
location.href = _global.hostname + '/index.html#/h5OpenError?url=' + this.query_url;
}
if (this.mckey) { if (this.mckey) {
this.$http.post(this.agent_url + "/h5_get_wxlogin_info", {mckey: this.mckey}).then(response => { this.$http.post(this.agent_url + "/h5_get_wxlogin_info", {mckey: this.mckey}).then(response => {
if (!response.data.status) { if (!response.data.status) {

42
src/main.js

@ -37,6 +37,21 @@ Vue.http.headers = {'Content-Type': 'application/x-www-form-urlencoded'}
Vue.http.options.xhr = {withCredentials: true} Vue.http.options.xhr = {withCredentials: true}
Vue.http.options.emulateJSON = true Vue.http.options.emulateJSON = true
let query = {};
if (window.location.href.split('?')[1]) {
query = window.location.href.split('?')[1].split('&').reduce(function (ret, pair) {
pair = pair.split('=');
ret[pair[0]] = pair[1];
return ret;
}, {});
}
if(query.url){
const parsedUrl = new URL(decodeURIComponent(query.url));
localStorage.setItem('query_url', query.url);
localStorage.setItem('agent_url', parsedUrl.origin);
}
//判断是否登录 //判断是否登录
let cookieobj = document.cookie; let cookieobj = document.cookie;
let Cookies = {}; let Cookies = {};
@ -51,7 +66,7 @@ let openid = 'openid_' + site_uid;
if (Cookies[openid] && Cookies['site_uid']) { if (Cookies[openid] && Cookies['site_uid']) {
islogin = true; islogin = true;
} }
window.islogin = islogin; window.islogin = false;
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
@ -60,5 +75,30 @@ new Vue({
components: {App}, components: {App},
template: '<App/>', template: '<App/>',
mounted: function () { mounted: function () {
if(window.location.href.indexOf('h5OpenError') === -1){
let agent_url = localStorage.getItem('agent_url');
if(agent_url === null || agent_url === ""){
let error = {
title_error:"商家尚未开通手机访问功能",
detail_error_one:"商家尚未开通手机访问功能",
}
localStorage.setItem('H5OpenError', JSON.stringify(error));
this.$router.push({ path: '/h5OpenError' });
return false;
}
let isweixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1;
if (!isweixin) {
let error = {
title_error:"只支持在微信中访问",
detail_error_one:"移动端只能在微信浏览器中访问",
detail_error_two:"请复制链接发送到手机微信端或者电脑端访问",
device:"手机微信端或者电脑端",
}
localStorage.setItem('H5OpenError', JSON.stringify(error));
this.$router.push({ path: '/h5OpenError?url=' + this.query_url });
return false;
}
}
} }
}); });

Loading…
Cancel
Save