소스 검색

功能优化

liuyiran 1 주 전
부모
커밋
f96ec4486a
10개의 변경된 파일97개의 추가작업 그리고 96개의 파일을 삭제
  1. 5 1
      api/login.js
  2. 25 0
      api/system/user.js
  3. 1 13
      config.js
  4. 0 7
      pages.json
  5. 58 58
      pages/index.vue
  6. 0 5
      pages/login.vue
  7. 1 1
      pages/mine/index.vue
  8. 1 4
      pages/mine/info/edit.vue
  9. 4 6
      pages/mine/info/index.vue
  10. 2 1
      store/modules/user.js

+ 5 - 1
api/login.js

@@ -38,7 +38,10 @@ export function register(data) {
 // 获取用户详细信息
 export function getInfo() {
   return request({
-    'url': '/getInfo',
+    'url': '/system/user/getInfo',
+		headers: {
+			isClientId:true,
+		},
     'method': 'get'
   })
 }
@@ -57,6 +60,7 @@ export function getCodeImg() {
     'url': '/captchaImage',
     headers: {
       isToken: false,
+			// isClientId:true,
     },
     method: 'get',
     timeout: 20000

+ 25 - 0
api/system/user.js

@@ -18,6 +18,9 @@ export function updateUserPwd(oldPassword, newPassword) {
 export function getUserProfile() {
   return request({
     url: '/system/user/profile',
+		headers: {
+			isClientId:true,
+		},
     method: 'get'
   })
 }
@@ -47,3 +50,25 @@ export function uploadPerson(data) {
 		file:data.file
   })
 }
+
+// 音频生成接口
+export function audioCreateVideo(data) {
+  return request({
+    url: '/system/user/profile',
+  	headers: {
+  		isClientId:true,
+  	},
+    method: 'post'
+  })
+}
+
+// 文本生成接口
+export function textCreateVideo(data) {
+  return request({
+    url: '/system/user/profile',
+  	headers: {
+  		isClientId:true,
+  	},
+    method: 'post'
+  })
+}

+ 1 - 13
config.js

@@ -2,7 +2,7 @@
 module.exports = {
   // baseUrl: 'https://vue.ruoyi.vip/prod-api',
   // baseUrl: 'http://localhost:8080',
-	baseUrl:"http://192.168.0.3:8848/api",
+	baseUrl:"http://192.168.149.19:8848/api",
   // 应用信息
   appInfo: {
     // 应用名称
@@ -11,17 +11,5 @@ module.exports = {
     version: "1.2.0",
     // 应用logo
     logo: "/static/images/xijiao/avator.png",
-    // 官方网站
-    // site_url: "",
-    // 政策协议
-  //   agreements: [{
-  //       title: "隐私政策",
-  //       url: ""
-  //     },
-  //     {
-  //       title: "用户服务协议",
-  //       url: ""
-  //     }
-  //   ]
   }
 }

+ 0 - 7
pages.json

@@ -13,15 +13,8 @@
 			"path": "pages/index",
 			"style": {
 				"navigationBarTitleText": "视频生成"
-				//   "navigationStyle": "custom"
 			}
 		},
-		// {
-		// 	"path": "pages/work/index",
-		// 	"style": {
-		// 		"navigationBarTitleText": "列表"
-		// 	}
-		// },
 		{
 			"path": "pages/list/index",
 			"style": {

+ 58 - 58
pages/index.vue

@@ -19,25 +19,13 @@
 				<text class="form-area-item-text">视频名称</text>
 				<input type="text" v-model="videoName" placeholder="请输入视频名称">
 			</view>
-			<!-- 			<view class="form-area-item" :key="timeStamp">
-				<text class="form-area-item-text">选择您的形象</text>
-				<button @click="chooseFile" class="cu-btn bg-red">选择文件</button>
-				<text class="file-name" v-if="fileInfo.name">{{fileInfo.name}}</text>
-				<text class="none-file" v-if="!showPerson">未选择文件</text>
-			</view> -->
 			<view class="form-area-item">
 				<text class="form-area-item-text">选择您的形象</text>
 				<button @click="chooseImage" class="cu-btn bg-red">选择图片</button>
 				<text class="none-file" v-if="!imagePath">未选择图片</text>
 				<image :src="imagePath" v-else mode="aspectFit" style="width: 30px; height: 30px;margin-left:10px" />
 			</view>
-			<!-- 			<view class="form-area-item">
-				<text class="form-area-item-text">选择模板</text>
-				<uni-data-select v-model="modelIndex" :localdata="array" @change="bindPickerChange"></uni-data-select>
-				<CustomModal :visible="isModalVisible" :message="modalMessage" :imageSrc="modalImageSrc" @confirm="onConfirm"
-					@cancel="onCancel" />
-			</view> -->
-			<view class="form-area-item">
+			<view class="form-area-item" style="align-items: baseline;">
 				<text class="form-area-item-text">视频内容</text>
 				<uni-data-checkbox selectedColor="#BD3124" selectedTextColor="#BD3124" v-model="current"
 					:localdata="videoContent" />
@@ -52,9 +40,12 @@
 			</view>
 			<view class="form-area-item" v-if="current=='record'">
 				<button @click="toggleRecording">{{ isRecording ? '停止录音' : '开始录音' }}</button>
-				<!-- 				<view v-if="audioPath" class="audio-bar" @click="playAudio">
-					🎵 录音文件(点击播放)
-				</view> -->
+			</view>
+			<view class="form-area-item" v-if="current=='audio'" :key="timeStamp">
+				<text class="form-area-item-text">选择音频文件</text>
+				<button @click="chooseFile" class="cu-btn bg-red">选择文件</button>
+				<text class="file-name" v-if="fileInfo.name">{{fileInfo.name}}</text>
+				<text class="none-file" v-if="!showPerson">未选择文件</text>
 			</view>
 			<audio v-if="audioPath" class="audio-bar" :src="audioPath" name="语音试听" poster="../static/images/xijiao/avator.png"
 				:action="audioAction" controls></audio>
@@ -69,18 +60,16 @@
 	</view>
 </template>
 <script>
-	// import CustomModal from '../components/CustomModal.vue';
 	import {
-		uploadPerson
+		uploadPerson,
+		audioCreateVideo,
+		textCreateVideo
 	} from "@/api/system/user"
 	import store from '@/store'
 	const recorderManager = uni.getRecorderManager();
 	const innerAudioContext = uni.createInnerAudioContext();
 	innerAudioContext.autoplay = true;
 	export default {
-		// components: {
-		// 	CustomModal
-		// },
 		data() {
 			return {
 				videoName: '',
@@ -92,7 +81,11 @@
 					{
 						value: 'record',
 						text: '语音录入'
-					}
+					},
+					{
+						value: 'audio',
+						text: '音频选择'
+					},
 				],
 				current: 'text',
 				imagePath: '',
@@ -117,7 +110,8 @@
 						text: 'timbre2'
 					}
 				],
-				personPath: ''
+				personPath: '',
+				createVideoPath: '',
 			}
 		},
 		onLoad() {
@@ -143,14 +137,17 @@
 			this.timeStamp = new Date().getTime()
 			this.fileInfo.path = uni.getStorageSync('filePath');
 			this.fileInfo.name = uni.getStorageSync('fileName');
-			if (this.fileInfo.name) this.showPerson = true
+			if (this.fileInfo.name) {
+				this.showPerson = true
+				this.uploadAudioPath(this.fileInfo.path)
+			}
 		},
 		methods: {
-			/* chooseFile() {
+			chooseFile() {
 				uni.navigateTo({
 					url: "/pages/root-filelist/root-filelist",
 				});
-			}, */
+			},
 			async chooseImage() {
 				const that = this;
 				uni.chooseImage({
@@ -169,19 +166,6 @@
 					}
 				});
 			},
