li.shaoyi 3 jaren geleden
bovenliggende
commit
f34bf48f01

+ 32 - 6
package-lock.json

@@ -17,6 +17,7 @@
         "long": "^5.2.0",
         "moment": "^2.29.3",
         "protobufjs": "^6.11.2",
+        "sortablejs": "^1.15.0",
         "uuid": "^8.3.2",
         "vant": "^3.4.8",
         "vue": "^3.2.13",
@@ -26,6 +27,7 @@
       },
       "devDependencies": {
         "@types/crypto-js": "^4.1.1",
+        "@types/sortablejs": "^1.13.0",
         "@types/uuid": "^8.3.4",
         "@typescript-eslint/eslint-plugin": "^5.4.0",
         "@typescript-eslint/parser": "^5.4.0",
@@ -2279,6 +2281,12 @@
         "@types/node": "*"
       }
     },
+    "node_modules/@types/sortablejs": {
+      "version": "1.13.0",
+      "resolved": "https://registry.npmjs.org/@types/sortablejs/-/sortablejs-1.13.0.tgz",
+      "integrity": "sha512-C3064MH72iEfeGCYEGCt7FCxXoAXaMPG0QPnstcxvPmbl54erpISu06d++FY37Smja64iWy5L8wOyHHBghWbJQ==",
+      "dev": true
+    },
     "node_modules/@types/uuid": {
       "version": "8.3.4",
       "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
@@ -10606,9 +10614,9 @@
       }
     },
     "node_modules/sortablejs": {
-      "version": "1.14.0",
-      "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz",
-      "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w=="
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.0.tgz",
+      "integrity": "sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w=="
     },
     "node_modules/source-map": {
       "version": "0.5.7",
@@ -11779,6 +11787,11 @@
         "vue": "^3.0.1"
       }
     },
+    "node_modules/vuedraggable/node_modules/sortablejs": {
+      "version": "1.14.0",
+      "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz",
+      "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w=="
+    },
     "node_modules/watchpack": {
       "version": "2.3.1",
       "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz",
@@ -14194,6 +14207,12 @@
         "@types/node": "*"
       }
     },
