瀏覽代碼

更新期货数据

ccjgmwz 3 年之前
父節點
當前提交
a2f1c3622c
共有 6 個文件被更改,包括 376 次插入19 次删除
  1. 23 12
      components/swiperup.vue
  2. 259 0
      pageB/info/info_list.vue
  3. 7 0
      pages.json
  4. 41 6
      pages/sale/information.vue
  5. 3 1
      store/index.js
  6. 43 0
      websocket_sdk.js

+ 23 - 12
components/swiperup.vue

@@ -1,15 +1,17 @@
 <template>
-	<view class="wrap">
+	<view class="wrap" @click="clickInfoList()">
 		 <swiper
 	  id="_swiper_up"
 	  :indicator-dots="indicatorDots"
 	  :autoplay="autoplay" :interval="interval" :duration="duration" vertical="true" circular="true">
 	  <block v-for="(item,index) in list" :key="index">
-	    <swiper-item>
+	    <swiper-item >
 			<view class="itme_text">
 				<view>
-					<image class='gb' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/gb.png'></image>
-					<image class='horn' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/horn.png'></image>{{item.port}}{{item.goodsName}}&nbsp;&nbsp;({{item.newOld}})&nbsp;&nbsp;{{item.price}}元/吨
+					<image class='gb' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/new.png'></image>
+					最新价格:<{{item.goodsName}}> 
+					<text style="margin-right: 10px;margin-left: 10px;" :class="item.newPrice > item.openPrice ? 'text-red':'text-green'">{{item.newPrice}}</text>
+					元/吨
 				</view>
 			</view>
 	    </swiper-item>
@@ -61,9 +63,15 @@
 			console.log(this.list)
 		},
 		methods: {
+			clickInfoList(){
+				uni.navigateTo({
+					url: `/pageB/info/info_list`
+				})
+			},
 			eventClick() {
 				this.$emit('eventClick');
 			}
+			
 		},
 	}
 </script>
@@ -85,29 +93,31 @@
 		position: absolute;
 		background: #fff;
 		display: block;
-		width: 35px;
-		height: 35px;
+		width: 32px;
+		height: 32px;
 		left: -15px;
 		z-index: 1;
-		-webkit-border-radius: 50%;
-		border-radius: 50%;
+		-webkit-border-radius: 30%;
+		border-radius: 30%;
 	}
 	.wrap::after{
 		content: "";
 		position: absolute;
 		background: #fff;
 		display: block;
-		width: 35px;
-		height: 35px;
+		width: 32px;
+		height: 32px;
 		right: -15px;
 		z-index: 1;
-		-webkit-border-radius: 50%;
-		border-radius: 50%;
+		-webkit-border-radius: 30%;
+		border-radius: 30%;
 	}
 	.gb{
 		width:27px;
 		height:21px;
 		vertical-align: middle;
+		margin-right: 10px;
+		
 	}
 	.horn{
 		width:14px;height:14px;
@@ -130,5 +140,6 @@
 	.itme_text {
 	  font-size: 26rpx;
 	  z-index: 999;
+	  color: #000000;
 	}
 </style>

文件差異過大導致無法顯示
+ 259 - 0
pageB/info/info_list.vue


+ 7 - 0
pages.json

@@ -539,6 +539,13 @@
 						"enablePullDownRefresh": true
 					}
 				},
