<template>
	<view>
		<z-paging ref="paging" refresher-only @onRefresh="onRefresh"
			:style="'background-color: '+theme.bg+';color: '+theme.text">
			<!-- 头部 -->
			<view slot="top" class="width-750 relative" :style="{height: `calc(${statusBar}px + 560rpx)`}">
				<view class="width-750 fixed1"
					:style="{paddingTop: statusBar + 'px', height: `calc(${statusBar}px + 560rpx)`}">
					<!-- 交易记录 -->
					<view class="height-110 padding-w-30 flex align-center justify-between">
						<view @click="_goback" class="cuIcon-back font-40 color-white"></view>
						<view @click="router.push('/pages/quantify/TransactionRecord?symbol='+symbol)" class="jilubox">
							{{i18n.Tactics.title1}}
						</view>
					</view>
					<!-- 警告 -->
					<view class="height-52 padding-w-30">
						<view v-if="cion_info.coin_tx==1"
							class="width-100b bj-FF4040 text-center radiu-10 padding-c-6 padding-w-10">
							<text class="font-24 color-white">{{cion_info.coin_waring}}</text>
						</view>
					</view>
					<!-- 币种 -->
					<view class="height-60 flex align-center justify-between padding-w-30">
						<view class="height-60 flex align-center">
							<image class="width-56 height-56 margin-r-10" :src="cion_info.image" mode=""></image>
							<text class="numbold-font color-white font-32">{{coinname}}</text>
							<view :class="ifxuanzhuan?'xuanzhuan_360':'xuanzhuan_0'" class="biaoqian1 margin-l-12">
								<text>{{cion_info.type == 1?i18n.Tactics.text1:i18n.Tactics.text2}}</text>
							</view>
							<view class="biaoqian margin-l-12">
								<text
									v-if="Language=='zh-cn'">{{i18n.Tactics.text3}}{{cion_info.strategy_xhcode}}{{i18n.Tactics.text4}}</text>
								<text v-else>{{i18n.Tactics.text3}}
									{{i18n.Tactics.text4}}{{cion_info.strategy_xhcode}}</text>
							</view>
						</view>
						<image @click="navBarObj" class="width-54 height-54" src="/static/imgs/quantify/shezhi@2x.png"
							mode=""></image>
					</view>
					<!-- 币种信息 -->
					<view class="height-270 padding-c-30 padding-w-30">
						<view class="height-105 flex">
							<view class="flex-1 height-100b flex direction-column justify-around">
								<text class="font-24 color-white">{{i18n.Tactics.text5}}</text>
								<text class="font-28 color-white numbold-font">{{cion_info.first_num}}</text>
							</view>
							<view class="flex-1 height-100b flex direction-column justify-around">
								<text class="font-24 color-white">{{i18n.Tactics.text6}}</text>
								<text v-if="lastData.close>0"
									class="font-28 color-white numbold-font">{{lastData.close.toFixed(cion_info.price_precision)}}</text>
								<text v-else class="font-28 color-white numbold-font">{{cion_info.coin_price}}</text>
							</view>
							<view class="flex-1 height-100b flex direction-column justify-around">
								<text class="font-24 color-white">{{i18n.Tactics.text7}}</text>
								<text class="font-28 color-white numbold-font">{{cion_info.bc_time}}</text>
							</view>
						</view>
						<view class="height-105 flex">
							<view class="flex-1 height-100b flex direction-column justify-around">
								<text class="font-24 color-white">{{i18n.Tactics.text8}}(USDT)</text>
								<text class="font-28 color-white numbold-font">{{cion_info.cc_amount}}</text>
							</view>
							<view class="flex-1 height-100b flex direction-column justify-around">
								<text class="font-24 color-white">{{i18n.Tactics.text9}}</text>
								<text class="font-28 color-white numbold-font">{{cion_info.cc_price}}</text>
							</view>
							<view class="flex-1 height-100b flex direction-column justify-around">
								<text class="font-24 color-white">{{i18n.Tactics.text10}}</text>
								<text class="font-28 color-white numbold-font">{{cion_info.cc_num}}</text>
							</view>
						</view>
					</view>
					<!-- 涨幅 -->
					<view class="height-80">
						<view class="zhangfubox">
							<view>
								<text v-if="cion_info.cc_price>0&&lastData.close!==0"
									:class="(lastData.close - cion_info.cc_price)>=0?'color-00C481':'color-FF4040'">{{i18n.Tactics.text11}}：{{((lastData.close - cion_info.cc_price)*100/cion_info.cc_price).toFixed(2)}}%</text>
								<text v-else>{{i18n.Tactics.text11}}：{{cion_info.increase}}</text>
							</view>
							<view>
								<text v-if="cion_info.cc_price>0&&lastData.close!==0"
									:class="(lastData.close - cion_info.cc_price)>=0?'text-green':'text-red'">{{i18n.Tactics.text12}}：{{((lastData.close - cion_info.cc_price)*cion_info.cc_num).toFixed(cion_info.price_precision)}}</text>
								<text
									v-else>{{i18n.Tactics.text12}}：{{((cion_info.coin_price - cion_info.cc_price)*cion_info.cc_num)|twoFilter}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 身体 -->
			<view class="width-750 padding-t-16 padding-b-200"
				:style="'background-color: '+theme.fu_bg+';color: '+theme.text">
				<view class="width-100b height-72 padding-w-40 flex align-center justify-between">
					<view @click="tabsChange(index)"
						class="flex-1 height-46 flex direction-column align-center justify-between"
						v-for="(item,index) in list" :key="index">
						<text :class="current==index?'':'color-C3C3C3'" class="weight-bold font-26">{{item}}</text>
						<view :style="current==index?'':'visibility: hidden;'" class="heng"></view>
					</view>
				</view>
				<!-- swiper必须设置flex:1，因为swiper有默认的高度，只有设置flex:1才可以铺满页面  -->
				<swiper style="height: 960rpx;" :current="current" @animationfinish="animationfinish"
					@change="onswiperchange">
					<swiper-item class="swiper-item" style="height: 100%;"
						:style="'background-color: '+theme.bg+';color: '+theme.text">
						<!-- 最高最低 -->
						<view class="height-108 padding-w-30 padding-c-16 flex justify-between">
							<view class="height-100b flex direction-column justify-between">
								<view v-if="lastData.close>0"
									:class="(lastData.close - dayData.open)>0?'color-00C481':'color-FF4040'">
									{{lastData.close.toFixed(cion_info.price_precision)}}
								</view>
								<view class="color-00C481" v-else>{{cion_info.coin_price}}</view>
								<view v-if="lastData.close>0">
									<text v-if="dayData.open>0&&lastData.close!==0"
										:class="(lastData.close - dayData.open)>=0?'color-00C481':'color-FF4040'"
										class="font-26 numbold-font">
										<text v-if="(lastData.close - dayData.open)>=0">+</text>
										{{((lastData.close - dayData.open)*100/dayData.open).toFixed(2)}}%</text>
									<text v-else class="font-26 numbold-font">0.00%</text>
								</view>
								<view v-else>
									<text class="font-26 numbold-font"></text>
								</view>
							</view>
							<view class="height-100b flex direction-column justify-between">
								<view class="flex align-center">
									<text class="font-24 color-C3C3C3">{{i18n.Tactics.gao}}：</text>
									<text
										class="font-24 nummedium-font">{{dayData.high.toFixed(cion_info.price_precision)}}</text>
								</view>
								<view class="flex align-center">
									<text class="font-24 color-C3C3C3">{{i18n.Tactics.di}}：</text>
									<text
										class="font-24 nummedium-font">{{dayData.low.toFixed(cion_info.price_precision)}}</text>
								</view>
							</view>
						</view>
						<!-- 量化信息 -->
						<view class="padding-w-30 flex align-center justify-between"
							:class="hide==true?'height-105':'height-288'">
							<view class="padding-c-23 flex direction-column justify-between"
								:class="hide==true?'height-105':'height-288 flex-1'">
								<view class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text13}}：</text>
									<text class="font-26 nummedium-font">{{cion_info.zy_percent | percentFilter}}</text>
								</view>
								<view v-if="hide==false" class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text14}}：</text>
									<text class="font-26 nummedium-font">{{cion_info.zy_ht | percentFilter}}</text>
								</view>
								<view v-if="hide==false" class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text15}}：</text>
									<text class="font-26 nummedium-font">＜{{cion_info.bcjg}}</text>
								</view>
								<view v-if="hide==false" class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text16}}：</text>
									<text
										class="font-26 nummedium-font">{{cion_info.pc_status==0?i18n.Tactics.text21:i18n.Tactics.text22}}</text>
								</view>
							</view>
							<view class="padding-c-23 flex direction-column justify-between"
								:class="hide==true?'height-105':'height-288 flex-1'">
								<view v-if="hide==false" class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text17}}：</text>
									<text class="font-26 nummedium-font">{{cion_info.double_max}}</text>
								</view>
								<view class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text18}}：</text>
									<text class="font-26 nummedium-font">{{cion_info.bcdf}}</text>
								</view>
								<view v-if="hide==false" class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text19}}：</text>
									<text class="font-26 nummedium-font">{{cion_info.bc_ht | percentFilter}}</text>
								</view>
								<view v-if="hide==false" class="flex align-center">
									<text class="font-28 color-C3C3C3">{{i18n.Tactics.text20}}：</text>
									<text
										class="font-26 nummedium-font">{{cion_info.is_now==1?i18n.Tactics.text21:i18n.Tactics.text22}}</text>
								</view>
							</view>
						</view>

					</swiper-item>
					<swiper-item class="swiper-item" style="height: 100%;">
						<!-- K线 -->
						<view style="width: 750rpx;height: 960rpx;display: block;"
							:style="'background-color: '+theme.bg+';color: '+theme.text">
							<iframe style="width: 750rpx;height: 960rpx;overflow: hidden" :src="src"
								frameborder="0"></iframe>
						</view>
					</swiper-item>
				</swiper>

				<!-- 时间选择 -->
				<!-- <view style="background-color: rgba(136,136,136,0.08);" class="relative">
				<view class="width-100b height-60 flex align-center justify-around padding-sm ">
					<view @click="changeTime(index)" v-for="(item,index) in timeList" :key="index">
						<view :class="time==index?'color-0165EE':'color-333333'">{{item.show}}</view>
					</view>
					<view @click="moreran = !moreran" class="">
						<view class="">
							{{moreran?'More':'Collapse'}}
						</view>
					</view>
				</view>
				<view v-if="!moreran" class="width-100b height-60 flex align-center justify-between absolute"
					style="background-color: rgba(136,136,136,0.08);bottom: -60rpx;">
					<view class="flex-1 text-center" @click="changeTime1(index)" v-for="(item,index) in timeList1"
						:key="index">
						<view :class="time1==index?'color-0165EE':'color-333333'">{{item.show}}</view>
					</view>
				</view>
			</view> -->

				<!-- 空盒子 -->
				<!-- <view class="height-50"></view> -->
			</view>
		</z-paging>

		<!-- 底部操作框 -->
		<view class="bottombox" :style="'background-color: '+theme.bg+';color: '+theme.text">
			<view v-if="cion_info.type == 2" @click="changeType2" :class="ifxuanzhuan?'xuanzhuan_360':'xuanzhuan_0'"
				class="flex-1 height-100b flex direction-column align-center justify-between">
				<image class="width-58 height-58" src="/static/imgs/quantify/danci@2x.png" mode=""></image>
				<text class="font-24">{{i18n.Tactics.text1}}</text>
			</view>
			<view v-if="cion_info.type == 1" @click="changeType1" :class="ifxuanzhuan?'xuanzhuan_360':'xuanzhuan_0'"
				class="flex-1 height-100b flex direction-column align-center justify-between">
				<image class="width-58 height-58" src="/static/imgs/quantify/CELUE@2x.png" mode=""></image>
				<text class="font-24">{{i18n.Tactics.text2}}</text>
			</view>
			<view @click="qcShow = true" class="flex-1 height-100b flex direction-column align-center justify-between">
				<image class="width-58 height-58" src="/static/imgs/quantify/qingcang@2x.png" mode=""></image>
				<text class="font-24">{{i18n.Tactics.text23}}</text>
			</view>
			<view @click="shoudongShow = true"
				class="flex-1 height-100b flex direction-column align-center justify-between">
				<image class="width-58 height-58" src="/static/imgs/quantify/shoudong@2x.png" mode=""></image>
				<text class="font-24">{{i18n.Tactics.text24}}</text>
			</view>
			<view v-if="cion_info.status==1" @click="JGShow = true"
				class="flex-1 height-100b flex direction-column align-center justify-between">
				<image class="width-58 height-58" src="/static/imgs/quantify/guanbi@2x.png" mode=""></image>
				<text class="font-24">{{i18n.Tactics.text22}}</text>
			</view>
			<view v-else @click="JGShow = true"
				class="flex-1 height-100b flex direction-column align-center justify-between">
				<image class="width-58 height-58" src="/static/imgs/quantify/qidong@2x.png" mode=""></image>
				<text class="font-24">{{i18n.Tactics.text25}}</text>
			</view>
		</view>

		<!-- 加仓弹窗 -->
		<u-popup v-model="shoudongShow" mode="center" border-radius="20">
			<view class="width-690 padding-20 radiu-20" :style="'background-color: '+theme.bg+';color: '+theme.text">
				<view class="width-100b height-70 text-center line-height-100">
					<text class="font-28 weight-bold weight-500">{{i18n.Tactics.text26}}USDT</text>
				</view>
				<view class="width-100b height-150 margin-c-10 padding-w-30 flex direction-column justify-around">
					<text class="font-26 weight-bold">{{i18n.Tactics.text27}}</text>
					<input class="width-100b height-86 font-26 numbold-font radiu-10 padding-w-20"
						:style="'background-color: '+theme.fu_bg+';color: '+theme.fu_text"
						:placeholder="i18n.Tactics.tos1" type="number" v-model="buynum" />
				</view>
				<view class="width-100b height-100 flex align-center justify-around">
					<view class="resetBtn" @click="shoudongShow = false,buynum = ''">{{i18n.Tactics.text28}}</view>
					<view class="inquireBtn" @click="add_cang">{{i18n.Tactics.text29}}</view>
				</view>
			</view>
		</u-popup>

		<!-- 清仓弹窗 -->
		<u-popup style="z-index: 5000;" :mask-close-able="false" border-radius="30" mode="center" v-model="qcShow"
			@click.stop="">
			<view class="width-600" :style="'background-color: '+theme.bg+';color: '+theme.text">
				<view
					class="width-100b height-220 padding-w-30 padding-c-30 flex direction-column align-center justify-between">
					<image class="width-64 height-64" src="/static/imgs/quantify/tongzhi@2x.png" mode=""></image>
					<view class="font-26 weight-bold text-center padding-w-20">{{i18n.Tactics.text30}}
					</view>
				</view>
				<view class="width-100b height-90 flex align-center justify-between">
					<view @click="qcShow=false" class="qcbtn1">{{i18n.Tactics.text28}}</view>
					<view class="qcbtn2" @click.stop="clean_cang"> {{i18n.Tactics.text29}}</view>
				</view>
			</view>
		</u-popup>

		<!-- 提示弹窗 -->
		<u-popup style="z-index: 5000;" border-radius="30" mode="center" v-model="JGShow">
			<view class="width-600" :style="'background-color: '+theme.bg+';color: '+theme.text">
				<view
					class="width-100b height-200 padding-w-30 padding-c-40 flex direction-column align-center justify-between">
					<image class="width-64 height-64" src="/static/imgs/quantify/tongzhi@2x.png" mode=""></image>
					<view class="font-26 weight-bold text-center padding-w-20">{{i18n.Tactics.text31}}
					</view>
				</view>
				<view class="width-100b height-90 flex align-center justify-between">
					<view @click="JGShow=false" class="qcbtn1">{{i18n.Tactics.text28}}</view>
					<view @click="qidong" class="qcbtn2"> {{i18n.Tactics.text29}}</view>
				</view>
			</view>
		</u-popup>

		<!-- 提示弹窗 -->
		<u-popup style="z-index: 5000;" :mask-close-able="false" border-radius="18" mode="center" v-model="TSShow">
			<view class="width-600 padding-b-20" :style="'background-color: '+theme.bg+';color: '+theme.text">
				<view
					class="width-100b height-220 padding-w-30 padding-c-40 flex direction-column align-center justify-between">
					<image class="width-64 height-64" src="/static/imgs/quantify/tongzhi@2x.png" mode=""></image>
					<view class="font-26 weight-bold text-center padding-w-20">{{cion_info.xinyu_waring}}
					</view>
				</view>
				<view class="width-100b height-90 flex align-center justify-center">
					<view @click="TSShow=false" class="qcbtn3">{{i18n.Tactics.text29}}</view>
				</view>
			</view>
		</u-popup>

		<!-- 去激活 -->
		<!-- <u-popup v-model="show2" mode="center" border-radius="20">
			<view class="width-600 bj-white padding-t-40 padding-b-50 padding-w-30 relative">
				<u-icon @click="show2=false" class="absolute" style="right: 20rpx;top: 12rpx;" name="close-circle"
					color="#88909E" size="36"></u-icon>
				<view class="width-100b text-center font-26 color-1B1B1B weight-bold">激活说明</view>
				<scroll-view scroll-y="true" style="max-height: 600rpx;">
					<view class="margin-c-40">{{msg}}</view>
				</scroll-view>
				<view @click="goJihuo" class="width-100b text-center font-26 color-2564F6 weight-bold">去激活~</view>
			</view>
		</u-popup> -->
		<u-popup style="z-index: 5000;" border-radius="18" mode="center" v-model="show2">
			<view class="width-600 padding-b-20" :style="'background-color: '+theme.bg+';color: '+theme.text">
				<view
					class="width-100b height-220 padding-w-30 padding-c-40 flex direction-column align-center justify-between">
					<image class="width-64 height-64" src="/static/imgs/quantify/tongzhi@2x.png" mode=""></image>
					<view class="font-26 weight-bold text-center padding-w-20">{{i18n.Tactics.text32}}
					</view>
				</view>
				<view class="width-100b height-90 flex align-center justify-center">
					<view @click="show2=false,router.push('/pages/my/safety/real')" class="qcbtn3">
						{{i18n.Tactics.text33}}
					</view>
				</view>
			</view>
		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBar: uni.getSystemInfoSync().statusBarHeight,
				Language: '',
				coinname: '',
				coinID: '',
				cion_info: {
					first_num: 0,
					coin_price: '0.000000',
					bc_time: 0,
					cc_amount: 0,
					cc_price: 0,
					cc_num: 0,
					zy_percent: 0,
					zy_ht: 0,
					bcjg: 0,
					double_max: 0,
					bcdf: 0,
					bc_ht: 0,
					type: 1,
					increase: 0,
					price_precision: 4
				},
				show2: false,
				msg: '',
				src: '',

				shoudongShow: false,
				qcShow: false,
				buynum: '',
				ifxuanzhuan: false,
				cionType: '',
				hide: false,

				JGShow: false,
				TSShow: false,
				qcFlag: true,
				symbol: "",
				period: "1min",
				wsId: "",
				subNVue: "",
				timeList: [{
						show: "1分",
						time: "1min",
						value: 60
					},
					{
						show: "15分",
						time: "15min",
						value: 900
					},
					{
						show: "1时",
						time: "60min",
						value: 3200
					},
					{
						show: "1天",
						time: "1day",
						value: 86400
					},
				],
				timeList1: [{
						show: "5分",
						time: "5min",
						value: 300
					},
					{
						show: "30分",
						time: "30min",
						value: 1800
					},
					{
						show: "1周",
						time: "1week",
						value: 604800
					},
					{
						show: "1月",
						time: "1mon",
						value: 2592000
					}
				],
				time1: -1,
				moreran: true,
				time: 0,
				dayData: {
					"open": 0,
					"close": 0,
					"low": 0,
					"high": 0,
				},
				lastData: {
					"open": 0,
					"close": 0,
					"low": 0,
					"high": 0,
				},
				list: ['Quantify Info', 'K-Line'],
				current: 0,

				theme: '',
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			}
		},
		filters: {
			// 百分号过滤器（保留小数点后两位）
			percentFilter: function(item) {
				return (item * 100).toFixed(2) + '%'
			},
			// 币种名称过滤器
			coinnameFilter: function(item) {
				var idx = item.indexOf('/')
				return item.slice(0, idx)
			},
			// 百分号过滤器（保留小数点后两位）
			twoFilter: function(item) {
				return Number(item).toFixed(2)
			}
		},
		onLoad(e) {
			this.list[0] = this.i18n.Tactics.text34
			this.list[1] = this.i18n.Tactics.text35
			this.coinID = ''
			console.log(e)
			this.coinname = e.name
			this.coinID = e.id
			this.subNVue = uni.getSubNVueById('popup')
		},
		onUnload() {
			this.coinID = ''
			console.log('id已重置')
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			} else {
				this.theme = this.$store.state.lightTheme
			}

			this.Language = uni.getStorageSync('Language')
			this.onSocketMessage()
			this.get_cionInfo(this.coinID)
			if (this.symbol !== "") {
				var toTime = Date.parse(new Date()) / 1000
				var fromTime = toTime - 60 * 200
				this.sendSocketMessage({
					"req": "market." + this.symbol + ".kline." + this.period,
					"id": getApp().globalData.wsId,
					"from": fromTime,
					"to": toTime
				})
				this.sendSocketMessage({
					"sub": "market." + this.symbol + ".kline." + this.period,
					"id": getApp().globalData.wsId,
				})
				this.sendSocketMessage({
					"sub": "market." + this.symbol + ".kline.1day",
					"id": getApp().globalData.wsId,
				})
			}
		},
		onReady: function() {
			uni.$on('closePopup', (res) => {
				console.log("打开了")
				this.subNVue.hide()
			})
			uni.$on('deal', (data) => {
				console.log("打开了")
				this.subNVue.hide()
				if (data.type == "qingcang") {
					this.clean_cang()
				}
				if (data.type == "qidong") {
					this.qidong()
				}
				if (data.type == "jiacang") {
					this.buynum = data.number
					this.add_cang()
				}
				if (data.type == "celue1") {
					this.changeType1()
				}
				if (data.type == "celue2") {
					this.changeType2()
				}
				if (data.type == "reConnect") {
					this.onSocketMessage()
				}
			})
		},
		onBackPress: function() {
			var that = this
			this.sendSocketMessage({
				"unsub": "market." + that.symbol + ".kline." + that.period,
				"id": getApp().globalData.wsId,
			})
			this.sendSocketMessage({
				"unsub": "market." + that.symbol + ".kline.1day",
				"id": getApp().globalData.wsId,
			})
			uni.$off('deal')
			uni.$off('closePopup')
			getApp().globalData.symbol = ""
			getApp().globalData.period = ""
		},
		methods: {
			onRefresh() {
				this.get_cionInfo(this.coinID)
				// 以告知z-paging下拉刷新结束，这样才可以开始下一次的下拉刷新
				setTimeout(() => {
					//1.5秒之后停止刷新动画
					this.$refs.paging.complete();
				}, 1500)
			},
			// tabs通知swiper切换
			tabsChange(index) {
				this.current = index;
			},
			onswiperchange(e) {
				// #ifndef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
				let index = e.target.current || e.detail.current;
				this.tabsChange(index);
				// #endif
			},
			animationfinish(e) {
				let current = e.detail.current;
				this.current = current;
			},
			goJihuo() {
				this.show2 = false
				uni.switchTab({
					url: '/pages/my/index'
				})
			},
			changeTime1(index) {
				this.moreran = true
				this.time = -1
				var that = this
				if (this.time1 == index) {

				} else {
					this.time1 = index
					this.sendSocketMessage({
						"unsub": "market." + that.symbol + ".kline." + that.period,
						"id": getApp().globalData.wsId,
					})
					this.period = this.timeList1[index].time
					var toTime = Date.parse(new Date()) / 1000
					var fromTime = toTime - this.timeList1[index].value * 200
					if (fromTime < 1501174800) {
						fromTime = 1501174800
					}
					getApp().globalData.symbol = that.symbol
					getApp().globalData.period = that.period
					this.sendSocketMessage({
						"req": "market." + that.symbol + ".kline." + that.period,
						"id": getApp().globalData.wsId,
						"from": fromTime,
						"to": toTime
					})
					this.sendSocketMessage({
						"sub": "market." + that.symbol + ".kline." + that.period,
						"id": getApp().globalData.wsId,
					})
					this.sendSocketMessage({
						"sub": "market." + that.symbol + ".kline.1day",
						"id": getApp().globalData.wsId,
					})
				}
			},
			changeTime(index) {
				this.moreran = true
				this.time1 = -1
				var that = this
				if (this.time == index) {

				} else {
					this.time = index
					this.sendSocketMessage({
						"unsub": "market." + that.symbol + ".kline." + that.period,
						"id": getApp().globalData.wsId,
					})
					this.period = this.timeList[index].time
					var toTime = Date.parse(new Date()) / 1000
					var fromTime = toTime - this.timeList[index].value * 200
					if (fromTime < 1501174800) {
						fromTime = 1501174800
					}
					getApp().globalData.symbol = that.symbol
					getApp().globalData.period = that.period
					this.sendSocketMessage({
						"req": "market." + that.symbol + ".kline." + that.period,
						"id": getApp().globalData.wsId,
						"from": fromTime,
						"to": toTime
					})
					this.sendSocketMessage({
						"sub": "market." + that.symbol + ".kline." + that.period,
						"id": getApp().globalData.wsId,
					})
					this.sendSocketMessage({
						"sub": "market." + that.symbol + ".kline.1day",
						"id": getApp().globalData.wsId,
					})
				}
			},
			// jiacang() {
			// 	var that = this
			// 	uni.$emit('showPopup', {
			// 		"content": {
			// 			num: that.cion_info.cc_num,
			// 			money: that.cion_info.cc_amount,
			// 			price: that.cion_info.cc_price
			// 		},
			// 		"type": "jiacang"
			// 	})
			// 	console.log(that.cion_info.cc_price)
			// 	this.subNVue.show('zoom-fade-out', 200)
			// },
			// guanbi() {
			// 	uni.$emit('showPopup', {
			// 		"content": "是否确认此操作？",
			// 		"type": "qidong"
			// 	})
			// 	this.subNVue.show('zoom-fade-out', 200)
			// },
			// qingcang() {
			// 	uni.$emit('showPopup', {
			// 		"content": "按照当前的价格，卖出所有资产，确定清仓吗？",
			// 		"type": "qingcang"
			// 	})
			// 	this.subNVue.show('zoom-fade-out', 200)
			// },
			// 加仓
			add_cang() {
				if (this.buynum == '') {
					this.tos(this.this.i18n.Tactics.tos1)
					return
				}
				uni.showLoading({
					title: ''
				})
				this.post('/strategy/add_cang', {
					coin_id: this.coinID,
					num: this.buynum
				}).then(res => {
					console.log(res)
					uni.hideLoading()
					if (res.code == 1) {
						this.tos(res.msg)
						this.buynum = ''
						this.shoudongShow = false
						this.get_cionInfo(this.coinID)
					} else {
						uni.hideToast()
						if (res.data.jump == 1) {
							this.shoudongShow = false
							this.msg = res.msg
							this.show2 = true
						}
					}
				})
			},
			// 清仓
			clean_cang() {
				if (!this.qcFlag) return
				uni.showLoading({
					title: ''
				})
				this.qcFlag = false
				this.post('/strategy/clean_cang', {
					coin_id: this.coinID
				}).then(res => {
					console.log(res)
					uni.hideLoading()
					this.qcFlag = true
					if (res.code == 1) {
						this.tos(res.msg)
						this.qcShow = false
						this.get_cionInfo(this.coinID)
					}
				})
			},
			navBarObj() {
				// 加密传递的对象数据
				// console.log(this.cion_info.bcjson)
				let item = encodeURIComponent(JSON.stringify(this.cion_info))
				var obj = this.cion_info.bcjson
				let bcjson = encodeURIComponent(JSON.stringify(obj))
				uni.navigateTo({
					url: '/pages/quantify/setTransaction?item=' + item + '&bcjson=' + bcjson
				})
			},
			get_cionInfo(id) {
				this.post('/strategy/get_strategy_coin', {
					coin_id: id
				}).then(res => {
					console.log('量化信息', res)
					if (res.code == 1) {
						this.symbol = res.data.symbol
						this.cion_info = res.data
						this.src = 'https://exchange.v5ico-kline.coddex.xyz/index.html?title=' + this.coinname +
							'&symbol=' + res.data.symbol + '&lang=' + uni.getStorageSync('Language')

						uni.$emit('cion_info', {
							"cion_info": res.data
						})
						this.cionType = res.data.type
						if (this.cion_info.xinyu == 1) {
							this.TSShow = true
						}
						// this.connectWS()

						var toTime = Date.parse(new Date()) / 1000
						var fromTime = toTime - 60 * 200
						this.sendSocketMessage({
							"req": "market." + this.symbol + ".kline." + this.period,
							"id": getApp().globalData.wsId,
							"from": fromTime,
							"to": toTime
						})
						this.sendSocketMessage({
							"sub": "market." + this.symbol + ".kline." + this.period,
							"id": getApp().globalData.wsId,
						})
						this.sendSocketMessage({
							"sub": "market." + this.symbol + ".kline.1day",
							"id": getApp().globalData.wsId,
						})
						getApp().globalData.symbol = this.symbol
						getApp().globalData.period = this.period
					}
				})
			},
			qidong() {
				var obj = {}
				if (this.cion_info.status == 1) {
					obj = {
						coin_id: this.coinID,
						status: 0,
					}
				}
				if (this.cion_info.status == 0) {
					obj = {
						coin_id: this.coinID,
						status: 1,
					}
				}
				this.post('/strategy/set_strategy', obj).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.tos(res.msg)
						this.JGShow = false
						this.get_cionInfo(this.coinID)
					}
					if (res.code == 0) {
						if (res.data.jump == 1) {
							uni.hideToast()
							this.JGShow = false
							this.msg = res.msg
							this.show2 = true
						}
					}
				})
			},
			changeType1() {
				uni.showLoading({
					title: ''
				})
				var obj = {
					coin_id: this.coinID,
					type: 2,
				}
				console.log(obj)
				this.post('/strategy/set_strategy', obj).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						// this.tos(res.msg)
						// that.cionType = 2
						this.get_cionInfo(this.coinID)
						this.ifxuanzhuan = !this.ifxuanzhuan
					} else {
						uni.hideToast()
						if (res.data.jump == 1) {
							this.JGShow = false
							this.msg = res.msg
							this.show2 = true
						}
					}
				})
			},
			changeType2() {
				uni.showLoading({
					title: ''
				})
				var obj = {
					coin_id: this.coinID,
					type: 1,
				}
				console.log(obj)
				this.post('/strategy/set_strategy', obj).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						// this.tos(res.msg)
						// that.cionType = 1
						this.get_cionInfo(this.coinID)
						this.ifxuanzhuan = !this.ifxuanzhuan
					} else {
						uni.hideToast()
						if (res.data.jump == 1) {
							this.JGShow = false
							this.msg = res.msg
							this.show2 = true
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.fixed1 {
		position: fixed;
		top: 0;
		z-index: 1000;
		background: #0056CC;
	}

	.title {
		font-size: 30rpx;
		font-weight: 700;
		color: #FFFFFF;
		position: absolute;
		right: 30rpx;
	}

	.jilubox {
		width: 180rpx;
		height: 56rpx;
		background: #0068D4;
		border: 1rpx solid #AACDFF;
		border-radius: 28rpx;
		font-size: 30rpx;
		line-height: 56rpx;
		color: #FFFFFF;
		text-align: center;
	}

	.biaoqian {
		padding: 0 18rpx;
		height: 40rpx;
		background: #FF7272;
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		color: #FFFFFF;
	}

	.biaoqian1 {
		padding: 0 18rpx;
		height: 40rpx;
		background: rgba(255, 255, 255, 0.1);
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		color: #FFFFFF;
	}

	.zhangfubox {
		height: 80rpx;
		background: linear-gradient(180deg, #304D75 0%, #304D75 100%);
		opacity: 1;
		border-radius: 0rpx 0rpx 20rpx 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 32rpx;
		color: #FFFFFF;
		padding: 0 30rpx;
	}

	.bottombox {
		width: 750rpx;
		height: 156rpx;
		padding: 28rpx 30rpx;
		// background: #FFFFFF;
		box-shadow: 0rpx 3rpx 6rpx rgba(0, 0, 0, 0.16);
		position: fixed;
		bottom: 0;
		display: flex;
	}

	.resetBtn {
		width: 260rpx;
		height: 76rpx;
		line-height: 76rpx;
		background: #8B99A2;
		border-radius: 10rpx;
		color: #FFFFFF;
		font-size: 28rpx;
		font-weight: bold;
		text-align: center;
	}

	.inquireBtn {
		width: 260rpx;
		height: 76rpx;
		line-height: 76rpx;
		background: #0165EE;
		border-radius: 10rpx;
		color: #FFFFFF;
		font-size: 28rpx;
		font-weight: bold;
		text-align: center;
	}

	.qcbtn1 {
		width: 320rpx;
		height: 86rpx;
		background: rgba(160, 171, 181, 0.1);
		border-radius: 0rpx 0rpx 0rpx 30rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #8B99A2;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.qcbtn2 {
		width: 320rpx;
		height: 90rpx;
		background: #0165EE;
		border-radius: 0rpx 0rpx 30rpx 0rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.qcbtn3 {
		width: 320rpx;
		height: 86rpx;
		background: #0165EE;
		border-radius: 20rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.heng {
		width: 48rpx;
		height: 4rpx;
		margin: 10 auto;
		background: #0165EE;
	}
</style>
