li.shaoyi 2 місяців тому
батько
коміт
744584b363

+ 1 - 0
src/packages/digital/assets/themes/default/default.less

@@ -38,6 +38,7 @@
     --van-button-default-border-color: var(--van-button-default-background);
     --van-button-primary-color: #000;
     --van-button-primary-background: #fff;
+    --van-button-primary-border-color: var(--van-button-primary-background);
 
     /* Vant-Checkbox */
     --van-checkbox-checked-icon-color: #DD364A !important;

+ 4 - 5
src/packages/digital/views/contract/components/account/index.vue

@@ -37,7 +37,7 @@
             <tfoot>
                 <tr>
                     <td colspan="3">
-                        <Button size="small" @click="navigateTo('wallet-transfer')">划转</Button>
+                        <Button size="small" @click="navigateTo('wallet-transfer', 0)">划转</Button>
                     </td>
                 </tr>
             </tfoot>
@@ -51,9 +51,8 @@ import { useNavigation } from '@mobile/router/navigation'
 import { useAccountStore } from '@/stores'
 
 const props = defineProps({
-    accountId: {
+    goodsId: {
         type: Number,
-        required: true
     }
 })
 
@@ -62,11 +61,11 @@ const { currentAccount } = accountStore.$toRefs()
 
 const { router } = useNavigation()
 
-const navigateTo = (name: string) => {
+const navigateTo = (name: string, accountId: number) => {
     router.push({
         name,
         query: {
-            id: props.accountId
+            id: accountId
         }
     })
 }

+ 2 - 2
src/packages/digital/views/contract/goods/detail/index.vue

@@ -46,7 +46,7 @@
                 </Field>
                 <Field label="开仓价值"></Field>
             </CellGroup>
-            <CellGroup inset style="margin-top: 20px;">
+            <CellGroup>
                 <Cell title="可用余额" value="0" />
                 <Cell title="可开数量" value="0" />
                 <Cell title="预估手续费" value="0" />
@@ -65,7 +65,7 @@
                 <contract-order v-bind="{ goodsId }" />
             </Tab>
             <Tab title="资金">
-                <contract-account v-bind="{ accountId: 0 }" />
+                <contract-account v-bind="{ goodsId }" />
             </Tab>
         </Tabs>
     </app-view>

+ 5 - 6
src/packages/digital/views/spot/components/account/index.vue

@@ -28,8 +28,8 @@
             <tfoot>
                 <tr>
                     <td colspan="2">
-                        <Button size="small" @click="navigateTo('wallet-deposit')">充值</Button>
-                        <Button size="small" @click="navigateTo('wallet-withdraw')">提现</Button>
+                        <Button size="small" @click="navigateTo('wallet-deposit', 0)">充值</Button>
+                        <Button size="small" @click="navigateTo('wallet-withdraw', 0)">提现</Button>
                     </td>
                 </tr>
             </tfoot>
@@ -42,19 +42,18 @@ import { Button } from 'vant'
 import { useNavigation } from '@mobile/router/navigation'
 
 const props = defineProps({
-    accountId: {
+    goodsId: {
         type: Number,
-        required: true
     }
 })
 
 const { router } = useNavigation()
 
-const navigateTo = (name: string) => {
+const navigateTo = (name: string, accountId: number) => {
     router.push({
         name,
         query: {
-            id: props.accountId
+            id: accountId
         }
     })
 }

+ 51 - 18
src/packages/digital/views/spot/goods/detail/index.vue

@@ -28,40 +28,43 @@
                 @click="formData.BuyOrSell = BuyOrSell.Sell">卖出</Button>
             </Col>
         </Row>
-        <Form ref="formRef" class="g-form__container">
+        <Form ref="formRef" class="g-form__container" @submit="onSubmit">
             <CellGroup inset>
                 <Field label="类型" is-link>
                     <template #input>
-                        <app-select :options="[]" />
+                        <app-select v-model="formData.PriceMode" :options="getPricemode2List()" />
                     </template>
                 </Field>
                 <Field label="价格">
                     <template #input>
-                        <app-stepper />
+                        <app-stepper v-model="formData.OrderPrice"
+                            :disabled="formData.PriceMode === PriceMode.Market" />
                     </template>
                 </Field>
                 <Field label="数量">
                     <template #input>
-                        <app-stepper />
+                        <app-stepper v-model="formData.OrderQty" />
                     </template>
                 </Field>
-                <Cell title="预估支付" value="0" />
+                <Cell title="预估支付" :value="calculations.estimate" />
             </CellGroup>
             <CellGroup inset v-if="formData.BuyOrSell === BuyOrSell.Buy">
-                <Cell title="可用余额" value="0" />
-                <Cell title="可开数量" value="0" />
-                <Cell title="预估手续费" value="0" />
+                <Cell title="可用余额" :value="calculations.available" />
+                <Cell title="可开数量" :value="calculations.qty" />
+                <Cell title="预估手续费" :value="calculations.free" />
             </CellGroup>
             <CellGroup inset v-if="formData.BuyOrSell === BuyOrSell.Sell">
-                <Cell title="可卖数量" value="0" />
-                <Cell title="可获金额" value="0" />
-                <Cell title="预估手续费" value="0" />
+                <Cell title="可卖数量" :value="calculations.qty" />
+                <Cell title="可获金额" :value="calculations.available" />
+                <Cell title="预估手续费" :value="calculations.free" />
             </CellGroup>
         </Form>
         <Row class="g-layout-block g-layout-block--inset">
             <Col span="24">
-            <Button type="success" block v-if="formData.BuyOrSell === BuyOrSell.Buy">买入</Button>
-            <Button type="danger" block v-if="formData.BuyOrSell === BuyOrSell.Sell">卖出</Button>
+            <Button type="success" block v-if="formData.BuyOrSell === BuyOrSell.Buy"
+                @click="formRef?.submit">买入</Button>
+            <Button type="danger" block v-if="formData.BuyOrSell === BuyOrSell.Sell"
+                @click="formRef?.submit">卖出</Button>
             </Col>
         </Row>
         <Tabs v-model:active="tabIndex" sticky>
@@ -69,7 +72,7 @@
                 <spot-order v-bind="{ goodsId }" />
             </Tab>
             <Tab title="资金">
-                <spot-account v-bind="{ accountId: 0 }" />
+                <spot-account v-bind="{ goodsId }" />
             </Tab>
         </Tabs>
     </app-view>
@@ -77,10 +80,13 @@
 
 <script lang="ts" setup>
 import { shallowRef, reactive, computed } from 'vue'
-import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, Col, Row } from 'vant'
+import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, Col, Row, FormInstance } from 'vant'
+import { fullloading } from '@/utils/vant'
+import { ClientType } from '@/constants/client'
 import { parsePercent } from '@/filters'
-import { BuyOrSell } from '@/constants/order'
+import { BuyOrSell, PriceMode, getPricemode2List } from '@/constants/order'
 import { useNavigation } from '@mobile/router/navigation'
+import { digitalOrder } from '@/services/api/trade'
 import { useFuturesStore } from '@/stores'
 import AppSelect from '@mobile/components/base/select/index.vue'
 import AppStepper from '@mobile/components/base/stepper/index.vue'
@@ -91,11 +97,26 @@ const { router, getQueryStringToNumber } = useNavigation()
 const goodsId = getQueryStringToNumber('id')
 const futuresStore = useFuturesStore()
 const tabIndex = shallowRef(0)
+const formRef = shallowRef<FormInstance>()
+
+const formData = reactive<Partial<Proto.DigitalOrderReq>>({
+    ClientType: ClientType.Web,
+    BuyOrSell: BuyOrSell.Buy,
+    PriceMode: PriceMode.Limit
+})
 
 const quote = computed(() => futuresStore.getQuoteInfo({ goodsid: goodsId }))
 
-const formData = reactive<Partial<Proto.DigitalOrderReq>>({
-    BuyOrSell: BuyOrSell.Buy
+const calculations = computed(() => {
+    const { agreeunit = 0 } = quote.value ?? {}
+    const { OrderPrice = 0, OrderQty = 0 } = formData
+
+    return {
+        estimate: OrderPrice * OrderQty * agreeunit,
+        available: 0,
+        qty: 0,
+        free: 0
+    }
 })
 
 const navigateToGoodsChart = () => {
@@ -106,6 +127,18 @@ const navigateToGoodsChart = () => {
         }
     })
 }
+
+const onSubmit = () => {
+    fullloading((hideLoading) => {
+        digitalOrder({
+            data: formData
+        }).then(() => {
+            hideLoading('提交成功', 'success')
+        }).catch((err) => {
+            hideLoading(err, 'fail')
+        })
+    })
+}
 </script>
 
 <style lang="less">

+ 1 - 0
src/services/api/trade/index.ts

@@ -437,6 +437,7 @@ export function digitalOrder(config: RequestConfig<Partial<Proto.DigitalOrderReq
     return http.mqRequest<Proto.DigitalOrderRsp>({
         data: {
             ClientSerialNo: v4(),
+            LoginID: loginStore.loginId,
             ...config.data
         },
         requestCode: 'DigitalOrderReq',