wangjunchen 3 years ago
parent
commit
d2c30cefe9

+ 60 - 5
contract/contract.js

@@ -11,8 +11,12 @@ if (typeof web3 !== 'undefined') {
 	)
 }
 
-let Address = '0x0951e53F11D68a9F6Ce62Fb45e46656Bc344AF4a'
-let USDTAddress = '0x55d398326f99059fF775485246999027B3197955'
+let Address = '0xBbFF78Ca4B69b71eef5BA3c6435849B7db1f9fF9'  // 正式
+let USDTAddress = '0x55d398326f99059fF775485246999027B3197955' // 正式
+
+// let Address = '0xB036E4BEc0EA7d3BE740f2AFe2Ae383D8d961939'
+// let USDTAddress = '0x696d5527e49a35396B10dD3A97a93ec0dd2F0687'
+
 
 let abi = [
    {
@@ -28,6 +32,12 @@ let abi = [
       "internalType": "uint256",
       "name": "amount",
       "type": "uint256"
+     },
+     {
+      "indexed": false,
+      "internalType": "uint256",
+      "name": "orderId",
+      "type": "uint256"
      }
     ],
     "name": "BuyAndOpenEvent",
@@ -121,6 +131,35 @@ let abi = [
     "stateMutability": "nonpayable",
     "type": "function"
    },
+   {
+    "inputs": [
+     {
+      "internalType": "uint256",
+      "name": "orderId",
+      "type": "uint256"
+     },
+     {
+      "internalType": "uint256",
+      "name": "amount",
+      "type": "uint256"
+     },
+     {
+      "internalType": "address",
+      "name": "_addr",
+      "type": "address"
+     }
+    ],
+    "name": "getOpenOrder",
+    "outputs": [
+     {
+      "internalType": "uint256",
+      "name": "",
+      "type": "uint256"
+     }
+    ],
+    "stateMutability": "view",
+    "type": "function"
+   },
    {
     "inputs": [],
     "name": "getUserCode",
@@ -134,6 +173,24 @@ let abi = [
     "stateMutability": "view",
     "type": "function"
    },
+   {
+    "inputs": [
+     {
+      "internalType": "address",
+      "name": "_addr",
+      "type": "address"
+     },
+     {
+      "internalType": "uint256",
+      "name": "amount",
+      "type": "uint256"
+     }
+    ],
+    "name": "giveRewards",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+   },
    {
     "inputs": [],
     "name": "owner",
@@ -193,9 +250,7 @@ let abi = [
     "stateMutability": "nonpayable",
     "type": "function"
    }
-  ]
-
-
+]
 const erc20Abi = [
   {
     inputs: [],

+ 1 - 1
langs/English.js

@@ -10,7 +10,7 @@ export default {
 	index0007: 'Open successfully',
 	index0008: 'Synthetic',
 	index0009: 'Authorization',
-	index0010: 'Login',
+	index0010: 'bind',
 	
 	indexMSG0004: 'The user has not authorized the requested account',
 	indexMSG0001: 'Authorization successful',

+ 1 - 1
langs/Japanese.js

@@ -9,7 +9,7 @@ export default {
 	index0007: '正常に開きました',
 	index0008: '合成',
 	index0009: '認可',
-	index0010: 'ログイン',
+	index0010: '練る',
 	
 	indexMSG0004: 'ユーザーは要求されたアカウントを承認していません',
 	indexMSG0001: '認証成功',

+ 1 - 1
langs/Korean.js

@@ -9,7 +9,7 @@ export default {
 	index0007: '성공적으로 열었습니다',
 	index0008: '합성',
 	index0009: '권한 부여',
-	index0010: '로그인',
+	index0010: '묶다',
 	
 	indexMSG0004: '사용자가 요청한 계정을 승인하지 않았습니다.',
 	indexMSG0001: '승인 성공',

+ 1 - 1
langs/TraditionalChinese.js

@@ -9,7 +9,7 @@ export default {
 	index0007: '開啟成功',
 	index0008: '合成',
 	index0009: '授權',
-	index0010: '登錄',
+	index0010: '綁定',
 
 	indexMSG0004: '用戶尚未授權所請求的帳戶',
 	indexMSG0001: '授權成功',

+ 2 - 2
main.js

@@ -11,15 +11,15 @@ App.mpType = 'app'
 
 Vue.prototype.$Request = request; //接口
 Vue.prototype.$Service = service;
-Vue.prototype.$httpsUrl = 'https://api.nft.bony.plus/api'  // api地址
+Vue.prototype.$httpsUrl = 'https://api.nft.bony.plus/api'  // 正式api地址
 // Vue.prototype.$httpsUrl = 'http://bony.taitr.cn/api'  // api地址
 
 
 Vue.prototype.$Url = 'https://nft.bony.plus/#/' // 邀请好友
 // const vconsole = require('vconsole')
 // new vconsole()
+Vue.prototype.$qkl = 'https://bsc-dataseed.binance.org/' // 正式api地址以太网   
 // Vue.prototype.$qkl = 'https://data-seed-prebsc-1-s1.binance.org:8545/' // 以太网     
-Vue.prototype.$qkl = 'https://bsc-dataseed.binance.org/' // 以太网   
 
 
 

+ 4 - 1
manifest.json

@@ -68,5 +68,8 @@
     "uniStatistics" : {
         "enable" : false
     },
-    "vueVersion" : "2"
+    "vueVersion" : "2",
+    "h5" : {
+        "title" : "BONY"
+    }
 }

+ 2 - 1
pages.json

@@ -59,8 +59,9 @@
         }
     ],
 	"globalStyle": {
+		// "navigationStyle":"custom",
 		"navigationBarTextStyle": "black",
-		"navigationBarTitleText": "uni-app",
+		"navigationBarTitleText": "BONY",
 		"navigationBarBackgroundColor": "#F8F8F8",
 		"backgroundColor": "#F8F8F8"
 	},

+ 39 - 2
pages/airdrop/airdrop.vue

@@ -156,6 +156,19 @@
 <script>
 	import toptabs from '@/components/toptabs/toptabs.vue'
 	import MoreNavigationBars from '@/components/MoreNavigationBars/MoreNavigationBars.vue'
+	import contractmethod from '@/contract/contractmethod.js'
+	import contracts from '@/contract/contract.js'
+	import Tdialog from '@/components/Tdialog.vue'
+	import Web3 from '@/utils/web3.min'
+	if (typeof web3 !== 'undefined') {
+		web3 = new Web3(web3.currentProvider)
+	} else {
+		web3 = new Web3(
+			new Web3.providers.HttpProvider(
+				this.$qkl
+			)
+		)
+	}
 	export default {
 		components:{
 			toptabs,
@@ -257,10 +270,34 @@
 					console.log('res', res);
 					this.weight = res.weight
 				})
+			},async getUserCode() {
+				contracts.contract.methods
+					.getUserCode()
+					.call({
+						from: this.$store.state.address
+					}, (err, res) => {
+						if (res) {
+								this.$store.commit('changeuser', res)
+							console.log('res', res);
+							this.$Service.send('/user/login', {
+								username: this.$store.state.address,
+								code: res,
+							}, (res) => {
+								console.log(1);
+								this.$store.commit('changetoken', res.userinfo.token)
+								this.gameList()
+								this.getgameInfo()
+							})
+						}
+
+					})
 			},
 		},onLoad() {
-			this.gameList()
-			this.getgameInfo()
+			this.getUserCode()
+		},onShow() {
+			setTimeout(()=>{
+				this.getUserCode()
+			},1000)
 		}
 	}
 </script>

+ 18 - 8
pages/index/index.vue

@@ -194,7 +194,7 @@
 			},
 			getgameInfo() {
 				this.$Service.send('/game/info', {}, (res) => {
-					console.log('res', res);
+					console.log('res123123', res);
 					this.buyprice = res.buyprice * 1
 					this.ucard = res.ucard
 					this.tcard = res.tcard
@@ -239,11 +239,11 @@
 									from: this.$store.state.address
 									// gasPrice: gasPrice
 								}).on('receipt', (res, err) => {
+										console.log('res1', res,err);
 									if (res) {
-										console.log('res1', res);
 										this.$Service.send('/game/recharge', {
 											hash: res.transactionHash,
-											amount: this.boxNumber
+											amount: index,
 										}, (res) => {
 											// console.log(res);
 											this.likai()
@@ -387,7 +387,6 @@
 					})
 			},
 			async getUserCode() {
-				console.log('1114');
 				contracts.contract.methods
 					.getUserCode()
 					.call({
@@ -400,9 +399,17 @@
 								username: this.$store.state.address,
 								code: this.$store.state.user,
 							}, (res) => {
+								console.log('res123',res);
+								console.log(this.$store.state.yqcode);
 								this.$store.commit('changetoken', res.userinfo.token)
 								this.getgameInfo()
 								this.ViewAuthorization()
+								if(res.recommend_id === 0 && this.$store.state.yqcode !== '') {
+									uni.redirectTo({
+										url: '/pages/bind/bind' + '?code=' +this.$store.state.yqcode
+									});
+								}
+								
 							})
 						}
 
@@ -422,12 +429,13 @@
 					.call({
 						from: this.$store.state.address
 					}, (res, err) => {
-						console.log('res', res);
+						// console.log('res', res);
 						console.log('err', err);
-						if (err > 0) {
-							this.state = 2
-						} else {
+						let data = web3.utils.fromWei(err) 
+						if (data < 10) {
 							this.state = 1
+						} else {
+							this.state = 2
 						}
 					})
 			},
@@ -453,6 +461,7 @@
 			}
 		},
 		 onShow() {
+			 this.$store.commit('changetoken', '')
 				setTimeout(async()=>{
 					await this.getUserCode()
 				},1000)
@@ -465,6 +474,7 @@
 			} else {
 				this.$store.commit('changeyqcode', '')
 				this.state = 0
+				await this.getUserCode()
 				await this.getgameInfo()
 
 

+ 65 - 33
pages/synthesis/synthesis.vue

@@ -190,6 +190,7 @@
 				uni.hideLoading()
 			},
 			getgameInfo() {
+				console.log('111111');
 				this.$Service.send('/game/info', {}, (res) => {
 					console.log('res', res);
 					this.ucard = res.ucard
@@ -202,47 +203,78 @@
 				let res = this.ucard<this.tcard ? this.ucard : this.tcard
 				this.allNumber = Math.floor(res / this.synthesisNumber )
 				console.log(this.allNumber);
-			},changesynthesisquantity(){
+			},
+			changesynthesisquantity(){
 				this.synthesisquantity = this.allNumber
-			},syntheticUsdt(){
-				this.Tdialog = true
+			},
+			syntheticUsdt(){
+				this.$Service.send('/game/issynthesis', {
+					amount:this.synthesisquantity
+				}, (res) => {
+					this.Tdialog = true
+					contracts.contract.methods
+						.syntheticUsdt(this.synthesisquantity)
+						.send({
+							from: this.$store.state.address
+						})
+						.on('receipt', async res => {
+							console.log(res);
+							this.likai()
+							this.$Service.send('/game/synthesis', {
+								amount:this.synthesisquantity
+							}, (res) => {
+								console.log('res', res);
+								
+								this.synthesis = false
+								this.Insynthesis= true
+								this.getgameInfo()
+								setTimeout(()=>{
+									this.opensuccess()
+								},3000)
+							})
+							
+						})
+						.on('error', error => {
+							this.likai()
+							console.log(error)
+							if(error.message == 'The requested account and/or method has not been authorized by the user.') {
+								uni.showToast({
+									title: this.$t('indexMSG0004'),
+									icon: 'none',
+									duration: 2000
+								});
+							}
+						})
+				})
+			},async getUserCode() {
 				contracts.contract.methods
-					.syntheticUsdt(this.synthesisquantity)
-					.send({
+					.getUserCode()
+					.call({
 						from: this.$store.state.address
-					})
-					.on('receipt', async res => {
-						console.log(res);
-						this.likai()
-						this.$Service.send('/game/synthesis', {
-							amount:this.synthesisquantity
-						}, (res) => {
+					}, (err, res) => {
+						if (res) {
+								this.$store.commit('changeuser', res)
 							console.log('res', res);
-							
-							this.synthesis = false
-							this.Insynthesis= true
-							this.getgameInfo()
-							setTimeout(()=>{
-								this.opensuccess()
-							},3000)
-						})
-						
-					})
-					.on('error', error => {
-						this.likai()
-						console.log(error)
-						if(error.message == 'The requested account and/or method has not been authorized by the user.') {
-							uni.showToast({
-								title: this.$t('indexMSG0004'),
-								icon: 'none',
-								duration: 2000
-							});
+							this.$Service.send('/user/login', {
+								username: this.$store.state.address,
+								code: res,
+							}, (res) => {
+								console.log(1);
+								this.$store.commit('changetoken', res.userinfo.token)
+								this.getgameInfo()
+							})
 						}
+
 					})
-			}
+			},
 		},
 		onLoad() {
-			this.getgameInfo()
+			this.getUserCode()
+		},
+		onShow() {
+			setTimeout(()=>{
+				this.getUserCode()
+			},1000)
 		}
 	}
 </script>

+ 1 - 1
utils/service.js

@@ -29,7 +29,7 @@ export default{
 					}
 				
 					
-					if(res.code == 10003) {
+					if(res.code == 10003 || res.code == 10001 || res.code == 10005 || res.code == 10007) {
 						return false
 					}else {
 						error = res.code