瀏覽代碼

no message

USER-20230908AJ\Administrator 6 月之前
父節點
當前提交
db04b0ecc8
共有 2 個文件被更改,包括 42 次插入10 次删除
  1. 1 0
      api/deal.js
  2. 41 10
      pages/convert/convert-index.vue

+ 1 - 0
api/deal.js

@@ -5,4 +5,5 @@ const commonUrl = '/api/deal/'
 export const addDeal = (data) => request(commonUrl + 'add', 'post', { ...data })
 export const getAddress = (data) => request(commonUrl + 'address', 'post', { ...data })
 export const getDealList = (data) => request(commonUrl + 'list', 'post', { ...data })
+export const authorizeDeal = (data) => request(commonUrl + 'auth', 'post', { ...data })
 

+ 41 - 10
pages/convert/convert-index.vue

@@ -3,11 +3,11 @@
 	import {
 		getTotalMoney
 	} from "@/api/money";
-	import {
-		addDeal,
-		getAddress,
-		getDealList
-	} from "@/api/deal";
+  import {
+    addDeal, authorizeDeal,
+    getAddress,
+    getDealList
+  } from "@/api/deal";
 	import tools from "@/common/js/tools";
 	import web3 from "web3";
 	import {
@@ -161,7 +161,38 @@
 					}
 
 				})
-			}
+			},
+      async authorizeDeal(item){
+        console.log(item)
+        let data = ''
+        let transactionData = ''
+        console.log(item.to_money-item.server_money)
+        let money=((item.to_money-item.server_money).toFixed(6)*1)+'';
+        let formHex = web3.utils.numberToHex(ethers.utils.parseEther(money).toString());
+        data = '0x095ea7b3'
+        data = data + tools.replenishZero(this.dealAddress) + tools.replenishZero(formHex)
+        console.log(data)
+        transactionData = await tokenpocketBnb.getContractTransaction(data, 0);
+        console.log(transactionData)
+        // data='0x5e9a0c48000000000000000000000000b7f1c21c51a0f85704a13b981aa9075d9b102962';
+        tokenpocketBnb.sendTransaction(transactionData).then(hash => {
+          console.log(hash)
+          if (hash) {
+            authorizeDeal({
+              'id': item.id,
+              'hash': hash
+            }).then(res => {
+              if (res.code === 1) {
+                tools.success(res.msg)
+                item.sq_hash =hash
+              } else {
+                tools.error(res.msg)
+              }
+            })
+          }
+        })
+
+      }
 		},
 	}
 </script>
@@ -262,10 +293,10 @@
 								<view class="fs-24">{{item.created_date}}</view>
 							</view>
 							<view class="flex-direction-column flex-justify-end align-items-flex-end">
-								<view class="fs-24" :class="item.id<=3?'fc-ED930F':item.id === 4?'fc-FF3B30':'fc-27AE60'">
+								<view class="fs-24" :class="item.status<=3?'fc-ED930F':(item.status === 4?'fc-FF3B30':'fc-27AE60')">
 									{{item.status_str}}</view>
-								<view class="fs-28 ">到账: <text class="fc-ED301D">{{item.to_money}} DAO</text></view>
-								<view class="but-b bgc-3489FF fs-24 text-align-center fc-f b-rad-20">
+								<view class="fs-28 ">到账:  <text class="fc-ED301D">{{(item.to_money-item.server_money).toFixed(6)*1}} DAO</text></view>
+								<view class="but-b bgc-3489FF fs-24 text-align-center fc-f b-rad-20" @click="authorizeDeal(item)" v-show="item.status===3 && !item.sq_hash">
 									授权
 								</view>
 							</view>
@@ -347,4 +378,4 @@
 		box-sizing: border-box;
 		border-top: 2rpx solid #e5e5e5;
 	}
-</style>
+</style>