shish 9 hónapja
szülő
commit
2338377c6b
3 módosított fájl, 82 hozzáadás és 103 törlés
  1. 9 102
      hdApp/src/admin/goods/add.vue
  2. 71 0
      hdApp/src/admin/goods/result.vue
  3. 2 1
      hdApp/src/pages.json

+ 9 - 102
hdApp/src/admin/goods/add.vue

@@ -1,12 +1,5 @@
 <template>
   <view class="app-content">
-    <!-- 加载状态 -->
-    <!-- <view v-if="loading" class="loading-overlay">
-      <view class="loading-content">
-        <view class="loading-spinner"></view>
-        <text class="loading-text">加载中...</text>
-      </view>
-    </view> -->
     
     <form @submit="commitForm">
       <view class="module-com input-line-wrap">
@@ -127,8 +120,8 @@
       </view>
 
       <view class="app-footer">
-        <button class="admin-button-com middle default" @click="goBack" :disabled="loading">取消</button>
-        <button class="admin-button-com middle blue" formType="submit" :disabled="loading">{{ loading ? '保存中...' : '保存' }}</button>
+        <button class="admin-button-com middle default" @click="goBack">取消</button>
+        <button class="admin-button-com middle blue" formType="submit" >保存</button>
       </view>
 
     </form>
@@ -142,18 +135,16 @@ import { getClass } from "@/api/category";
 import { addGoodsData } from "@/api/goods"
 import { delImage } from "@/api/pic-text";
 import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
