浏览代码

新增用户信息

李万涛 1 年之前
父节点
当前提交
cd6bb37d1c
共有 6 个文件被更改,包括 205 次插入122 次删除
  1. 13 0
      api/my/index.js
  2. 1 1
      common/config.js
  3. 20 0
      pages/robot/index.vue
  4. 62 45
      pages/user/user.vue
  5. 99 76
      pages/user/userinfo.vue
  6. 10 0
      utils/request/responseInterceptors.js

+ 13 - 0
api/my/index.js

xqd
@@ -0,0 +1,13 @@
+//我的相关:
+const {
+	http
+} = uni.$u
+
+
+//获取用户信息
+export const userInfo = (params, config = {}) => http.post('index.php/api.Digit/getUserInfo', params, config)
+
+
+
+//修改用户信息
+export const updateUserInfo = (params, config = {}) => http.post('index.php/api.Digit/userUpdate', params, config)

+ 1 - 1
common/config.js

xqd
@@ -1,3 +1,3 @@
 module.exports = {
-	baseUrl: 'https://t20.9026.com/api/'
+	baseImgUrl: 'http://t3.9026.com/index.php/api.common/upload?uniacid=5059'
 }

+ 20 - 0
pages/robot/index.vue

xqd xqd xqd
@@ -197,6 +197,9 @@
 						})
 					}
 				}, 10000)
+				console.log('timer-------------', _this.timer);
+				// clearInterval(_this.timer)
+				uni.setStorageSync('timer', _this.timer)
 			}
 			getApp().from = ''
 
