| | |
| | | (detailData.direction === 'buy' && detailData.state == 'created' && parseFloat(detailData['close_price']) * 1 < parseFloat(detailData['open_price']) * 1) || |
| | | (detailData.direction !== 'buy' && detailData.state !== 'created' && parseFloat(price) * 1 > parseFloat(detailData['open_price']) * 1) || |
| | | (detailData.direction !== 'buy' && detailData.state == 'created' && parseFloat(detailData['close_price']) * 1 > parseFloat(detailData['open_price']) * 1), |
| | | }">{{ detailData.state !== 'created' ? price : detailData[item.key] }}</p> |
| | | }"> |
| | | <!-- {{ detailData.state !== 'created' ? price : detailData[item.key] }}{{newprice}}</p> --> |
| | | {{newprice}}</p> |
| | | <p class="font-30 " :class="colorChoose(item)" v-else>{{ handleBuyWord(item) }}</p> |
| | | </li> |
| | | </ul> |
| | |
| | | </template> |
| | | <script> |
| | | import { Circle, CountDown } from 'vant'; |
| | | import { WS_URL } from '@/config' |
| | | export default { |
| | | name: 'PopupDelivery', |
| | | components: { |
| | |
| | | [CountDown.name]: CountDown |
| | | }, |
| | | props: { |
| | | symbol:{ |
| | | type: String, |
| | | default: '', |
| | | }, |
| | | showBtns: { |
| | | type: Boolean, |
| | | default: false, |
| | |
| | | ] |
| | | } |
| | | }, |
| | | mounted (){ |
| | | this.fetchDeepData() |
| | | }, |
| | | created() { |
| | | if (!(this.detailData.state === 'created')) {// 交割已完成 |
| | | this.handleInit() |
| | |
| | | arr: [], |
| | | currentRate: 0, // 当前进度 |
| | | interval: null, |
| | | newprice:"", |
| | | sockets: { |
| | | quotes: null, // 行情 |
| | | deep: null /// 深度 |
| | | }, |
| | | rate: 0, // 目标进度 |
| | | // listItem: [ |
| | | // {id: 1, text: '购买价', key: 'open_price'}, |
| | |
| | | // ] |
| | | } |
| | | }, |
| | | deactivated(){ |
| | | this.closeSocket() |
| | | }, |
| | | methods: { |
| | | closeSocket() { |
| | | this.sockets.deep.close() |
| | | // this.sockets.quotes && this.sockets.quotes.close() |
| | | // this.sockets.deep && this.sockets.deep.close() |
| | | this.sockets.quotes = null |
| | | this.sockets.deep = null |
| | | }, |
| | | fetchDeepData() { |
| | | |
| | | this.startDeepSocket() // socket |
| | | }, |
| | | startDeepSocket() { |
| | | this.sockets.deep = new WebSocket(`${WS_URL}/3/${this.symbol}`) |
| | | this.sockets.deep.onmessage = (evt) => { |
| | | const { data } = evt |
| | | const { code, data: _data } = JSON.parse(data) |
| | | // console.log(_data.bids[0].price); |
| | | this.newprice = _data.asks[0].price |
| | | } |
| | | }, |
| | | continueToBuy() { |
| | | if (this.detailData.state !== 'created') { |
| | | return |
| | | } |
| | | console.log() |
| | | this.$emit('continueToBuy', this.detailData) |
| | | this.closeSocket() |
| | | |
| | | //this.$router.push(`/trendDetails/${symbol}`) |
| | | }, |
| | |
| | | }, |
| | | onClose() { /// 关闭 |
| | | this.$emit('close') |
| | | this.closeSocket() |
| | | |
| | | } |
| | | } |
| | | } |