From 0d29d9a2bf0d893a67f1263bb9525131a50a2128 Mon Sep 17 00:00:00 2001
From: jhzh <1628036192@qq.com>
Date: Sat, 23 Mar 2024 11:12:55 +0800
Subject: [PATCH] 首次提交大宝wap

---
 src/page/trading/buy.vue |  224 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 117 insertions(+), 107 deletions(-)

diff --git a/src/page/trading/buy.vue b/src/page/trading/buy.vue
index 5b408fe..7d74fe9 100644
--- a/src/page/trading/buy.vue
+++ b/src/page/trading/buy.vue
@@ -59,7 +59,6 @@
             <div class="right_sw flexJy" style="width:auto;">
               <div class="addorj" @click="gdJian">
 
-
                 <img src="@/assets/img/ic_number_jian.png" alt />
               </div>
               <div class="addorj"></div>
@@ -74,7 +73,7 @@
           </div>
           <div class="tr_es flexJy">
             <div class="top_input">
-              <input type="number" onkeyup="value=value.replace(/[^\d]/g,'')" v-model="num">
+              <input type="number" onkeyup="value=value.replace(/[^\d]/g,'')"  v-model="num">
             </div>
             <div class="right_sw flexJy" style="width:auto;">
               <div class="addorj" @click="jyslJian">
@@ -98,25 +97,27 @@
               </div> -->
           </div>
           <div class="tr_rs">