@@ -403,6 +406,14 @@
 					});
 
 				} else if (e.value[0] == '复制链接') {
+					if (this.delItem.state == 0) {
+						uni.showToast({
+							title: '数字人正在生成中,请稍后复制链接',
+							icon: 'none'
+						})
+						return
+					}
+
 					uni.setClipboardData({
 						data: this.delItem.url,
 						success: function() {
@@ -413,6 +424,15 @@
 						}
 					});
 				} else if (e.value[0] == '下载视频') {
+					if (this.delItem.state == 0) {
+						uni.showToast({
+							title: '数字人正在生成中,请稍后下载视频',
+							icon: 'none'
+						})
+						return
+					}
+
+
 					const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
 						.test(
 							navigator.userAgent) ? false : true;

+ 62 - 45
pages/user/user.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -9,9 +9,10 @@
 					<image class="avatar" mode="aspectFill" src="/static/images/head.jpg"></image>
 					<view class="nickname">点击立即登录/注册</view>
 				</view>
-				<view class="info" @click="" v-else>
-					<image class="avatar" mode="aspectFill" src="/static/images/head.jpg"></image>
-					<view class="nickname1" style="align-items: center;">您已登录</view>
+				<view class="info" @click="modify" v-else>
+					<image class="avatar" mode="aspectFill"
+						:src="userInfo.head?userInfo.head:'/static/images/head.jpg'"></image>
+					<view class="nickname1" style="align-items: center;">{{userInfo.nick?userInfo.nick:'默认用户'}}</view>
 				</view>
 			</view>
 
@@ -76,15 +77,15 @@
 			<!-- <view style="border-radius: 20rpx; overflow: hidden; margin: 0 20rpx;">
 			<com-nav :list="list" :col="4"></com-nav>
 		</view> -->
-			<view class="com-item">
-				<view class="com-wrap">
-					<!-- #ifdef MP-WEIXIN -->
-					<view v-if="appInfo.wxad_user && appInfo.wxad_user >= 1">
+			<!-- <view class="com-item">
+				<view class="com-wrap"> -->
+			<!-- #ifdef MP-WEIXIN -->
+			<!-- 	<view v-if="appInfo.wxad_user && appInfo.wxad_user >= 1">
 						<wike-flow-main :flowtype="appInfo.wxad_user" :banner_id="appInfo.banner_id"
 							:video_banner_id="appInfo.video_banner_id" :native_id="appInfo.native_id"></wike-flow-main>
-					</view>
-					<!-- #endif -->
-				</view>
+					</view> -->
+			<!-- #endif -->
+			<!-- 		</view>
 			</view>
 			<view v-if="userData.vip_info&&userData.is_validity>0" class="com-item">
 				<view class="com-wrap">
@@ -96,17 +97,17 @@
 						<u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
 					</view>
 				</view>
-			</view>
+			</view> -->
 			<!-- 用户功能 -->
-			<!-- <view class="com-item">
+			<view class="com-item" v-if="hasLogin">
 				<view class="com-wrap">
-					<view class="cell" @click="showcarmi = true">
+					<!-- 	<view class="cell" @click="showcarmi = true">
 						<view class="cell-left">
 							<u-icon name="coupon-fill" color="#e83a30" size="22"></u-icon>
 							<view class="cell-text">卡密兑换</view>
 						</view>
 						<u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
-					</view>
+					</view> -->
 					<navigator class="cell" v-for="(item, index) in userList" :key="index" :url="item.url"
 						@click="getroute">
 						<view class="cell-left">
@@ -115,35 +116,36 @@
 						</view>
 						<u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
 					</navigator>
-					<navigator class="cell" :url="isLogin ? '/pages/user/member/record' : '/pages/user/signin'"
+					<!-- <navigator class="cell" :url="isLogin ? '/pages/user/member/record' : '/pages/user/signin'"
 						@click="getroute">
 						<view class="cell-left">
 							<u-icon name="bookmark-fill" color="#892fe8" size="22"></u-icon>
 							<view class="cell-text">{{appInfo.number_alias?appInfo.number_alias:'点数'}}/会员套餐记录</view>
 						</view>
 						<u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
-					</navigator>
+					</navigator> -->
 				</view>
-			</view> -->
+			</view>
 
 			<!-- 用户服务 -->
 			<view class="com-item">
-				<view class="com-wrap">
-					<view v-if="!hasLogin" class="cell" @click="getlogin">
+				<view class="com-wrap" v-if="!hasLogin">
+					<view class="cell" @click="getlogin">
 						<view class="cell-left">
 							<!-- <u-icon name="scan" color="#007aff" size="22"></u-icon> -->
 							<view class="cell-text">立即登录</view>
 						</view>
 						<u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
 					</view>
+				</view>
 
-					<view v-if="hasLogin" class="cell" @click="loginout">
+				<view class="com-wrap" v-if="hasLogin">
+					<!-- 	<view class="cell" @click="loginout">
 						<view class="cell-left">
-							<!-- <u-icon name="scan" color="#007aff" size="22"></u-icon> -->
 							<view class="cell-text">退出登录</view>
 						</view>
 						<u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
-					</view>
+					</view> -->
 
 					<!-- 	<view v-if="qrcode" class="cell" @click="getqrcode">
 						<view class="cell-left">
@@ -474,6 +476,10 @@
 	import {
 		API_ROOT
 	} from '@/common/request/request';
+
+	import {
+		userInfo
+	} from '@/api/my/index.js'
 	let interstitialAd = null,
 		timer,
 		time2;
@@ -481,6 +487,8 @@
 		components: {},
 		data() {
 			return {
+				userInfo: {},
+
 				hasLogin: false,
 
 				// API_ROOT: API_ROOT,
@@ -539,28 +547,29 @@
 						text: '送礼提醒'
 					}
 				],
-				// userList: [{
-				// 		title: '订单记录',
-				// 		icon: 'shopping-cart-fill',
-				// 		path: 'coupon-fill',
-				// 		url: '/pages/user/orderrecord/orderrecord',
-				// 		color: '#26b3a0'
-				// 	},
-				// 	{
-				// 		title: '问答记录',
-				// 		icon: 'question-circle-fill',
-				// 		path: 'collect-list',
-				// 		url: '/pages/user/takenotes/takenotes',
-				// 		color: '#31c9e8'
-				// 	},
-				// 	{
-				// 		title: '修改用户信息',
-				// 		icon: 'setting-fill',
-				// 		path: 'collect-list',
-				// 		url: '/pages/user/userinfo',
-				// 		color: '#5ac725'
-				// 	},
-				// ],
+				userList: [
+					// {
+					// 	title: '订单记录',
+					// 	icon: 'shopping-cart-fill',
+					// 	path: 'coupon-fill',
+					// 	url: '/pages/user/orderrecord/orderrecord',
+					// 	color: '#26b3a0'
+					// },
+					// {
+					// 	title: '问答记录',
+					// 	icon: 'question-circle-fill',
+					// 	path: 'collect-list',
+					// 	url: '/pages/user/takenotes/takenotes',
+					// 	color: '#31c9e8'
+					// },
+					{
+						title: '修改用户信息',
+						icon: 'setting-fill',
+						path: 'collect-list',
+						url: '/pages/user/userinfo',
+						color: '#5ac725'
+					},
+				],
 				// serverList: [{
 				// 		title: '客服中心',
 				// 		icon: 'server-fill',
@@ -598,7 +607,14 @@
 			...mapGetters(['appInfo', 'homeTemplate', 'isLogin', 'userInfo', 'userData'])
 		},
 
