Commit 2b339666 Harvey

no message

1 个父辈 f50543b3
//const baseUrl = 'https://app.ydniu.com/graphql'
const baseUrl = '/test_graphql'
//const baseUrl = '/graphql'
//const baseUrl = '/test_graphql'
const baseUrl = '/graphql'
function request(options = {}) {
let header = Object.assign({
"Accept": "application/json",
"ydn-cookie":'connect.sid=s%3AXYMD32sp1XaZ80WfkFHUCXY3TWDWwVFS.8vXF9rK5dFqcejYW6J15Gu%2F1woUNKrBTIwWKizrcA20'
"Accept": "application/json"
}, options.header)
return new Promise((resolve, reject) => {
......@@ -36,17 +35,28 @@ function post(options = {}) {
}
async function graphql(options = {}) {
let header = {}
try {
if (Android) {
header["ydn-cookie"] = JSON.parse(Android.getSystemInfo())['cookie']
}
} catch (e) {
console.log(e.message)
}
let opts = Object.assign({
type: 'query'
}, options)
var body = []
let body = []
body.push(`${opts.type}{${opts.name}`)
if (opts.args) body.push(`(${opts.args})`)
if (opts.body) body.push(`{${opts.body}}`)
body.push('}')
let res = await post({
header,
data: {
query: body.join('')
}
......@@ -54,14 +64,15 @@ async function graphql(options = {}) {
res = res.data.data[opts.name]
if (res.Error == '未登录') {
try{
Android.webGoBack("")
}catch(e){
uni.navigateTo({
url: `/login?from=${encodeURIComponent(getCurrentPages()[0].__page__.fullPath)}`
})
}
if (res.Error == '未登录') {
try {
if (Android) window.location.href = 'ydncp://www.ydniu.com?type=7'
} catch (e) {
console.log(e.message)
uni.navigateTo({
url: `/login?from=${encodeURIComponent(getCurrentPages()[0].__page__.fullPath)}`
})
}
return
}
......
......@@ -7,10 +7,6 @@
</template>
<script>
//#ifdef H5
const $h5 = require('@/static/js/h5-utils.js')
//#endif
export default {
data() {
return {
......@@ -21,7 +17,6 @@
}
},
async onLoad(e) {
//#ifdef H5
if (e) {
this.title = e.text
this.text = e.text
......@@ -32,7 +27,15 @@
})
}
$h5.head_tv(this.src)
//#ifdef H5
try {
if (Android) {
const $h5 = require('@/static/js/h5-utils.js')
$h5.head_tv(this.src)
}
} catch (e) {
}
//#endif
},
methods: {}
......@@ -42,9 +45,8 @@
<style scoped>
.page-content {
top: 50px;
width: 100vw;
width: 80vw;
padding: 10px 5vw;
}
.page-content image {
......
......@@ -51,7 +51,7 @@
text: '七星彩',
value: 18
}],
list: [],
leftData: [],
rightData: [],
mode: 'widthFix',
......@@ -66,9 +66,7 @@
$h5.remove_uni_page_head()
}
} catch (e) {}
//#endif
this.bindData()
},
methods: {
......
......@@ -13,22 +13,4 @@ export function head_tv(url) {
$(".uni-page-head-hd").click(function(){
Android.webGoBack("")
});
}
export function getHeaders() {
var req = new XMLHttpRequest();
req.open('GET', document.location.href, false);
req.send(null);
var headerArr = req.getAllResponseHeaders().split('\r\n');
var headers = {};
headerArr.forEach(item => {
if (item !== '') {
var index = item.indexOf(':');
var key = item.slice(0, index);
var value = item.slice(index + 1).trim();
headers[key] = value
}
});
return headers
}
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!