+				{
+				    "path" : "info/info_list",
+				    "style" : {
+						"navigationBarTitleText": "期货信息",
+						"enablePullDownRefresh": false
+					}
+				},
 				{
 				    "path" : "contract/contract_detail",
 				    "style" : {

+ 41 - 6
pages/sale/information.vue

@@ -22,7 +22,7 @@
 				<text class="num">{{swiperLength}}</text>
 			</view> -->
 		</view> 
-		<swiper-up :list="portInfo"></swiper-up>
+		<swiper-up :list="infoList" ></swiper-up>
 		<scroll-view style='margin-top:12px;padding:0 20px;' scroll-x class="nav">
 			<view class="flex text-center">
 				<view style='position:relative;' class="cu-item flex-sub" :class="item.value==TabCur?'text-white':''" v-for="item in categoryList"@tap="tabSelect" :data-id="item.value">
@@ -130,7 +130,6 @@
 			<view v-show="isLoadMore">
 			    <uni-load-more :status="loadStatus" ></uni-load-more>
 			</view>
-			
 		</view>
 	</view>
 </template>
@@ -178,7 +177,8 @@
 				loadStatus:'loading',  //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
 				TabCur: 0,
 				category:0,
-				current: 0
+				current: 0,
+				infoList1:[]
 			};
 		},
 		onReady() {
@@ -188,11 +188,45 @@
 			this.pages = 1
 			this.isLoadMore = false
 			this.loadStatus = 'more'
-			const that = this
 			this.loadData()
 		},
 		onLoad(options) {
-			
+			var that = this
+			var infoList = [];
+			uni.request({
+			    url: "https://hq.sinajs.cn/list=C0,C2109,C2111,C2201,C2203,C2205,C2207,A0,A2109,A2111,A2201,A2203,A2205,A2207",
+			    // url: "https://hq.sinajs.cn/list=C2109",
+			    header: {
+			        'content-type': 'application/x-www-form-urlencoded'
+			    },
+			    success: function(result) {
+			        // resolve调用后,即可传递到调用方使用then或者async+await同步方式进行处理逻辑
+					var tmp = result.data.split('"')
+					for(var i = 1; i<tmp.length;i=i+2){
+						var list = tmp[i].split(",")
+						var data = {
+							goodsName:list[0],
+							newPrice:list[6],
+							openPrice:list[2]
+						}
+						if(data.goodsName){
+							infoList.push(data)
+						}
+					}
+					let name = 'infoList';
+					let value = infoList;
+					that.$store.commit('$uStore', {
+						name,
+						value
+					});
+					// console.log("infoList",infoList)
+			    },
+			    fail: function(e) {
+			        console.log('error in...')
+			        // reject调用后,即可传递到调用方使用catch或者async+await同步方式进行处理逻辑
+			        reject(e)
+			    },
+			})
 		},
 		onPageScroll(e) {
 			this.scrollTop = e.scrollTop;
@@ -214,6 +248,7 @@
 			...mapState(['hasLogin', 'userInfo'])
 		},
 		methods: {
+			
 			DotStyle(e) {
 				this.dotStyle = e.detail.value
 			},
@@ -343,7 +378,7 @@
 					//价格简报
 					if (data.portInfo) {
 						that.portInfo = data.portInfo
-						console.log(that.portInfo)
+						console.log("portInfo",that.portInfo)
 					}
 					//分类5Buttom
 					if (data.advertisement.t4) {

+ 3 - 1
store/index.js

@@ -11,7 +11,7 @@ try {
 }
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
-let saveStateKeys = ['firendItem','userData','pushRes','myTip','taskTip','contractTip','liangxinTip','packet','linkItem','memberItem','memberItemIndex','chatItem','clientId'];
+let saveStateKeys = ['firendItem','userData','pushRes','myTip','taskTip','contractTip','liangxinTip','packet','linkItem','memberItem','memberItemIndex','chatItem','clientId','infoList'];
 
 // 保存变量到本地存储中
 const saveLifeData = function(key, value) {
@@ -53,6 +53,8 @@ const store = new Vuex.Store({
 		hasLogin: false,
 		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
 		pushRes:lifeData.pushRes?lifeData.pushRes: {},
+		//期货数据获取
+		infoList:lifeData.infoList?lifeData.infoList: [],
 		//我的气泡提示
 		myTip:lifeData.myTip?lifeData.myTip: 0,
 		//我的气泡提示

+ 43 - 0
websocket_sdk.js

@@ -35,6 +35,7 @@ export default class Websocket {
             //发送心跳
             _this.sendHeartbeatData(options);
 			_this.getTips()
+			_this.getInfo()
         }, this._timeout);
     }
     // 监听websocket连接关闭
@@ -296,4 +297,46 @@ export default class Websocket {
 			})
 		})
 	}
+	getInfo(){
+		return new Promise(resolve => {
+			var hour = new Date().getHours();
+			if((hour >= 9 && hour < 12) ||(hour >= 13 && hour < 15)){
+				var infoList = [];
+				uni.request({
+				    url: "https://hq.sinajs.cn/list=C0,C2109,C2111,C2201,C2203,C2205,C2207,A0,A2109,A2111,A2201,A2203,A2205,A2207",
+				    // url: "https://hq.sinajs.cn/list=C2109",
+				    header: {
+				        'content-type': 'application/x-www-form-urlencoded'
+				    },
+				    success: function(result) {
+				        // resolve调用后,即可传递到调用方使用then或者async+await同步方式进行处理逻辑
+						var tmp = result.data.split('"')
+						for(var i = 1; i<tmp.length;i=i+2){
+							var list = tmp[i].split(",")
+							var data = {
+								goodsName:list[0],
+								newPrice:list[6],
+								openPrice:list[2]
+							}
+							if(data.goodsName){
+								infoList.push(data)
+							}
+						}
+						let name = 'infoList';
+						let value = infoList;
+						store.commit('$uStore', {
+							name,
+							value
+						});
+						// console.log("infoList",infoList)
+				    },
+				    fail: function(e) {
+				        console.log('error in...')
+				        // reject调用后,即可传递到调用方使用catch或者async+await同步方式进行处理逻辑
+				        reject(e)
+				    },
+				})
+			}
+		})
+	}
 }

部分文件因文件數量過多而無法顯示