-		onShow: function() {
+		async onShow() {
+			let res = await userInfo()
+
+			if (res.code == 0) {
+				this.userInfo = res.msg
+			}
+			console.log('我的-用户信息返回值:', res);
+
 			if (uni.getStorageSync('token')) {
 				this.hasLogin = true
 			}
@@ -759,6 +775,7 @@
 			// 		})
 			// },
 			getCommissionSetting() {
+				return
 				this.$http('conf.getGroupConf', {
 					group: 'system.commission'
 				}).then(res => {

+ 99 - 76
pages/user/userinfo.vue

xqd xqd xqd xqd xqd xqd
@@ -10,35 +10,16 @@
 					<view class='item acea-row row-between-wrapper'>
 						<view>头像</view>
 						<view class="avatar-box" @click.stop='uploadpic'>
-							<image mode="aspectFill" :src="userinfo.avatar?userinfo.avatar:'/static/images/head.jpg'">
+							<image mode="aspectFill" :src="userinfo.head?userinfo.head:'/static/images/head.jpg'">
 							</image>
 						</view>
-						<!-- #ifdef MP-WEIXIN -->
-						<button style="padding: 0;" class="getbutton" open-type="chooseAvatar"
-							@chooseavatar="onChooseAvatar"></button>
-						<!-- #endif -->
 					</view>
 					<view class='item acea-row row-between-wrapper'>
 						<view>昵称</view>
-						<view class='input'><input type='nickname' name='nickname' placeholder="请输入昵称"
-								:value='userinfo.nickname'></input>
+						<view class='input'><input type='nickname' name='nick' placeholder="请输入昵称"
+								:value='userinfo.nick' v-model="userinfo.nick"></input>
 						</view>
 					</view>
-					<view v-if="userinfo.id_number" class='item acea-row row-between-wrapper'>
-						<view>ID号</view>
-						<view class='input acea-row row-between-wrapper'>
-							<input type='text' :value='userinfo.id_number' disabled='true' class='id'></input>
-							<u-icon name="lock" size="22" color="#868686"></u-icon>
-						</view>
-					</view>
-					<!-- #ifdef MP -->
-					<view class='item acea-row row-between-wrapper'>
-						<view>权限设置</view>
-						<view class="input" @click="Setting">
-							点击管理<u-icon name="arrow-right" size="17" color="#868686" top="1"></u-icon>
-						</view>
-					</view>
-					<!-- #endif -->
 				</view>
 				<button class='modifyBnt' style="background: linear-gradient(to right, #00ca88, #00BCD4);"
 					hover-class="hoversubmit" formType="submit">保存修改</button>
@@ -64,6 +45,13 @@
 		apiurl
 	} from '@/common/request/request';
 	// import Header from '@/components/header.vue';
+	import {
+		userInfo,
+		updateUserInfo
+	} from '@/api/my/index.js'
+	import
+	uploadImgUrl
+	from '@/common/config.js';
 	export default {
 		// components: {
 		// 	Header
@@ -89,15 +77,23 @@
 		computed: {
 			...mapGetters(['appInfo', 'isLogin', 'userInfo'])
 		},
-		onLoad() {
+		async onLoad() {
 			let that = this;
-			that.userinfo = that.userInfo
+			// that.userinfo = that.userInfo
 			if (this.platform == 'wxMiniProgram') {
 				var menumtop = uni.getMenuButtonBoundingClientRect().top - uni.getSystemInfoSync().statusBarHeight;
 				var paddingtop = uni.getSystemInfoSync().statusBarHeight + menumtop;
 				this.tobheight = menumtop + paddingtop + uni.getMenuButtonBoundingClientRect().height;
 			}
 
+			let res = await userInfo()
+
+			if (res.code == 0) {
+				this.userinfo = res.msg
+			}
+			console.log('修改用户信息-用户信息返回值:', res);
+			// console.log('上传图片路径:', uploadImgUrl.baseImgUrl);
+
 		},
 		methods: {
 			...mapActions(['logout']),
@@ -225,34 +221,29 @@
 			 */
 			outLogin: function() {
 				let that = this;
-				if (that.loginType == 'h5') {
-					uni.showModal({
-						confirmColor: '#26B3A0',
-						title: '提示',
-						content: '确认退出登录?',
-						success: function(res) {
-							if (res.confirm) {
-								// getLogout()
-								// 	.then(res => {
-								// console.log(res.code);
-								// uni.clearStorage()
-								that.logout();
-								// that.$store.commit("LOGOUT");
-								// uni.navigateBack({})
-								uni.redirectTo({
+				uni.showModal({
+					confirmColor: '#26B3A0',
+					title: '提示',
+					content: '确认退出登录?',
+					success: function(res) {
+						if (res.confirm) {
+							uni.removeStorageSync('token')
+
+							if (uni.getStorageSync('timer')) {
+								console.log('logout-timer', Number(uni.getStorageSync('timer')));
+								clearInterval(Number(uni.getStorageSync('timer')))
+								uni.removeStorageSync('timer')
+							}
+							setTimeout(() => {
+								uni.reLaunch({
 									url: '/pages/user/signin'
 								})
-								// uni.reLaunch({
-								// 	url: '/pages/index/index'
-								// })
-								// })
-								// .catch(err => {});
-							} else if (res.cancel) {
-								console.log('用户点击取消');
-							}
+							}, 1500)
+						} else if (res.cancel) {
+							console.log('用户点击取消');
 						}
-					});
-				}
+					}
+				});
 			},
 
 			/**
@@ -269,16 +260,18 @@
 						const tempFilePaths = res.tempFilePaths;
 						//上传服务器将服务器;
 						uni.uploadFile({
-							url: apiurl('common/upload'),
+							url: uploadImgUrl.baseImgUrl,
 							filePath: tempFilePaths[0],
 							name: 'file',
 							formData: {
-								accept: 'image'
+								accept: 'image',
+								upload_type: 'ali-oss'
 							},
 							success: res2 => {
 								let a = JSON.parse(res2.data);
+								console.log('上传图片返回值:', a.data.path);
 								if (a.code == 0) {
-									that.userinfo.avatar = a.data.path
+									that.userinfo.head = a.data.path.trim()
 									that.ifimg = true
 								} else {
 									uni.showToast({
@@ -296,38 +289,68 @@
 			/**
 			 * 提交修改
 			 */
-			formSubmit: function(e) {
+			async formSubmit(e) {
 				let that = this,
 					value = e.detail.value;
 
-				if (!that.ifimg && !that.userInfo.avatar) return that.$u.toast('保存失败,请上传头像');
-				if (value.nickname == that.userinfo.nickname && !that.userInfo.nickname) return that.$u.toast(
-					'保存失败,请填写昵称');
-				if (value.nickname == that.userinfo.nickname && !that.ifimg) return that.$u.toast('保存失败,您并没有修改');
-				that.$http('user.profile', {
-					nickname: value.nickname,
-					avatar: that.userinfo.avatar
-				}).then(res => {
-					if (res.code == 0) {
+				if (!that.userinfo.head) return that.$u.toast('请上传头像');
+				if (!that.userinfo.nick) return that.$u.toast(
+					'请填写昵称');
+				// if (value.nick == that.userinfo.nick && !that.ifimg) return that.$u.toast('保存失败,您并没有修改');
+				console.log('修改用户信息传递的参数:', {
+					nick: value.nick,
+					head: that.userinfo.head
+				});
+				// return
+				let res = await updateUserInfo({
+					nick: value.nick,
+					head: that.userinfo.head
+				})
+
+
+				console.log('修改用户信息返回值:', res);
+
+				if (res.code == 0) {
+					setTimeout(function() {
 						uni.showToast({
-							title: '保存中...',
+							title: '修改成功',
 							duration: 1000,
-							icon: 'loading',
 						})
-						that.$store.dispatch('getUserInfo')
 						setTimeout(function() {
-							uni.showToast({
-								title: '保存成功',
-								duration: 1000,
-							})
-							setTimeout(function() {
-								uni.navigateBack()
-							}, 1000);
+							uni.navigateBack()
 						}, 1000);
-					} else {
-						that.$u.toast('保存失败,请重试');
-					}
-				})
+					}, 1000);
+				} else {
+					uni.showToast({
+						title: res.msg,
+						duration: 1000,
+						icon: 'none'
+					})
+				}
+				// that.$http('user.profile', {
+				// 	nickname: value.nickname,
+				// 	avatar: that.userinfo.avatar
+				// }).then(res => {
+				// 	if (res.code == 0) {
+				// 		uni.showToast({
+				// 			title: '保存中...',
+				// 			duration: 1000,
+				// 			icon: 'loading',
+				// 		})
+				// 		that.$store.dispatch('getUserInfo')
+				// 		setTimeout(function() {
+				// 			uni.showToast({
+				// 				title: '保存成功',
+				// 				duration: 1000,
+				// 			})
+				// 			setTimeout(function() {
+				// 				uni.navigateBack()
+				// 			}, 1000);
+				// 		}, 1000);
+				// 	} else {
+				// 		that.$u.toast('保存失败,请重试');
+				// 	}
+				// })
 			}
 		}
 	}

+ 10 - 0
utils/request/responseInterceptors.js

xqd
@@ -30,6 +30,16 @@ module.exports = (vm) => {
 		/*  对响应错误做点什么 (statusCode !== 200)*/
 		let statusCode = response.statusCode
 		if (statusCode == 401) {
+			if (uni.getStorageSync('timer')) {
+				console.log('logout-timer----401', Number(uni.getStorageSync('timer')));
+				clearInterval(Number(uni.getStorageSync('timer')))
+				uni.removeStorageSync('timer')
+			}
+			// if (localStorage.getItem('timer')) {
+			// 	console.log('logout-timer', Number(localStorage.getItem('timer')));
+			// 	clearInterval(Number(localStorage.getItem('timer')))
+			// 	localStorage.removeItem('timer')
+			// }
 			uni.clearStorageSync()
 			uni.showToast({
 				title: '您的登录已失效,或您已在其他地方登录',