-			/* 			bindPickerChange(e) {
-							const tempOption = this.array.find(item => item.value == e).text;
-							this.modalMessage = `您选择的是: ${tempOption}`;
-							this.modalImageSrc = '../static/images/xijiao/avator.png';
-							this.isModalVisible = true;
-							this.modelIndex = e
-						},
-						onConfirm() {
-							this.isModalVisible = false;
-						},
-						onCancel() {
-							this.isModalVisible = false;
-						}, */
 			radioChange(evt) {
 				for (let i = 0; i < this.videoContent.length; i++) {
 					if (this.videoContent[i].value === evt.detail.value) {
@@ -194,6 +178,7 @@
 			toggleRecording() {
 				if (this.isRecording) {
 					this.recorderManager.stop();
+					this.uploadAudioPath(this.audioPath)
 				} else {
 					// 开始录音前,如果已有录音则清空
 					if (this.audioPath) {
@@ -210,17 +195,6 @@
 					this.isRecording = true;
 				}
 			},
-			// playAudio() {
-			// 	if (!this.audioPath) {
-			// 		uni.showToast({
-			// 			title: '没有可播放的录音',
-			// 			icon: 'none'
-			// 		});
-			// 		return;
-			// 	}
-			// 	this.innerAudioContext.src = this.audioPath;
-			// 	this.innerAudioContext.play();
-			// },
 			uploadImagePath() {
 				let data = {
 					file: this.imagePath
@@ -229,20 +203,22 @@
 					this.personPath = response.data.url
 				})
 			},
+			uploadAudioPath(url) {
+				let data = {
+					file: url
+				}
+				uploadPerson(data).then(response => {
+					this.personAudio = response.data.url
+				})
+			},
 			jumpToList() {
 				let missingFields = [];
 				if (!this.videoName.trim()) {
 					missingFields.push('视频名称');
 				}
-				// if (!this.fileInfo.path) {
-				// 	missingFields.push('人物形象');
-				// }
 				if (!this.imagePath) {
 					missingFields.push('人物形象');
 				}
-				// if (!this.modelIndex) {
-				// 	missingFields.push('视频模板');
-				// }
 				const hasContent = this.videoText.trim() !== '' && this.timbre;
 				const hasVoice = this.audioPath;
 				if (!hasContent && !hasVoice) {
@@ -256,6 +232,32 @@
 				uni.navigateTo({
 					url: 'list/creatingVideo/creatingVideo',
 				});
+				if (this.current == 'record' || this.current == 'audio') {
+					let data = {
+						'persona_template': this.personPath,
+						'persona_audio': this.personAudio,
+					}
+					audioCreateVideo(data).then(response => {
+						if (response.status == 200) {
+							this.createVideoPath = response.data
+						}
+					}).catch(e => {
+						uni.showToast({
+							title: '视频返回成功'
+						})
+					})
+				} else if (this.current == 'text') {
+					let data = {
+						'persona_template': this.personPath,
+						'voice_type': this.timbre,
+						'audio_text': this.videoText,
+					}
+					textCreateVideo(data).then(response => {
+						if (response.status == 200) {
+							this.createVideoPath = response.data
+						}
+					})
+				}
 			},
 			dialogClose() {
 				console.log('点击关闭')
@@ -267,8 +269,6 @@
 	.content {
 		display: flex;
 		flex-direction: column;
-		/* 		align-items: center;
-		justify-content: center; */
 	}
 
 	.uni-margin-wrap {

+ 0 - 5
pages/login.vue

@@ -29,11 +29,6 @@
         <text class="text-grey1">没有账号?</text>
         <text @click="handleUserRegister" class="text-red">立即注册</text>
       </view>
-			<!--      <view class="xieyi text-center">
-        <text class="text-grey1">登录即代表同意</text>
-        <text @click="handleUserAgrement" class="text-red">《用户协议》</text>
-        <text @click="handlePrivacy" class="text-red">《隐私协议》</text>
-      </view -->
     </view>
      
   </view>

+ 1 - 1
pages/mine/index.vue

@@ -155,7 +155,7 @@
         margin-left: 15px;
 
         .u_title {
-          font-size: 18px;
+          font-size: 14px;
           line-height: 30px;
         }
       }

+ 1 - 4
pages/mine/info/edit.vue

@@ -11,9 +11,6 @@
         <uni-forms-item label="邮箱" name="email">
           <uni-easyinput v-model="user.email" placeholder="请输入邮箱" />
         </uni-forms-item>
-        <uni-forms-item label="性别" name="sex" required>
-          <uni-data-checkbox selectedColor="#BD3124" selectedTextColor="#BD3124" v-model="user.sex" :localdata="sexs" />
-        </uni-forms-item>
       </uni-forms>
       <button @click="submit" class="bg-red">提交</button>
     </view>
@@ -77,7 +74,7 @@
     methods: {
       getUser() {
         getUserProfile().then(response => {
-          this.user = response.data
+          this.user = response.data.user
         })
       },
       submit(ref) {

+ 4 - 6
pages/mine/info/index.vue

@@ -4,9 +4,6 @@
       <uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="昵称" :rightText="user.nickName" />
       <uni-list-item showExtraIcon="true" :extraIcon="{type: 'phone-filled'}" title="手机号码" :rightText="user.phonenumber" />
       <uni-list-item showExtraIcon="true" :extraIcon="{type: 'email-filled'}" title="邮箱" :rightText="user.email" />
-      <!-- <uni-list-item showExtraIcon="true" :extraIcon="{type: 'auth-filled'}" title="岗位" :rightText="postGroup" />
-      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'staff-filled'}" title="角色" :rightText="roleGroup" />
-      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'calendar-filled'}" title="创建日期" :rightText="user.createTime" /> -->
     </uni-list>
   </view>
 </template>
@@ -28,9 +25,10 @@
     methods: {
       getUser() {
         getUserProfile().then(response => {
-          this.user = response.data
-          this.roleGroup = response.roleGroup
-          this.postGroup = response.postGroup
+					console.log(response,'-----------')
+          this.user = response.data.user
+          this.roleGroup = response.data.roleGroup
+          this.postGroup = response.data.postGroup
         })
       }
     }

+ 2 - 1
store/modules/user.js

@@ -71,7 +71,8 @@ const user = {
     GetInfo({ commit, state }) {
       return new Promise((resolve, reject) => {
         getInfo().then(res => {
-          const user = res.user
+					console.log(res,'0-0-0-0-0')
+          const user = res.data.user
 		  let avatar = user.avatar || ""
 		  if (!isHttp(avatar)) {
             avatar = (isEmpty(avatar)) ? defAva : baseUrl + avatar