Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

<template> <div class="container"> <div class="w-left"> <div class="grid-content…

  1. User
                <div class="w-left">
                    <div class="grid-content bg-purple el-row--flex">
                        <div class="el-row">
                            <div class="itemText">
                                <div class="border">{{$t("估值保证金")}}</div>
                                <div class="border textRight">{{myMargin}}</div>
                            </div>
                            <div class="itemText">
                                <div class="border">{{$t("总估值损益")}}</div>
                                <div class="border textRight">{{(realTimeProfit+realizedProfit).toFixed(2)}}</div>
                            </div>
    
                            <div class="itemText">
                                <div class="border">{{$t("实时盈亏")}}</div>
                                <div class="border textRight">{{realTimeProfit}}</div>
                            </div>
                            <div class="itemText">
                                <div class="border">{{$t("已实现损益")}}</div>
                                <div class="border textRight">{{realizedProfit}}</div>
                            </div>
                            <div class="itemText">
                                <div class="border">{{$t("储备余额")}}</div>
                                <div class="border textRight">{{myMoney}}</div>
                            </div>
    
                        </div>
                        <div class="el-row">
    
                        </div>
                        <div class="el-column" style="padding-top: 5px">
                            <div class="rowpannel1">
                                <div class="rowpannel1"  >
                                    <el-checkbox v-model="preSellNumChecked">{{$t("止盈")}}</el-checkbox>
                                    <div class="rowpannel1">
                                        <el-input-number size="small" style="padding-left: 5px;width: 80px" v-model="preSellNum" controls-position="right" @change="handleChange" label="手" :min="1" :max="100"></el-input-number>{{$t("格")}}
                                    </div>
                                    <span style="padding-left: 25px">{{$t("持仓数量")}}</span>
                                </div>
                                <div style="display: flex">
    
                                    <div style="margin-left: 40px" class="textAndInput" >
                                        <span  class="textInputBlue">{{$t("卖出持仓")}}</span>
                                        <el-input
                                                style="width: 50px;"
                                                size = "small"
                                                :placeholder="$t('请输入内容')"
                                                v-model="totalSellNum"
                                                readOnly
                                                class="custom-input">
                                        </el-input>
                                    </div>
                                    <span   class="textInputRed">{{$t("买入持仓")}}</span>
                                    <div class="textAndInput" >
    
                                        <el-input
                                                style="width: 50px;"
                                                size = "small"
    
                                                :placeholder="$t('请输入内容')"
                                                v-model="totalBuyNum"
                                                readOnly
                                                class="custom-input">
                                        </el-input>
                                    </div>
                                </div>
    
                                <el-button style="margin-left: 40px; width: 100px;" size="small" type="info" plain @click="reset">{{$t("重置")}}</el-button>
                            </div>
                            <div class="rowpannel1" style="padding-top: 5px;">
                                <div class="rowpannel1"  >
                                    <el-checkbox v-model="preDownNumChecked">{{$t("止损")}}</el-checkbox>
                                    <div class="rowpannel1">
                                        <el-input-number size="small"  style="padding-left: 5px;;width: 80px " v-model="preDownNum" controls-position="right" @change="handleChange" label="手" :min="1" :max="100"></el-input-number>{{$t("格")}}
                                    </div>
                                    <span style="padding-left: 25px">{{$t("下单数量")}}</span>
                                </div>
    
                                <div style="display: flex;">
    
                                    <div style="display: flex;align-items: center">
                                        <el-input-number size="small" style="padding-left: 10px;;width: 80px" v-model="hands" controls-position="right" @change="handleChange" label="手" :min="1" ></el-input-number>{{$t("手")}}
                                    </div>
    
                                    <div style="display: flex;padding-left: 20px">
                                        <el-button size="small" type="info" plain @click="updateHands(1)">1</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(2)">2</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(3)">3</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(4)">4</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(5)">5</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(10)">10</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(20)">20</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(50)">50</el-button>
                                        <el-button size="small" type="info" plain @click="updateHands(100)">100</el-button>
                                    </div>
    
                                </div>
    
                            </div>
                        </div>
                    </div>
                    <div class="el-row rowpannel">
                        <el-button size="small" type="primary" @click="buyIndex(marketRows[selectedRowIndex].curValue,-1)">{{$t("市价出售")}}(F10)</el-button>
                        <el-button size="small" type="success" @click="sellAll()">{{$t("全品类平仓")}}</el-button>
                        <el-button size="small" type="success" @click="sellCur()">{{$t("现品类平仓")}}</el-button>
                        <el-button size="small" type="danger"  @click="buyIndex(marketRows[selectedRowIndex].curValue,1)">{{$t("市价买入")}}(F11)</el-button>
    
                    </div>
                    <div class="el-row table-container" ref="tableContainer" >
                        <table>
                            <thead class="fixed-header">
                            <tr>
                                <th style="color:cornflowerblue">MIT</th>
                                <th>{{$t("空持仓")}}</th>
                                <th>{{$t("未成交")}}</th>
                                <th>{{$t("卖出")}}</th>
                                <th>{{$t("价格")}}</th>
                                <th>{{$t("买入")}}</th>
                                <th>{{$t("未成交")}}</th>
                                <th>{{$t("多持仓")}}</th>
                                <th style="color: darkred">MIT</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(row, index) in rows" :key="index" :class="{ 'highlight-row': row.basePrice === currentIndex }">
                                <td style="background-color: #79b6f554">{{ row.mitSell?row.mitSell:''}}</td>
                                <td style="background-color: #79b6f5a6">{{ row.shortPos }}</td>
    
                                <td>{{ row.sellUnComp }}</td>
                                <td class="buy-row"
                                    @click="buyIndex(row.basePrice,-1)">{{ row.sellNum }}</td>
                                <td  style="background-color: #a1ccfa">{{ row.basePrice }}</td>
    
                                <td class="buy-row"
                                    @click="buyIndex(row.basePrice,1)">{{ row.buyNum }}</td>
                                <td>{{ row.bugUnComp }}</td>
                                <td style="background-color: #f56c6c9c">{{ row.longPos }}</td>
                                <td style="background-color: #f56c6c42">{{ row.mitBuy?row.mitBuy:''}}</td>
                            </tr>
                            </tbody>
                            <tfoot>
                            <tr>
    
                                <td>{{ totalsellMit }}</td>
                                <td>{{ totalsell }}</td>
                                <td colspan="1">{{ total_unsell }}</td>
                                <td> </td>
                                <td> </td>
                                <td> </td>
                                <td>{{ total_unbuy }}</td>
                                <td>{{ totalbuy }}</td>
                                <td>{{ totalbuyMit }}</td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                    <div class="rowpannel" style="display: flex; justify-content: space-between;">
                        <el-button size="small" style="flex-grow: 1;" type="info" plain>{{$t("取消")}}</el-button>
                        <el-button size="small" style="flex-grow: 1;" type="primary">{{$t("取消")}}</el-button>
                        <el-button size="small" style="flex-grow: 1;" type="warning" @click="cancelAll">{{$t("全品类取消")}}</el-button>
                        <el-button size="small" style="flex-grow: 1;" type="warning" @click="cancelCur">{{$t("现品类取消")}}</el-button>
                        <el-button size="small" style="flex-grow: 1;" type="primary">{{$t("取消")}}</el-button>
                        <el-button size="small" style="flex-grow: 1; margin-right: 20px;" type="info" plain>{{$t("取消")}}</el-button>
                    </div>
    
                    <div class="el-row bottom-table"  :style="adjustedHeight">
                        <table>
                            <thead>
                                <tr>
                                    <th>{{$t("方向")}}</th>
                                    <th>{{$t("合约")}}</th>
                                    <th>{{$t("止盈")}}</th>
                                    <th>{{$t("止损")}}</th>
                                    <th>{{$t("仓位")}}</th>
                                    <th>{{$t("价格")}}</th>
                                    <th>{{$t("盈亏")}}</th>
                                    <th>{{$t("操作")}}</th>
                                </tr>
                            </thead>
                            <tbody>
    
                            <tr v-for="(row, index) in myOrders" :key="index"  >
                                <td> <dict-tag :options="dict.type.trade_type" :value="row.buyType"/> </td>
                                <td>{{ row.name }}</td>
                                <td class="buy-row" @click="openDialog(row)">{{ row.stopSurplus }}<i v-if="row.stopSurplus" class="gray el-icon-error" @click="cancelSurplus(row)"></i></td>
                                <td class="buy-row">{{ row.stopLoss }}<i v-if="row.stopLoss" class="gray el-icon-error" @click="cancelLoss(row)"></i></td>
                                <td>{{ row.hands }}</td>
                                <td>{{ row.baseNum }}</td>
                                <td>{{ row.profit }}</td>
                                <td>
                                    <el-button v-if="row.status === 0" size="mini" type="info" plain @click="cancelOrder(row)">{{$t("取消")}}</el-button>
                                    <el-button v-else size="mini" type="warning" plain @click="sellOrder(row)">{{$t("平仓")}}</el-button>
                                </td>
                            </tr>
                            </tbody>
    
                        </table>
                    </div>
                </div>
                <div  class="w-right">
                    <div class="" style="border: 1px solid gray">
    
                        <el-checkbox class="checkbox" v-model="skipChecked" @change="saveToLocalStorage('skipChecked',skipChecked)">{{$t("跳过确认")}}</el-checkbox>
                        <el-checkbox class="checkbox" v-model="oneButtonchecked" @change="saveToLocalStorage('oneButtonchecked',oneButtonchecked)">{{$t("一键下单")}}</el-checkbox>
                        <el-checkbox class="checkbox" v-model="fixCurChecked" @change="saveToLocalStorage('fixCurChecked',fixCurChecked)">{{$t("时价居中")}}</el-checkbox>
                        <el-checkbox class="checkbox" v-model="voiceChecked" @change="saveToLocalStorage('voiceChecked',voiceChecked)">{{$t("语音播报")}}</el-checkbox>
    
                    </div>
                    <div class="curinfo" v-if="marketRows[selectedRowIndex]">
                        <div class="w50">
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("最新")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].price}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("开盘")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].Open}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("高价")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].High}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("低价")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].Low}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("截止日")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].Time}}</span>
                            </div>
                        </div>
                        <div class="w50">
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("昨收")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].LastClose}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("幅度")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].DiffRate}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("成交量")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].TotalVol}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("买量")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].BV1}}</span>
                            </div>
                            <div class="vinfo">
                                <span class="vinfokey">{{$t("卖量")}}</span>
                                <span class="whitebg">{{marketRows[selectedRowIndex].SV1}}</span>
                            </div>
                        </div>
                    </div>
    
                    <div class="subject-container" style="padding-top: 5px;font-size: 13px">
                        <table>
                            <thead>
                            <tr>
                                <th>{{$t("名称")}}</th>
                                <th>{{$t("代码")}}</th>
                                <th>{{$t("月份")}}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(row, index) in marketRows" :key="index" :class="{ 'selected-row': selectedRowIndex === index }" @click="selectRow(index)">
                                <td>{{ row.name }}</td>
                                <td>{{ row.code }}</td>
                                <td>{{ row.contract }}</td>
    
                            </tr>
                            </tbody>
    
                        </table>
                    </div>
                    <div class="userbuy-container" :style="adjustedHeightRight">
                        <table style="padding-top: 5px">
                            <thead>
                            <tr>
                                <th style="text-align: center">{{$t("时间")}}</th>
                                <th style="text-align: center">{{$t("价格")}}</th>
                                <th style="text-align: center">{{$t("数量")}}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(row, index) in marketTrade" :key="index">
                                <td class="smalltd" style="text-align: center">{{ row.time }}</td>
                                <td class="smalltd" style="text-align: center;color: red">{{ row.price }}</td>
                                <td class="smalltd"  :class="{ 'blue-text': row.amount < 0 }" style="text-align: center">{{ row.amount }}</td>
    
                            </tr>
                            </tbody>
    
                        </table>
                    </div>
                </div>
        <audio ref="audioCancel" src="../assets/cancel.mp3"></audio>
        <audio ref="audioSell" src="../assets/sell.mp3"></audio>
        <audio ref="audioOrder" src="../assets/order.mp3"></audio>
        <audio ref="audioBuild" src="../assets/build.mp3"></audio>
        <audio ref="audioStopSurplus" src="../assets/stopSurplus.mp3"></audio>
        <audio ref="audioStopLoss" src="../assets/stopLoss.mp3"></audio>
        <audio ref="audioPrepare" src="../assets/prepare.mp3"></audio>
    
    
    </div>
    
  2. Assistant

    将上述代码转换为UniApp移动端应用需要对HTML模板和JavaScript部分进行调整。以下是转换后的代码:

    Template

    <template>
        <view class="container">
    
            <view class="w-left">
                <view class="grid-content bg-purple">
                    <view>
                        <view class="itemText">
                            <view class="border">{{ $t('估值保证金') }}</view>
                            <view class="border textRight">{{ myMargin }}</view>
                        </view>
                        <view class="itemText">
                            <view class="border">{{ $t('总估值损益') }}</view>
                            <view class="border textRight">{{ (realTimeProfit + realizedProfit).toFixed(2) }}</view>
                        </view>
                        <view class="itemText">
                            <view class="border">{{ $t('实时盈亏') }}</view>
                            <view class="border textRight">{{ realTimeProfit }}</view>
                        </view>
                        <view class="itemText">
                            <view class="border">{{ $t('已实现损益') }}</view>
                            <view class="border textRight">{{ realizedProfit }}</view>
                        </view>
                        <view class="itemText">
                            <view class="border">{{ $t('储备余额') }}</view>
                            <view class="border textRight">{{ myMoney }}</view>
                        </view>
                    </view>
                    <view>
                    </view>
                    <view style="padding-top: 5px">
                        <view class="rowpannel1">
                            <view class="rowpannel1">
                                <uni-checkbox v-model="preSellNumChecked">{{ $t('止盈') }}</uni-checkbox>
                                <view class="rowpannel1">
                                    <uni-number-box :value="preSellNum" @input="handleNumberChangePreSell($event.target.value)" min="1" max="100"></uni-number-box>{{ $t('格') }}
                                </view>
                                <text style="padding-left: 25px">{{ $t('持仓数量') }}</text>
                            </view>
                            <view style="display: flex">
                                <view style="margin-left: 40px" class="textAndInput">
                                    <text class="textInputBlue">{{ $t('卖出持仓') }}</text>
                                    <uni-input
                                        style="width: 50px;"
                                        :placeholder="$t('请输入内容')"
                                        v-model="totalSellNum"
                                        readonly
                                    ></uni-input>
                                </view>
                                <text class="textInputRed">{{ $t('买入持仓') }}</text>
                                <view class="textAndInput">
                                    <uni-input
                                        style="width: 50px;"
                                        :placeholder="$t('请输入内容')"
                                        v-model="totalBuyNum"
                                        readonly
                                    ></uni-input>
                                </view>
                            </view>
                            <uni-button style="margin-left: 40px; width: 100px;" @click="reset">{{ $t("重置") }}</uni-button>
                        </view>
                        <view class="rowpannel1" style="padding-top: 5px;">
                            <view class="rowpannel1">
                                <uni-checkbox v-model="preDownNumChecked">{{ $t('止损') }}</uni-checkbox>
                                <view class="rowpannel1">
                                    <uni-number-box :value="preDownNum" @input="handleNumberChangePreDown($event.target.value)" min="1" max="100"></uni-number-box>{{ $t('格') }}
                                </view>
                                <text style="padding-left: 25px">{{ $t('下单数量') }}</text>
                            </view>
                            <view style="display: flex;">
                                <view style="display: flex; align-items: center">
                                    <uni-number-box :value="hands" @input="handleNumberChangeHands($event.target.value)" min="1"></uni-number-box>{{ $t('手') }}
                                </view>
                                <view style="display: flex; padding-left: 20px">
                                    <uni-button @click="updateHands(1)">1</uni-button>
                                    <uni-button @click="updateHands(2)">2</uni-button>
                                    <uni-button @click="updateHands(3)">3</uni-button>
                                    <uni-button @click="updateHands(4)">4</uni-button>
                                    <uni-button @click="updateHands(5)">5</uni-button>
                                    <uni-button @click="updateHands(10)">10</uni-button>
                                    <uni-button @click="updateHands(20)">20</uni-button>
                                    <uni-button @click="updateHands(50)">50</uni-button>
                                    <uni-button @click="updateHands(100)">100</uni-button>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="rowpannel">
                    <uni-button type="primary" @click="buyIndex(marketRows[selectedRowIndex].curValue,-1)">{{ $t("市价出售") }}(F10)</uni-button>
                    <uni-button type="success" @click="sellAll()">{{ $t("全品类平仓") }}</uni-button>
                    <uni-button type="success" @click="sellCur()">{{ $t("现品类平仓") }}</uni-button>
                    <uni-button type="danger" @click="buyIndex(marketRows[selectedRowIndex].curValue,1)">{{ $t("市价买入") }}(F11)</uni-button>
                </view>
                <view class="table-container" ref="tableContainer">
                    <uni-table>
                        <uni-tr>
                            <uni-th style="color:cornflowerblue">MIT</uni-th>
                            <uni-th>{{ $t("空持仓") }}</uni-th>
                            <uni-th>{{ $t("未成交") }}</uni-th>
                            <uni-th>{{ $t("卖出") }}</uni-th>
                            <uni-th>{{ $t("价格") }}</uni-th>
                            <uni-th>{{ $t("买入") }}</uni-th>
                            <uni-th>{{ $t("未成交") }}</uni-th>
                            <uni-th>{{ $t("多持仓") }}</uni-th>
                            <uni-th style="color: darkred">MIT</uni-th>
                        </uni-tr>
                        <uni-tr v-for="(row, index) in rows" :key="index" :class="{ 'highlight-row': row.basePrice === currentIndex }">
                            <uni-td style="background-color: #79b6f554">{{ row.mitSell ? row.mitSell : '' }}</uni-td>
                            <uni-td style="background-color: #79b6f5a6">{{ row.shortPos }}</uni-td>
                            <uni-td>{{ row.sellUnComp }}</uni-td>
                            <uni-td class="buy-row" @click="buyIndex(row.basePrice, -1)">{{ row.sellNum }}</uni-td>
                            <uni-td style="background-color: #a1ccfa">{{ row.basePrice }}</uni-td>
                            <uni-td class="buy-row" @click="buyIndex(row.basePrice, 1)">{{ row.buyNum }}</uni-td>
                            <uni-td>{{ row.bugUnComp }}</uni-td>
                            <uni-td style="background-color: #f56c6c9c">{{ row.longPos }}</uni-td>
                            <uni-td style="background-color: #f56c6c42">{{ row.mitBuy ? row.mitBuy : '' }}</uni-td>
                        </uni-tr>
                        <uni-tr>
                            <uni-td>{{ totalsellMit }}</uni-td>
                            <uni-td>{{ totalsell }}</uni-td>
                            <uni-td colspan="1">{{ total_unsell }}</uni-td>
                            <uni-td></uni-td>
                            <uni-td></uni-td>
                            <uni-td></uni-td>
                            <uni-td>{{ total_unbuy }}</uni-td>
                            <uni-td>{{ totalbuy }}</uni-td>
                            <uni-td>{{ totalbuyMit }}</uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
                <view class="rowpannel" style="display: flex; justify-content: space-between;">
                    <uni-button style="flex-grow: 1;" @click="cancelAll">{{ $t("全品类取消") }}</uni-button>
                    <uni-button style="flex-grow: 1;" @click="cancelCur">{{ $t("现品类取消") }}</uni-button>
                </view>
                <view class="bottom-table">
                    <uni-table>
                        <uni-tr>
                            <uni-th>{{ $t("方向") }}</uni-th>
                            <uni-th>{{ $t("合约") }}</uni-th>
                            <uni-th>{{ $t("止盈") }}</uni-th>
                            <uni-th>{{ $t("止损") }}</uni-th>
                            <uni-th>{{ $t("仓位") }}</uni-th>
                            <uni-th>{{ $t("价格") }}</uni-th>
                            <uni-th>{{ $t("盈亏") }}</uni-th>
                            <uni-th>{{ $t("操作") }}</uni-th>
                        </uni-tr>
                        <uni-tr v-for="(row, index) in myOrders" :key="index">
                            <uni-td>{{ row.buyType }}</uni-td>
                            <uni-td>{{ row.name }}</uni-td>
                            <uni-td class="buy-row" @click="openDialog(row)">{{ row.stopSurplus }}
                                <uni-icon v-if="row.stopSurplus" type="close" size="16" color="#999" @click="cancelSurplus(row)"></uni-icon>
                            </uni-td>
                            <uni-td class="buy-row">{{ row.stopLoss }}
                                <uni-icon v-if="row.stopLoss" type="close" size="16" color="#999" @click="cancelLoss(row)"></uni-icon>
                            </uni-td>
                            <uni-td>{{ row.hands }}</uni-td>
                            <uni-td>{{ row.baseNum }}</uni-td>
                            <uni-td>{{ row.profit }}</uni-td>
                            <uni-td>
                                <uni-button v-if="row.status === 0" size="mini" @click="cancelOrder(row)">{{ $t("取消") }}</uni-button>
                                <uni-button v-else size="mini" @click="sellOrder(row)">{{ $t("平仓") }}</uni-button>
                            </uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
            </view>
            <view class="w-right">
                <view style="border: 1px solid gray">
                    <uni-checkbox class="checkbox" v-model="skipChecked" @change="saveToLocalStorage('skipChecked', skipChecked)">{{ $t("跳过确认") }}</uni-checkbox>
                    <uni-checkbox class="checkbox" v-model="oneButtonchecked" @change="saveToLocalStorage('oneButtonchecked', oneButtonchecked)">{{ $t("一键下单") }}</uni-checkbox>
                    <uni-checkbox class="checkbox" v-model="fixCurChecked" @change="saveToLocalStorage('fixCurChecked', fixCurChecked)">{{ $t("时价居中") }}</uni-checkbox>
                    <uni-checkbox class="checkbox" v-model="voiceChecked" @change="saveToLocalStorage('voiceChecked', voiceChecked)">{{ $t("语音播报") }}</uni-checkbox>
                </view>
                <view class="curinfo" v-if="marketRows[selectedRowIndex]">
                    <view class="w50">
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("最新") }}</text>
                            <text>{{ marketRows[selectedRowIndex].price }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("开盘") }}</text>
                            <text>{{ marketRows[selectedRowIndex].Open }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("高价") }}</text>
                            <text>{{ marketRows[selectedRowIndex].High }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("低价") }}</text>
                            <text>{{ marketRows[selectedRowIndex].Low }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("截止日") }}</text>
                            <text>{{ marketRows[selectedRowIndex].Time }}</text>
                        </view>
                    </view>
                    <view class="w50">
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("昨收") }}</text>
                            <text>{{ marketRows[selectedRowIndex].LastClose }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("幅度") }}</text>
                            <text>{{ marketRows[selectedRowIndex].DiffRate }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("成交量") }}</text>
                            <text>{{ marketRows[selectedRowIndex].TotalVol }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("买量") }}</text>
                            <text>{{ marketRows[selectedRowIndex].BV1 }}</text>
                        </view>
                        <view class="vinfo">
                            <text class="vinfokey">{{ $t("卖量") }}</text>
                            <text>{{ marketRows[selectedRowIndex].SV1 }}</text>
                        </view>
                    </view>
                </view>
                <view class="subject-container" style="padding-top: 5px;font-size: 13px">
                    <uni-table>
                        <uni-tr>
                            <uni-th>{{ $t("名称") }}</uni-th>
                            <uni-th>{{ $t("代码") }}</uni-th>
                            <uni-th>{{ $t("月份") }}</uni-th>
                        </uni-tr>
                        <uni-tr v-for="(row, index) in marketRows" :key="index" :class="{ 'selected-row': selectedRowIndex === index }" @click="selectRow(index)">
                            <uni-td>{{ row.name }}</uni-td>
                            <uni-td>{{ row.code }}</uni-td>
                            <uni-td>{{ row.contract }}</uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
                <view class="userbuy-container">
                    <uni-table>
                        <uni-tr>
                            <uni-th style="text-align: center">{{ $t("时间") }}</uni-th>
                            <uni-th style="text-align: center">{{ $t("价格") }}</uni-th>
                            <uni-th style="text-align: center">{{ $t("数量") }}</uni-th>
                        </uni-tr>
                        <uni-tr v-for="(row, index) in marketTrade" :key="index">
                            <uni-td style="text-align: center">{{ row.time }}</uni-td>
                            <uni-td style="text-align: center;color: red">{{ row.price }}</uni-td>
                            <uni-td style="text-align: center">{{ row.amount }}</uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
            </view>
            
            <!-- 音频播放相关代码(暂时不适用于移动端,可根据具体实现调整) -->
            <audio ref="audioCancel" src="../assets/cancel.mp3"></audio>
            <audio ref="audioSell" src="../assets/sell.mp3"></audio>
            <audio ref="audioOrder" src="../assets/order.mp3"></audio>
            <audio ref="audioBuild" src="../assets/build.mp3"></audio>
            <audio ref="audioStopSurplus" src="../assets/stopSurplus.mp3"></audio>
            <audio ref="audioStopLoss" src="../assets/stopLoss.mp3"></audio>
            <audio ref="audioPrepare" src="../assets/prepare.mp3"></audio>
    
        </view>
    </template>
    

    Script

    修改 script 部分来适应 uniapp 功能,可以使用 vue 的写法,但需要将部分组件方法改为 uni-ui 组件方法。

    import { getUserProfile, getMyMoney } from "@/api/system/user";
    import {
        getMarketList,
        addTrade,
        cancelOrder,
        closePositon,
        myUnfinishOrders,
        getMyMargin,
        getMyRealTimeProfit,
        getRealizedProfit,
        marketDate,
        getMyPosition,
        cancelStrategy,
        sellAll,
        cancelAll,
        getLatestOrders
    } from "@/api/market";
    
    export default {
        data() {
            return {
                visible: false,
                num: 1,
                none: '',
                socket: null,
                checkList: [],
                input: 0,
                myMargin: 0,
                realTimeProfit: 0,
                realizedProfit: 0,
                curValue: {},
                rows: [],
                myOrders: [{}],
                selectedRowIndex: 0, // 初始化选中的行索引为-1
                marketRows: [],
                marketTrade: [], //市场交易数据 买卖
                checked: false,
                currentIndex: 0, // 当前指数
                hands: 1,
                preDownNum: 5, //止损
                preSellNum: 5, //止赢
                preDownNumChecked: false,
                preSellNumChecked: false,
                voiceChecked: false,
                fixCurChecked: false,
                oneButtonchecked: false,
                skipChecked: false,
                windowHeight: 0,
                mydata: [],
                totalbuy: 0,
                total_unbuy: 0,
                total_unsell: 0,
                totalsell: 0,
                totalSellNum: 0,
                totalBuyNum: 0,
                totalsellMit: 0,
                totalbuyMit: 0,
                myMoney: 0,
                showPointer: false
            };
        },
        computed: {
            adjustedHeightRight() {
                return `height: ${this.windowHeight - 780}px;`;
            },
            adjustedHeight() {
                return `height: ${this.windowHeight - 800}px;`;
            }
        },
        onReady() {
            this.getWindowHeight();
            uni.onWindowResize(this.getWindowHeight); // 监听窗口大小变化
    
            this.skipChecked = Boolean(uni.getStorageSync('skipChecked'));
            this.oneButtonchecked = Boolean(uni.getStorageSync('oneButtonchecked'));
            this.fixCurChecked = Boolean(uni.getStorageSync('fixCurChecked'));
            this.voiceChecked = Boolean(uni.getStorageSync('voiceChecked'));
    
            const params = {
                pageNum: 1,