Sfoglia il codice sorgente

feat 激活码入库的功能

ylong 3 mesi fa
parent
commit
2b7b2cee73

+ 1 - 1
config/request.js

@@ -1,7 +1,7 @@
 /**
  * 文档地址:https://uiadmin.net/uview-plus/js/http.html
  */
-const baseUrl = "https://bk.shuhi.com";
+const baseUrl = "https://bpi.shuhi.com";
 export function initRequest() {
     console.log("初始化了 http 请求代码");
     // 初始化请求配置

+ 277 - 272
pages/index/wms/code-storage-add.vue

@@ -1,273 +1,278 @@
-<template>
-    <view class="container">
-        <!-- 书籍信息展示区域 -->
-        <view class="book-info-section" v-if="bookInfo.bookName">
-            <view class="book-cover">
-                <image :src="bookInfo.cover || '/static/img/default-book.png'" class="cover-image" mode="aspectFit" />
-            </view>
-            <view class="book-details">
-                <text class="book-title">{{ bookInfo.bookName }}</text>
-                <text class="book-isbn">{{ bookInfo.isbn }}</text>
-                <text class="book-publisher">{{ bookInfo.publish }}</text>
-                <text class="book-author">{{ bookInfo.author }}</text>
-                <text class="book-date">{{ bookInfo.pubDate }}</text>
-            </view>
-        </view>
-
-        <!-- 上传图片区域 -->
-        <view class="upload-section">
-            <view class="upload-label">上传图片</view>
-            <view class="upload-content">
-                <cy-upload :filename="form.imgUrl" @update:filename="form.imgUrl = $event" @success="onUploadSuccess"
-                    name="imgUrl" :maxCount="1" :max-size="1024 * 1024" url="/activation/bookActivationInfo/uploadImg">
-                </cy-upload>
-            </view>
-        </view>
-
-        <!-- 底部按钮 -->
-        <view class="fixed-bottom">
-            <u-button size="large" type="warning" @click="cancelForm" text="取消" class="cancel-button" />
-            <u-button size="large" type="success" @click="submitForm" text="提交" class="submit-button" />
-        </view>
-    </view>
-</template>
-
-<script setup>
-import {
-    ref,
-    reactive,
-    onUnmounted
-} from 'vue';
-import {
-    onLoad,
-    onShow
-} from '@dcloudio/uni-app'
-import cyUpload from '@/components/cy-upload/index.vue'
-
-const form = ref({
-    "isbn": "",
-    "imgUrl": ""
-});
-
-// 书籍信息
-const bookInfo = ref({});
-
-// 图片上传状态
-const isImageUploaded = ref(false);
-
-onShow(() => {
-    // 从本地存储获取书籍信息
-    const storedInfo = uni.getStorageSync('bookInfo');
-    bookInfo.value = storedInfo
-})
-
-// 图片上传成功回调
-function onUploadSuccess(result) {
-    console.log('图片上传成功:', result);
-    isImageUploaded.value = true;
-}
-
-// 取消操作
-function cancelForm() {
-    uni.navigateBack();
-}
-
-function submitForm() {
-    if (!form.value.imgUrl || form.value.imgUrl.length === 0) {
-        uni.$u.toast('请先上传图片');
-        return;
-    }
-
-    if (!isImageUploaded.value) {
-        uni.$u.toast('图片正在上传中,请稍候');
-        return;
-    }
-
-    // 这里应该调用实际的API接口
-    uni.$u.http.post('/activation/bookActivationInfo/activationAdd', {
-        isbn: bookInfo.value.isbn,
-        img: form.value.imgUrl[0]
-    }).then(res => {
-        if (res.code == 200) {
-            uni.$u.toast('提交成功')
-            let text = '提交成功,请销毁激活码'
-            uni.$u.ttsModule.speak(text)
-            // 返回上一页
-            uni.navigateBack();
-        } else {
-            let text = '提交失败:' + (res.msg || '未知错误')
-            uni.$u.toast(text)
-            uni.$u.ttsModule.speak(text)
-        }
-    }).catch(err => {
-        uni.$u.ttsModule.speak('网络错误')
-    })
-}
-
-// #ifdef APP-PLUS
-const { unregister } = uni.$u.useEventListener((e) => {
-    form.value.isbn = e.barcode;
-    queryBookInfo(e.barcode);
-});
-// #endif
-
-onUnmounted(() => {
-    // #ifdef APP-PLUS
-    unregister();
-    // #endif
-});
-</script>
-
-<style>
-page {
-    background-color: #ffffff;
-}
-</style>
-
-<style scoped>
-.container {
-    display: flex;
-    flex-direction: column;
-    padding: 20px;
-    min-height: 100vh;
-    background-color: #f5f5f5;
-}
-
-/* 书籍信息展示区域 */
-.book-info-section {
-    display: flex;
-    background-color: white;
-    border-radius: 6px;
-    padding: 20rpx;
-    margin-bottom: 30rpx;
-}
-
-.book-cover {
-    width: 150rpx;
-    /* height: 160rpx; */
-    margin-right: 30rpx;
-    flex-shrink: 0;
-}
-
-.cover-image {
-    width: 100%;
-    height: 100%;
-    border-radius: 8rpx;
-}
-
-.book-details {
-    flex: 1;
-    display: flex;
-    flex-direction: column;
-    justify-content: space-between;
-}
-
-.book-title {
-    font-size: 32rpx;
-    font-weight: bold;
-    color: #333;
-    margin-bottom: 8rpx;
-}
-
-.book-isbn {
-    font-size: 28rpx;
-    color: #666;
-    margin-bottom: 6rpx;
-}
-
-.book-publisher {
-    font-size: 26rpx;
-    color: #666;
-    margin-bottom: 6rpx;
-}
-
-.book-author {
-    font-size: 26rpx;
-    color: #666;
-    margin-bottom: 6rpx;
-}
-
-.book-date {
-    font-size: 24rpx;
-    color: #999;
-}
-
-/* 上传图片区域 */
-.upload-section {
-    background-color: white;
-    border-radius: 12px;
-    padding: 30rpx;
-    margin-bottom: 120rpx;
-}
-
-.upload-label {
-    font-size: 32rpx;
-    font-weight: bold;
-    color: #333;
-    margin-bottom: 20rpx;
-}
-
-.upload-content {
-    display: flex;
-    gap: 30rpx;
-    align-items: flex-start;
-}
-
-/* 提示框样式 */
-.tip-box {
-    display: flex;
-    background-color: #fff3cd;
-    border: 1px solid #ffeaa7;
-    border-radius: 8px;
-    padding: 20rpx;
-    flex: 1;
-    align-items: flex-start;
-}
-
-.tip-number {
-    background-color: #f39c12;
-    color: white;
-    width: 40rpx;
-    height: 40rpx;
-    border-radius: 50%;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    font-size: 24rpx;
-    font-weight: bold;
-    margin-right: 20rpx;
-    flex-shrink: 0;
-}
-
-.tip-content {
-    flex: 1;
-    display: flex;
-    flex-direction: column;
-}
-
-.tip-text {
-    font-size: 24rpx;
-    color: #856404;
-    line-height: 1.4;
-    margin-bottom: 8rpx;
-}
-
-.tip-success {
-    font-size: 24rpx;
-    color: #155724;
-    line-height: 1.4;
-    margin-bottom: 8rpx;
-}
-
-.tip-limit {
-    font-size: 24rpx;
-    color: #856404;
-    line-height: 1.4;
-    margin-bottom: 15rpx;
-}
-
-.tip-author {
-    font-size: 20rpx;
-    color: #6c757d;
-}
+<template>
+	<view class="container">
+		<!-- 书籍信息展示区域 -->
+		<view class="book-info-section" v-if="bookInfo.bookName">
+			<view class="book-cover">
+				<image :src="bookInfo.cover || '/static/img/default-book.png'" class="cover-image" mode="aspectFit" />
+			</view>
+			<view class="book-details">
+				<text class="book-title">{{ bookInfo.bookName }}</text>
+				<text class="book-isbn">{{ bookInfo.isbn }}</text>
+				<text class="book-publisher">{{ bookInfo.publish }}</text>
+				<text class="book-author">{{ bookInfo.author }}</text>
+				<text class="book-date">{{ bookInfo.pubDate }}</text>
+			</view>
+		</view>
+
+		<!-- 上传图片区域 -->
+		<view class="upload-section">
+			<view class="upload-label">上传图片</view>
+			<view class="upload-content">
+				<cy-upload :filename="form.imgUrl" @update:filename="form.imgUrl = $event" @success="onUploadSuccess"
+					name="imgUrl" :maxCount="1" :max-size="1024 * 1024" url="/activation/bookActivationInfo/uploadImg">
+				</cy-upload>
+			</view>
+		</view>
+
+		<!-- 底部按钮 -->
+		<view class="fixed-bottom">
+			<u-button size="large" type="warning" @click="cancelForm" text="取消" class="cancel-button" />
+			<u-button size="large" type="success" @click="submitForm" text="提交" class="submit-button" />
+		</view>
+	</view>
+</template>
+
+<script setup>
+	import {
+		ref,
+		reactive,
+		onUnmounted,
+		nextTick
+	} from 'vue';
+	import {
+		onLoad,
+		onShow
+	} from '@dcloudio/uni-app'
+	import cyUpload from '@/components/cy-upload/index.vue'
+
+	const form = ref({
+		"isbn": "",
+		"imgUrl": ""
+	});
+
+	// 书籍信息
+	const bookInfo = ref({});
+
+	// 图片上传状态
+	const isImageUploaded = ref(false);
+
+	onShow(() => {
+		// 从本地存储获取书籍信息
+		nextTick(() => {
+			const storedInfo = uni.getStorageSync('bookInfo');
+			bookInfo.value = storedInfo
+		})
+	})
+
+	// 图片上传成功回调
+	function onUploadSuccess(result) {
+		console.log('图片上传成功:', result);
+		isImageUploaded.value = true;
+	}
+
+	// 取消操作
+	function cancelForm() {
+		uni.navigateBack();
+	}
+
+	function submitForm() {
+		if (!form.value.imgUrl || form.value.imgUrl.length === 0) {
+			uni.$u.toast('请先上传图片');
+			return;
+		}
+
+		if (!isImageUploaded.value) {
+			uni.$u.toast('图片正在上传中,请稍候');
+			return;
+		}
+
+		// 这里应该调用实际的API接口
+		uni.$u.http.post('/activation/bookActivationInfo/activationAdd', {
+			isbn: bookInfo.value.isbn,
+			img: form.value.imgUrl[0]
+		}).then(res => {
+			if (res.code == 200) {
+				uni.$u.toast('提交成功')
+				let text = '提交成功,请销毁激活码'
+				uni.$u.ttsModule.speak(text)
+				// 返回上一页
+				uni.navigateBack();
+			} else {
+				let text = '提交失败:' + (res.msg || '未知错误')
+				uni.$u.toast(text)
+				uni.$u.ttsModule.speak(text)
+			}
+		}).catch(err => {
+			uni.$u.ttsModule.speak('网络错误')
+		})
+	}
+
+	// #ifdef APP-PLUS
+	const {
+		unregister
+	} = uni.$u.useEventListener((e) => {
+		form.value.isbn = e.barcode;
+		queryBookInfo(e.barcode);
+	});
+	// #endif
+
+	onUnmounted(() => {
+		// #ifdef APP-PLUS
+		unregister();
+		// #endif
+	});
+</script>
+
+<style>
+	page {
+		background-color: #ffffff;
+	}
+</style>
+
+<style scoped>
+	.container {
+		display: flex;
+		flex-direction: column;
+		padding: 20px;
+		min-height: 100vh;
+		background-color: #f5f5f5;
+	}
+
+	/* 书籍信息展示区域 */
+	.book-info-section {
+		display: flex;
+		background-color: white;
+		border-radius: 6px;
+		padding: 20rpx;
+		margin-bottom: 30rpx;
+	}
+
+	.book-cover {
+		width: 150rpx;
+		/* height: 160rpx; */
+		margin-right: 30rpx;
+		flex-shrink: 0;
+	}
+
+	.cover-image {
+		width: 100%;
+		height: 100%;
+		border-radius: 8rpx;
+	}
+
+	.book-details {
+		flex: 1;
+		display: flex;
+		flex-direction: column;
+		justify-content: space-between;
+	}
+
+	.book-title {
+		font-size: 32rpx;
+		font-weight: bold;
+		color: #333;
+		margin-bottom: 8rpx;
+	}
+
+	.book-isbn {
+		font-size: 28rpx;
+		color: #666;
+		margin-bottom: 6rpx;
+	}
+
+	.book-publisher {
+		font-size: 26rpx;
+		color: #666;
+		margin-bottom: 6rpx;
+	}
+
+	.book-author {
+		font-size: 26rpx;
+		color: #666;
+		margin-bottom: 6rpx;
+	}
+
+	.book-date {
+		font-size: 24rpx;
+		color: #999;
+	}
+
+	/* 上传图片区域 */
+	.upload-section {
+		background-color: white;
+		border-radius: 12px;
+		padding: 30rpx;
+		margin-bottom: 120rpx;
+	}
+
+	.upload-label {
+		font-size: 32rpx;
+		font-weight: bold;
+		color: #333;
+		margin-bottom: 20rpx;
+	}
+
+	.upload-content {
+		display: flex;
+		gap: 30rpx;
+		align-items: flex-start;
+	}
+
+	/* 提示框样式 */
+	.tip-box {
+		display: flex;
+		background-color: #fff3cd;
+		border: 1px solid #ffeaa7;
+		border-radius: 8px;
+		padding: 20rpx;
+		flex: 1;
+		align-items: flex-start;
+	}
+
+	.tip-number {
+		background-color: #f39c12;
+		color: white;
+		width: 40rpx;
+		height: 40rpx;
+		border-radius: 50%;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		font-size: 24rpx;
+		font-weight: bold;
+		margin-right: 20rpx;
+		flex-shrink: 0;
+	}
+
+	.tip-content {
+		flex: 1;
+		display: flex;
+		flex-direction: column;
+	}
+
+	.tip-text {
+		font-size: 24rpx;
+		color: #856404;
+		line-height: 1.4;
+		margin-bottom: 8rpx;
+	}
+
+	.tip-success {
+		font-size: 24rpx;
+		color: #155724;
+		line-height: 1.4;
+		margin-bottom: 8rpx;
+	}
+
+	.tip-limit {
+		font-size: 24rpx;
+		color: #856404;
+		line-height: 1.4;
+		margin-bottom: 15rpx;
+	}
+
+	.tip-author {
+		font-size: 20rpx;
+		color: #6c757d;
+	}
 </style>

+ 18 - 5
pages/index/wms/code-storage.vue

@@ -4,8 +4,8 @@
             <view class="input-group">
                 <u-input :customStyle="customStyle" :placeholder-style="placeholderStyle" v-model="form.isbn"
                     placeholder="扫描/输入ISBN" border="surround" />
-                <u-button :customStyle="customStyle" type="info" color="#a4adb3" 
-                    @click="handleBarcode(form.isbn)" text="确定" />
+                <u-button :customStyle="customStyle" type="info" color="#a4adb3" @click="handleBarcode(form.isbn)"
+                    text="确定" />
             </view>
         </view>
 
@@ -47,12 +47,24 @@ function scanCode() {
     });
 }
 