-            <div class="top_bzz">
-              <span>{{ if_us == 1 ? $t('hj102') + '($)' : if_us == '2' ? $t('hj102') + '(HK$)' : $t('hj102') + '(¥)'
+            <div class="top_bzz" style="padding-bottom: 0.2rem;">
+              <span style="text-align: left;">{{ if_us == 1 ? $t('hj102') + '($)' : if_us == '2' ? $t('hj102') + '(HK$)' : $t('hj102') + '(₹)'
               }}</span>
-              <span>{{ if_us == 1 ? $t('hj103') + '($)' : if_us == '2' ? $t('hj103') + '(HK$)' : $t('hj103') + '(¥)'
+              <span style="text-align: right;">{{ if_us == 1 ? $t('hj103') + '($)' : if_us == '2' ? $t('hj103') + '(HK$)' : $t('hj103') + '(₹)'
               }}</span>
             </div>
+
             <div class="bottom_bzz">
               <!-- <span>{{ (nowPrice/ selectCycle).toFixed(2) }}</span> -->
-              <span>{{ (nowPrice / selectCycle * 100).toFixed(2) }}</span>
-              <span v-if="$store.state.userInfo.userAmt == undefined">¥0.00</span>
-              <span v-if="$store.state.userInfo && type != '0'" style="white-space: nowarp;">
+              <span>{{ (nowPrice / selectCycle * num).toFixed(2) }}</span>
+              <!-- <span>{{ (nowPrice / selectCycle * num * 100).toFixed(2) }}</span> -->
+              <span v-if="$store.state.userInfo.userAmt == undefined">₹0.00</span>
+              <span v-if="$store.state.userInfo.userIndexAmt != undefined && type != '0'" style="white-space: nowarp;">
                 {{ if_us == 1 ? '$' + (Number($store.state.userInfo.userIndexAmt) / 7.1).toFixed(2) : if_us == '2' ?
                     'HK$' +
-                    Number($store.state.userInfo.userIndexAmt / 0.9).toFixed(2) : '¥' + $store.state.userInfo.userIndexAmt
+                    Number($store.state.userInfo.userIndexAmt / 0.9).toFixed(2) : '₹' + $store.state.userInfo.userIndexAmt
                 }}
               </span>
               <span v-if="$store.state.userInfo.userAmt != undefined && type == '0'" style="white-space: nowarp;">
                 {{ if_us == 1 ? '$' + (Number($store.state.userInfo.userAmt) / 7.1).toFixed(2) : if_us == '2' ? 'HK$' +
-                    Number($store.state.userInfo.userAmt / 0.9).toFixed(2) : '¥ ' + $store.state.userInfo.userAmt
+                    Number($store.state.userInfo.userAmt / 0.9).toFixed(2) : '₹ ' + $store.state.userInfo.userAmt
                 }}
               </span>
             </div>
@@ -190,13 +191,13 @@
 </template>
 
 <script>
-import * as api from "@/axios/api";
-import {
-  Toast
-} from "mint-ui";
+import * as api from '@/axios/api'
+// import {
+//   Toast
+// } from 'mint-ui'
 export default {
   name: 'trBuy',
-  created() {
+  created () {
     if (this.$route.query.t) {
       this.tabsCurrentIndex = Number(this.$route.query.t)
       console.log(this.tabsCurrentIndex)
@@ -206,6 +207,9 @@
       this.profitTarget = Number(this.$route.query.m)
       this.zhisun = Number(this.$route.query.m)
       this.nums = Number(this.$route.query.m)
+    }
+    if (this.$route.query.id) {
+      this.id = this.$route.query.id
     }
     if (this.$route.query.code) {
       this.code = this.$route.query.code
@@ -220,7 +224,7 @@
       this.if_us = this.$route.query.if_us
     }
   },
-  data() {
+  data () {
     return {
       tradingArr: [this.$t('hj84'), this.$t('hj85')],
       tabsCurrentIndex: 0,
@@ -243,10 +247,12 @@
       showGg: false,
       profitTarget: 0,
       if_us: 0,
+      bayType: '',
+      id: '',
       actions: [
         { name: '100X', subname: this.$t('hj102') },
         { name: '200X', subname: this.$t('hj102') },
-        { name: '300X', subname: this.$t('hj102') },
+        { name: '300X', subname: this.$t('hj102') }
       ],
       profitArr: [
         {
@@ -262,42 +268,49 @@
           checked: false
         }
       ]
+
     }
   },
-  mounted() {
-    this.getUserInfo();
-    this.getSettingInfo();
+  mounted () {
+    this.getUserInfo()
+    this.getSettingInfo()
+    this.bayType = this.$route.query.bayType
+    if (this.bayType == 'in') {
+      this.priceTabs = [this.$t('hj108'), this.$t('hj109')]
+    } else if (this.bayType == 'qh') {
+      this.priceTabs = [this.$t('hj108')]
+    }
   },
   watch: {
-    checkedZy(val) {
+    checkedZy (val) {
       if (navigator.vibrate) {
         // 支持
-        navigator.vibrate([55]);
+        navigator.vibrate([55])
       }
     },
-    checkedZs(val) {
+    checkedZs (val) {
       if (navigator.vibrate) {
         // 支持
-        navigator.vibrate([55]);
+        navigator.vibrate([55])
       }
     }
   },
   methods: {
-    handleBack() {
-      this.$router.go(-1);
+    handleBack () {
+      this.$router.go(-1)
     },
-    handleTradingClick(index) {
-      this.tabsCurrentIndex = index;
+    handleTradingClick (index) {
+      this.tabsCurrentIndex = index
     },
-    handleTabsClick(item, index) {
-      this.priceTabsCurrentIndex = index;
+    handleTabsClick (item, index) {
+      this.priceTabsCurrentIndex = index
     },
-    jyslJian() {
-      if (typeof this.num == 'string') {
+    jyslJian () {
+      if (typeof this.num === 'string') {
         this.num = 1
       } else {
         if (this.num > 1) {
-          if (typeof this.num == 'string') {
+          if (typeof this.num === 'string') {
             this.num = Number((this.num) - 1)
           } else {
             this.num = Number((this.num) - 1)
@@ -307,10 +320,9 @@
         }
       }
     },
-    gdJian() {
-
+    gdJian () {
       if (this.nums > 1) {
-        if (typeof this.nums == 'string') {
+        if (typeof this.nums === 'string') {
           this.nums = Number(Number(this.nums) - 1).toFixed(2)
         } else {
           this.nums = Number(Number(this.nums) - 1).toFixed(2)
@@ -318,35 +330,32 @@
       } else {
         this.nums = this.nowPrice
       }
-
     },
-    zYjian() {
+    zYjian () {
       if ((Number(this.profitTarget) - 1).toFixed(2) < this.nowPrice) {
         this.profitTarget = this.nowPrice
       } else {
         this.profitTarget = (Number(this.profitTarget) - 1).toFixed(2)
       }
-
     },
-    zSjia() {
+    zSjia () {
       if ((Number(this.zhisun) + 1).toFixed(2) > this.nowPrice) {
         this.zhisun = this.nowPrice
       } else {
         this.zhisun++
       }
     },
-    zsInt(e) {
-      if (typeof e.target.value == 'string') {
+    zsInt (e) {
+      if (typeof e.target.value === 'string') {
         this.zhisun = this.nowPrice
       } else {
         if (Number(e.target.value) > this.nowPrice) {
           this.zhisun = this.nowPrice
         }
       }
-
     },
-    zyInt(e) {
-      if (typeof e.target.value == 'string') {
+    zyInt (e) {
+      if (typeof e.target.value === 'string') {
         this.profitTarget = this.nowPrice
       } else {
         if (Number(e.target.value) < Number(this.nowPrice)) {
@@ -354,11 +363,10 @@
         }
       }
     },
-    onSelect(val) {
+    onSelect (val) {
       this.selectCycle = val.gg
-
     },
-    gdOrSetBuy() {
+    gdOrSetBuy () {
       if (this.priceTabsCurrentIndex == 0) {
         this.setBuy()
       } else {
@@ -366,20 +374,20 @@
       }
       if (navigator.vibrate) {
         // 支持
-        navigator.vibrate([55]);
+        navigator.vibrate([55])
       }
     },
-    //挂单
-    async gdBuy() {
+    // 挂单
+    async gdBuy () {
       if (this.buying) {
-        return;
+        return
       }
       this.buying = true
       let opts = {
         stockId: this.code,
-        buyNum: this.num * 100,
+        buyNum: this.num,
         lever: this.selectCycle ? this.selectCycle : 0,
-        targetPrice: this.nums,
+        targetPrice: this.nums
       }
       if (this.tabsCurrentIndex == 0) {
         opts.buyType = 1
@@ -387,7 +395,7 @@
         opts.buyType = 0
       }
       if (this.checkedZy) {
-        //opts.profitTarget = this.profitTarget.substring(0,this.profitTarget.indexOf(".")+3)
+        // opts.profitTarget = this.profitTarget.substring(0,this.profitTarget.indexOf(".")+3)
         opts.profitTarget = this.profitTarget
       }
       if (this.checkedZs) {
@@ -396,18 +404,18 @@
       let data = await api.guadan(opts)
       this.buying = false
       if (data.status === 0) {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg, 'elAlertType': 'success' });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg, 'elAlertType': 'success' })
         this.getUserInfo()
         this.$router.push('/warehouse?index=1')
       } else {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg })
       }
     },
-    //买卖
-    setBuy() {
+    // 买卖
+    setBuy () {
       if (!this.$store.state.userInfo.idCard) {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': this.$t('hj111') });
-        this.$router.push('/authentication')
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': this.$t('hj111') })
+        this.$router.push('/authentications')
         return
       }
       // if (!this.agree) {
@@ -420,7 +428,7 @@
       //   Toast('请选择子账户')
       // } else {}
       if (this.buying) {
-        return;
+        return
       }
       this.buying = true
       let opts = {}
@@ -431,10 +439,10 @@
         // lever: this.selectCycle ? this.selectCycle : 0,
         // subaccountNumber:this.subaccountNumber
 
-        //买入是买涨buyType:0, 卖出是买跌buyType:1,卖出的状态是0,买入的状态是1
-        buyNum: this.num * 100, // 单位为手
-        //buyNum: (this.num.match(/\d+/g))[0] * 100, // 单位为手
-        lever: this.selectCycle ? this.selectCycle : 0,
+        // 买入是买涨buyType:0, 卖出是买跌buyType:1,卖出的状态是0,买入的状态是1
+        buyNum: this.num, // 单位为手
+        // buyNum: (this.num.match(/\d+/g))[0] * 100, // 单位为手
+        lever: this.selectCycle ? this.selectCycle : 0
       }
       if (this.tabsCurrentIndex == 0) {
         opts.buyType = 1
@@ -442,79 +450,75 @@
         opts.buyType = 0
       }
       if (this.checkedZy) {
-        //opts.profitTarget = this.profitTarget.substring(0,this.profitTarget.indexOf(".")+3)
+        // opts.profitTarget = this.profitTarget.substring(0,this.profitTarget.indexOf(".")+3)
         opts.profitTarget = this.profitTarget
       }
       if (this.checkedZs) {
         opts.stopLoss = this.zhisun
       }
       if (this.type == 0) {
-        //股票
+        // 股票
         this.gpBuy(opts)
         //   opts.stockId= this.code,
-        //  data = await api.buy(opts)  
+        //  data = await api.buy(opts)
       } else {
-        //指数
+        // 指数
         this.zsBuy(opts)
         //   opts.indexId= this.code,
         //  data = await api.indexBuy(opts)
       }
-
-
     },
-    //股票买入
-    async gpBuy(opts) {
-      opts.stockId = this.code
+    // 股票买入
+    async gpBuy (opts) {
+      opts.stockId = this.id
       let data = await api.buy(opts)
       this.buying = false
       if (data.status === 0) {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg, 'elAlertType': 'success' });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg, 'elAlertType': 'success' })
         this.getUserInfo()
-        this.$router.push('/orderlist?index=2')
+        this.$router.push('/warehouse?index=0')
       } else {
         if (data.msg.indexOf('不在交易时段内') > -1) {
-          this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': this.$t('hj113') });
+          this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': this.$t('hj113') })
         } else {
-          this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg });
+          this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg })
         }
-
       }
     },
-    //指数买入
-    async zsBuy(opts) {
-      opts.indexId = this.type
+    // 指数买入
+    async zsBuy (opts) {
+      opts.indexId = this.id
       let data = await api.indexBuy(opts)
       this.buying = false
       if (data.status === 0) {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg, 'elAlertType': 'success' });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg, 'elAlertType': 'success' })
         this.getUserInfo()
-        this.$router.push('/orderlist?index=2')
+        this.$router.push('/warehouse?index=0')
       } else {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg })
       }
     },
-    async getUserInfo() {
+    async getUserInfo () {
       // 获取用户信息
       //   let showcookie = this.getCookie('USER_TOKEN');
-      let data = await api.getUserInfo();
+      let data = await api.getUserInfo()
       if (data.status === 0) {
         // this.getProductSetting()
-        this.$store.state.userInfo = data.data;
+        this.$store.state.userInfo = data.data
       } else {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg })
       }
-      this.$store.state.user = this.user;
+      this.$store.state.user = this.user
     },
-    async getSettingInfo() {
+    async getSettingInfo () {
       // 网站设置信息
       let data = await api.getSetting()
       if (data.status === 0) {
         // 成功
         this.settingInfo = data.data
         // 杠杆倍数
-        //data.data.siteLever根据/分割成数组
-        //this.siteLeverList = data.data.siteLever.split('/')
-
+        // data.data.siteLever根据/分割成数组
+        // this.siteLeverList = data.data.siteLever.split('/')
 
         this.selectCycle = data.data.siteLever
         if (this.$store.state.userInfo !== undefined && this.$store.state.userInfo !== null && this.$store.state.userInfo.phone !== '' && this.$store.state.userInfo.siteLever != null) {
@@ -529,29 +533,28 @@
           this.selectCycle = data.data.siteLever.split('/')[0]
           this.siteLeverList = []
           for (let i = 0; i < data.data.siteLever.split('/').length; i++) {
-
             let val = data.data.siteLever.split('/')[i]
             var ccet = (Number(this.nowPrice) / Number(val)).toFixed(2)
-            //let item = { label: val + '倍', value: val ,bzj:ccet}
+            // let item = { label: val + '倍', value: val ,bzj:ccet}
             let item = { name: val + 'X', subname: this.$t('hj102') + ':' + (ccet * 100).toFixed(2), gg: val, bzj: ccet }
             this.siteLeverList.push(item)
           }
         }
       } else {
-        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg });
+        this.$store.commit('elAlertShow', { 'elAlertShow': true, 'elAlertText': data.msg })
       }
-    },
+    }
   },
   filters: {
-    getName(name) {
+    getName (name) {
       if (name.length > 15) {
-        return name.substring(0, 14);
+        return name.substring(0, 14)
       } else {
-        return name;
+        return name
       }
     }
   }
-};
+}
 </script>
 
 <style scoped lang="less">
@@ -830,7 +833,7 @@
     border-bottom: 0.05rem solid rgb(236, 236, 236);
 
     >div {
-      width: 20%;
+      // width: 20%;
       height: 50%;
       display: flex;
       align-items: center;
@@ -847,10 +850,10 @@
   width: 100%;
   height: auto;
   background: #fff;
-  padding: .2rem .8rem;
+  padding: .8rem .8rem;
   display: flex;
   align-items: flex-end;
-  padding-top: 0.8rem;
+  // padding-top: 0.8rem;
 
   >div {
     width: 100%;
@@ -962,4 +965,11 @@
 
   }
 }
-</style>
\ No newline at end of file
+/deep/.van-overlay{
+  z-index: 10000!important;
+}
+
+/deep/.van-popup{
+  z-index: 10001!important;
+}
+</style>

--
Gitblit v1.9.3