<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 + 324rpx)`}">
				<view class="width-750 fixed1"
					:style="{paddingTop: statusBar + 'px', height: `calc(${statusBar}px + 324rpx)`}">
					<!-- 搜索框 -->
					<view class="height-150 padding-t-25 padding-b-63 padding-w-30 flex align-center justify-between">
						<view class="width-610 flex align-center justify-between">
							<view class="flex align-center">
								<!-- <image class="width-52 height-52 radiu-50b" :src="currtitleList[curr_index].image" mode=""></image> -->
								<image class="width-52 height-52 radiu-26" src="/static/imgs/quantify/APT@2x@2x.png"
									mode=""></image>
								<!-- <u-icon class="margin-l-12" name="arrow-down-fill" color="#FFF" size="20"></u-icon> -->
							</view>
							<view style="background: #3282F0;"
								class="width-497 height-60 radiu-30 padding-w-24 flex align-center">
								<image class="width-33 height-33" src="/static/imgs/quantify/sousuo@2x.png" mode="">
								</image>
								<input class="flex-1 height-60 padding-l-10 font-26 numbold-font color-white"
									:adjust-position="true" :placeholder="i18n.quantify.text23"
									placeholder-style="color:#FFF;" type="text" v-model="seachWord"
									@input="seachList" />
							</view>
						</view>
						<image @click.stop="router.push('/pages/quantify/shezhi')" class="width-56 height-56 radiu-50b"
							src="/static/imgs/quantify/shezhi@2x.png" mode="">
						</image>
					</view>
					<!-- 币种数量 -->
					<view class="beijing flex align-center justify-between padding-w-20">
						<view class="flex align-center direction-column">
							<text class="font-22 color-white margin-b-10">{{i18n.quantify.text1}}</text>
							<text class="font-24 color-white nummedium-font">{{allNum}}</text>
						</view>
						<view class="flex align-center direction-column">
							<text class="font-22 color-white margin-b-10">{{i18n.quantify.text2}}</text>
							<text class="font-24 color-white nummedium-font">{{serviceNum}}</text>
						</view>
						<view class="flex align-center direction-column">
							<text class="font-22 color-white margin-b-10">{{i18n.quantify.text3}}</text>
							<text class="font-24 color-white nummedium-font ">{{closeNum}}</text>
						</view>
					</view>
					<!-- 选择 -->
					<view style="border-radius: 30rpx 30rpx 0 0;"
						:style="'background-color: '+theme.bg+';color: '+theme.text"
						class="height-72 flex align-center justify-between padding-w-60">
						<view @click="selectMeun(index)"
							class="height-72 flex direction-column align-center justify-center"
							v-for="(item,index) in meunList" :key="index">
							<text :class="meunIndex==index?'font-28 weight-bold color-0165EE':'color-C3C3C3 font-26'"
								class="">{{item}}</text>
							<view v-if="meunIndex==index" class="huakuai"></view>
						</view>
					</view>
				</view>
			</view>
			<!-- 身体 -->
			<view class="width-750 padding-t-16">
				<!-- 信誉不足 -->
				<view v-if="xinyu" class="width-100b padding-c-10">
					<view style="background: rgba(255,0,0,0.7);"
						class="width-690 margin-0-auto text-center radiu-10 padding-10">
						<text class="font-24 color-white">{{xinyu_waring}}</text>
					</view>
				</view>
				<!-- 全部 -->
				<view v-if="meunIndex==0" class="width-100b">
					<view class="width-100b height-140 padding-w-30 padding-c-20 margin-b-4 flex direction-column justify-between"
						v-for="(item,index) in coinList" :key="index"
						@click="router.push('/pages/quantify/Tactics?id='+ item.id +'&name='+item.coinname)">
						<view class="width-100b height-60 flex align-center justify-between">
							<view class="flex align-center">
								<image v-if="popupShow" @click.stop="selectFlag(0,index)"
									class="width-40 height-40 margin-r-10" :src="item.check?xuanzhong:weixuan" mode="">
								</image>
								<view v-if="item.status==1" class="kaiqizhong">
									<!-- <view class="width-16 height-16 radiu-8 bj-00C481 margin-r-5"></view> -->
									<text>{{i18n.quantify.text4}}</text>
								</view>
								<view v-else class="guanbizhong">
									<!-- <view class="width-16 height-16 radiu-8 bj-FF4040 margin-r-5"></view> -->
									<text>{{i18n.quantify.text5}}</text>
								</view>
								<image class="width-40 height-40 margin-l-10" :src="item.image" mode=""></image>
								<text class="font-28 numbold-font margin-w-10">{{item.coinname}}</text>
								<view class="labelNum text-center line-height-30">
									<text>{{item.strategy_xhcode}}</text>
								</view>
							</view>
							<view class="numbold-font" :class="item.increase >= 0?'zhangBox':'dieBox'">
								{{item.increase | percentFilter}}%
							</view>
						</view>
						<view
							class="width-100b height-60 line-height-60 padding-r-10 flex align-center justify-between">
							<view class="flex align-center">
								<view v-if="item.coin_desc && wordFiterDUO(item.coin_desc) == true" class="descBox1">
									{{item.coin_desc}}
								</view>
								<view v-if="item.coin_desc && wordFiterKONG(item.coin_desc) == true" class="descBox2">
									{{item.coin_desc}}
								</view>
								<text class="font-26 color-C3C3C3">{{i18n.quantify.text6}}：<span
										class="numbold-font">{{item.price}}</span></text>
							</view>
							<text class="font-26 color-C3C3C3">{{item.type == 1?i18n.quantify.text7:i18n.quantify.text8}}</text>
						</view>
					</view>
				</view>
				<!-- 循环 -->
				<view v-if="meunIndex==1" class="width-100b">
					<view class="width-100b height-140 padding-w-30 padding-c-20 margin-t-2 flex direction-column justify-between"
						v-for="(item,index) in list1" :key="index"
						@click="router.push('/pages/quantify/Tactics?id='+ item.coin_id +'&name='+item.coinname)">
						<view class="width-100b height-60 flex align-center justify-between">
							<view class="flex align-center">
								<image v-if="popupShow" @click.stop="selectFlag(1,index)"
									class="width-40 height-40 margin-r-10" :src="item.check?xuanzhong:weixuan" mode="">
								</image>
								<view v-if="item.status==1" class="kaiqizhong">
									<!-- <view class="width-16 height-16 radiu-8 bj-00C481 margin-r-5"></view> -->
									<text>{{i18n.quantify.text4}}</text>
								</view>
								<view v-else class="guanbizhong">
									<!-- <view class="width-16 height-16 radiu-8 bj-FF4040 margin-r-5"></view> -->
									<text>{{i18n.quantify.text5}}</text>
								</view>
								<image class="width-40 height-40" :src="item.image" mode=""></image>
								<text class="font-28 numbold-font margin-w-10">{{item.coinname}}</text>
								<view class="labelNum text-center line-height-30">
									<text>{{item.strategy_xhcode}}</text>
								</view>
							</view>
							<view class="numbold-font" :class="item.increase >= 0?'zhangBox':'dieBox'">
								{{item.increase | percentFilter}}%
							</view>
						</view>
						<view
							class="width-100b height-60 line-height-60 padding-r-10 flex align-center justify-between">
							<view class="width-100b flex align-center justify-between">
								<view class="flex align-center height-60">
									<view v-if="item.coin_desc && wordFiterDUO(item.coin_desc) == true"
										class="descBox1">
										{{item.coin_desc}}
									</view>
									<view v-if="item.coin_desc && wordFiterKONG(item.coin_desc) == true"
										class="descBox2">
										{{item.coin_desc}}
									</view>
									<text class="font-26 color-C3C3C3 margin-r-10">{{i18n.quantify.text9}}：<span
											class="numbold-font">{{Number(item.cc_num).toFixed(2)}}</span></text>
									<text v-if="item.fukui.slice(0,1)=='-'"
										class="font-26 color-FF4040">{{i18n.quantify.text10}}：<span
											class="numbold-font">{{item.fukui}}</span></text>
									<text v-else class="font-26 color-00C481">{{i18n.quantify.text10}}：<span
											class="numbold-font">{{item.fukui}}</span></text>
								</view>
								<text v-if="item.pc_status==0"
									class="font-26 weight-bold color-00C481">{{i18n.quantify.text11}}</text>
								<text v-else class="font-26 weight-bold color-FF4040">{{i18n.quantify.text12}}</text>
							</view>
						</view>
					</view>
					<!-- <view class="cu-load color-798690 bj-white" :class="state1"></view> -->
					<view class="">
						<view v-if="loading" class="width-100b padding-c-50 flex align-center justify-center">
							<u-loading show mode="circle" size="40"></u-loading>
						</view>
						<view v-if="!loading&&list1.length==0"
							class="width-100b padding-c-50 flex direction-column align-center justify-center">
							<text class="font-28 nummedium-font color-C3C3C3">{{i18n.mine.share.no}}</text>
						</view>
					</view>
				</view>
				<!-- 单次 -->
				<view v-if="meunIndex==2" class="width-100b">
					<view
						class="width-100b height-140 padding-w-30 padding-c-20 margin-t-2 flex direction-column justify-between"
						v-for="(item,index) in list2" :key="index"
						@click="router.push('/pages/quantify/Tactics?id='+ item.coin_id +'&name='+item.coinname)">
						<view class="width-100b height-60 flex align-center justify-between">
							<view class="flex align-center">
								<image v-if="popupShow" @click.stop="selectFlag(2,index)"
									class="width-40 height-40 margin-r-10" :src="item.check?xuanzhong:weixuan" mode="">
								</image>
								<view v-if="item.status==1" class="kaiqizhong">
									<!-- <view class="width-16 height-16 radiu-8 bj-00C481 margin-r-5"></view> -->
									<text>{{i18n.quantify.text4}}</text>
								</view>
								<view v-else class="guanbizhong">
									<!-- <view class="width-16 height-16 radiu-8 bj-FF4040 margin-r-5"></view> -->
									<text>{{i18n.quantify.text5}}</text>
								</view>
								<image class="width-40 height-40" :src="item.image" mode=""></image>
								<text class="font-28 numbold-font margin-w-10">{{item.coinname}}</text>
								<view class="labelNum text-center line-height-30">
									<text>{{item.strategy_xhcode}}</text>
								</view>
							</view>
							<view class="numbold-font" :class="item.increase >= 0?'zhangBox':'dieBox'">
								{{item.increase | percentFilter}}%
							</view>
						</view>
						<view
							class="width-100b height-60 line-height-60 padding-r-10 flex align-center justify-between">
							<view class="width-100b flex align-center justify-between">
								<view class="flex align-center height-60">
									<view v-if="item.coin_desc && wordFiterDUO(item.coin_desc) == true"
										class="descBox1">
										{{item.coin_desc}}
									</view>
									<view v-if="item.coin_desc && wordFiterKONG(item.coin_desc) == true"
										class="descBox2">
										{{item.coin_desc}}
									</view>
									<text class="font-26 color-C3C3C3 margin-r-10">{{i18n.quantify.text9}}：<span
											class="numbold-font">{{Number(item.cc_num).toFixed(2)}}</span></text>
									<text v-if="item.fukui.slice(0,1)=='-'"
										class="font-26 color-FF4040">{{i18n.quantify.text10}}：<span
											class="numbold-font">{{item.fukui}}</span></text>
									<text v-else class="font-26 color-00C481">{{i18n.quantify.text10}}：<span
											class="numbold-font">{{item.fukui}}</span></text>
								</view>
								<text v-if="item.pc_status==0"
									class="font-26 weight-bold color-00C481">{{i18n.quantify.text11}}</text>
								<text v-else class="font-26 weight-bold color-FF4040">{{i18n.quantify.text12}}</text>
							</view>
						</view>
					</view>
					<!-- <view class="cu-load color-798690 bj-white" :class="state2"></view> -->
					<view class="">
						<view v-if="loading" class="width-100b padding-c-50 flex align-center justify-center">
							<u-loading show mode="circle" size="40"></u-loading>
						</view>
						<view v-if="!loading&&list2.length==0"
							class="width-100b padding-c-50 flex direction-column align-center justify-center">
							<text class="font-28 nummedium-font color-C3C3C3">{{i18n.mine.share.no}}</text>
						</view>
					</view>
				</view>
				<!-- 空盒子 -->
				<view v-if="popupShow" class="width-100b height-320"></view>
				<view v-else class="width-100b height-80"></view>
			</view>

		</z-paging>

		<!-- 操作台 -->
		<view :class="popupShow?'bottomBox_top':'bottomBox'"
		 :style="'background-color: '+theme.bg">
			<view class="width-100b height-80 flex align-center justify-between">
				<text class="font-26 color-0165EE">{{i18n.quantify.text13}}：<span
						class="nummedium-font">{{currtitleList[curr_index].usdtnum}}</span></text>
				<view class="flex align-center justify-end">
					<view @click.stop="allselect" v-if="popupShow" class="quanxuanBtn">
						{{allcheck?i18n.quantify.text14:i18n.quantify.text15}}
					</view>
					<view class="plszBtn" @click.stop="popupShow = !popupShow">{{i18n.quantify.text16}}</view>
				</view>
			</view>
			<view class="width-100b height-50 line-height-50 flex align-center">
				<u-icon name="info-circle" color="#0165EE" size="28"></u-icon>
				<text class="margin-l-6 font-24 weight-bold color-0165EE">{{i18n.quantify.text17}}</text>
			</view>
			<view class="width-100b height-140 margin-t-10 flex align-center justify-between">
				<view v-if="meunIndex == 1||meunIndex==0" @click.stop="changeType1"
					:class="ifxuanzhuan?'xuanzhuan_360':'xuanzhuan_0'"
					class="width-110 height-100b flex direction-column align-center justify-center">
					<image class="width-84 height-84" src="/static/imgs/quantify/danci@2x.png" mode=""></image>
					<text class="font-26 weight-bold color-0165EE margin-t-8">{{i18n.quantify.text7}}</text>
				</view>
				<view v-if="meunIndex == 2||meunIndex==0" @click.stop="changeType2"
					:class="ifxuanzhuan?'xuanzhuan_360':'xuanzhuan_0'"
					class="width-110 height-100b flex direction-column align-center justify-center">
					<image class="width-84 height-84" src="/static/imgs/quantify/CELUE@2x.png" mode=""></image>
					<text class="font-26 weight-bold color-0165EE margin-t-8">{{i18n.quantify.text8}}</text>
				</view>
				<view @click.stop="setting"
					class="width-110 height-100b flex direction-column align-center justify-center">
					<image class="width-84 height-84" src="/static/imgs/quantify/shezhi.png" mode=""></image>
					<text style="white-space: nowrap;"
						class="font-26 weight-bold color-0165EE margin-t-8">{{i18n.quantify.text18}}</text>
				</view>
				<view v-if="meunIndex!=0" @click.stop="qcShow=true"
					class="width-110 height-100b flex direction-column align-center justify-center">
					<image class="width-84 height-84" src="/static/imgs/quantify/qingcang@2x.png" mode=""></image>
					<text class="font-26 weight-bold color-0165EE margin-t-8">{{i18n.quantify.text19}}</text>
				</view>
				<view v-if="pc_type&&meunIndex!=0" @click.stop="stopCover(1)"
					class="width-110 height-100b flex direction-column align-center justify-center">
					<image class="width-84 height-84" src="/static/imgs/quantify/guanbi@2x.png" mode=""></image>
					<text class="font-26 weight-bold color-0165EE margin-t-8">{{i18n.quantify.text12}}</text>
				</view>
				<view v-if="!pc_type&&meunIndex!=0" @click.stop="stopCover(0)"
					class="width-110 height-100b flex direction-column align-center justify-center">
					<image class="width-84 height-84" src="/static/imgs/quantify/qidong@2x.png" mode=""></image>
					<text class="font-26 weight-bold color-0165EE margin-t-8">{{i18n.quantify.text11}}</text>
				</view>
			</view>
		</view>

		<!-- 清仓弹窗 -->
		<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-52 height-52" src="/static/imgs/quantify/tongzhi@2x.png" mode=""></image>
					<view class="font-28 weight-bold text-center padding-w-20">{{i18n.quantify.text20}}
					</view>
				</view>
				<view class="width-100b height-90 flex align-center justify-between">
					<view @click="qcShow=false" class="qcbtn1">{{i18n.quantify.text15}}</view>
					<view class="qcbtn2" @click.stop="clean_cang">{{i18n.quantify.text21}}</view>
				</view>
			</view>
		</u-popup>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				allcheck: true,
				leftshow: false,
				xinyu: 0,
				xinyu_waring: '',
				statusBar: uni.getSystemInfoSync().statusBarHeight,
				seachWord: '',

				meunList: ['全部', '策略循环', '单次策略'],
				meunIndex: 0,

				xuanzhong: '/static/imgs/quantify/xuanzhong@2x.png',
				weixuan: '/static/imgs/quantify/weixuanzhong@2x.png',

				popupShow: false,

				qcShow: false,
				qcFlag: true,

				currtitleList: ['火币', 'Binance', 'OKEx', 'Coinbase'],
				exchange_id: uni.getStorageSync('exchange_id') || 1,
				curr_index: uni.getStorageSync('curr_index') || 0,
				coinList: [],
				copy_coinList: [],
				copy_list1: [],
				list1: [],
				page1: 1,
				state1: 'more',
				copy_list2: [],
				list2: [],
				page2: 1,
				state2: 'more',

				ifxuanzhuan: false,
				onceARR: [],
				moreARR: [],
				allARR: [],

				pc_type: true,
				cionType: 1,

				loading: true,

				list: [],
				theme: '',
			}
		},
		filters: {
			// 百分号过滤器（保留小数点后两位）
			percentFilter: function(item) {
				return (item * 100).toFixed(2)
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
			// 运行中策略
			serviceNum: function() {
				var n = 0;
				if (this.meunIndex == 0) {
					this.coinList.forEach(function(item) {
						if (item.status == 1) {
							n++
						}
					})
					return n;
				}
				if (this.meunIndex == 1) {
					this.list1.forEach(function(item) {
						if (item.status == 1) {
							n++
						}
					})
					return n;
				}
				if (this.meunIndex == 2) {
					this.list2.forEach(function(item) {
						if (item.status == 1) {
							n++
						}
					})
					return n;
				}
				if (this.meunIndex == 3) {
					return 0;
				}
			},
			allNum: function() {
				var n = 0;
				if (this.meunIndex == 0) {
					return this.coinList.length;
				}
				if (this.meunIndex == 1) {
					return this.list1.length;
				}
				if (this.meunIndex == 2) {
					return this.list2.length;
				}
				if (this.meunIndex == 3) {
					return 0;
				}
			},
			closeNum: function() {
				var n = 0;
				if (this.meunIndex == 0) {
					this.coinList.forEach(function(item) {
						if (item.status == 0) {
							n++
						}
					})
					return n;
				}
				if (this.meunIndex == 1) {
					this.list1.forEach(function(item) {
						if (item.status == 0) {
							n++
						}
					})
					return n;
				}
				if (this.meunIndex == 2) {
					this.list2.forEach(function(item) {
						if (item.status == 0) {
							n++
						}
					})
					return n;
				}
				if (this.meunIndex == 3) {
					return 0;
				}
			}
		},
		onReachBottom() {
			// 循环
			if (this.meunIndex == 1) {
				this.page1++
				this.getlist1()
			}
			// 单次
			if (this.meunIndex == 2) {
				this.page2++
				this.getlist2()
			}
		},
		onHide() {
			this.popupShow = false
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			}else{
				this.theme = this.$store.state.lightTheme
			}
			// 始终使用浅色主题的底部栏
			uni.setTabBarStyle({
				backgroundColor: '#FFFFFF',
				color: "#D1D3D8",
				selectedColor: "#0165EE"
			})
			this.meunList[0] = this.i18n.quantify.text22
			this.meunList[1] = this.i18n.quantify.text8
			this.meunList[2] = this.i18n.quantify.text7
			this.curr_index = uni.getStorageSync('curr_index') || 0
			this.exchange_id = uni.getStorageSync('exchange_id') || 1
			if (uni.getStorageSync('token')) {
				this.get_exchange()
				// 循环
				if (this.meunIndex == 1) {
					this.againtop()
				}
				// 单次
				if (this.meunIndex == 2) {
					this.onetop()
				}
			} else {
				this.router.relaunch('/pages/login/index')
			}
			console.log("????????????????????????????")
			var that = this
			uni.$on("onPullDownRefresh", function() {
				console.log("????????????????????????????")
				that.get_exchange()
				// 循环
				if (that.meunIndex == 1) {
					that.againtop()
				}
				// 单次
				if (that.meunIndex == 2) {
					that.onetop()
				}
				uni.stopPullDownRefresh()
			})
			uni.$on("onReachBottom", function() {
				// 循环
				if (that.meunIndex == 1) {
					that.page1++
					that.getlist1()
				}
				// 单次
				if (that.meunIndex == 2) {
					that.page2++
					that.getlist2()
				}
			})
		},
		// onPullDownRefresh() {
		// 	let that = this
		// 	console.log('下拉刷新');
		// 	console.log("????????????????????????????")
		// 	that.get_exchange()
		// 	// 循环
		// 	if (that.meunIndex == 1) {
		// 		that.againtop()
		// 	}
		// 	// 单次
		// 	if (that.meunIndex == 2) {
		// 		that.onetop()
		// 	}
		// 	setTimeout(function() {
		// 		uni.stopPullDownRefresh();
		// 	}, 800);
		// },
		onReachBottom() {
			let that = this
			// 循环
			if (that.meunIndex == 1) {
				that.page1++
				that.getlist1()
			}
			// 单次
			if (that.meunIndex == 2) {
				that.page2++
				that.getlist2()
			}
		},
		destroyed: function() {
			uni.$off("onPullDownRefresh")
			uni.$off("onReachBottom")
		},
		methods: {
			onRefresh() {
				this.get_exchange()
				// 循环
				if (this.meunIndex == 1) {
					this.againtop()
				}
				// 单次
				if (this.meunIndex == 2) {
					this.onetop()
				}
				// 以告知z-paging下拉刷新结束，这样才可以开始下一次的下拉刷新
				setTimeout(() => {
					//1.5秒之后停止刷新动画
					this.$refs.paging.complete();
				}, 1500)
			},
			wordFiterDUO(str) {
				if (str.indexOf("做多") != -1) {
					return true
				} else {
					return false
				}
			},
			wordFiterKONG(str) {
				if (str.indexOf("做空") != -1) {
					return true
				} else {
					return false
				}
			},
			changeCion(index) {
				this.cionType = index
				this.get_newInfo()
			},
			// 全选
			allselect() {
				this.allcheck = !this.allcheck
				if (this.meunIndex == 0) {
					var temp = []
					let arr = []
					var data = this.coinList
					this.coinList = []
					this.coinList = data
					if (this.allcheck) {
						this.coinList.forEach(item => {
							item.check = false
						})
						arr = []
					} else {
						this.coinList.forEach(item => {
							item.check = true
							arr.push(item.id)
						})
					}
					console.log(arr)
					this.allARR = arr
				}
				if (this.meunIndex == 1) {
					var temp = []
					let arr = []
					if (this.allcheck) {
						this.list1.forEach(item => {
							item.check = false
						})
						arr = []
					} else {
						this.list1.forEach(item => {
							item.check = true
							arr.push(item.coin_id)
						})
					}
					console.log(arr)
					this.moreARR = arr
				}
				if (this.meunIndex == 2) {
					var temp = []
					let arr = []
					if (this.allcheck) {
						this.list2.forEach(item => {
							item.check = false
						})
						arr = []
					} else {
						this.list2.forEach(item => {
							item.check = true
							arr.push(item.coin_id)
						})
					}
					console.log(arr)
					this.onceARR = arr
				}
			},
			get_newInfo() {
				if (this.meunIndex == 0) {
					this.coinList = []
					this.get_exchange()
				}
				if (this.meunIndex == 1) {
					this.list1 = []
					this.page1 = 1
					this.state1 = 'more'
					this.moreARR = []
					this.againtop()
				}
				if (this.meunIndex == 2) {
					this.list2 = []
					this.page2 = 1
					this.state2 = 'more'
					this.onceARR = []
					this.onetop()
				}
			},
			// 停止补仓设置
			stopCover(type) {
				var temparr = []
				if (this.meunIndex == 0) {
					console.log(this.allARR)
					if (this.allARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.allARR
				}
				if (this.meunIndex == 1) {
					console.log(this.moreARR)
					if (this.moreARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.moreARR
				}
				if (this.meunIndex == 2) {
					console.log(this.onceARR)
					if (this.onceARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.onceARR
				}
				console.log(temparr)
				var obj = {
					coin_id: temparr.join(','),
					pc_status: type
					// 0=正常补仓   1=停止补仓
				}
				let that = this
				uni.showLoading({
					title: that.i18n.quantify.tos2
				})
				console.log(obj)
				this.post('/strategy/set_strategy', obj).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						this.tos(res.msg)
						this.popupShow = false
						this.get_newInfo()
					}
				})
			},
			// 批量交易设置
			setting() {
				var temparr = []
				if (this.meunIndex == 0) {
					console.log(this.allARR)
					if (this.allARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.allARR
				}
				if (this.meunIndex == 1) {
					console.log(this.moreARR)
					if (this.moreARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.moreARR
				}
				if (this.meunIndex == 2) {
					console.log(this.onceARR)
					if (this.onceARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.onceARR
				}
				uni.navigateTo({
					url: '/pages/quantify/setTransaction?idArr=' + temparr
				})
			},
			// 循环策略列表（发起单次策略）
			changeType1() {
				// console.log(this.moreARR)
				var obj = {}
				if (this.meunIndex == 0) {
					if (this.allARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					obj = {
						coin_id: this.allARR.join(','),
						type: 1,
					}
				}
				if (this.meunIndex == 1) {
					if (this.moreARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					obj = {
						coin_id: this.moreARR.join(','),
						type: 1,
					}
				}
				let that = this
				uni.showLoading({
					title: that.i18n.quantify.tos2
				})
				console.log(obj)
				this.post('/strategy/set_strategy', obj).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						this.tos(res.msg)
						this.ifxuanzhuan = !this.ifxuanzhuan
						this.get_newInfo()
					}
				})
			},
			// 单次策略列表（发起循环策略）
			changeType2() {
				// console.log(this.onceARR)
				var obj = {}
				if (this.meunIndex == 0) {
					if (this.allARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					obj = {
						coin_id: this.allARR.join(','),
						type: 2,
					}
				}
				if (this.meunIndex == 2) {
					if (this.onceARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					obj = {
						coin_id: this.onceARR.join(','),
						type: 2,
					}
				}
				let that = this
				uni.showLoading({
					title: that.i18n.quantify.tos2
				})
				console.log(obj)
				this.post('/strategy/set_strategy', obj).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						this.tos(res.msg)
						this.ifxuanzhuan = !this.ifxuanzhuan
						this.get_newInfo()
					}
				})
			},
			// 清仓
			clean_cang() {
				if (!this.qcFlag) return
				if (this.meunIndex == 0 || this.meunIndex == 3) {
					this.tos(this.i18n.quantify.tos3)
					return
				}
				var temparr = []
				if (this.meunIndex == 1) {
					console.log(this.moreARR)
					if (this.moreARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.moreARR
				}
				if (this.meunIndex == 2) {
					console.log(this.onceARR)
					if (this.onceARR.length == 0) {
						this.tos(this.i18n.quantify.tos1)
						return
					}
					temparr = this.onceARR
				}
				let that = this
				uni.showLoading({
					title: that.i18n.quantify.tos4
				})
				this.qcFlag = false
				// console.log(temparr.join(','))
				this.post('/strategy/clean_cang', {
					coin_id: temparr.join(',')
				}).then(res => {
					console.log(res)
					uni.hideLoading()
					this.qcFlag = true
					if (res.code == 1) {
						this.tos(res.msg)
						this.qcShow = false
						this.get_newInfo()
					}
				})
			},
			seachList() {
				if (this.meunIndex == 0) {
					this.coinList = this.copy_coinList
					if (this.seachWord) {
						console.log(this.seachWord)
						var len = this.coinList.length;
						var arr = [];
						for (var i = 0; i < len; i++) {
							//如果字符串中不包含目标字符会返回-1
							if (this.coinList[i].coinname.indexOf(this.seachWord.toUpperCase()) >= 0) {
								arr.push(this.coinList[i]);
							}
						}
						console.log(arr)
						this.coinList = arr
					}
				}
				if (this.meunIndex == 1) {
					this.list1 = this.copy_list1
					if (this.seachWord) {
						console.log(this.seachWord)
						var len = this.list1.length;
						var arr = [];
						for (var i = 0; i < len; i++) {
							//如果字符串中不包含目标字符会返回-1
							if (this.list1[i].coinname.indexOf(this.seachWord.toUpperCase()) >= 0) {
								arr.push(this.list1[i]);
							}
						}
						console.log(arr)
						this.list1 = arr
					}
				}
				if (this.meunIndex == 2) {
					this.list2 = this.copy_list2
					if (this.seachWord) {
						console.log(this.seachWord)
						var len = this.list2.length;
						var arr = [];
						for (var i = 0; i < len; i++) {
							//如果字符串中不包含目标字符会返回-1
							if (this.list2[i].coinname.indexOf(this.seachWord.toUpperCase()) >= 0) {
								arr.push(this.list2[i]);
							}
						}
						console.log(arr)
						this.list2 = arr
					}
				}
			},

			selectMeun(index) {
				this.allcheck = true
				this.seachWord = ''
				this.meunIndex = index
				this.onceARR = []
				this.moreARR = []
				this.allARR = []
				if (index == 0) {
					this.get_exchange()
					// this.coinList = this.copy_coinList
					// this.coinList.forEach(item => {
					// 	item.check = false
					// })
				}
				if (index == 1) {
					this.list1 = []
					this.page1 = 1
					this.state1 = 'more'
					this.againtop()
				}
				if (index == 2) {
					this.list2 = []
					this.page2 = 1
					this.state2 = 'more'
					this.onetop()
				}
			},
			selectTitle(index) {
				// this.seachWord = ''
				// this.coinList = []
				// uni.setStorageSync('curr_index',index)
				// this.curr_index = index
				// uni.setStorageSync('exchange_id',this.currtitleList[index].id)
				// this.exchange_id = this.currtitleList[index].id
				// this.coinList = this.currtitleList[index].coins
				// this.copy_coinList = this.currtitleList[index].coins
				// this.get_newInfo()
				// this.leftshow = false
				// console.log(this.coinList)
				this.seachWord = ''
				this.coinList = []
				uni.setStorageSync('curr_index', index)
				this.curr_index = index
				uni.setStorageSync('exchange_id', this.currtitleList[index].id)
				console.log()
				if (this.currtitleList[index].ws_url != uni.getStorageSync('socket_url')) {
					uni.setStorageSync('socket_url', this.currtitleList[index].ws_url)
					console.log('改变了地址！！！！！！！！！')
					this.changeExchange()
				}

				this.exchange_id = this.currtitleList[index].id
				this.coinList = this.currtitleList[index].coins
				this.copy_coinList = this.currtitleList[index].coins
				this.get_newInfo()
				this.leftshow = false
				console.log(this.coinList)
			},
			selectFlag(type, index) {
				if (type == 0) {
					console.log(this.coinList[index].check)
					this.coinList[index].check = !this.coinList[index].check
					var data = this.coinList
					this.coinList = []
					this.coinList = data
					let temp = this.coinList.filter(val => {
						return val.check == true;
					})

					this.pc_type = temp.some(item => {
						return item.pc_status == 0
					})

					console.log(temp)
					let arr = []
					temp.forEach(val => {
						arr.push(val.id)
					})
					console.log(arr)
					this.allARR = arr
				}
				if (type == 1) {
					// console.log(this.list1[index].check)
					this.list1[index].check = !this.list1[index].check
					let temp = this.list1.filter(val => {
						return val.check == true;
					})
					this.pc_type = temp.some(item => {
						return item.pc_status == 0
					})
					console.log(temp)
					let arr = []
					temp.forEach(val => {
						arr.push(val.coin_id)
					})
					console.log(arr)
					this.moreARR = arr
				}
				if (type == 2) {
					// console.log(this.list2[index].check)
					this.list2[index].check = !this.list2[index].check
					let temp = this.list2.filter(val => {
						return val.check == true;
					})
					this.pc_type = temp.some(item => {
						return item.pc_status == 0
					})
					console.log(temp)
					let arr = []
					temp.forEach(val => {
						arr.push(val.coin_id)
					})
					console.log(arr)
					this.onceARR = arr
				}
			},
			get_exchange() {
				this.coinList = []
				let that = this
				// uni.showLoading({
				// 	title: that.i18n.quantify.tos5
				// })
				this.post('/strategy/get_exchange', {
					coin_type: this.cionType
				}).then(res => {
					// uni.hideLoading()
					// console.log('结果', res)
					if (res.code == 1) {
						// this.currtitleList = res.data
						// // this.curr_index = 0
						// var temp = res.data[0].coins
						// temp.forEach(val => {
						// 	val.check = false;
						// })
						// this.coinList = temp
						// this.copy_coinList = temp
						// this.xinyu = res.data.xinyu
						// this.xinyu_waring = res.data.xinyu_waring

						this.currtitleList = res.data
						console.log('打印的什么', res.data)
						this.curr_index = 0
						var temp = res.data[this.curr_index].coins
						temp.forEach(val => {
							val.check = false;
						})
						this.coinList = temp
						this.copy_coinList = temp
						this.xinyu = res.data.xinyu
						this.xinyu_waring = res.data.xinyu_waring
						if (this.currtitleList[this.curr_index].ws_url != uni.getStorageSync('socket_url')) {
							uni.setStorageSync('socket_url', this.currtitleList[this.curr_index].ws_url)
							this.changeExchange()
						}

						// this.currlist = res.data
						// this.coinList = this.currlist[this.curr_index].coins
						// this.exchange_id = this.currlist[this.curr_index].id
						// uni.setStorageSync('curr_index',this.curr_index)
						// uni.setStorageSync('exchange_id', this.currlist[this.curr_index].id)
						// if (this.currlist[this.curr_index].ws_url != uni.getStorageSync('socket_url')) {
						// 	uni.setStorageSync('socket_url', this.currlist[this.curr_index].ws_url)
						// 	this.changeExchange()
						// }
					}
				})
			},
			// 循环
			getlist1() {
				if (this.state1 == 'over' || this.state1 == 'nodata') return
				this.loading = true
				this.state1 = 'loading'
				this.post('/strategy/get_strategy', {
					page: this.page1,
					coin_type: this.cionType,
					type: 2
				}).then(res => {
					if (res.code == 1) {
						var temp = res.data.data
						temp.forEach(val => {
							val.check = false;
						})
						var that = this
						setTimeout(function() {
							this.loading = false
							that.list1 = that.list1.concat(temp)
							that.copy_list1 = that.copy_list1.concat(temp)
							if (that.page1 >= res.data.last_page) {
								that.state1 = 'over'
							}
						}, 500)
					}
				})
			},
			// 单次
			getlist2() {
				if (this.state2 == 'over' || this.state2 == 'nodata') return
				this.loading = true
				this.state2 = 'loading'
				this.post('/strategy/get_strategy', {
					page: this.page2,
					coin_type: this.cionType,
					type: 1
				}).then(res => {
					if (res.code == 1) {
						var temp = res.data.data
						temp.forEach(val => {
							val.check = false;
						})
						var that = this
						setTimeout(function() {
							this.loading = false
							that.list2 = that.list2.concat(temp)
							that.copy_list2 = that.copy_list2.concat(temp)
							if (that.page2 >= res.data.last_page) {
								that.state2 = 'over'
							}
						}, 500)
					}
				})
			},
			againtop() {
				this.loading = true
				let that = this
				// uni.showLoading({
				// 	title: that.i18n.quantify.tos5
				// })
				var obj = {
					page: 1,
					coin_type: this.cionType,
					type: 2,
					exchange_id: this.exchange_id,
				}
				this.post('/strategy/get_strategy', obj).then(res => {
					console.log(res)
					// uni.hideLoading()
					if (res.code == 1) {
						this.loading = false
						var temp = res.data.data
						temp.forEach(val => {
							val.check = false;
						})
						this.list1 = temp
						this.copy_list1 = temp
						if (this.list1.length == 0) {
							this.state1 = 'nodata'
							return
						}
						if (this.page1 >= res.data.last_page) {
							this.state1 = 'over'
							return
						}
					}
				})
			},
			onetop() {
				this.loading = true
				let that = this
				// uni.showLoading({
				// 	title: that.i18n.quantify.tos5
				// })
				var obj = {
					page: 1,
					coin_type: this.cionType,
					type: 1,
					exchange_id: this.exchange_id,
				}
				this.post('/strategy/get_strategy', obj).then(res => {
					console.log(res)
					// uni.hideLoading()
					if (res.code == 1) {
						this.loading = false
						var temp = res.data.data
						temp.forEach(val => {
							val.check = false;
						})
						// 单次
						this.list2 = temp
						this.copy_list2 = temp
						if (this.list2.length == 0) {
							this.state2 = 'nodata'
							return
						}
						if (this.page2 >= res.data.last_page) {
							this.state2 = 'over'
							return
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.fixed1 {
		position: fixed;
		top: 0;
		z-index: 1010;
		background: #0165EE;
	}

	.huakuai {
		width: 54rpx;
		height: 4rpx;
		background: #0165EE;
		border-radius: 2rpx;
		margin-top: 2rpx;
	}

	.beijing {
		width: 690rpx;
		height: 105rpx;
		border: 1rpx solid #A8D0FF;
		background: linear-gradient(180deg, #348AFF 0%, #449BFF 100%);
		opacity: 1;
		border-radius: 10rpx 10rpx 0 0;
		margin: 0 auto;
	}

	.shezhiBtn {
		width: 120rpx;
		height: 50rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(255, 255, 255, 0.61);
		border-radius: 10rpx;
		font-size: 24rpx;
		font-weight: bold;
		color: #33A593;
		text-align: center;
		line-height: 50rpx;
	}

	.quanxuanBtn {
		width: 100rpx;
		height: 56rpx;
		margin-right: 8rpx;
		background: #0165EE;
		border-radius: 4rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 56rpx;
	}

	.bottomBox {
		width: 100%;
		height: 300rpx;
		position: fixed;
		z-index: 998;
		padding: 0 30rpx;
		border-radius: 30rpx;
		// background: #1785EF;
		// background: #EEF5FF;
		box-shadow: 0rpx -7rpx 12rpx 0rpx rgba(23, 133, 239, 0.3);
		transition: all 0.5s;
		/* #ifdef H5 */
		bottom: -120rpx;
		/* #endif */

		/* #ifndef H5 */
		bottom: -214rpx;
		/* #endif */
	}

	.bottomBox_top {
		width: 100%;
		height: 300rpx;
		position: fixed;
		z-index: 998;
		padding: 0 30rpx;
		border-radius: 30rpx;
		// background: #1785EF;
		// background: #EEF5FF;
		box-shadow: 0rpx -7rpx 12rpx 0rpx rgba(23, 133, 239, 0.3);
		transition: all 0.5s;
		/* #ifdef H5 */
		bottom: 90rpx;
		/* #endif */

		/* #ifndef H5 */
		bottom: 0rpx;
		/* #endif */
	}

	.zhangBox {
		width: 126rpx;
		height: 54rpx;
		// padding: 15rpx 10rpx;
		background: #00C481;
		border-radius: 8rpx;
		text-align: center;
		line-height: 56rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #FFFFFF;
	}

	.dieBox {
		width: 126rpx;
		height: 54rpx;
		// padding: 15rpx 10rpx;
		background: #FF4040;
		border-radius: 8rpx;
		text-align: center;
		line-height: 56rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #FFFFFF;
	}

	.xiala {
		top: 114rpx;
		transition: all 0.3s;
	}

	.shangla {
		top: -290rpx;
		transition: all 0.3s;
	}

	.xuanzhuan_90 {
		transform: rotate(-90deg);
	}

	.xuanzhuan_0 {
		transform: rotate(0deg);
		transition: all 0.3s;
	}

	.xuanzhuan_360 {
		transform: rotateY(360deg);
		transition: all 0.3s;
	}

	.qcBox {
		width: 600rpx;
		// height: 320rpx;
		background: #FFFFFF;
	}

	.qcbtn1 {
		width: 320rpx;
		height: 86rpx;
		background: rgba(160, 171, 181, 0.2);
		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;
	}

	.kaiqiBtn {
		width: 96rpx;
		height: 40rpx;
		text-align: center;
		line-height: 40rpx;
		background-color: #1F57FF;
		color: #FFFFFF;
		margin-left: 12rpx;
		font-size: 22rpx;
		border-radius: 18rpx;
	}

	.guanbiBtn {
		width: 96rpx;
		height: 40rpx;
		text-align: center;
		line-height: 40rpx;
		background-color: #999999;
		color: #f7f7f7;
		margin-left: 12rpx;
		font-size: 22rpx;
		border-radius: 18rpx;
	}

	.labelNum {
		width: 54rpx;
		height: 30rpx;
		background: rgba(1, 101, 238, 0.3);
		border-radius: 15rpx;
		font-size: 24rpx;
		font-weight: bold;
		color: #0165EE;
	}

	.plszBtn {
		width: 140rpx;
		height: 56rpx;
		background: #0165EE;
		border-radius: 4rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 56rpx;
	}

	.descBox1 {
		width: 120rpx;
		height: 40rpx;
		border-radius: 10rpx;
		margin-right: 10rpx;
		background: #E4FFF6;
		text-align: center;
		line-height: 40rpx;
		font-size: 22rpx;
		color: #00C481;
		font-weight: bold;
	}

	.descBox2 {
		width: 120rpx;
		height: 40rpx;
		border-radius: 10rpx;
		margin-right: 10rpx;

		background: #FFECEC;
		text-align: center;
		line-height: 40rpx;
		font-size: 22rpx;
		color: #FF4040;
		font-weight: bold;
	}
</style>
