lyqu 4 лет назад
Родитель
Сommit
1a80d18aa9

+ 1 - 1
common/conf/config.js

@@ -11,7 +11,7 @@ const redireactUrl = 'https://vote.guosen-fumao.cn/vote-h5/index.html#/pages/act
 const authUrl = (activity) => { return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURIComponent(redireactUrl+activity)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`};
 
 //获取用户的Access-token
-const atUrl = (code) =>{ return `https://api.weixin.qq.com/sns/oauth2/access_token?appid=${appId}&secret=${appSecret}&code=${code}&grant_type=authorization_code`}
+const atUrl = (code) => { return `https://api.weixin.qq.com/sns/oauth2/access_token?appid=${appId}&secret=${appSecret}&code=${code}&grant_type=authorization_code`}
 
 //拉取用户信息
 const getWXUserInfoUrl = (ACCESS_TOKEN, OPENID) => { 

+ 3 - 1
common/http/http.api.js

@@ -14,6 +14,7 @@ let userUrl = {
 	boostUrl: 'cyzh-activity/activity/getHitPersonDetail',
 	loginUrl: '/cyzh-loginUser/loginuser/login',
 	detailUrl: '/cyzh-loginUser/loginuser/detail',
+	submitUrl: '/cyzh-loginUser/loginuser/submit',
 }
 // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分:
 // https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
@@ -32,7 +33,8 @@ const install = (Vue, vm) => {
 	let user = {
 		boost:(params = {}) => vm.$u.get(userUrl.boostUrl, params),
 		login:(params = {}) => vm.$u.post(userUrl.loginUrl, params),
-		detail:(params = {}) => vm.$u.post(userUrl.detailUrl, params),
+		detail:(params = {}) => vm.$u.get(userUrl.detailUrl, params),
+		submit:(params = {}) => vm.$u.post(userUrl.submitUrl, params),
 	}
 	// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
 	vm.$u.api = {wxInfo, activity, user};

+ 18 - 3
components/homeViews/activity-view.vue

@@ -1,7 +1,7 @@
 <template>
 	<view>
 		<view class="searchBar">
-			<search-bar :disabled="true"></search-bar>
+			<search-bar :disabled="true" @onNavigator="navByIcon('/pages/activityList/activity/hot', 2)"></search-bar>
 		</view>
 		<view class="padding-tb bg-white">
 			<u-image width="100%" height="350" :src="activity.cover" @click="navByIcon('/pages/activityList/activity/activityDetail', 0)"></u-image>
@@ -80,6 +80,7 @@
 </template>
 
 <script>
+	import {authUrl} from '@/common/conf/config.js'
 	import searchBar from "@/components/basic/search-bar.vue";
 	export default {
 		components: {
@@ -130,9 +131,23 @@
 				if (index == 0) { //图片 和 活动详情
 					url = path + "?poster=" + this.activity.poster; 
 				}
-				if (index == 1 || index == 2) { //报名 和 热榜
+				if (index == 1) { //报名
 					url = path + "?activityId=" + this.activityId;
 				}
+				if (index == 2) { //热榜
+					let userId = uni.getStorageSync("userId")
+					if (this.$u.test.isEmpty(userId)) {
+						window.location.href = authUrl(this.activityId);
+					} else {
+						url = path + "?activityId=" + this.activityId;
+					}
+				}
+				if (index == 3) { //我的奖金
+					url = path;
+				}
+				if (index == 4) { //更多
+					url = path;
+				}
 				uni.navigateTo({
 					url: url,
 				})
@@ -140,7 +155,7 @@
 			//跳转需要带惨方法
 			navWithParm(id) {
 				uni.navigateTo({
-					url: "/pages/activityList/activity/boost?activityId=" + this.activityId + "&userId=" + id,
+					url: "/pages/activityList/activity/boost?activityId=" + this.activityId + "&receiverId=" + id,
 				})
 			},
 		}

+ 13 - 11
components/homeViews/mine-view.vue

@@ -3,15 +3,15 @@
 		<view class="container">
 			<view class="flex justify-between align-center" style="height: 200upx;" v-if="isLogin">
 				<view class="padding-left">
-					<view class="text-black text-bold text-xl">{{userData.nickname}}</view>
+					<view class="text-black text-bold text-xl">{{userData.nickName}}</view>
 					<view class="flex align-center padding-top-sm">
 						<view>
-							<view class="text-black text-bold">205</view>
+							<view class="text-black text-bold">{{+userData.totalHot}}</view>
 							<view class="text-gray text-sm margin-top-xs">热力</view>
 						</view>
 						<view style="height: 60upx;border: #dadada 1px solid; margin: 0 30upx;"></view>
 						<view>
-							<view class="text-black text-bold">886</view>
+							<view class="text-black text-bold">{{+userData.totalPoints}}</view>
 							<view class="text-gray text-sm margin-top-xs">积分</view>
 						</view>
 						<view class="padding-left">
@@ -24,7 +24,7 @@
 				</view>
 				<view class="flex align-center">
 					<view class="padding-right">
-						<u-avatar :src="userData.headimgurl" size="120"></u-avatar>
+						<u-avatar :src="userData.avatar" size="120"></u-avatar>
 					</view>
 				</view>
 			</view>
@@ -71,7 +71,7 @@
 </template>
 
 <script>
-	import {authUrl } from '@/common/conf/config.js'
+	import {authUrl} from '@/common/conf/config.js'
 	export default {
 		props: {
 			activityId: {
@@ -82,8 +82,6 @@
 		data() {
 			return {
 				userData: {},
-				hotVaule: '205',
-				points: '886',
 				isLogin: false,
 				iconList: [
 					{name: '我的礼品', icon: '/static/icon-gift.png', width: '36upx', height: '33upx', url: '/pages/activityList/mine/myGift'},
@@ -119,13 +117,17 @@
 			//跳转需要带参数
 			edit() {
 				uni.navigateTo({
-					url: '/pages/activityList/mine/edit'
+					url: '/pages/activityList/mine/edit?userId=' + this.userData.id
 				})
 			},
 			navByIcon(url) {
-				uni.navigateTo({
-					url: url 
-				})
+				if (!this.isLogin) {
+					this.toAuth();
+				} else {
+					uni.navigateTo({
+						url: url 
+					})
+				}
 			}
 		}
 	}

+ 26 - 6
pages/activityList/activity/boost.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<view class="bg-img" style="height: 563upx;" :style="{'backgroundImage':'url('+ boostDetail.cover +')'}">></view>
+		<view class="bg-img" style="height: 563upx;" :style="{'backgroundImage':'url('+ boostDetail.cover +')'}"></view>
 		<view class="head">
 			<view class="title">为{{boostDetail.nickName}}打榜</view>
 			<view class="flex justify-between align-center padding-lr">
@@ -15,7 +15,7 @@
 					</view>
 				</view>
 				<view class="text-center">
-					<button class="cu-btn round theme-bg-color text-white text-bold">
+					<button class="cu-btn round theme-bg-color text-white text-bold" @click="userBoost">
 						<text>打榜</text>
 						<text class="cuIcon-hot padding-lr-xs"></text>
 						<text>X{{boostDetail.activityHotValue}}</text>
@@ -78,7 +78,7 @@
 				<view class="text-gray text-sm">立白助力礼包A</view>
 				<view class="text-gray text-sm">可得300积分,可用于国信商城兑换</view>
 				<view class="padding">
-					<u-button class="custom-style" shape="circle">去支付</u-button>
+					<u-button class="custom-style" shape="circle" @click="pay">去支付</u-button>
 				</view>
 			</view>
 		</u-popup>
@@ -100,16 +100,36 @@
 				],
 				count: 1,
 				currentPresentSum: 0,
+				activityId: '',
+				senderId: '',
 			}
 		},
 		onLoad(options) {
-			this.getBoostDetail(options.activityId, options.userId);
+			this.activityId = optionss.activityId;
+			this.senderId = uni.getStorageSync("userId");
+			this.getBoostDetail(options.activityId, options.receiverId);
 			this.currentPresentSum = this.present[this.current].price;
 		},
 		methods: {
+			//打榜助力
+			userBoost() {
+				if (this.$u.test.isEmpty(senderId)) {
+					window.location.href = authUrl(this.activityId);
+				} else {
+					
+				}
+			},
+			//礼物支付
+			pay() {
+				if (this.$u.test.isEmpty(senderId)) {
+					window.location.href = authUrl(this.activityId);
+				} else {
+					
+				}
+			},
 			//获取助力详情
-			getBoostDetail(activityId, userId) {
-				this.$u.api.user.boost({activityId: activityId,receiverId: userId, senderId: null}).then(res => {
+			getBoostDetail(activityId, receiverId) {
+				this.$u.api.user.boost({activityId: activityId, receiverId: receiverId, senderId: this.senderId}).then(res => {
 					this.boostDetail = res;
 				})
 			},

+ 4 - 1
pages/activityList/activity/hot.vue

@@ -1,7 +1,7 @@
 <template>
 	<view>
 		<view class="searchBar">
-			<search-bar :disabled="true"></search-bar>
+			<search-bar :disabled="false" @onSearch="onSearch"></search-bar>
 		</view>
 		<block v-for="(item, index) in hotList" :key="index">
 			<u-line color="#e8e8e8"></u-line>
@@ -55,6 +55,9 @@
 				uni.navigateTo({
 					url: "/pages/activityList/activity/boost"
 				})
+			},
+			onSearch(value) {
+				console.log(value);
 			}
 		}
 	}

+ 49 - 6
pages/activityList/mine/edit.vue

@@ -2,12 +2,12 @@
 	<view>
 		<view class="flex padding justify-between align-center">
 			<view class="title">头像</view>
-			<u-avatar src="/static/avatar.png" size="120"></u-avatar>
+			<u-avatar :src="userData.avatar" size="120"></u-avatar>
 		</view>
 		<u-line color="#f1f1f1"></u-line>
 		<view class="flex padding justify-between align-center">
 			<view class="title">昵称</view>
-			<u-input v-model="name" :clearable="false" inputAlign="right" placeholder="请输入昵称"></u-input>
+			<u-input v-model="userData.nickName" :clearable="false" inputAlign="right" placeholder="请输入昵称"></u-input>
 		</view>
 		<u-line color="#f1f1f1"></u-line>
 		<view class="flex padding justify-between align-center">
@@ -32,7 +32,7 @@
 		</view>
 		<view class="flex justify-end padding-right-sm padding-bottom-sm text-gray">{{introduction.length}} / 60</view>
 		<view class="footer-fixed margin-bottom">
-			<u-button class="custom-style" shape="circle">保存</u-button>
+			<u-button class="custom-style" shape="circle" @click="save">保存</u-button>
 		</view>
 	</view>
 </template>
@@ -41,8 +41,9 @@
 	export default {
 		data() {
 			return {
+				userData: {},
 				name: 'Daniel Hua',
-				sex: '',
+				sex: '',
 				sexShow: false,
 				border: true,
 				show: false,
@@ -58,18 +59,60 @@
 					}
 				],
 				calendarShow: false,
-				birthday: '2020-7-14',
+				birthday: '',
 				introduction: '',
 			}
 		},
+		onLoad(options) {
+			this.getUserInfo(options.userId);
+		},
 		methods: {
+			getUserInfo(userId) {
+				this.$u.api.user.detail({id: userId}).then(res => {
+					this.userData = res;
+					if (res.gender == 1) {
+						this.sex = '男';
+					} else if (res.gender == 2) {
+						this.sex = "女";
+					} else {
+						this.sex = "未知"; 
+					}
+				})
+			},
 			// 点击actionSheet回调
 			actionSheetCallback(index) {
 				this.sex = this.actionSheetList[index].text;
 			},
 			change(e) {
-				console.log(e);
 				this.birthday = e.result;
+			},
+			save() {
+				if (this.$u.test.isEmpty(this.introduction) || this.$u.test.isEmpty(this.userData.nickName)) {
+					uni.showToast({
+						icon: "none",
+						title: "请填写个人昵称和个人介绍",
+					})
+					return;
+				} else {
+					let data = {
+						id: this.userData.id,
+						name: this.userData.nickName,
+						gender: this.sex == '男' ? 1 : this.sex == '女' ? 2 : 0,
+						introduce: this.introduction,
+					}
+					this.$u.api.user.submit(data).then(res => {
+						uni.showToast({
+							icon: "none",
+							title: "修改成功",
+							duration: 2000,
+							success() {
+								uni.navigateBack({
+									delta: 1
+								})
+							}
+						})
+					})
+				}
 			}
 		}
 	}

+ 0 - 1
pages/index/index.vue

@@ -30,7 +30,6 @@
 			}
 		},
 		methods: {
-			
 			change(index) {
 				this.current = index;
 			}