+    "@types/sortablejs": {
+      "version": "1.13.0",
+      "resolved": "https://registry.npmjs.org/@types/sortablejs/-/sortablejs-1.13.0.tgz",
+      "integrity": "sha512-C3064MH72iEfeGCYEGCt7FCxXoAXaMPG0QPnstcxvPmbl54erpISu06d++FY37Smja64iWy5L8wOyHHBghWbJQ==",
+      "dev": true
+    },
     "@types/uuid": {
       "version": "8.3.4",
       "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
@@ -20353,9 +20372,9 @@
       }
     },
     "sortablejs": {
-      "version": "1.14.0",
-      "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz",
-      "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w=="
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.0.tgz",
+      "integrity": "sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w=="
     },
     "source-map": {
       "version": "0.5.7",
@@ -21232,6 +21251,13 @@
       "integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==",
       "requires": {
         "sortablejs": "1.14.0"
+      },
+      "dependencies": {
+        "sortablejs": {
+          "version": "1.14.0",
+          "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz",
+          "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w=="
+        }
       }
     },
     "watchpack": {

+ 2 - 0
package.json

@@ -19,6 +19,7 @@
     "long": "^5.2.0",
     "moment": "^2.29.3",
     "protobufjs": "^6.11.2",
+    "sortablejs": "^1.15.0",
     "uuid": "^8.3.2",
     "vant": "^3.4.8",
     "vue": "^3.2.13",
@@ -28,6 +29,7 @@
   },
   "devDependencies": {
     "@types/crypto-js": "^4.1.1",
+    "@types/sortablejs": "^1.13.0",
     "@types/uuid": "^8.3.4",
     "@typescript-eslint/eslint-plugin": "^5.4.0",
     "@typescript-eslint/parser": "^5.4.0",

+ 1 - 1
public/config/appconfig.json

@@ -1,4 +1,4 @@
 {
   "version": "3.0.0",
-  "apiUrl": "http://192.168.31.203:8080/cfg?key=test_203"
+  "apiUrl": "http://fgy.muchinfo.cn:28280/cfg?key=mtp_20"
 }

+ 1 - 1
src/business/account/index.ts

@@ -13,7 +13,7 @@ export function useAccount() {
         loading = ref(false);
 
     const account = reactive<Proto.LoginReq>({
-        LoginID: '1000',
+        LoginID: 'xyy',
         LoginPWD: '123456',
         GUID: v4(),
         LoginType: 0,

+ 4 - 4
src/components/base/tab/index.vue

@@ -1,8 +1,8 @@
 <!-- 标签栏组件 -->
 <template>
   <div class="app-tab">
-    <ul class="app-tab__list" v-if="dataSource.length">
-      <li :class="['app-tab__list-item', selectedIndex === index && 'active']" v-for="(item, index) in dataSource"
+    <ul class="app-tab__list" v-if="dataList.length">
+      <li :class="['app-tab__list-item', selectedIndex === index && 'active']" v-for="(item, index) in dataList"
         :key="index" @click="onChange(index)">
         {{ prop ? item[prop] : '标签' + index }}
       </li>
@@ -17,7 +17,7 @@ import { ref, watch } from 'vue'
 const emit = defineEmits(['update:dataIndex', 'change']);
 
 const props = defineProps({
-  dataSource: {
+  dataList: {
     type: Array,
     default: () => ([]),
   },
@@ -39,7 +39,7 @@ const onChange = (index: number) => {
   if (selectedIndex.value !== index) {
     selectedIndex.value = index;
     emit('update:dataIndex', index);
-    emit('change', index, props.dataSource[index]);
+    emit('change', index, props.dataList[index]);
   }
 }
 

+ 1 - 1
src/mock/account.ts

@@ -5,7 +5,7 @@ const getLoginId = {
         code: 200,
         msg: 'success',
         total: 0,
-        data: '110000000001'
+        data: '133900000005'
     }
 }
 

+ 3 - 3
src/packages/mobile/components/base/tabbar/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="app-tabbar">
     <div class="app-tabbar__warpper" :style="styles">
-      <template v-for="(item, index) in dataSource" :key="index">
+      <template v-for="(item, index) in dataList" :key="index">
         <div class="app-tabbar__item" @click="onChange(index)">
           <slot :item="item" :index="index">
             <!--判断是否图片图标-->
@@ -33,7 +33,7 @@ const emit = defineEmits(['change', 'update:dataIndex'])
 
 const props = defineProps({
   // 数据列表
-  dataSource: {
+  dataList: {
     type: Array as PropType<Tabbar[]>,
     default: () => ([]),
   },
@@ -61,7 +61,7 @@ const onChange = (index: number) => {
   if (selectedIndex.value !== index) {
     selectedIndex.value = index;
     emit('update:dataIndex', index);
-    emit('change', index, props.dataSource[index]);
+    emit('change', index, props.dataList[index]);
   }
 }
 

+ 3 - 3
src/packages/mobile/components/base/table/index.vue

@@ -12,7 +12,7 @@
                 </Draggable>
             </thead>
             <tbody>
-                <template v-for="(row, i) in dataSource" :key="i">
+                <template v-for="(row, i) in dataList" :key="i">
                     <tr class="app-table__row" @click="rowClick(i)">
                         <td class="app-table__cell expand" v-if="$slots.expand">
                             <Icon name="arrow-down" v-if="selectedIndex === i" />
@@ -45,7 +45,7 @@ const emit = defineEmits(['rowClick'])
 
 const props = defineProps({
     // 数据列表
-    dataSource: {
+    dataList: {
         type: Array,
         default: () => ([]),
     },
@@ -63,7 +63,7 @@ const rowClick = (index: number) => {
     } else {
         selectedIndex.value = index;
     }
-    emit('rowClick', index, props.dataSource[index]);
+    emit('rowClick', index, props.dataList[index]);
 }
 </script>
 

+ 5 - 2
src/packages/mobile/views/home/components/market/index.vue

@@ -5,7 +5,10 @@
       <Grid :column-num="3" style="margin-bottom: .2rem;">
         <GridItem icon="photo-o" text="商品" :to="{ name: 'order' }" v-for="index in 6" :key="index" />
       </Grid>
-      <app-table :data-source="quoteList" :columns="columns" @row-click="rowClick">
+      <app-table :data-list="quoteList" :columns="columns" @row-click="rowClick">
+        <template #expand>
+          扩展
+        </template>
         <template #last="{ row }">
           <span :class="handlePriceColor(row.last, row.presettle)">{{ handleNoneValue(row.last) }}</span>
         </template>
@@ -81,7 +84,7 @@ const rowClick = (index: number) => {
 }
 
 onActivated(() => {
-  addSubscribe(['pp2205', 'pp2206', 'b2205', 'b2206'], uuid);
+  addSubscribe(['cu2206', 'cu2207', 'cu2208', 'cu2209', 'cu2301', 'cu2303', 'cu2304'], uuid);
 })
 
 onDeactivated(() => {

+ 75 - 1
src/packages/mobile/views/home/components/order/index.vue

@@ -3,12 +3,86 @@
     <app-navbar title="订单" :show-back-button="false"></app-navbar>
     <div class="home-order__container g-flex__body">
       <Empty description="暂无数据" />
+      <table ref="dragTable" class="app-table__body" cellspacing="0" cellpadding="0"
+        style="width:100%;text-align:center;">
+        <thead>
+          <tr>
+            <th v-for="(column, i) in columns" :key="i">
+              <Button>{{ column.label }}</Button>
+            </th>
+          </tr>
+        </thead>
+        <tbody>
+          <tr v-for="(row, i) in tableList" :key="i">
+            <td v-for="(column, j) in columns" :key="j">
+              <Button>{{ row[column.key] }}</Button>
+            </td>
+          </tr>
+        </tbody>
+      </table>
     </div>
   </div>
 </template>
 
 <script lang="ts" setup>
-import { Empty } from 'vant'
+import { ref, onMounted } from 'vue'
+import { Empty, Button } from 'vant'
+import { queryGoodsList } from '@/services/api/goods'
+import Sortable from 'sortablejs'
+
+const dragTable = ref<HTMLElement>();
+const tableList = ref<Ermcp.Goods[]>([]);
+
+const columns = [
+  {
+    key: 'id',
+    label: '序号',
+  },
+  {
+    key: 'goodsCode',
+    label: '合约',
+  },
+  {
+    key: 'goodsName',
+    label: '商品',
+  },
+  {
+    key: 'lastPrice',
+    label: '最新价',
+  }
+]
+
+queryGoodsList({
+  success: (res) => {
+    tableList.value = res.data;
+  }
+})
+
+onMounted(() => {
+  const el = dragTable.value
+  if (el) {
+    const getHeader = () => el.querySelector('thead tr') as HTMLElement;
+    const getRows = () => el.querySelectorAll('tbody tr');
+
+    new Sortable(getHeader(), {
+      animation: 150,
+      draggable: 'th',
+      onStart: (e) => {
+        const columns: HTMLTableCellElement[] = [];
+        const rows = getRows();
+
+        rows.forEach((row) => {
+          const cells = row.querySelectorAll('td');
+          if (e.oldIndex !== undefined) {
+            columns.push(cells[e.oldIndex]);
+          }
+        })
+
+        console.log(e, columns.map((e) => e.innerText));
+      },
+    })
+  }
+})
 </script>
 
 <style lang="less">

+ 1 - 1
src/packages/mobile/views/home/index.vue

@@ -3,7 +3,7 @@
     <keep-alive>
       <component class="g-flex__body" :is="components[componentId]"></component>
     </keep-alive>
-    <AppTabbar :data-source="tabList" @change="onChange" fixed />
+    <app-tabbar :data-list="tabList" @change="onChange" fixed />
   </div>
 </template>
 

+ 1 - 1
src/packages/mobile/views/order/detail/index.vue

@@ -2,7 +2,7 @@
   <div class="order-detail g-flex">
     <app-navbar title="详情" />
     <div class="g-flex__body">
-      <app-tab theme="menu" :data-source="chartCycleTypeList" :data-index="1" @change="tabChange" />
+      <app-tab theme="menu" :data-list="chartCycleTypeList" :data-index="1" @change="tabChange" />
       <component :is="components.echartsTimeline" v-if="selectedCycleType === ChartCycleType.time" />
       <component :is="components.echartsKline" :cycle-type="selectedCycleType" v-else />
     </div>

+ 3 - 3
src/packages/pc/components/base/contextmenu/index.vue

@@ -2,8 +2,8 @@
 <template>
   <div class="app-contextmenu" v-show="showContextmenu" @contextmenu.prevent.capture @click="close">
     <ul class="app-contextmenu__list" :style="styles">
-      <li class="app-contextmenu__list-item" v-for="item in dataSource" :key="item.code" @click.stop="chooseMenu(item)">
-        {{item.label}}
+      <li class="app-contextmenu__list-item" v-for="item in dataList" :key="item.code" @click.stop="chooseMenu(item)">
+        {{ item.label }}
       </li>
     </ul>
   </div>
@@ -18,7 +18,7 @@ const emit = defineEmits(["click"]);
 
 defineProps({
   // 右键菜单列表
-  dataSource: {
+  dataList: {
     type: Array as PropType<Contextmenu[]>,
     default: () => [],
   },

+ 1 - 3
src/packages/pc/components/base/table/index.vue

@@ -14,8 +14,6 @@
         </template>
       </el-table-column>
     </el-table>
-    <!-- 右键菜单功能,暂未实现 -->
-    <slot name="contextmenu"></slot>
   </div>
 </template>
 
@@ -27,7 +25,7 @@ defineProps({
   columns: {
     type: Array as PropType<TableColumn[]>,
     default: () => ([])
-  }
+  },
 })
 </script>
 

+ 1 - 1
src/packages/pc/components/layouts/sidebar/index.vue

@@ -2,7 +2,7 @@
   <el-scrollbar :class="['app-sidebar', modelValue && 'is-hide']" view-class="app-sidebar__view">
     <div class="app-sidebar__menu">
       <el-menu :default-active="$route.name" :collapse="modelValue" @select="routerTo" unique-opened>
-        <app-submenu :data-source="menus"></app-submenu>
+        <app-submenu :data-list="menus"></app-submenu>
       </el-menu>
     </div>
     <div :class="['app-sidebar__mask', modelValue && 'is-hide']" @click="hideSidebar(true)" v-if="isMobile"></div>

+ 7 - 7
src/packages/pc/components/layouts/submenu/index.vue

@@ -1,18 +1,18 @@
 <template>
-  <template v-for="(item,index) in dataSource" :key="index">
+  <template v-for="(item, index) in dataList" :key="index">
     <el-sub-menu :index="item.name" v-if="item.children">
       <template #title>
         <!--如果没有图标,用标题第一个字代替-->
-        <i :class="[ item.icon, 'menu-icon' ]" v-if="item.icon"></i>
-        <i class="text-icon menu-icon" v-else>{{ item.label.slice(0,1) }}</i>
+        <i :class="[item.icon, 'menu-icon']" v-if="item.icon"></i>
+        <i class="text-icon menu-icon" v-else>{{ item.label.slice(0, 1) }}</i>
         <span v-if="item.icon">{{ item.label }}</span>
         <span v-else>{{ item.label.slice(1) }}</span>
       </template>
       <!--如果存在子级,递归调用自身-->
-      <app-submenu :data-source="item.children"></app-submenu>
+      <app-submenu :data-list="item.children"></app-submenu>
     </el-sub-menu>
     <el-menu-item :index="item.name" :route="{ path: item.path, replace: true }" v-else>
-      <i :class="[ item.icon, 'menu-icon' ]" v-if="item.icon"></i>
+      <i :class="[item.icon, 'menu-icon']" v-if="item.icon"></i>
       <span>{{ item.label }}</span>
     </el-menu-item>
   </template>
@@ -24,10 +24,10 @@ import { defineComponent } from "vue";
 export default defineComponent({
   name: "AppSubmenu",
   props: {
-    dataSource: {
+    dataList: {
       type: Array,
       required: true,
     },
   },
-});
+})
 </script>

+ 4 - 4
src/packages/pc/components/modules/button-group/index.vue

@@ -1,8 +1,8 @@
 <!-- 按钮组 -->
 <template>
-  <ul class="app-button-group" v-if="data.length">
-    <li class="app-button-group__item" v-for="(item,index) in data" :key="index">
-      <el-button :type="getButtonType(item.code)" @click="onClick(item.code)">{{item.label}}</el-button>
+  <ul class="app-button-group" v-if="dataList.length">
+    <li class="app-button-group__item" v-for="(item, index) in dataList" :key="index">
+      <el-button :type="getButtonType(item.code)" @click="onClick(item.code)">{{ item.label }}</el-button>
     </li>
   </ul>
 </template>
@@ -11,7 +11,7 @@
 const emit = defineEmits(['click'])
 
 defineProps({
-  data: {
+  dataList: {
     type: Array,
     default: () => ([])
   }

+ 1 - 1
src/packages/pc/components/modules/echarts-kline/index.vue

@@ -54,7 +54,7 @@
             <app-echarts :option="options.cci" v-model:dataIndex="dataIndex" @ready="indicatorReady" />
           </section>
         </div>
-        <app-tab theme="menu" :data-source="chartSeriesTypeList" @change="tabChange" />
+        <app-tab theme="menu" :data-list="chartSeriesTypeList" @change="tabChange" />
       </template>
     </template>
   </div>

+ 1 - 1
src/packages/pc/views/market/goods/index.vue

@@ -2,7 +2,7 @@
   <app-view class="futures-goods" @ready="onReady">
     <div>全局共享数据:{{ goodsList }}</div>
     <el-button @click="clearGoods">清空</el-button>
-    <app-tab theme="menu" :data-source="chartCycleTypeList" :data-index="1" @change="tabChange" />
+    <app-tab theme="menu" :data-list="chartCycleTypeList" :data-index="1" @change="tabChange" />
     <component :is="components.echartsTimeline" style="height:70%;" v-if="selectedCycleType === ChartCycleType.time" />
     <component :is="components.echartsKline" :cycle-type="selectedCycleType" style="height:70%;" v-else />
     <!-- <div ref="scrollEl" style="height:300px;overflow-y:auto;">

+ 4 - 4
src/packages/pc/views/market/quote/index.vue

@@ -6,7 +6,7 @@
       @row-click="rowClickExpand" @row-contextmenu="rowContextmenu">
       <!-- 展开行 -->
       <template #expand="{ row }">
-        <app-button-group :data="handleButton(row)" @click="openComponent" />
+        <app-button-group :data-list="handleButton(row)" @click="openComponent" />
       </template>
     </app-table>
     <el-button @click="socket.connectTrade()">连接交易服务</el-button>
@@ -16,9 +16,9 @@
       <app-tab-component :options="{ selectedRow, code: 'quote' }" />
     </template>
     <!-- 右键菜单 -->
-    <app-contextmenu :data-source="handleButton(selectedRow)" @click="openComponent" />
+    <app-contextmenu :data-list="handleButton(selectedRow)" @click="openComponent" />
     <!-- 弹窗组件 -->
-    <component :is="components[componentId]" :selected-row="selectedRow" @closed="closeComponent" v-if="componentId" />
+    <component :is="components[componentId]" v-bind="{ selectedRow }" @closed="closeComponent" v-if="componentId" />
   </app-view>
 </template>
 
@@ -76,7 +76,7 @@ const handleButton = (item?: Ermcp.Goods) => {
   }
 }
 
-const subscribe = addSubscribe(['pp2205', 'pp2206', 'b2205', 'b2206']);
+const subscribe = addSubscribe(['cu2206', 'cu2207', 'cu2208', 'cu2209', 'cu2301', 'cu2303', 'cu2304']);
 
 queryGoodsList({
   success: (res) => {

+ 4 - 4
src/services/api/account/index.ts

@@ -7,26 +7,26 @@ import { TradeRequest } from '@/services/socket/trade/interface'
  * 用户登录
  */
 export function login(params: TradeRequest<Proto.LoginReq, Proto.LoginRsp>) {
-    return tradeServerRequest(params, 'LoginReq', 'LoginRsp');
+    return tradeServerRequest('LoginReq', 'LoginRsp', params);
 }
 
 /**
  * 查询账户菜单
  */
-export function queryAccountMenu(params: HttpRequest<unknown, Ermcp.AccountMenu[]>) {
+export function queryAccountMenu(params: HttpRequest<{ rsp: Ermcp.AccountMenu[] }>) {
     return httpRequest('/account/menu', 'get', params);
 }
 
 /**
  * 查询登录ID
  */
-export function queryLoginId(params: HttpRequest<{ username: string }, string>) {
+export function queryLoginId(params: HttpRequest<{ req: { username: string }, rsp: string }>) {
     return httpRequest('/User/GetLoginID', 'get', params);
 }
 
 /**
  * 查询资金账户信息
  */
-export function queryTaAccounts(params: HttpRequest<Ermcp.TaAccountsReq, Ermcp.TaAccountsRsp[]>) {
+export function queryTaAccounts(params: HttpRequest<{ req: Ermcp.TaAccountsReq, rsp: Ermcp.TaAccountsRsp[] }>) {
     return httpRequest('/TaAccount/GetTaAccounts', 'get', params);
 }

+ 1 - 1
src/services/api/goods/index.ts

@@ -4,6 +4,6 @@ import { HttpRequest } from '@/services/http/interface'
 /**
  * 商品列表
  */
-export function queryGoodsList(params: HttpRequest<unknown, Ermcp.Goods[]>) {
+export function queryGoodsList(params: HttpRequest<{ rsp: Ermcp.Goods[] }>) {
     return httpRequest('/goods', 'get', params);
 }

+ 2 - 2
src/services/api/quote/index.ts

@@ -4,13 +4,13 @@ import { HttpRequest } from '@/services/http/interface'
 /**
  * 历史行情
  */
-export function queryHistoryDatas(params: HttpRequest<{ goodscode?: string }, Ermcp.QueryHistoryDatasRsp[]>) {
+export function queryHistoryDatas(params: HttpRequest<{ req: { goodscode?: string }, rsp: Ermcp.QueryHistoryDatasRsp[] }>) {
     return httpRequest('/Quote/QueryHistoryDatas', 'get', params);
 }
 
 /**
  * 历史行情
  */
-export function queryTSData(params: HttpRequest<{ goodscode?: string }, Ermcp.QueryTSDataRsp>) {
+export function queryTSData(params: HttpRequest<{ req: { goodscode?: string }, rsp: Ermcp.QueryTSDataRsp }>) {
     return httpRequest('/Quote/QueryTSData', 'get', params);
 }

+ 3 - 3
src/services/http/index.ts

@@ -60,7 +60,7 @@ http.interceptors.response.use(
 /**
  * Http请求
  */
-export async function httpRequest<T, R>(url: string, method: Method, params: HttpRequest<T, R>) {
+export async function httpRequest<T extends { req?: unknown, rsp?: unknown }>(url: string, method: Method, params: HttpRequest<T>) {
     const { success, fail, complete } = params;
     //const { goCommonSearchUrl } = service.config;
 
@@ -76,7 +76,7 @@ export async function httpRequest<T, R>(url: string, method: Method, params: Htt
     }
 
     await http(requestConfig).then((res) => {
-        const data = res.data as HttpResponse<R>;
+        const data = res.data as HttpResponse<T['rsp']>;
         switch (data.code) {
             case ResultCode.InvalidToken:
                 //退出登录
@@ -86,7 +86,7 @@ export async function httpRequest<T, R>(url: string, method: Method, params: Htt
                 return Promise.reject('令牌无效');
             case ResultCode.Success:
                 success && success(data);
-                break;
+                return Promise.resolve();
             default:
                 return Promise.reject(data.msg);
         }

+ 4 - 4
src/services/http/interface.ts

@@ -1,9 +1,9 @@
 /**
  * Http请求参数
  */
-export interface HttpRequest<Req = unknown, Rsp = unknown> {
-    data?: Req;
-    success?: (res: HttpResponse<Rsp>) => void;
+export interface HttpRequest<T extends { req?: unknown, rsp?: unknown } = object> {
+    data?: T['req'];
+    success?: (res: HttpResponse<T['rsp']>) => void;
     fail?: (err: string) => void;
     complete?: () => void;
 }
@@ -15,7 +15,7 @@ export interface HttpResponse<T> {
     code: ResultCode;
     msg: string;
     total: number;
-    data: T
+    data: T;
 }
 
 /**

+ 2 - 2
src/services/index.ts

@@ -52,10 +52,10 @@ export default new (class {
             this.appConfig.then((res) => {
                 const { apiUrl } = res.data;
                 // 获取服务接口地址
-                httpRequest<unknown, typeof this.config>(apiUrl, 'get', {
+                httpRequest(apiUrl, 'get', {
                     success: (res) => {
                         console.log('服务配置信息', res.data);
-                        this.config = res.data;
+                        this.config = res.data as typeof this.config;
                         this.isReady = true;
                         resolve();
 

+ 4 - 4
src/services/socket/trade/index.ts

@@ -31,7 +31,7 @@ function getProtoHeader(funCode: keyof typeof FunCode, header?: IMessageHead, ma
  * @param rspCode 回调代码
  * @param marketId 市场ID
  */
-function tradeServerMiddleware<Req, Rsp>(params: TradeRequest<Req, Rsp>, reqCode: keyof typeof FunCode, rspCode: keyof typeof FunCode, marketId?: number): Promise<Rsp> {
+function tradeServerMiddleware<Req, Rsp>(reqCode: keyof typeof FunCode, rspCode: keyof typeof FunCode, params: TradeRequest<Req, Rsp>, marketId?: number): Promise<Rsp> {
     params.data.Header = getProtoHeader(reqCode, params.data.Header, marketId);
     console.log(reqCode, FunCode[reqCode], params.data);
 
@@ -75,16 +75,16 @@ function tradeServerMiddleware<Req, Rsp>(params: TradeRequest<Req, Rsp>, reqCode
  * @param rspCode 
  * @param marketId 
  */
-export async function tradeServerRequest<Req, Rsp>(params: TradeRequest<Req, Rsp & TradeResponse>, reqCode: keyof typeof FunCode, rspCode: keyof typeof FunCode, marketId?: number) {
+export async function tradeServerRequest<Req, Rsp>(reqCode: keyof typeof FunCode, rspCode: keyof typeof FunCode, params: TradeRequest<Req, Rsp & TradeResponse>, marketId?: number) {
     const { success, fail, complete } = params;
 
-    await tradeServerMiddleware(params, reqCode, rspCode, marketId).then((res) => {
+    await tradeServerMiddleware(reqCode, rspCode, params, marketId).then((res) => {
         const { RetCode, RetDesc } = res;
 
         switch (RetCode) {
             case 0: {
                 success && success(res);
-                break;
+                return Promise.resolve();
             }
             case -1: {
                 // 管理端错误消息