瀏覽代碼

持仓分析

jwyu 2 年之前
父節點
當前提交
d75f33f5e0

+ 10 - 0
api/positionAnalysis.js

@@ -0,0 +1,10 @@
+// 持仓分析模块
+
+import { httpGet, httpPost } from "@/utils/request.js";
+
+/**
+ * 持仓分析列表
+ */
+export const apiPositionAnalysisList=()=>{
+    return httpGet('/trade/analysis/classify',{})
+}

+ 3 - 1
pages/pc.vue

@@ -23,7 +23,9 @@ const mapObj=new Map([
     ['pages-voice/voiceDetail','/voice/detail'],
     ['pages-roadShow/video/list','/roadshow/video/list'],
     ['pages/roadShow/video/list','/roadshow/video/list'],
-    ['pages-report/reportForVariety/list','/report/varietyreportlist']
+    ['pages-report/reportForVariety/list','/report/varietyreportlist'],
+    ['pages/positionAnalysis/index','/positionanalysis/index'],
+    ['pages/positionAnalysis/detail','/positionanalysis/detail']
 ])//map映射小程序页面路径对应h5页面路径
 import {apiUserInfo} from '@/api/user'
 import {apiGetSceneToParams} from '@/api/common'

+ 66 - 8
pages/positionAnalysis/components/indexContent.vue

@@ -1,20 +1,30 @@
 <template>
     <view class="list-content-wrap">
         <view class="top-box">
-            <text style="margin-right:20rpx">4品种</text>
-            <text>2023-2-06 13:30:30</text>
+            <text style="margin-right:20rpx">{{num}}品种</text>
+            <text>{{time}}</text>
         </view>
         <view class="list-wrap">
-            <view class="flex item" v-for="item in 4" :key="item">
-                <view class="label">动力煤</view>
+            <view class="flex item" v-for="item in list" :key="item.classify_name">
+                <view class="label">{{item.classify_name}}</view>
                 <view style="flex:1">
-                    <view class="opt">zc</view>
-                    <view class="opt">zcccccc</view>
-                    <view class="opt">zc</view>
-                    <view class="opt">zcccccc</view>
+                    <view 
+                        class="opt" 
+                        v-for="_item in item.items" 
+                        :key="_item.classify_type"
+                        @click="goDetail(_item,item)"
+                    >{{_item.classify_type}}</view>
                 </view>
             </view>
         </view>
+        <view class="empty-box" v-if="!list||list.length===0">
+            <image
+                :src="globalImgUrls.chartEmpty"
+                mode="widthFix"
+            />
+            <view>无数据~</view>
+        </view>
+          
     </view>
       
 </template>
@@ -23,6 +33,44 @@
 const dayjs=require('@/utils/dayjs.min')
 export default {
     name:'IndexContent',
+    props:{
+        time:{
+            default:''
+        },
+        num:{
+            default:''
+        },
+        list:{
+            default:null
+        },
+        exchange:{
+            default:''
+        }
+    },
+    methods: {
+        goDetail(_item,item){
+            const queryObj={
+                classify_name:item.classify_name,
+                classify_type:_item.classify_type,
+                exchange:this.exchange
+            }
+            let queryObjStr=''
+            for (const key in queryObj) {
+                if(!queryObjStr){
+                        queryObjStr=`${key}=${queryObj[key]}`
+                }else{
+                    queryObjStr=`${queryObjStr}&${key}=${queryObj[key]}`
+                }
+            }
+            uni.navigateTo({
+                url: `/pages/positionAnalysis/detail?${queryObjStr}`,
+                success: (result) => {},
+                fail: () => {},
+                complete: () => {}
+            });
+              
+        }
+    },
     
 }
 </script>
@@ -56,4 +104,14 @@ export default {
         }
     }
 }
+.empty-box{
+    text-align: center;
+    font-size: 32rpx;
+    color: #999;
+    padding-top: 150rpx;
+    image{
+        width: 346rpx;
+        margin-bottom: 57rpx;
+    }
+}
 </style>

+ 35 - 5
pages/positionAnalysis/detail.vue

@@ -1,5 +1,5 @@
 <template>
-    <web-view :src="url"></web-view>
+    <web-view :src="url" @message="handleGetMessage"></web-view>
 </template>
 
 <script>
