fix: 微信小程序兼容性调整
- config.vue: picker 组件使用条件编译,H5/APP使用u-picker,微信小程序使用原生picker - detail.vue: 交易表单input使用条件编译,H5/APP使用u-input,微信小程序使用原生input - 保留u-button和u-toast在所有平台使用
This commit is contained in:
parent
a9f3692aa8
commit
e7a3f1d26c
@ -23,6 +23,7 @@
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">选择逻辑模板</text>
|
||||
<!-- #ifdef H5 || APP-PLUS -->
|
||||
<u-picker
|
||||
:show="showStrategyPicker"
|
||||
:columns="[strategies.map(s => s.name)]"
|
||||
@ -39,11 +40,25 @@
|
||||
<u-icon name="arrow-down" size="14" color="#9CA3AF"></u-icon>
|
||||
</view>
|
||||
</u-picker>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<picker @change="onStrategyChange" :value="strategyIndex" :range="strategies" range-key="name">
|
||||
<view class="picker-box" @click="showStrategyPicker = true">
|
||||
<view class="flex-row items-center gap-2" v-if="selectedStrategy">
|
||||
<view class="strategy-dot" :style="{ backgroundColor: selectedStrategy.color }"></view>
|
||||
<text class="picker-text">{{ selectedStrategy.name }}</text>
|
||||
</view>
|
||||
<text class="picker-placeholder" v-else>点击选择逻辑规则</text>
|
||||
<uni-icons type="bottom" size="14" color="#9CA3AF"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
<!-- #endif -->
|
||||
<text class="helper-text" v-if="selectedStrategy">{{ selectedStrategy.desc }}</text>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">组合币种</text>
|
||||
<!-- #ifdef H5 || APP-PLUS -->
|
||||
<u-picker
|
||||
:show="showCurrencyPicker"
|
||||
:columns="[currencyList.map(c => c.name)]"
|
||||
@ -56,6 +71,15 @@
|
||||
<u-icon name="arrow-down" size="14" color="#9CA3AF"></u-icon>
|
||||
</view>
|
||||
</u-picker>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<picker @change="onCurrencyChange" :value="currencyIndex" :range="currencyList" range-key="name">
|
||||
<view class="picker-box" @click="showCurrencyPicker = true">
|
||||
<text class="picker-text">{{ currencyList[currencyIndex].name }}</text>
|
||||
<uni-icons type="bottom" size="14" color="#9CA3AF"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
<!-- #endif -->
|
||||
<text class="helper-text">创建后币种不可修改,所有交易只能使用该币种</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -190,6 +214,30 @@ const currencyIndex = ref(0); // 默认CNY
|
||||
const showStrategyPicker = ref(false);
|
||||
const showCurrencyPicker = ref(false);
|
||||
|
||||
// 小程序原生 picker 事件处理
|
||||
const onStrategyChange = (e) => {
|
||||
strategyIndex.value = e.detail.value;
|
||||
showStrategyPicker.value = false;
|
||||
|
||||
// 调用原有的策略变更逻辑
|
||||
const strategy = strategies.value[strategyIndex.value];
|
||||
if (strategy && strategy.parameters && strategy.parameters.assets) {
|
||||
form.value.stocks = strategy.parameters.assets.map(asset => ({
|
||||
name: asset.symbol,
|
||||
price: '',
|
||||
amount: '',
|
||||
date: ''
|
||||
}));
|
||||
} else {
|
||||
form.value.stocks = [{ name: '', price: '', amount: '', date: '' }];
|
||||
}
|
||||
};
|
||||
|
||||
const onCurrencyChange = (e) => {
|
||||
currencyIndex.value = e.detail.value;
|
||||
showCurrencyPicker.value = false;
|
||||
};
|
||||
|
||||
// 防止重复请求的标志
|
||||
let isFetching = false;
|
||||
|
||||
|
||||
@ -249,6 +249,7 @@
|
||||
<view class="form-item">
|
||||
<text class="form-label">{{ transactionType === 'sell' ? '选择持仓' : '股票代码' }}</text>
|
||||
<view class="relative">
|
||||
<!-- #ifdef H5 || APP-PLUS -->
|
||||
<u-input
|
||||
v-model="transactionForm.stockCode"
|
||||
:placeholder="transactionType === 'sell' ? '点击选择要卖出的持仓' : '请输入股票代码搜索'"
|
||||
@ -266,6 +267,17 @@
|
||||
@input="onStockInput"
|
||||
@click="handleStockInputClick"
|
||||
/>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<input
|
||||
v-model="transactionForm.stockCode"
|
||||
class="stock-input"
|
||||
:placeholder="transactionType === 'sell' ? '点击选择要卖出的持仓' : '请输入股票代码搜索'"
|
||||
:disabled="transactionType === 'sell'"
|
||||
@input="onStockInput"
|
||||
@click="handleStockInputClick"
|
||||
/>
|
||||
<!-- #endif -->
|
||||
<!-- 搜索下拉列表 -->
|
||||
<view class="search-dropdown" v-if="searchResults.length > 0">
|
||||
<view
|
||||
|
||||
Loading…
Reference in New Issue
Block a user