shish 2 сар өмнө
parent
commit
239a7e85bc

+ 154 - 3
hdApp/src/admin/goods/list.vue

@@ -87,6 +87,7 @@
                   <text @click.stop="printLabel(goodsItem)">打标签</text>
                   <text @click.stop="getStockChange(goodsItem)">库存明细</text>
                   <text @click.stop="editDesc(goodsItem)">编辑简介</text>
+                  <text @click.stop="moreAction(goodsItem)">更多</text>
                 </view>
               </view>
               <!-- 底部占位,避免最后一个商品操作按钮被遮挡 -->
@@ -181,18 +182,43 @@
       </view>
     </view>
 
+    <uni-popup ref="rightShowMore" background-color="#fff" type="center" :animation="true" class="class-popup-style">
+      <view class="action-popup-container">
+        <view class="action-button-item">
+          <button class="action-button" @click="getMyPoster()">生成海报</button>
+        </view>
+        <view class="action-button-item cancel">
+          <button class="action-button cancel" @click="closeRightShow()">取消</button>
+        </view>
+      </view>
+    </uni-popup>
+
+    <uni-popup ref="posterShow" background-color="#fff" type="center" :animation="true" class="class-popup-style">
+      <view class="poster-popup-wrap">
+        <text class="poster-close" @click="closePoster()">×</text>
+        <view class="poster-img-wrap">
+          <image class="poster-img" :src="posterUrl" mode="widthFix" />
+        </view>
+        <view class="poster-save-wrap">
+          <button class="admin-button-com big blue poster-save-btn" @click="downloadImg">保存图片</button>
+        </view>
+      </view>
+    </uni-popup>
+
   </view>
 </template>
 <script>
 import AppSearchModule from "@/components/module/app-search"
 import AppWrapperEmpty from "@/components/app-wrapper-empty"
