hwq 3 years ago
parent
commit
24ec21dca2
6 changed files with 270 additions and 72 deletions
  1. 10 1
      api/index.js
  2. 17 0
      api/money.js
  3. 1 1
      components/top/top.vue
  4. 125 41
      pages/index/share.vue
  5. 115 28
      pages/private/private.vue
  6. 2 1
      utils/rocessor.js

+ 10 - 1
api/index.js

@@ -34,4 +34,13 @@ export function group(data) {
 		method:'get',
 		data
 	})
-}
+}
+
+//推荐用户列表
+export function spreadList(data) {
+	return request({
+		url:'/api/user/spreadList',
+		method:'get',
+		data
+	})
+}

+ 17 - 0
api/money.js

@@ -70,4 +70,21 @@ export function extractUSDT(data) {
 		method: 'post',
 		data
 	});
+}
+
+// 购买XBH
+export function buyHXB(data) {
+	return request({
+		url: '/api/user/buyHXB',
+		method: 'post',
+		data
+	});
+}
+// 购买人数列表
+export function activityList(data) {
+	return request({
+		url: '/api/user/activityList',
+		method: 'get',
+		data
+	});
 }

+ 1 - 1
components/top/top.vue

@@ -132,7 +132,7 @@ export default {
 			if (accounts[0] == undefined) {
 				this.foxlogin();
 			} else {
-				console.log(accounts[0]);
+				console.log(accounts[0],"123456");
 				this.setAddress(accounts[0]);
 				this.changeAddress();
 				logins({ address: obj.address }).then(({ data }) => {

+ 125 - 41
pages/index/share.vue

@@ -6,10 +6,10 @@
 		<view class="center-wrap">
 			<image src="../../static/img/tj-bg.png" mode="" class="tj-bg"></image>
 			<view class="center-tit">邀请地址</view>
-			<view class="tj-jl flex" @click="opneYj">
+			<!-- <view class="tj-jl flex" @click="opneYj">
 				<text>业</text>
 				<text>绩</text>
-			</view>
+			</view> -->
 			<view class="tj-lj-tit">【链接地址】</view>
 			<view class="tj-lj flex">
 				<view class="lj-tit">邀请链接:</view>
@@ -20,11 +20,14 @@
 				<view class="lj-tit">绑定关系:</view>
 				<view class="lj-info clamp" v-if="!userInfo.spread"><input type="text" v-model="recommend" value="" /></view>
 				<view class="lj-info clamp" v-if="userInfo.spread">{{ userInfo.spread.address | addFile }}</view>
-				<view class="lj-copy" v-if="!userInfo.spread" @click="spare()">绑定推荐关系</view>
+				<view class="lj-copy" v-if="!userInfo.spread" @click="spare()">绑定关系</view>
 			</view>
 		</view>
-		<view class="tj-look" @click="button()">查看推荐</view>
-		<uni-popup ref="yeji" type="center">
+		<view class="bottom">
+			<image class="bottom-bg" src="../../static/img/bottom.png" mode=""></image>
+			<view class="btn" @click="button()">查看推荐</view>
+		</view>
+		<!-- <uni-popup ref="yeji" type="center">
 			<view class="yj-wrap">
 				<view class="yj-tit">收益明细</view>
 				<image src="../../static/img/yj-bg.png" mode="" class="yj-logo"></image>
@@ -61,7 +64,7 @@
 					</swiper>
 				</view>
 			</view>
-		</uni-popup>
+		</uni-popup> -->
 		<uni-popup ref="yeji1" type="center">
 			<view class="yj-wrap">
 				<view class="yj-tit">我的推荐</view>
@@ -71,21 +74,18 @@
 						<view class="">钱包地址</view>
 						<view class="">时间</view>
 					</view>
-					<swiper class="yj-info-scroll" :current="tabIndex" duration="300">
-						<swiper-item v-for="item in navList">
-							<scroll-view scroll-y="true" class="yj-info-scroll" @scrolltolower="loadMore">
-								<view v-for="itemt in item.list" class="">
-									<view class="flex yj-info">
-										<view class="">{{ itemt.time }}</view>
-										<view class="">{{ itemt.val }}</view>
-									</view>
-								</view>
-								<uni-load-more :status="item.loadingType"></uni-load-more>
-							</scroll-view>
-						</swiper-item>
-					</swiper>
+					<scroll-view scroll-y="true" class="yj-info-scroll" @scrolltolower="spreadList">
+						<view v-for="itemt in List" class="">
+							<view class="flex yj-info">
+								<view class="address clamp">{{ itemt.address }}</view>
+								<view class="time">{{ itemt.spread_time }}</view>
+							</view>
+						</view>
+						<uni-load-more :status="loadingType"></uni-load-more>
+					</scroll-view>
 				</view>
 			</view>
+			<view class="popup-x" @click="closeRecord()"><image src="../../static/img/x.png" mode=""></image></view>
 		</uni-popup>
 	</view>
 </template>
@@ -93,6 +93,8 @@
 <script>
 import top from '@/components/top/top.vue';
 import { mapState, mapMutations } from 'vuex';
+import { addSpread, spreadList } from '@/api/index.js';
+import { getTime } from '@/utils/rocessor.js';
 import uniCopy from '@/components/js_sdk/xb-copy/uni-copy.js';
 export default {
 	comments: {
@@ -104,7 +106,7 @@ export default {
 	filters: {
 		addFile(provider) {
 			if (provider.length >= 19) {
-				var subStr1 = provider.substr(0, 14);
+				var subStr1 = provider.substr(0, 13);
 				var subStr2 = provider.substr(provider.length - 6, 6);
 				var subStr = subStr1 + '...' + subStr2;
 				provider = subStr;
@@ -132,10 +134,41 @@ export default {
 					loadingType: 'more'
 				}
 			],
-			tabIndex: 0
+			List:[],
+			tabIndex: 0,
+			page: 1,
+			limit: 8,
+			loadingType: 'more'
 		};
 	},
+	onShow() {
+		this.spreadList();
+	},
 	methods: {
+		closeRecord() {
+			this.$refs.yeji1.close();
+		},
+		spreadList(){
+			let obj = this;
+			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
+				return;
+			}
+			spreadList({page:obj.page,limit:obj.limit}).then(({data}) =>{
+				data.data.list.forEach(e =>{
+					if(e.spread_time != null){
+						e.spread_time = getTime(e.spread_time)
+					}
+				})
+				this.List = this.List.concat(data.data.list);
+				if(data.data.list.length != obj.limit){
+					obj.loadingType = 'noMore'
+				}else {
+					obj.page++
+					obj.loadingType = 'more'
+				}
+			})
+			obj.loadingType = 'loading';
+		},
 		copy(value) {
 			let obj = this;
 			let content = value; //需要复制的内容
@@ -153,6 +186,31 @@ export default {
 				});
 			}
 		},
+		spare() {
+			const obj = this;
+			if (this.recommend == '') {
+				this.$api.msg('请填写要加入流量的地址');
+				return;
+			}
+
+			uni.showModal({
+				title: '提示',
+				content: '您是否要绑定到改流量(' + this.recommend + ')',
+				success: function(res) {
+					if (res.confirm) {
+						addSpread({ address: obj.recommend }).then(e => {
+							console.log(e, '123468');
+							if (e.code == 1) {
+								obj.$api.msg('绑定成功');
+								window.location.reload();
+							}
+						});
+					} else if (res.cancel) {
+						console.log('用户点击取消');
+					}
+				}
+			});
+		},
 		qrR() {},
 		opneYj() {
 			this.$refs.yeji.open();
@@ -285,7 +343,7 @@ page {
 		position: absolute;
 		top: 560rpx;
 	}
-	
+
 	.tj-lj1 {
 		width: 636rpx;
 		height: 67rpx;
@@ -298,7 +356,7 @@ page {
 		left: 0;
 		margin: auto;
 	}
-	
+
 	.tj-lj {
 		width: 636rpx;
 		height: 67rpx;
@@ -321,7 +379,7 @@ page {
 		color: #ffffff;
 		line-height: 67rpx;
 	}
-	
+
 	.lj-info {
 		width: 148rpx;
 		flex-grow: 1;
@@ -332,7 +390,7 @@ page {
 		color: #ffffff;
 		line-height: 67rpx;
 	}
-	
+
 	.lj-copy {
 		flex-shrink: 0;
 		width: 148rpx;
@@ -345,19 +403,36 @@ page {
 	}
 }
 
-.tj-look {
-	width: 450rpx;
-	height: 75rpx;
-	background: linear-gradient(0deg, #ff7206, #ffdd7e);
-	box-shadow: 0px 2rpx 8rpx 0px rgba(207, 126, 57, 0.7);
-	border-radius: 38rpx;
-	margin: 55rpx auto 0;
-	font-size: 36rpx;
-	font-family: zihun164hao-fangyuehei;
-	font-weight: bold;
-	color: #ffffff;
-	line-height: 75rpx;
-	text-align: center;
+.bottom {
+	padding-top: 182rpx;
+	position: relative;
+	width: 750rpx;
+	height: 434rpx;
+	margin-top: -118rpx;
+	.bottom-bg {
+		position: absolute;
+		top: 0;
+		left: 0;
+		right: 0;
+		height: 100%;
+		width: 100%;
+	}
+	.btn {
+		position: relative;
+		z-index: 3;
+		margin: 0 auto;
+		width: 450rpx;
+		height: 76rpx;
+		background: linear-gradient(0deg, #ff7206, #ffdd7e);
+		box-shadow: 0px 2px 8px 0px rgba(207, 126, 57, 0.7);
+		border-radius: 38rpx;
+		text-align: center;
+		line-height: 76rpx;
+		font-size: 36rpx;
+		font-family: zihun164hao-fangyuehei;
+		font-weight: 400;
+		color: #ffffff;
+	}
 }
 
 .yj-wrap {
@@ -452,18 +527,27 @@ page {
 	}
 
 	.yj-info-scroll {
-		// touch-action: none;
 		width: 582rpx;
 		height: 320rpx;
-
-		// background-color: red;
 		.yj-info {
 			font-size: 28rpx;
 			font-family: PingFang SC;
 			font-weight: bold;
 			color: #ffffff;
 			line-height: 38rpx;
+			.address {
+				width: 60%;
+			}
 		}
 	}
 }
+.popup-x {
+	margin: 62rpx auto 0;
+	width: 66rpx;
+	height: 66rpx;
+	image {
+		width: 100%;
+		height: 100%;
+	}
+}
 </style>

+ 115 - 28
pages/private/private.vue

@@ -10,7 +10,7 @@
 			<image class="main-bg" src="../../static/img/sm-bg.png" mode=""></image>
 			<view class="title">恒星私募</view>
 			<view class="font">私募单价</view>
-			<view class="num">0.5USDT</view>
+			<view class="num">{{ money }}{{ moneyType }}</view>
 			<view class="tip-title">【私募相关】</view>
 			<view class="tip">
 				恒星是一个集“元宇宙+NFT卡牌+DeFi+养成/经营/竞技”的加密链上游戏,是一款基于Solidity语言开发的去中心化GameFi应用,首发BSC链,基于银河系元宇宙原型,打造了一个集抽取盲盒开卡牌,NFT交易,LP质押获得收益的链上元宇宙游戏,
@@ -25,16 +25,19 @@
 			<view class="popup-record">
 				<view class="record-title">私募记录</view>
 				<view class="xian"><image src="../../static/img/xian.png" mode=""></image></view>
-				<view class="record-main-title flex">
-					<view class="item">认购金额</view>
-					<view class="item">认购数量</view>
-					<view class="item">认购时间</view>
-				</view>
-				<view class="record-main flex" v-for="(item, index) in 10">
-					<view class="item">0.5USDT</view>
-					<view class="item">1HXB</view>
-					<view class="item">2022.02.10</view>
-				</view>
+				<scroll-view scroll-y="true" class="yj-info-scroll" @scrolltolower="list">
+					<view class="record-main-title flex">
+						<view class="item">认购金额</view>
+						<view class="item">认购数量</view>
+						<view class="item">认购时间</view>
+					</view>
+					<view class="record-main flex" v-for="(item, index) in activity">
+						<view class="item">{{ item.number * 1 }}{{ item.token }}</view>
+						<view class="item">{{ item.get_num * 1 }}{{ item.get_token }}</view>
+						<view class="item">{{ item.createtime }}</view>
+					</view>
+					<uni-load-more :status="loadingType"></uni-load-more>
+				</scroll-view>
 			</view>
 			<view class="popup-x" @click="closeRecord()"><image src="../../static/img/x.png" mode=""></image></view>
 		</uni-popup>
@@ -46,7 +49,7 @@
 					<view class="shu"></view>
 					<view class="num-font">
 						私募单价:
-						<text>0.5USDT</text>
+						<text>{{ money }}{{ moneyType }}</text>
 					</view>
 				</view>
 				<view class="buy-num ren-num">
@@ -57,24 +60,18 @@
 					<input type="text" class="input" placeholder="请输入认购金额" placeholder-class="inputPlace" v-model="num" value="" />
 					<view class="unit">USDT</view>
 				</view>
-				<view class="buy-tip">可用</view>
+				<!-- <view class="buy-tip">可用</view> -->
 				<view class="buy-num ren-num">
 					<view class="shu"></view>
 					<view class="num-font">认购数量</view>
 				</view>
 				<view class="buy-input" style="padding-bottom: 18rpx;">
-					<view class="input" style="color: #08EDE7;">
-						0
-					</view>
+					<view class="input" style="color: #08EDE7;">{{ HXB }}</view>
 					<view class="unit">HXB</view>
 				</view>
 				<view class="btn-box">
-					<view class="btn-left" @click="close()">
-						取消
-					</view>
-					<view class="btn-right ">
-						购买
-					</view>
+					<view class="btn-left" @click="close()">取消</view>
+					<view class="btn-right " @click="buy()">购买</view>
 				</view>
 			</view>
 		</uni-popup>
@@ -84,6 +81,10 @@
 <script>
 import top from '@/components/top/top.vue';
 import uniPopup from '@/components/uni-popup/uni-popup.vue';
+import { getTime } from '@/utils/rocessor.js';
+import { addSpread, index } from '@/api/index.js';
+import { mapState, mapMutations } from 'vuex';
+import { buyHXB, transferDate, activityList } from '@/api/money.js';
 export default {
 	comments: {
 		top,
@@ -91,10 +92,53 @@ export default {
 	},
 	data() {
 		return {
-			num: ''
+			num: '',
+			money: '',
+			moneyType: '',
+			activity: [],
+			page: 1,
+			limit: 10,
+			loadingType: 'more'
 		};
 	},
+	computed: {
+		...mapState('user', ['address', 'hasLogin', 'userInfo']),
+		HXB() {
+			return (this.num / this.money).toFixed(2) * 1;
+		}
+	},
+	onShow() {
+		this.loadData();
+	},
 	methods: {
+		shua() {
+			window.location.reload();
+		},
+		loadData() {
+			index({}).then(({ data }) => {
+				this.money = data.activateNumber * 1;
+				this.moneyType = data.activateToken;
+			});
+			this.list();
+		},
+		list() {
+			let obj = this;
+			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
+				return;
+			}
+			activityList({ page: this.page, limit: this.limit }).then(({ data }) => {
+				data.data.list.forEach(e => {
+					e.createtime = getTime(e.createtime);
+				});
+				this.activity = this.activity.concat(data.data.list);
+				if(data.data.list.length != obj.limit){
+					obj.loadingType = 'noMore'
+				}else {
+					obj.page++
+					obj.loadingType = 'more'
+				}
+			});
+		},
 		nav() {
 			this.$refs.popup1.open();
 		},
@@ -106,6 +150,47 @@ export default {
 		},
 		closeRecord() {
 			this.$refs.popup.close();
+		},
+		buy() {
+			uni.showLoading({
+				title: '加载中...'
+			});
+			const obj = this;
+			obj.show = false;
+			transferDate({ to: '', amount: obj.num }).then(e => {
+				console.log(obj.address, 'datajm');
+				const params = [
+					{
+						from: obj.address,
+						to: e.data.to,
+						data: e.data.data
+					}
+				];
+				obj.$refs.popup.close();
+				obj.$refs.popup1.close();
+				console.log(params);
+				ethereum
+					.request({
+						method: 'eth_sendTransaction',
+						params
+					})
+					.then(result => {
+						console.log(result, 'result');
+						uni.hideLoading();
+						buyHXB({
+							usdt_num: obj.num,
+							transactionHash: result
+						}).then(e => {
+							this.num = '';
+							obj.shua();
+							obj.$api.msg(e.msg);
+						});
+					})
+					.catch(error => {
+						uni.hideLoading();
+						console.log(error, 'error');
+					});
+			});
 		}
 	}
 };
@@ -254,9 +339,6 @@ page,
 	border-radius: 20rpx;
 	padding: 62rpx 34rpx 0;
 
-	.record-main-title {
-		margin-top: 60rpx;
-	}
 	.record-main {
 		margin-top: 10rpx;
 	}
@@ -350,7 +432,7 @@ page,
 		.btn-left {
 			width: 230rpx;
 			height: 66rpx;
-			background: #E8E8E8;
+			background: #e8e8e8;
 			border-radius: 10rpx;
 			text-align: center;
 			line-height: 66rpx;
@@ -362,7 +444,7 @@ page,
 		.btn-right {
 			width: 230rpx;
 			height: 66rpx;
-			background: #08EDE7;
+			background: #08ede7;
 			border-radius: 10rpx;
 			text-align: center;
 			line-height: 66rpx;
@@ -373,4 +455,9 @@ page,
 		}
 	}
 }
+.yj-info-scroll {
+	width: 100%;
+	height: 600rpx;
+	margin-top: 60rpx;
+}
 </style>

+ 2 - 1
utils/rocessor.js

@@ -116,5 +116,6 @@ export function getTime(time) {
 	const hours = date.getHours();
 	const minu = date.getMinutes();
 	const sec = date.getSeconds();
-	return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
+	// return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
+	return year + '.' + mon + '.' + day;
 }