Commit 2b339666 Harvey

no message

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