-import {categoryListInfo,getCategoryToGoods,print,getRise} from "@/api/goods"
+import {categoryListInfo,getCategoryToGoods,print,getRise,getPoster} from "@/api/goods"
+import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
 import { list } from "@/mixins"
 export default {
   name: "list",
   components: {
     AppWrapperEmpty,
-    AppSearchModule
+    AppSearchModule,
+    uniPopup
   },
   mixins: [list],
   data() {
@@ -221,6 +247,8 @@ export default {
         { label: '有库存', value: 1 },
         { label: '没库存', value: 0 }
       ],
+      currentInfo: {},
+      posterUrl: '',
       flowerNumOptions: [
         { label: '6支', value: 6 },
         { label: '9支', value: 9 },
@@ -357,6 +385,45 @@ export default {
     editDesc(item){
       this.$util.pageTo({url: "/admin/goods/picTextAdd-Edit?gId="+item.id+'&name='+item.name})
     },
+    moreAction(item) {
+      this.currentInfo = item
+      this.$refs.rightShowMore.open('top')
+    },
+    closeRightShow() {
+      this.$refs.rightShowMore.close()
+    },
+    closePoster() {
+      this.$refs.posterShow.close()
+    },
+    getMyPoster() {
+      this.closeRightShow()
+      const that = this
+      uni.showLoading({ mask: true })
+      getPoster({ id: this.currentInfo.id, env_version: this.$util.getMiniEnvVersion() }).then(res => {
+        uni.hideLoading()
+        if (res.code == 1) {
+          that.posterUrl = res.data.imgUrl
+          that.$refs.posterShow.open('top')
+        }
+      })
+    },
+    downloadImg() {
+      const that = this
+      uni.downloadFile({
+        url: this.posterUrl,
+        success: (res) => {
+          if (res.statusCode === 200) {
+            uni.saveImageToPhotosAlbum({
+              filePath: res.tempFilePath,
+              success() {
+                that.$refs.posterShow.close()
+                uni.showToast({ title: '保存成功' })
+              }
+            })
+          }
+        }
+      })
+    },
     goBottom(){
       if (!this.list.finished) {
         this.getGoodsList().then((res) => {
@@ -584,11 +651,13 @@ page {
         width: 96%;
         margin-top: 16upx;
         color: rgb(180, 178, 178);
+        flex-wrap: wrap;
+        gap: 12upx 0;
         text{
           border:1px solid rgb(196, 193, 193);
           border-radius: 15upx;
           font-size:22upx;
-          padding:12upx 25upx 12upx 25upx;
+          padding:12upx 18upx;
         }
       }
       .img-blo {
@@ -957,4 +1026,86 @@ page {
     }
   }
 }
+
+.class-popup-style {
+  z-index: 999999;
+}
+
+.action-popup-container {
+  display: grid;
+  grid-template-columns: 1fr 1fr;
+  gap: 24upx;
+  padding: 50upx 40upx 60upx 40upx;
+  max-height: 99vh;
+  overflow-y: auto;
+  width: 92vw;
+  max-width: 650upx;
+  margin: 0 auto;
+
+  .action-button-item.cancel {
+    grid-column: 1 / -1;
+    margin-top: 30upx;
+  }
+}
+
+.action-button {
+  width: 100%;
+  height: 120upx;
+  border: 2upx solid #d0d7de;
+  border-radius: 16upx;
+  background: #ffffff;
+  color: #24292f;
+  font-size: 34upx;
+  font-weight: 600;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+
+  &.cancel {
+    background: #f6f8fa;
+    color: #656d76;
+    font-size: 32upx;
+  }
+}
+
+.poster-popup-wrap {
+  display: flex;
+  width: 100vw;
+  padding: 20upx 20upx 40upx;
+  flex-direction: column;
+  align-items: center;
+  max-height: 100vh;
+  overflow: auto;
+  position: relative;
+}
+
+.poster-close {
+  position: absolute;
+  right: 50upx;
+  top: 10upx;
+  font-size: 70upx;
+  line-height: 1;
+}
+
+.poster-img-wrap {
+  width: 100%;
+  text-align: center;
+  margin-top: 75upx;
+}
+
+.poster-img {
+  width: 70%;
+  margin: 0 auto;
+  border: 1upx solid #cccccc;
+}
+
+.poster-save-wrap {
+  width: 100%;
+  margin-top: 65upx;
+  text-align: center;
+}
+
+.poster-save-btn {
+  width: 300upx;
+}
 </style>

+ 2 - 2
hdApp/src/admin/item/list2.vue

@@ -438,7 +438,7 @@ export default {
 			this.closeRightShow()
 			let that = this
 			uni.showLoading({mask:true})
-			getPoster({id:this.currentInfo.id}).then(res=>{
+			getPoster({ id: this.currentInfo.id, env_version: this.$util.getMiniEnvVersion() }).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
 					that.posterUrl = res.data.imgUrl
@@ -450,7 +450,7 @@ export default {
 			this.closeRightShow()
 			let that = this
 			uni.showLoading({mask:true})
-			getPoster({id:this.currentInfo.id}).then(res=>{
+			getPoster({ id: this.currentInfo.id, env_version: this.$util.getMiniEnvVersion() }).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
 					that.posterUrl = res.data.imgUrl

+ 4 - 0
hdApp/src/api/goods/index.js

@@ -19,6 +19,10 @@ export const getDetail = data => {
 	return https.get('/goods/detail', data)
 }
 
+export const getPoster = data => {
+	return https.get('/goods/get-poster', data)
+}
+
 
 export const getPlantCg = async data => {
 	return https.get("/plant-cg/list", data);

+ 7 - 1
hdApp/src/utils/util.js

@@ -553,6 +553,11 @@ export async function callUp(mobile){
 	//#endif
 }
 
+/** 海报/太阳码:开发构建用 develop,正式构建用 release */
+export const getMiniEnvVersion = () => {
+	return process.env.NODE_ENV === 'development' ? 'develop' : 'release'
+}
+
 export default {
 	isEmpty,
 	copyObject,
@@ -575,5 +580,6 @@ export default {
 	hitRemind,
 	noStockRemind,
 	callUp,
-	afterAppLoginSuccess
+	afterAppLoginSuccess,
+	getMiniEnvVersion
 };

+ 44 - 36
mallApp/src/pages/goods/detail.vue

@@ -95,6 +95,7 @@ import SelPopup from "./components/sel-popup.vue";
 import { share } from "@/mixins";
 import { mapGetters } from "vuex";
 import { getDetail } from "@/api/goods";
+import { getHdInfo } from "@/api/hd";
 import RichMediaViewer from "@/components/RichMediaViewer/index.vue";
 export default {
   name: "detail",
@@ -122,36 +123,15 @@ export default {
       shopInfo: {},
     };
   },
-  onLoad(option) {
-    // 兼容旧版本通过 options 传递参数
-    if (Object.keys(option).length > 0) {
-      this.initializeOption(option);
-      // 如果是普通路由跳转,直接获取商品信息
-      this.getGoodsInfo();
-      this.hdId = this.option.hdId || 0;
-      this.account = this.option.account || 0;
-    }
-
+  onLoad() {
     const eventChannel = this.getOpenerEventChannel();
     eventChannel.on('acceptDataFromChatPage', (data) => {
-      console.log("---------- detail data: ", data);
-      // 兼容
-      if (Object.keys(option).length == 0) {
-        this.option = {...data};
-        this.hdId = this.option.hdId || 0;
-        this.account = this.option.account || 0;
+      if (!this.option || Object.keys(this.option).length === 0) {
+        this.option = { ...data };
       }
       this.initializeChatPage(data);
-      // eventChannel 执行完成后,获取商品信息
-      this.getGoodsInfo();
+      this.loadGoodsDetail();
     });
-
-    // this.hdId = this.option.hdId ? this.option.hdId : 0;
-    // this.account = this.option.account ? this.option.account : 0;
-    // if (option.shopId || option.goodsId) {
-    //   console.log("---------- option: ", option);
-    //   this.shopInfo = option;
-    // }
   },
   onPageScroll(e) {
     // console.log('Scroll position:', parseInt(e.scrollTop))
@@ -172,6 +152,25 @@ export default {
   },
   methods: {
     init() {
+      if (!this.option || !this.option.id) {
+        return;
+      }
+      this.initializeOption(this.option);
+      this.hdId = this.option.hdId || 0;
+      this.account = this.option.account || 0;
+      const id = Number(this.option.id) || 0;
+      const account = Number(this.option.account) || 0;
+      if (id > 0 && account > 0) {
+        uni.setStorageSync('account', account);
+        getHdInfo().then((res) => {
+          if (res.code == 1 && res.data.hd && res.data.hd.id) {
+            this.hdId = res.data.hd.id;
+          }
+          this.loadGoodsDetail();
+        });
+        return;
+      }
+      this.loadGoodsDetail();
     },
 
     initializeOption(option) {
@@ -216,8 +215,7 @@ export default {
         { key: 'hdId', type: 'positiveNumber' },
         { key: 'account', type: 'positiveNumber' },
         { key: 'shopId', type: 'positiveNumber' },
-        { key: 'id', type: 'positiveNumber' }, // 商品id
-        { key: 'categoryId', type: 'positiveNumber' },
+        { key: 'id', type: 'positiveNumber' },
         { key: 'name', type: 'nonEmpty' },
         { key: 'avatar', type: null }
       ];
@@ -266,25 +264,22 @@ export default {
         );
       }
     },
-    getGoodsInfo() {
-      console.log("---------- this.option: ", this.option);
+    loadGoodsDetail() {
       const id = parseInt(this.option.id);
       if (isNaN(id) || id <= 0) {
         this.$msg("商品id数据异常");
         return;
       }
 
-      const categoryId = parseInt(this.option.categoryId);
-      if (isNaN(categoryId) || categoryId <= 0) {
-        this.$msg("商品分类数据异常");
-        return;
-      }
+      const categoryId = parseInt(this.option.categoryId) || 0;
+      const account = this.option.account || uni.getStorageSync('account') || 0;
+      const hdId = this.hdId || this.option.hdId || 0;
 
       getDetail({
         id: id,
         categoryId: categoryId,
-        account: this.option.account,
-        hdId: this.option.hdId,
+        account: account,
+        hdId: hdId,
       }).then((res) => {
         // console.log('商品数据加载成功:', res.data)
         if (this.$util.isEmpty(res.data)) {
@@ -315,6 +310,19 @@ export default {
         content = (res.data.picText && res.data.picText.content) || "[]";
         this.common_previewContent =
           typeof content === "string" ? JSON.parse(content) : content || [];
+
+        const sharePrice = res.data.priceType == 1
+          ? (res.data.price ? parseFloat(res.data.price).toFixed(2) : 0)
+          : '面议';
+        const shareParams = {
+          title: (res.data.name || '') + ' ¥' + sharePrice,
+          desc: sharePrice,
+          imgUrl: res.data.cover || res.data.smallCover || '',
+          pagePath: `pages/goods/detail?id=${id}&account=${account}`
+        };
+        if (typeof this.jweixinFn === 'function') {
+          this.jweixinFn(shareParams);
+        }
       });
     },
     // 更换数量