Browse Source

Merge branch 'refs/heads/milestone-20251031-简版功能开发' into lihuilin/feature-20251024095243-我的

# Conflicts:
#	pages.json
#	pages/setting/account.vue
#	utils/http.js
zhaowenkang/feature-20251028181547-行情页面
lihui 4 weeks ago
parent
commit
654ec484c2
  1. 17
      api/deepExploration/deepExploration.js
  2. 10
      package-lock.json
  3. 1
      package.json
  4. 61
      pages.json
  5. 823
      pages/deepExploration/MainForceActions.vue
  6. 655
      pages/marketSituation/chartExample.vue
  7. 219
      pages/marketSituation/marketCondition.vue
  8. 15
      pages/marketSituation/marketOverview.vue
  9. 25
      pages/setting/account.vue
  10. 39
      utils/http.js

17
api/deepExploration/deepExploration.js

@ -74,7 +74,24 @@ export const getModel4Second = (data) => {
})
}
//不搜索时走这个
export const getModeldefault = (data) => {
return http({
method: 'POST',
url: '/api/coze/default',
data
})
}
//k线数据
export const getData = (data) => {
return http({
method: 'POST',
url: '/api/coze/WorkFlowData',
data
})
}
//历史记录列表
export const RecordListApi = (data) => {

10
package-lock.json

@ -8,6 +8,7 @@
"@dcloudio/uni-ui": "^1.5.11",
"@element-plus/icons-vue": "^2.3.2",
"element-plus": "^2.11.5",
"highlight.js": "^11.11.1",
"marked": "^2.0.1",
"pinia": "^3.0.3",
"pinia-plugin-persistedstate": "^4.5.0",
@ -480,6 +481,15 @@
"license": "MIT",
"peer": true
},
"node_modules/highlight.js": {
"version": "11.11.1",
"resolved": "https://registry.npmmirror.com/highlight.js/-/highlight.js-11.11.1.tgz",
"integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/hookable": {
"version": "5.5.3",
"license": "MIT"

1
package.json

@ -3,6 +3,7 @@
"@dcloudio/uni-ui": "^1.5.11",
"@element-plus/icons-vue": "^2.3.2",
"element-plus": "^2.11.5",
"highlight.js": "^11.11.1",
"marked": "^2.0.1",
"pinia": "^3.0.3",
"pinia-plugin-persistedstate": "^4.5.0",

61
pages.json

@ -29,16 +29,6 @@
}
},
{
"path": "pages/start/index/index",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "uni-app",
"disableSwipeBack": true,
"titleNView": false,
"bounce": false
}
},
{
"path": "pages/start/Registration/Registration",
"style": {
"navigationBarTitleText": "",
@ -98,7 +88,25 @@
}
},
{
"path": "pages/home/marketSituation",
"path": "pages/marketSituation/marketSituation",
"style": {
"navigationStyle": "custom",
"disableSwipeBack": true,
"titleNView": false,
"bounce": false
}
},
{
"path": "pages/marketSituation/globalIndex",
"style": {
"navigationStyle": "custom",
"disableSwipeBack": true,
"titleNView": false,
"bounce": false
}
},
{
"path": "pages/marketSituation/marketDetail",
"style": {
"navigationStyle": "custom",
"disableSwipeBack": true,
@ -116,7 +124,7 @@
}
},
{
"path": "pages/home/deepExploration",
"path": "pages/deepExploration/deepExploration",
"style": {
"navigationStyle": "custom",
"disableSwipeBack": true,
@ -134,7 +142,17 @@
}
},
{
"path": "pages/blank/blank",
"path": "pages/blank/institutionalTrendsBriefing",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"disableSwipeBack": true,
"titleNView": false,
"bounce": false
}
},
{
"path": "pages/blank/notice",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
@ -260,14 +278,29 @@
}
},
{
"path" : "pages/home/marketCondition",
"path" : "pages/marketSituation/marketCondition",
"style" :
{
"navigationBarTitleText" : "行情",
"navigationStyle": "custom"
}
},{
"path": "pages/deepExploration/MainForceActions",
"style": {
"navigationStyle": "custom",
"disableSwipeBack": true,
"titleNView": false,
"bounce": false
}
},
{
"path" : "pages/deepExploration/stockSelectDetail",
"style" :
{
"navigationBarTitleText": "选股策略"
}
},
{
"path" : "pages/setting/createPwd",
"style" :
{

823
pages/deepExploration/MainForceActions.vue

@ -47,9 +47,12 @@
<view class="txt">
<view class="txtHeader">
<image src="/static/deepExploration-images/plus.png" mode="aspectFill"></image>
<text>主力追踪</text>
<text>{{navItems[currentIndex].name}}</text>
</view>
<view class="txtContent">
<view v-if="loading" class="loading">加载中...</view>
<rich-text :nodes="htmlContent"></rich-text>
</view>
<view class="txtContent"></view>
</view>
</view>
</view>
@ -78,7 +81,12 @@
getModel3Second,
getModel4First,
getModel4Second,
getModeldefault,
getData
} from '/api/deepExploration/deepExploration.js'
import marked from 'marked'; // marked
import hljs from 'highlight.js';
import 'highlight.js/styles/atom-one-dark.css'; //
//
const type = ref('deepExploration')
@ -104,43 +112,25 @@
//
const searchStock = () => {
htmlContent.value = ''
console.log('搜索参数:', stockName.value);
if (currentIndex.value == 0) {
handleModel(0)
} else if (currentIndex.value == 1) {
console.log(index);
handleModel(1)
} else if (currentIndex.value == 2) {
console.log(index);
handleModel(2)
} else if (currentIndex.value == 3) {
console.log(index);
handleModel(3)
}else{
if (currentIndex.value ) {
handleModels()
getServerData()
} else {
uni.showToast({
title: '请选择模块',
icon: 'none',
duration: 2000
})
title: '请选择模块',
icon: 'none',
duration: 2000
})
}
}
//
const handleModel = (index) => {
const handleModel = async(index) => {
htmlContent.value = ''
currentIndex.value = index
if (currentIndex.value == 0) {
console.log(index);
handleTrack()
} else if (currentIndex.value == 1) {
console.log(index);
handleRadar()
} else if (currentIndex.value == 2) {
console.log(index);
handleDecode()
} else if (currentIndex.value == 3) {
console.log(index);
handleCapitalFlow()
}
await handleModels()
}
const stockName = ref('')
@ -150,52 +140,116 @@
const recordId = ref('')
const parentId = ref('')
const stockId = ref('')
//
const handleTrack = async () => {
const market = ref('')
const loading = ref(true);
const error = ref('');
const htmlContent = ref('');
const markdownContent = ref('');
const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
return `<p>${text}</p>`;
};
// marked
marked.setOptions({
highlight: (code, lang) => {
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(code, {
language: lang
}).value;
}
return hljs.highlightAuto(code).value;
},
renderer,
breaks: true, // <br>
gfm: true, // GitHub flavored Markdown
sanitize: false, // HTML<span style>
});
//
const handleModels = async () => {
try {
const result = await getModel1First({
content: searchName.value,
language: "cn",
marketList: "hk,cn,usa,my,sg,vi,in,gb",
model: 1
})
console.log('result', result);
if (result.code == 200) {
stockCode.value = result.data.code
stockName.value = result.data.name
recordId.value = result.data.recordId
parentId.value = result.data.parentId
stockId.value = result.data.stockId
language.value = result.data.language
// markdownContent.value = '\n## 📊 \n\n### 🕵 \n\t1. 📊 360.249 412.577 444.330\n\t2. 🔍 \n\t3. 📈 \n\n### 📊 :\n\t- 📉 : <font color=\"#13c2c2\">443.092</font> \n - 📈 : <font color=\"#ff4d4f\">466.458</font>\n\t- 📉 : <font color=\"#13c2c2\">447.354</font>\n\t- 📈 : <font color=\"#ff4d4f\">462.514</font>\n\t<font color=\"#722ed1\">AI线</font>\n\n### \n\t\t\t<font color=\"#fa8c16\">K线</font>\n\t\t\t<font color=\"#eb2f96\"></font>\n\n---\n<font color=\"#8c8c8c\">*AI*</font>\n '
// htmlContent.value = marked.parse(markdownContent.value);
loading.value = true;
if (searchName.value == '') {
console.log('没有搜索',searchName.value);
const rresult = await handleDefault()
// markdownContent.value = res.data.markdown
htmlContent.value = marked.parse(markdownContent.value);
}else{
console.log('搜索',searchName.value);
const result = await getModel1First({
content: searchName.value,
language: "cn",
marketList: "hk,cn,usa,my,sg,vi,in,gb",
model: currentIndex.value+1
})
console.log('result', result);
if (result.code == 200) {
stockCode.value = result.data.code
stockName.value = result.data.name
recordId.value = result.data.recordId
parentId.value = result.data.parentId
stockId.value = result.data.stockId
language.value = result.data.language
market.value = result.data.market
} else {
return
}
const res = await getModel1Second({
language: language.value,
recordId: recordId.value,
parentId: parentId.value,
stockId: stockId.value
stockId: stockId.value,
token: 'pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q'
})
if (res.code == 200) {
const rawMarkdown = res.data.markdown;
const adaptedMarkdown = rawMarkdown.replace(/^### /gm, ''); // ###
markdownContent.value = adaptedMarkdown;
// markdownContent.value = res.data.markdown
htmlContent.value = marked.parse(markdownContent.value);
}
console.log('res', res);
}
} catch {
error.value = e.message || '加载失败,请重试';
} finally {
loading.value = false;
}
}
//
const handleRadar = () => {
}
//
const handleDecode = () => {
const handleDefault = async () => {
const result = await getModeldefault({
token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
model: currentIndex.value+1
})
const rawMarkdown = result.data.markdown;
const adaptedMarkdown = rawMarkdown.replace(/^### /gm, ''); // ###
markdownContent.value = adaptedMarkdown;
htmlContent.value = marked.parse(markdownContent.value);
}
//
const handleCapitalFlow = () => {
}
const getServerData = async() =>{
const result = await getData({
market: market.value || '',
code: searchName || '',
language: "cn",
brainPrivilegeState: 1,
marketList: "usa.sg.my.hk.cn.can.vi.th.in.gb"
})
console.log('k线数据',result);
}
// 1. K线
const opts = ref({
@ -265,302 +319,302 @@
const chartData = ref({})
// K线methods
const getServerData = () => {
//
setTimeout(() => {
const res = {
"categories": [
"2025/08/25",
"2025/08/26",
"2025/08/27",
"2025/08/28",
"2025/08/29",
"2025/09/01",
"2025/09/02",
"2025/09/03",
"2025/09/04",
"2025/09/05",
"2025/09/08",
"2025/09/09",
"2025/09/10",
"2025/09/11",
"2025/09/12",
"2025/09/15",
"2025/09/16",
"2025/09/17",
"2025/09/18",
"2025/09/19",
"2025/09/22",
"2025/09/23",
"2025/09/24",
"2025/09/25",
"2025/09/26",
"2025/09/29",
"2025/09/30",
"2025/10/09",
"2025/10/10",
"2025/10/13",
"2025/10/14",
"2025/10/15",
"2025/10/16",
"2025/10/17",
"2025/10/20",
"2025/10/21",
"2025/10/22",
"2025/10/23",
"2025/10/24",
"2025/10/27"
],
series: [{
"name": "贵州茅台",
"data": [
[
1470.01,
1496.0,
1466.0,
1499.33
],
[
1490.32,
1474.23,
1480.01,
1481.61
],
[
1481.88,
1484.93,
1448.0,
1448.0
],
[
1447.97,
1456.1,
1438.77,
1446.1
],
[
1453.0,
1482.58,
1452.0,
1480.0
],
[
1482.2,
1488.0,
1465.7,
1476.1
],
[
1478.66,
1509.0,
1478.0,
1491.3
],
[
1491.0,
1503.5,
1466.0,
1480.55
],
[
1472.0,
1479.3,
1460.47,
1480.66
],
[
1471.0,
1486.97,
1464.0,
1483.0
],
[
1483.0,
1506.44,
1477.5,
1501.23
],
[
1505.0,
1509.95,
1493.42,
1505.0
],
[
1506.66,
1529.95,
1496.0,
1522.01
],
[
1522.01,
1526.02,
1508.5,
1523.5
],
[
1526.0,
1538.02,
1510.53,
1516.0
],
[
1515.87,
1517.48,
1501.5,
1515.1
],
[
1515.1,
1520.99,
1496.21,
1499.98
],
[
1499.99,
1510.28,
1490.01,
1493.0
],
[
1492.0,
1497.8,
1463.5,
1467.96
],
[
1467.99,
1475.5,
1457.01,
1467.97
],
[
1465.09,
1467.97,
1450.01,
1453.35
],
[
1450.5,
1457.5,
1440.0,
1447.42
],
[
1434.07,
1456.78,
1434.07,
1442.0
],
[
1442.83,
1445.21,
1436.0,
1439.0
],
[
1441.18,
1447.11,
1428.01,
1435.0
],
[
1439.38,
1469.99,
1435.0,
1460.86
],
[
1460.0,
1460.76,
1440.0,
1443.99
],
[
1436.0,
1439.38,
1420.0,
1436.78
],
[
1437.6,
1439.94,
1427.5,
1430.0
],
[
1415.7,
1422.85,
1415.12,
1419.2
],
[
1429.99,
1464.0,
1429.99,
1451.02
],
[
1450.98,
1463.0,
1445.08,
1462.0
],
[
1461.92,
1484.95,
1458.88,
1484.91
],
[
1483.1,
1488.0,
1454.03,
1455.0
],
[
1455.0,
1469.5,
1454.88,
1457.93
],
[
1459.0,
1469.94,
1455.5,
1462.26
],
[
1462.08,
1465.73,
1456.0,
1458.7
],
[
1455.0,
1468.8,
1447.2,
1467.98
],
[
1467.95,
1478.88,
1449.34,
1450.0
],
[
1440.0,
1452.49,
1435.99,
1440.41
]
],
}]
}
// .value
chartData.value = JSON.parse(JSON.stringify(res))
}, 500)
}
// const getServerData = () => {
// //
// setTimeout(() => {
// const res = {
// "categories": [
// "2025/08/25",
// "2025/08/26",
// "2025/08/27",
// "2025/08/28",
// "2025/08/29",
// "2025/09/01",
// "2025/09/02",
// "2025/09/03",
// "2025/09/04",
// "2025/09/05",
// "2025/09/08",
// "2025/09/09",
// "2025/09/10",
// "2025/09/11",
// "2025/09/12",
// "2025/09/15",
// "2025/09/16",
// "2025/09/17",
// "2025/09/18",
// "2025/09/19",
// "2025/09/22",
// "2025/09/23",
// "2025/09/24",
// "2025/09/25",
// "2025/09/26",
// "2025/09/29",
// "2025/09/30",
// "2025/10/09",
// "2025/10/10",
// "2025/10/13",
// "2025/10/14",
// "2025/10/15",
// "2025/10/16",
// "2025/10/17",
// "2025/10/20",
// "2025/10/21",
// "2025/10/22",
// "2025/10/23",
// "2025/10/24",
// "2025/10/27"
// ],
// series: [{
// "name": "",
// "data": [
// [
// 1470.01,
// 1496.0,
// 1466.0,
// 1499.33
// ],
// [
// 1490.32,
// 1474.23,
// 1480.01,
// 1481.61
// ],
// [
// 1481.88,
// 1484.93,
// 1448.0,
// 1448.0
// ],
// [
// 1447.97,
// 1456.1,
// 1438.77,
// 1446.1
// ],
// [
// 1453.0,
// 1482.58,
// 1452.0,
// 1480.0
// ],
// [
// 1482.2,
// 1488.0,
// 1465.7,
// 1476.1
// ],
// [
// 1478.66,
// 1509.0,
// 1478.0,
// 1491.3
// ],
// [
// 1491.0,
// 1503.5,
// 1466.0,
// 1480.55
// ],
// [
// 1472.0,
// 1479.3,
// 1460.47,
// 1480.66
// ],
// [
// 1471.0,
// 1486.97,
// 1464.0,
// 1483.0
// ],
// [
// 1483.0,
// 1506.44,
// 1477.5,
// 1501.23
// ],
// [
// 1505.0,
// 1509.95,
// 1493.42,
// 1505.0
// ],
// [
// 1506.66,
// 1529.95,
// 1496.0,
// 1522.01
// ],
// [
// 1522.01,
// 1526.02,
// 1508.5,
// 1523.5
// ],
// [
// 1526.0,
// 1538.02,
// 1510.53,
// 1516.0
// ],
// [
// 1515.87,
// 1517.48,
// 1501.5,
// 1515.1
// ],
// [
// 1515.1,
// 1520.99,
// 1496.21,
// 1499.98
// ],
// [
// 1499.99,
// 1510.28,
// 1490.01,
// 1493.0
// ],
// [
// 1492.0,
// 1497.8,
// 1463.5,
// 1467.96
// ],
// [
// 1467.99,
// 1475.5,
// 1457.01,
// 1467.97
// ],
// [
// 1465.09,
// 1467.97,
// 1450.01,
// 1453.35
// ],
// [
// 1450.5,
// 1457.5,
// 1440.0,
// 1447.42
// ],
// [
// 1434.07,
// 1456.78,
// 1434.07,
// 1442.0
// ],
// [
// 1442.83,
// 1445.21,
// 1436.0,
// 1439.0
// ],
// [
// 1441.18,
// 1447.11,
// 1428.01,
// 1435.0
// ],
// [
// 1439.38,
// 1469.99,
// 1435.0,
// 1460.86
// ],
// [
// 1460.0,
// 1460.76,
// 1440.0,
// 1443.99
// ],
// [
// 1436.0,
// 1439.38,
// 1420.0,
// 1436.78
// ],
// [
// 1437.6,
// 1439.94,
// 1427.5,
// 1430.0
// ],
// [
// 1415.7,
// 1422.85,
// 1415.12,
// 1419.2
// ],
// [
// 1429.99,
// 1464.0,
// 1429.99,
// 1451.02
// ],
// [
// 1450.98,
// 1463.0,
// 1445.08,
// 1462.0
// ],
// [
// 1461.92,
// 1484.95,
// 1458.88,
// 1484.91
// ],
// [
// 1483.1,
// 1488.0,
// 1454.03,
// 1455.0
// ],
// [
// 1455.0,
// 1469.5,
// 1454.88,
// 1457.93
// ],
// [
// 1459.0,
// 1469.94,
// 1455.5,
// 1462.26
// ],
// [
// 1462.08,
// 1465.73,
// 1456.0,
// 1458.7
// ],
// [
// 1455.0,
// 1468.8,
// 1447.2,
// 1467.98
// ],
// [
// 1467.95,
// 1478.88,
// 1449.34,
// 1450.0
// ],
// [
// 1440.0,
// 1452.49,
// 1435.99,
// 1440.41
// ]
// ],
// }]
// }
// // .value
// chartData.value = JSON.parse(JSON.stringify(res))
// }, 500)
// }
// onReady
onMounted(() => {
@ -584,8 +638,9 @@
<style scoped lang="scss">
.main {
width: 100%;
height: 100vh;
min-height: 100vh;
background-color: #fff;
padding-bottom: 120rpx;
.search {
position: relative;
@ -660,7 +715,6 @@
}
.graphAndTxt {
height: 300rpx;
background-color: #fff;
border-radius: 50rpx 50rpx 0 0;
padding: 68.6rpx 36.5rpx 0 36.5rpx;
@ -783,6 +837,51 @@
.txtContent {
min-height: 200rpx;
padding: 20rpx 30rpx;
margin-bottom: 100rpx;
::v-deep * {
box-sizing: border-box;
width: 100% !important; //
white-space: normal !important; //
word-wrap: break-word !important; // /
}
//
::v-deep h2 {
font-size: 32rpx;
color: #333;
margin: 25rpx 0 15rpx;
line-height: 1.5;
}
//
::v-deep p {
font-size: 26rpx;
color: #666;
margin: 15rpx 0;
line-height: 1.8; //
text-align: justify; //
}
//
::v-deep ul,
::v-deep ol {
margin: 15rpx 0 15rpx 30rpx;
}
::v-deep li {
margin: 10rpx 0;
line-height: 1.6;
}
//
.loading {
text-align: center;
padding: 50rpx 0;
color: #666;
font-size: 26rpx;
}
}
}
}

655
pages/marketSituation/chartExample.vue

@ -1,655 +0,0 @@
<template>
<view style="width: 750rpx; height: 750rpx;">
<l-echart ref="chartRef" @finished="initChart"></l-echart>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
const chartRef = ref(null)
// window.innerWidth
const systemInfo = uni.getSystemInfoSync()
const screenWidth = ref(systemInfo.screenWidth || 375) // 375px
// 30
const generateAIGoldBullData = () => {
const data = []
for (let i = 0; i < 30; i++) {
// [, , , , , ]
const buySignal = Math.random() > 0.7 ? 1 : 0 // 30%
const sellSignal = Math.random() > 0.8 ? 1 : 0 // 20%
const holdSignal = Math.random() > 0.5 ? 1 : 0 // 50%
const strength = Math.floor(Math.random() * 3) + 1 // 1-3
const volume = Math.floor(Math.random() * 2000) + 500 // 500-2500
data.push([i, buySignal, sellSignal, holdSignal, strength, volume])
}
return data
}
//
var option
const AIGoldBull = ref({
JN: generateAIGoldBullData()
})
//
const t = ref({
suoxie: 'zh',
tianxian: '天线',
feixian: '飞线',
zhoongxian: '中线',
liuxian: '流线',
Klinetext_5: 'K线5',
Klinetext_6: 'K线6',
maipan: '买盘',
maipan1: '卖盘'
})
// 30K线 [, , , , ]
const generateKLineData = () => {
const data = []
let basePrice = 2450 //
for (let i = 0; i < 30; i++) {
const date = new Date(2024, 0, i + 1).toISOString().split('T')[0]
//
const volatility = (Math.random() - 0.5) * 50 // ±25
const open = basePrice + volatility
const highVolatility = Math.random() * 30 + 10 // 10-40
const lowVolatility = Math.random() * 30 + 10 // 10-40
const high = Math.max(open, open + highVolatility)
const low = Math.min(open, open - lowVolatility)
const closeVolatility = (Math.random() - 0.5) * 20
const close = Math.max(low, Math.min(high, open + closeVolatility))
data.push([date,
Math.round(open * 100) / 100,
Math.round(high * 100) / 100,
Math.round(low * 100) / 100,
Math.round(close * 100) / 100
])
basePrice = close //
}
return data
}
// 30 [, 1, 2, 1, 2, 3]
const generateWaveVolData = () => {
const data = []
for (let i = 0; i < 30; i++) {
const date = new Date(2024, 0, i + 1).toISOString().split('T')[0]
//
const vol1 = Math.floor(Math.random() * 2000) + 800 // 800-2800
const vol2 = Math.floor(Math.random() * 1500) + 600 // 600-2100
//
const indicator1 = Math.floor(Math.random() * 30) + 40 // 40-70
const indicator2 = Math.floor(Math.random() * 40) + 50 // 50-90
const indicator3 = Math.floor(Math.random() * 35) + 60 // 60-95
data.push([date, vol1, vol2, indicator1, indicator2, indicator3])
}
return data
}
// 30线 [MA5, MA10, MA20, MA30]
const generateFTLineData = () => {
const data = []
let ma5Base = 2450
let ma10Base = 2445
let ma20Base = 2440
let ma30Base = 2435
for (let i = 0; i < 30; i++) {
// 线
ma5Base += (Math.random() - 0.5) * 10
ma10Base += (Math.random() - 0.5) * 8
ma20Base += (Math.random() - 0.5) * 6
ma30Base += (Math.random() - 0.5) * 4
data.push([
Math.round(ma5Base * 100) / 100,
Math.round(ma10Base * 100) / 100,
Math.round(ma20Base * 100) / 100,
Math.round(ma30Base * 100) / 100
])
}
return data
}
//
const mockKLineData = generateKLineData()
const mockWaveVolData = generateWaveVolData()
const mockFTLineData = generateFTLineData()
// RSI ()
const generateRSIData = () => {
const data = []
for (let i = 0; i < 30; i++) {
const rsi = Math.random() * 60 + 20 // RSI20-80
data.push(Math.round(rsi * 100) / 100)
}
return data
}
// MACD
const generateMACDData = () => {
const data = []
for (let i = 0; i < 30; i++) {
const macd = (Math.random() - 0.5) * 20 // MACD-1010
const signal = (Math.random() - 0.5) * 15 // 线
const histogram = macd - signal //
data.push([
Math.round(macd * 100) / 100,
Math.round(signal * 100) / 100,
Math.round(histogram * 100) / 100
])
}
return data
}
//
const generateBollingerData = () => {
const data = []
let middleLine = 2450
for (let i = 0; i < 30; i++) {
middleLine += (Math.random() - 0.5) * 10
const upperBand = middleLine + Math.random() * 30 + 20 //
const lowerBand = middleLine - Math.random() * 30 - 20 //
data.push([
Math.round(upperBand * 100) / 100,
Math.round(middleLine * 100) / 100,
Math.round(lowerBand * 100) / 100
])
}
return data
}
//
const generateVolumeAnalysisData = () => {
const data = []
for (let i = 0; i < 30; i++) {
const buyVolume = Math.floor(Math.random() * 1500) + 500 //
const sellVolume = Math.floor(Math.random() * 1500) + 500 //
const netVolume = buyVolume - sellVolume //
data.push([buyVolume, sellVolume, netVolume])
}
return data
}
//
const generateMarketSentimentData = () => {
const sentiments = ['极度恐慌', '恐慌', '中性', '贪婪', '极度贪婪']
const data = []
for (let i = 0; i < 30; i++) {
const sentimentIndex = Math.floor(Math.random() * 100) // 0-100
const sentimentLabel = sentiments[Math.floor(sentimentIndex / 20)]
data.push({
date: new Date(2024, 0, i + 1).toISOString().split('T')[0],
index: sentimentIndex,
label: sentimentLabel,
fearGreedRatio: Math.random() * 100
})
}
return data
}
//
const generateNewsEventsData = () => {
const events = [
'美联储利率决议',
'非农就业数据发布',
'通胀数据公布',
'地缘政治紧张',
'央行政策变化',
'经济数据超预期',
'市场技术突破',
'大宗商品价格波动'
]
const data = []
for (let i = 0; i < 10; i++) { // 10
const randomDay = Math.floor(Math.random() * 30) + 1
const event = events[Math.floor(Math.random() * events.length)]
const impact = Math.floor(Math.random() * 5) + 1 // 1-5
data.push({
date: new Date(2024, 0, randomDay).toISOString().split('T')[0],
event: event,
impact: impact,
type: Math.random() > 0.5 ? 'positive' : 'negative'
})
}
return data.sort((a, b) => new Date(a.date) - new Date(b.date))
}
//
const generatePricePredictionData = () => {
const data = []
let currentPrice = 2450
for (let i = 0; i < 7; i++) { // 7
const date = new Date(2024, 1, i + 1).toISOString().split('T')[0] // 2
// AI
const prediction = currentPrice + (Math.random() - 0.5) * 100
const confidence = Math.random() * 40 + 60 // 60-100%
const upperBound = prediction + Math.random() * 50
const lowerBound = prediction - Math.random() * 50
data.push({
date: date,
predicted_price: Math.round(prediction * 100) / 100,
confidence: Math.round(confidence),
upper_bound: Math.round(upperBound * 100) / 100,
lower_bound: Math.round(lowerBound * 100) / 100
})
currentPrice = prediction
}
return data
}
//
const extractedDrawData = {
KLine20: mockKLineData,
WAVEVOL: mockWaveVolData,
FTLINE: mockFTLineData,
RSI: generateRSIData(),
MACD: generateMACDData(),
BOLLINGER: generateBollingerData(),
VOLUME_ANALYSIS: generateVolumeAnalysisData(),
MARKET_SENTIMENT: generateMarketSentimentData(),
NEWS_EVENTS: generateNewsEventsData(),
PRICE_PREDICTION: generatePricePredictionData()
}
const fnShowEcharts4 = (extractedDrawData) => {
const splitData = (b) => {
const a = JSON.parse(JSON.stringify(b))
let categoryData = []
let values = []
for (let i = 0; i < a.length; i++) {
categoryData.push(a[i].splice(0, 1)[0])
values.push(a[i])
}
return {
categoryData,
values
}
}
var bodongliang = splitData(extractedDrawData.WAVEVOL)
function bodongliangData(values, i) {
return values.map((subArray) => subArray[i])
}
function calculateMA(index, data) {
let result = []
if (data.FTLINE) {
data.FTLINE.forEach((item) => {
result.push(item[index])
})
}
return result
}
function vwToPx(vw) {
return (screenWidth.value * vw) / 100
}
var dealData = splitData(extractedDrawData.KLine20)
var dealGnBullData = AIGoldBull.value.JN
const textEcharts = t.value
const firstLegend = computed(() => {
if (screenWidth.value < 768) {
if (textEcharts.suoxie === 'en' || textEcharts.suoxie === 'th') {
return '2%'
} else if (textEcharts.suoxie === 'kr') {
return '2%'
} else {
return '2%'
}
} else {
return textEcharts.suoxie === 'en' ||
textEcharts.suoxie === 'th' ||
textEcharts.suoxie === 'kr'
? '9%'
: '9%'
}
})
const processBarData = (data) => {
const barData = []
data.forEach((item) => {
let color
switch (item[4]) {
case 1:
color = '#13E113'
break
case 2:
color = '#FF0E00'
break
case 3:
color = '#0000FE'
break
case 4:
color = '#1397FF'
break
}
barData.push({
value: item[5],
itemStyle: {
normal: {
color: color
}
}
})
})
return { barData }
}
const { barData } = processBarData(dealGnBullData)
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
backgroundColor: 'rgba(119, 120, 125, 0.6)',
borderWidth: 1,
borderColor: '#77787D',
padding: 10,
textStyle: {
color: '#fff'
}
},
axisPointer: {
link: [
{
xAxisIndex: 'all'
}
],
label: {
backgroundColor: '#77787D'
}
},
toolbox: {
show: false
},
grid: [
{
left: screenWidth.value > 768 ? '10%' : '12%',
right: screenWidth.value > 768 ? '4%' : '6%',
top: screenWidth.value > 768 ? '10%' : '12%',
height: screenWidth.value > 768 ? '35%' : '34%',
containLabel: false
},
{
left: screenWidth.value > 768 ? '10%' : '12%',
right: screenWidth.value > 768 ? '4%' : '6%',
top: screenWidth.value > 768 ? '48%' : '48%',
height: screenWidth.value > 768 ? '19%' : '21%',
containLabel: false
},
{
left: screenWidth.value > 768 ? '10%' : '12%',
right: screenWidth.value > 768 ? '4%' : '6%',
top: screenWidth.value > 768 ? '70%' : '71%',
height: screenWidth.value > 768 ? '19%' : '21%',
containLabel: false
}
],
xAxis: [
{
type: 'category',
data: dealData.categoryData,
boundaryGap: true,
axisLine: { onZero: false },
splitLine: { show: false },
min: 'dataMin',
max: 'dataMax',
axisPointer: {
z: 100,
label: {
show: false //
}
},
axisLine: {
lineStyle: {
color: 'black'
}
}, //
axisLabel: { show: false },
axisTick: { show: false }
},
{
type: 'category',
gridIndex: 1,
data: dealData.categoryData,
boundaryGap: true,
axisPointer: {
z: 100,
label: {
show: false //
}
},
axisLine: { lineStyle: { color: 'black' } },
axisLabel: {
show: false,
interval: 'auto'
},
axisTick: { show: false }
},
{
type: 'category',
gridIndex: 2,
data: dealData.categoryData,
boundaryGap: true,
axisLine: { lineStyle: { color: 'black' } },
axisLabel: {
show: true,
interval: 'auto',
fontSize: screenWidth.value > 768 ? 15 : 9
},
axisTick: { show: false }
}
],
yAxis: [
{
scale: true,
gridIndex: 0,
position: 'left',
axisLabel: {
inside: false,
align: 'right',
fontSize: screenWidth.value > 768 ? 15 : 9
},
axisLine: {
show: true,
lineStyle: {
fontSize: '',
color: 'black'
}
},
axisTick: { show: false },
splitLine: { show: false }
},
{
scale: true,
gridIndex: 1,
splitNumber: 4,
min: 0,
minInterval: 1,
axisLabel: {
show: true,
fontSize: screenWidth.value > 768 ? 15 : 9,
margin: 8,
},
axisLine: { show: true, lineStyle: { color: 'black' } },
axisTick: { show: false },
splitLine: { show: true, lineStyle: { type: 'dashed' } },
boundaryGap: ['20%', '20%']
},
{
scale: true,
gridIndex: 2,
splitNumber: 2,
axisLabel: {
show: true,
fontSize: screenWidth.value > 768 ? 15 : 9
},
axisLine: { show: true, lineStyle: { color: 'black' } },
axisTick: { show: false },
splitLine: { show: false }
}
],
dataZoom: [
{
type: 'inside',
xAxisIndex: [0, 1, 2],
start: 50,
end: 100
},
{
show: true,
xAxisIndex: [0, 1, 2],
type: 'slider',
start: 50,
end: 100
}
],
series: [
{
type: 'candlestick',
name: '日K',
xAxisIndex: 0,
yAxisIndex: 0,
data: dealData.values,
itemStyle: {
normal: {
color0: 'red',
color: 'green',
borderColor0: 'red',
borderColor: 'green'
}
},
gridIndex: 1
},
{
name: '成交量',
type: 'bar',
barWidth: '70%',
xAxisIndex: 1,
yAxisIndex: 1,
data: barData,
},
// {
// name: textEcharts.feixian,
// type: 'line',
// data: calculateMA(1, extractedDrawData),
// smooth: true,
// symbol: 'none',
// xAxisIndex: 2,
// yAxisIndex: 2,
// itemStyle: {
// normal: {
// color: '#00a32e',
// lineStyle: {
// color: '#00a32e',
// width: 2,
// type: 'solid'
// }
// }
// }
// },
// {
// name: textEcharts.zhoongxian,
// type: 'line',
// data: calculateMA(2, extractedDrawData),
// smooth: true,
// symbol: 'none',
// xAxisIndex: 2,
// yAxisIndex: 2,
// itemStyle: {
// normal: {
// color: '#de0000',
// lineStyle: {
// color: '#de0000',
// width: 2,
// type: 'solid'
// }
// }
// }
// },
// {
// name: textEcharts.tianxian,
// type: 'line',
// data: calculateMA(3, extractedDrawData),
// smooth: true,
// symbol: 'none',
// xAxisIndex: 2,
// yAxisIndex: 2,
// itemStyle: {
// normal: {
// color: '#ffb300',
// lineStyle: {
// color: '#ffb300',
// width: 2,
// type: 'solid'
// }
// }
// }
// },
// {
// name: textEcharts.liuxian,
// type: 'line',
// data: calculateMA(4, extractedDrawData),
// smooth: true,
// symbol: 'none',
// xAxisIndex: 2,
// yAxisIndex: 2,
// itemStyle: {
// normal: {
// color: '#00c8ff',
// lineStyle: {
// color: '#00c8ff',
// width: 2,
// type: 'solid'
// }
// }
// }
// },
]
}
initChart()
}
//
onMounted(() => {
//
fnShowEcharts4(extractedDrawData)
})
//
const initChart = async () => {
if (!chartRef.value) return
try {
const chart = await chartRef.value.init(echarts)
chart.setOption(option)
} catch (error) {
console.error('图表初始化失败:', error)
}
}
</script>

219
pages/marketSituation/marketCondition.vue

@ -1497,8 +1497,8 @@ const sendTcpMessage = (command) => {
messageData = {
command: "daily_data",
stock_code: "GBPAUD.FXCM",
start_date: "20251001",
end_date: "20251023",
start_date: "20250801",
end_date: "20251029",
};
break;
// 线
@ -1515,7 +1515,7 @@ const sendTcpMessage = (command) => {
messageData = {
command: "monthly_data",
stock_code: "000001.SZ",
start_date: "2024912",
start_date: "20201130",
end_date: "20251029",
};
break;
@ -1850,6 +1850,45 @@ const parseStockData = (message) => {
}
}
}
} else if ((typeof message === "string" && message.includes("monthly_data_start")) || isMorePacket.monthly_data) {
if (typeof message === "string" && message.includes("monthly_data_start")) {
console.log("开始接受分包数据");
receivedMessage = "";
} else {
console.log("接收分包数据过程中");
}
isMorePacket.monthly_data = true;
receivedMessage += message;
// }JSON
if (receivedMessage.includes("monthly_data_complete")) {
console.log("接受分包数据结束");
isMorePacket.monthly_data = false;
console.log("展示数据", receivedMessage);
const result = findJsonPacket(receivedMessage, "monthly_data_complete");
if (result.error) {
throw new Error("解析JSON字符串失败");
} else {
parsedMessage = result.json;
console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
if (parsedMessage.type === "monthly_data") {
klineData.value = parsedMessage.data.map((item) => ({
open: item.bid_open,
close: item.bid_close,
high: item.bid_high,
low: item.bid_low,
volume: item.vol,
amount: item.amount,
date: item.trade_date ? `${item.trade_date.slice(0, 4)}-${item.trade_date.slice(4, 6)}-${item.trade_date.slice(6, 8)}` : item.trade_date,
}));
stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close;
touchState.offset = canvasWidth.value / klineData.value.length / 2;
console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice);
drawChart();
}
}
}
} else if ((typeof message === "string" && message.includes("daily_one_minutes_data_start")) || isMorePacket.daily_one_minutes_data) {
if (typeof message === "string" && message.includes("daily_one_minutes_data_start")) {
console.log("开始接受分包数据");
@ -1873,15 +1912,171 @@ const parseStockData = (message) => {
parsedMessage = result.json;
console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
if (parsedMessage.type === "daily_one_minutes_data") {
// klineData.value = parsedMessage.data.map((item) => ({
// open: item.open,
// close: item.close,
// high: item.high,
// low: item.low,
// volume: item.volume,
// amount: item.amount,
// date: item.time,
// }));
klineData.value = parsedMessage.data.map((item) => ({
open: item.open,
close: item.close,
high: Math.max(item.low, item.high),
low: Math.min(item.low, item.high),
volume: item.volume,
amount: item.amount,
date: item.timestamp,
}));
stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close;
touchState.offset = canvasWidth.value / klineData.value.length / 2;
console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice);
drawChart();
}
}
}
} else if ((typeof message === "string" && message.includes("daily_five_minutes_data_start")) || isMorePacket.daily_five_minutes_data) {
if (typeof message === "string" && message.includes("daily_five_minutes_data_start")) {
console.log("开始接受分包数据");
receivedMessage = "";
} else {
console.log("接收分包数据过程中");
}
isMorePacket.daily_five_minutes_data = true;
receivedMessage += message;
// }JSON
if (receivedMessage.includes("daily_five_minutes_data_complete")) {
console.log("接受分包数据结束");
isMorePacket.daily_five_minutes_data = false;
console.log("展示数据", receivedMessage);
const result = findJsonPacket(receivedMessage, "daily_five_minutes_data_complete");
if (result.error) {
throw new Error("解析JSON字符串失败");
} else {
parsedMessage = result.json;
console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
if (parsedMessage.type === "daily_five_minutes_data") {
klineData.value = parsedMessage.data.map((item) => ({
open: item.open,
close: item.close,
high: Math.max(item.low, item.high),
low: Math.min(item.low, item.high),
volume: item.volume,
amount: item.amount,
date: item.timestamp,
}));
stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close;
touchState.offset = canvasWidth.value / klineData.value.length / 2;
console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice);
drawChart();
}
}
}
} else if ((typeof message === "string" && message.includes("daily_fifteen_minutes_data_start")) || isMorePacket.daily_fifteen_minutes_data) {
if (typeof message === "string" && message.includes("daily_fifteen_minutes_data_start")) {
console.log("开始接受分包数据");
receivedMessage = "";
} else {
console.log("接收分包数据过程中");
}
isMorePacket.daily_fifteen_minutes_data = true;
receivedMessage += message;
// }JSON
if (receivedMessage.includes("daily_fifteen_minutes_data_complete")) {
console.log("接受分包数据结束");
isMorePacket.daily_fifteen_minutes_data = false;
console.log("展示数据", receivedMessage);
const result = findJsonPacket(receivedMessage, "daily_fifteen_minutes_data_complete");
if (result.error) {
throw new Error("解析JSON字符串失败");
} else {
parsedMessage = result.json;
console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
if (parsedMessage.type === "daily_fifteen_minutes_data") {
klineData.value = parsedMessage.data.map((item) => ({
open: item.open,
close: item.close,
high: Math.max(item.low, item.high),
low: Math.min(item.low, item.high),
volume: item.volume,
amount: item.amount,
date: item.timestamp,
}));
stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close;
touchState.offset = canvasWidth.value / klineData.value.length / 2;
console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice);
drawChart();
}
}
}
} else if ((typeof message === "string" && message.includes("daily_thirty_minutes_data_start")) || isMorePacket.daily_thirty_minutes_data) {
if (typeof message === "string" && message.includes("daily_thirty_minutes_data_start")) {
console.log("开始接受分包数据");
receivedMessage = "";
} else {
console.log("接收分包数据过程中");
}
isMorePacket.daily_thirty_minutes_data = true;
receivedMessage += message;
// }JSON
if (receivedMessage.includes("daily_thirty_minutes_data_complete")) {
console.log("接受分包数据结束");
isMorePacket.daily_thirty_minutes_data = false;
console.log("展示数据", receivedMessage);
const result = findJsonPacket(receivedMessage, "daily_thirty_minutes_data_complete");
if (result.error) {
throw new Error("解析JSON字符串失败");
} else {
parsedMessage = result.json;
console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
if (parsedMessage.type === "daily_thirty_minutes_data") {
klineData.value = parsedMessage.data.map((item) => ({
open: item.open,
close: item.close,
high: Math.max(item.low, item.high),
low: Math.min(item.low, item.high),
volume: item.volume,
amount: item.amount,
date: item.timestamp,
}));
stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close;
touchState.offset = canvasWidth.value / klineData.value.length / 2;
console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice);
drawChart();
}
}
}
} else if ((typeof message === "string" && message.includes("daily_sixty_minutes_data_start")) || isMorePacket.daily_sixty_minutes_data) {
if (typeof message === "string" && message.includes("daily_sixty_minutes_data_start")) {
console.log("开始接受分包数据");
receivedMessage = "";
} else {
console.log("接收分包数据过程中");
}
isMorePacket.daily_sixty_minutes_data = true;
receivedMessage += message;
// }JSON
if (receivedMessage.includes("daily_sixty_minutes_data_complete")) {
console.log("接受分包数据结束");
isMorePacket.daily_sixty_minutes_data = false;
console.log("展示数据", receivedMessage);
const result = findJsonPacket(receivedMessage, "daily_sixty_minutes_data_complete");
if (result.error) {
throw new Error("解析JSON字符串失败");
} else {
parsedMessage = result.json;
console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
if (parsedMessage.type === "daily_sixty_minutes_data") {
klineData.value = parsedMessage.data.map((item) => ({
open: item.open,
close: item.close,
high: Math.max(item.low, item.high),
low: Math.min(item.low, item.high),
volume: item.volume,
amount: item.amount,
date: item.timestamp,
}));
stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close;
touchState.offset = canvasWidth.value / klineData.value.length / 2;
console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice);

15
pages/marketSituation/marketOverview.vue

@ -5,7 +5,6 @@
<!-- 可滚动内容区域 -->
<scroll-view class="content_scroll" scroll-y="true" :style="{ top: contentTopPosition + 'px' }">
<view class="content">
<button @click="goToChartExample">图表</button>
<view class="map">
<image src="/static/marketSituation-image/map.png" mode="widthFix"></image>
</view>
@ -52,13 +51,6 @@ const isWarnTextOverflow = ref(false); // warn文字是否溢出
const pageIndex = ref(0);
const scrollToView = ref("");
//
const goToChartExample = () => {
uni.navigateTo({
url: "/pages/marketSituation/chartExample",
});
};
// contenttop
const contentTopPosition = computed(() => {
const statusBarHeight = iSMT.value || 0;
@ -650,8 +642,7 @@ watch(headerHeight, (newHeight) => {
margin: 0;
box-sizing: border-box;
width: 100%;
padding: 30rpx 20rpx;
gap: 20rpx;
padding: 30rpx 0;
}
.card_item {
@ -665,7 +656,7 @@ watch(headerHeight, (newHeight) => {
@media (max-width: 600rpx) {
.cards_grid {
grid-template-columns: repeat(2, 1fr);
padding: 30rpx 20rpx;
padding: 30rpx 0;
}
}
@ -673,7 +664,7 @@ watch(headerHeight, (newHeight) => {
@media (max-width: 400rpx) {
.cards_grid {
grid-template-columns: 1fr;
padding: 30rpx 20rpx;
padding: 30rpx 0;
}
}

25
pages/setting/account.vue

@ -67,6 +67,8 @@
ref,
onMounted
} from 'vue'
import {useUserStore} from "../../stores/modules/userInfo"
import {
getUserInfo
} from "@/api/member";
@ -74,27 +76,20 @@
// const dccode = ref('')
const userInfoRes = ref({})
const showLogout = ref(false)
const userInfoPromise = getUserInfo()
userInfoPromise.then(res => {
if (res.code === 200) {
userInfoRes.value.dccode = res.data.dccode;
userInfoRes.value.dcname = res.data.dcname;
userInfoRes.value.hasPwd = res.data.hasPassword;
console.log('用户信息', userInfoRes.value)
} else {
uni.showToast({
title: '用户信息请求失败',
icon: 'none',
})
}
})
const userStore = useUserStore()
const handleConfirmLogout = () => {
userStore.clearUserInfo()
showLogout.value = false
uni.showToast({
title: '退出登录成功',
icon: 'none',
})
uni.navigateTo({
url: '/pages/start/login/login'
})
}
const goToBind = () => {

39
utils/http.js

@ -1,7 +1,7 @@
import { useUserStore } from "../stores/modules/userInfo"
import { useDeviceStore } from "../stores/modules/deviceInfo"
// const baseURL = "https://hwjb.homilychart.com/testApi"
const baseURL = "http://192.168.40.8:9000"
const baseURL = "https://dbqb.nfdxy.net/testApi"
const httpInterceptor = {
@ -22,30 +22,31 @@ const httpInterceptor = {
// 打印最终请求地址
console.log('HTTP(finalUrl)=', options.url)
// 2.请求超时,默认60s
options.timeout = 60000
options.timeout = 10000
console.log(options)
//3 添加小程序端请求头
const sys = uni.getSystemInfoSync();
// 为对齐后端文档示例,client 固定为 ios(如需按平台设置再改回)
const client = 'ios';
const deviceInfo =useDeviceStore()
options.header = {
...options.header,
'source-client': 'miniapp',
// 标准头与文档头同时设置,确保兼容
'content-type': 'application/json',
// 'contentType': 'application/json',
'version': '1',
'client': client,
'deviceId':'1'
'contentType': 'application/json',
'version': uni.getSystemInfoSync().appVersion,
'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android',
'deviceId': deviceInfo.deviceInfo.deviceId
}
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore()
// const token = memberStore.userInfo?.token || options.data?.token
options.header.token = '9cd87893b9282b6a7a6cc9b780c905db'
const token = '9cd87893b9282b6a7a6cc9b780c905db'
if (token) {
options.header.token = token
}
const token = memberStore.userInfo?.token || options.data?.token
// const token = '1b3a58424c5324e40d4bf4d085e18047'
if (token) {
options.header.token = token
}
// 避免误用 Authorization 头,后端要求的是 token 头
// if (options.header.Authorization) delete options.header.Authorization
return options
@ -62,6 +63,12 @@ export const http = (options) => {
// 1.请求成功
success: (result) => {
if (result.statusCode >= 200 && result.statusCode < 300) {
if (result.data.code === 401) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
}
resolve(result.data)
} else if (result.statusCode === 401) {
// 清除登录信息
@ -84,7 +91,7 @@ export const http = (options) => {
fail: (err) => {
reject(err)
uni.showToast({
title: '网络错误',
title: '请求超时',
icon: 'none'
})
}

Loading…
Cancel
Save