-//import productMins from "@/mixins/product"; //复制页面代码时,没去掉
 import inputRestore from "@/mixins/inputRestore";
 export default {
   name: "add",
   components: { TuiListCell, AppUploader,htzImageUpload },
-	mixins: [inputRestore], //productMins, 
+	mixins: [inputRestore], 
   data() {
     return {
       headers:{token:''},
       status: 1,
 			selectJobType: "addGoodsSelectItem",
-      loading: false, // 新增加载状态
       form: {
         name: "",
         price: "",
@@ -270,16 +261,10 @@ export default {
       }
     },
     init() {
-      this.loading = true;
       getClass().then(res => {
         if(res.code && res.code == 1){
           this.categoryData = res.data
         }
-      }).catch(err => {
-        console.error('获取分类失败:', err);
-        this.$msg('获取分类信息失败');
-      }).finally(() => {
-        this.loading = false;
       })
     },
     // 封面选择
@@ -362,7 +347,6 @@ export default {
       }
       
       that.$util.confirmModal({content:'确认添加?'},() => {
-        this.loading = true; // 开始加载
         uni.showLoading({mask:true})
         let formData = JSON.parse(JSON.stringify(this.form));
         
@@ -382,55 +366,18 @@ export default {
         if(formData.stockSet === '0'){
           formData.stock = 9999;
         }
-        
         addGoodsData({ status: this.status, ...formData }).then(res => {
           uni.hideLoading()
-          // this.removeFromSaveDirect()
-          
-          // 把新增的商品添加到商品列表页的商品数组的第一项
-          if (res.code === 1 && res.data) {
-            try {
-              let pages = getCurrentPages();
-              let prevPage = pages[pages.length - 2];
-              if (prevPage && prevPage.$vm && prevPage.$vm.list && prevPage.$vm.list.data) {
-                // 构造新商品数据,确保包含显示需要的字段
-                const newGoodsItem = {
-                  id: res.data.id || res.data.goodsId,
-                  name: formData.name,
-                  price: formData.priceType === '1' ? parseFloat(formData.price || 0) : 0,
-                  priceType: parseInt(formData.priceType),
-                  stock: formData.stockSet === '1' ? parseInt(formData.stock || 0) : 9999,
-                  actualSold: 0,
-                  smallCover: this.currentImgData.length > 0 ? this.currentImgData[this.form.shopImg.findIndex(img => img === this.form.shortCover)] || this.currentImgData[0] : '',
-                  ...res.data
-                };
-                // 将新商品添加到列表第一项
-                prevPage.$vm.list.data.unshift(newGoodsItem);
-                prevPage.$vm.list.total = (prevPage.$vm.list.total || 0) + 1;
-              }
-              this.$msg("添加成功")
-            } catch (error) {
-              console.log('更新列表页数据失败:', error);
-            }
+          if (res.code === 1) {
+              let id = res.data.id?res.data.id:0
+              let name = res.data.name?res.data.name:''
+              that.pageTo({url:'/admin/goods/result?id='+id+'&name='+name})
           }
-          
-          setTimeout(function(){
-            uni.navigateBack({})
-          },1500)
-        }).catch(err => {
-          uni.hideLoading()
-          this.$msg(err.msg || '添加失败')
-        }).finally(() => {
-          this.loading = false; // 结束加载
         })
       })
     },
     commitForm(e) {
-      // 防止重复提交
-      if (this.loading) {
-        return;
-      }
-      
+   
       let rules = [
         {
           name: "name",
@@ -493,9 +440,7 @@ export default {
       let formData = e.detail.value;
       let checkRes = form.validation(formData, rules);
       if (!checkRes) {
-        setTimeout(() => {
-          this.confirmFn();
-        });
+         this.confirmFn();
       } else {
         this.$msg(checkRes);
       }
@@ -533,44 +478,6 @@ export default {
   padding-bottom: 100upx;
 }
 
-/* 加载状态样式 */
-.loading-overlay {
-  position: fixed;
-  top: 0;
-  left: 0;
-  right: 0;
-  bottom: 0;
-  background-color: rgba(0, 0, 0, 0.5);
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  z-index: 999999;
-}
-
-.loading-content {
-  background-color: #fff;
-  border-radius: 20upx;
-  padding: 40upx;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-}
-
-.loading-spinner {
-  width: 60upx;
-  height: 60upx;
-  border: 4upx solid #f3f3f3;
-  border-top: 4upx solid #09C567;
-  border-radius: 50%;
-  animation: spin 1s linear infinite;
-  margin-bottom: 20upx;
-}
-
-.loading-text {
-  font-size: 28upx;
-  color: #666;
-}
-
 @keyframes spin {
   0% { transform: rotate(0deg); }
   100% { transform: rotate(360deg); }

+ 71 - 0
hdApp/src/admin/goods/result.vue

@@ -0,0 +1,71 @@
+<template>
+	<view class="app-content">
+		<view class="billing_box_bg">
+			<view class="top-view"> </view>
+			<view class="result-view">
+				<view class="iconfont iconchenggong"></view>
+				<view class="result-title">添加成功</view>
+			</view>
+		</view>
+	</view>
+</template>
+<script>
+export default {
+    name: "result",
+	methods: {
+		init(){
+
+		},
+		goBackHome() {
+			uni.navigateBack({})
+		}
+	}
+};
+</script>
+<style lang="scss" scoped>
+.go-back{
+	width: 80%;
+	height: 80upx;
+	color: #FFFFFF;
+	margin-top: 50upx;
+	background: #3385FF;
+	border-radius: 10upx;
+	font-size:30upx;
+}
+.billing_box_bg {
+	position: relative;
+	padding: 60upx 30upx;
+	display: flex;
+	background: white;
+	flex-direction: column;
+    background-color: #f5f5f5;
+	.top-view {
+		position: absolute;
+		top: 0;
+		left: 0;
+		width: 100%;
+		height: 299upx;
+		background: #3385ff;
+		border-radius: 0upx 0upx 83upx 83upx;
+	}
+	.result-view {
+		position: relative;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		padding: 70upx;
+		width: 100%;
+		background: #ffffff;
+		border-radius: 20upx;
+		z-index: 1;
+		.iconchenggong {
+			font-size: 100upx;
+			color: $mainColor1;
+		}
+		.result-title {
+			margin: 20upx 0 70upx;
+			font-size: 32upx;
+		}
+	}
+}
+</style>

+ 2 - 1
hdApp/src/pages.json

@@ -319,7 +319,8 @@
 				{ "path": "pdGoodsDetail", "style": { "navigationBarTitleText": "详情" } },
 				{ "path": "categorySort", "style": { "navigationBarTitleText": "排序" } },
 				{ "path": "goodsSort", "style": { "navigationBarTitleText": "排序" } },
-				{ "path": "picTextAdd-Edit", "style": { "navigationBarTitleText": "创建简介" } }
+				{ "path": "picTextAdd-Edit", "style": { "navigationBarTitleText": "创建简介" } },
+				{ "path": "result", "style": { "navigationBarTitleText": "添加成功" }}
 			]
 		},
 		{