@@ -7,12 +7,31 @@ import {h5BaseUrl} from '@/utils/config'
 export default {
     data () {
         return {
-            url:''
+            url:'',
+            msgObj:{}
+
+        }
+    },
+    onShareAppMessage() {
+        let paramsStr=''
+        for(const key in this.msgObj.params){
+            if(!paramsStr){
+                paramsStr=`${key}=${this.msgObj.params[key]}`
+            }else{
+                paramsStr=`${paramsStr}&${key}=${this.msgObj.params[key]}`
+            }
+        }
+        return {
+            title:this.msgObj.title||'持仓分析详情',
+            path:`/pages/positionAnalysis/detail?${paramsStr}&from=share`,
+            imageUrl:this.msgObj.shareImg||''
         }
     },
     onLoad(options){
         const queryObj={
-            id:0,
+            classify_name:options.classify_name,
+            classify_type:options.classify_type,
+            exchange:options.exchange,
             token:this.$store.state.user.token||uni.getStorageSync("token"),
             timestamp:new Date().getTime(),//防止缓存
         }
@@ -26,10 +45,21 @@ export default {
         }
         console.log('拼接字符串:',queryObjStr);
         this.url=`${h5BaseUrl}/hzyb/chart/positionanalysis?${queryObjStr}#wechat_redirect`
-    }
+    },
+    methods: {
+        // 获取到用户点击转发时从h5页面传来的参数
+        handleGetMessage(e){
+            const data=e.detail.data[e.detail.data.length-1]
+            console.log('h5传来的数据',data);
+            this.msgObj=data
+        }
+    },
 }
 </script>
 
 <style>
-
+page{
+    padding-bottom: constant(safe-area-inset-bottom);
+    padding-bottom: env(safe-area-inset-bottom);
+}
 </style>

+ 32 - 26
pages/positionAnalysis/index.vue

@@ -6,48 +6,37 @@
             animated 
             swipeable 
             color="#E3B377"
+            id="tabs"
         >
             <van-tab 
-                :title="item.title" 
-                v-for="item in opts" 
-                :key="item.val"
-            ><indexContent/></van-tab>
+                :title="item.exchange" 
+                v-for="item in list" 
+                :key="item.exchange"
+                :name="item.exchange"
+            >
+                <indexContent :list="item.items" :num="item.num" :time="item.data_time" :exchange="item.exchange"/>
+            </van-tab>
         </van-tabs>
     </view>
       
 </template>
 
 <script>
+import {apiPositionAnalysisList} from '@/api/positionAnalysis.js'
 import indexContent from './components/indexContent.vue'
 export default {
     components:{indexContent},
     data() {
         return {
-            opts:[
-                {
-                    title:'郑商所',
-                    val:'1'
-                },
-                {
-                    title:'大商所',
-                    val:'2'
-                },
-                {
-                    title:'上期所',
-                    val:'3'
-                },
-                {
-                    title:'中金所',
-                    val:'4'
-                },
-                {
-                    title:'能源所',
-                    val:'5'
-                }
-            ]
+            list:[],
+            activeType:''
         }
     },
+    onLoad(){
+        this.getList()
+    },
     onPullDownRefresh() {
+        this.getList()
 		setTimeout(() => {
 			uni.stopPullDownRefresh()
 		}, 1500);
@@ -58,10 +47,27 @@ export default {
 			title:'持仓分析',
 		}
 	},
+    methods: {
+        async getList(){
+            const res=await apiPositionAnalysisList()
+            if(res.code===200){
+                this.list=res.data||[]
+                this.activeType=res.data[0]&&res.data[0].exchange
+                this.$nextTick(()=>{
+                    this.selectComponent('#tabs').resize();
+                })
+                
+            }
+        }
+    },
 }
 </script>
 
 <style lang="scss">
+page{
+    padding-bottom: constant(safe-area-inset-bottom);
+    padding-bottom: env(safe-area-inset-bottom);
+}
 .van-sticky-wrap--fixed{
     box-shadow: 0px 4px 4px rgba(198, 198, 198, 0.25);
 }

+ 2 - 1
pages/report/report.vue

@@ -123,7 +123,8 @@ export default {
         ['sandbox','/pages-sandTable/sandTable'],
         ['activity','/pages/activity/activity'],
         ['pricedriven','/pages/pricedriven/pricedriven'],
-        ['video','/pages/video/videoList']
+        ['video','/pages/video/videoList'],
+        ['position_analysis','/pages/positionAnalysis/index']
       ]),
       tabCards: []
     }

+ 1 - 1
utils/request.js

@@ -97,7 +97,7 @@ const http=(url,params,method)=>{
 			method:method,
 			header:{
 				Authorization:store.state.user.token,
-				version:'yb11.6'
+				version:'yb11.8'
 			},
 			success(e) {
 				// 接口404