+//isbn正则校验是否符合
+function checkIsbn(isbn) {
+    const isbn13Regex = /^(?:97[89]-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d)$/;
+    if (isbn13Regex.test(isbn)) {
+        return true;
+    }
+    return false;
+}
+
 function handleBarcode(code) {
     if (!code) return uni.$u.toast('请输入ISBN')
-    
+
+    // 验证ISBN格式
+    if (!checkIsbn(code)) {
+        return uni.$u.ttsModule.speak('不是正确的ISBN码')
+    }
+
     // 这里可以添加ISBN查询逻辑
-    uni.$u.toast('ISBN: ' + code);
-    
     uni.$u.http.post('/activation/bookActivationInfo/queryBookBasicByIsbn/' + code).then(res => {
         if (res.code == 200) {
             // 处理查询成功的逻辑
@@ -101,6 +113,7 @@ onUnmounted(() => {
         background-color: #fff;
     }
 }
+
 .scan-button {
     width: 100%;
 }

File diff suppressed because it is too large
+ 0 - 1
unpackage/dist/build/app-plus/app-config-service.js


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/app-service.js


+ 1 - 1
unpackage/dist/build/app-plus/manifest.json

@@ -171,7 +171,7 @@
     "uni-app": {
       "control": "uni-v3",
       "vueVersion": "3",
-      "compilerVersion": "4.75",
+      "compilerVersion": "4.76",
       "nvueCompiler": "uni-app",
       "renderer": "auto",
       "nvue": {

File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/pages/book/index.css


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/pages/index/detail/book-audit.css


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/pages/index/detail/index.css


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/pages/index/express/weight-modify.css


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/pages/index/wms/code-storage-add.css


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/pages/index/wms/code-storage.css


File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/build/app-plus/uni-app-view.umd.js


Some files were not shown because too many files changed in this diff