shish 2 месяцев назад
Родитель
Сommit
8bfc3fb609
1 измененных файлов с 58 добавлено и 0 удалено
  1. 58 0
      hdApp/src/admin/goods/list.vue

+ 58 - 0
hdApp/src/admin/goods/list.vue

@@ -184,6 +184,9 @@
 
     <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="shareGoods()">分享到微信</button>
+        </view>
         <view class="action-button-item">
           <button class="action-button" @click="getMyPoster()">分享海报</button>
         </view>
@@ -201,9 +204,11 @@
 import AppSearchModule from "@/components/module/app-search"
 import AppWrapperEmpty from "@/components/app-wrapper-empty"
 import {categoryListInfo,getCategoryToGoods,print,getRise,getPoster} from "@/api/goods"
+import { getWeixinId } from "@/api/invite"
 import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
 import ItemPosterPopup from '@/components/item-poster-popup.vue'
 import { list } from "@/mixins"
+import { mapGetters } from "vuex"
 export default {
   name: "list",
   components: {
@@ -241,6 +246,7 @@ export default {
       ],
       currentInfo: {},
       posterUrl: '',
+      getAppIdList: {},
       flowerNumOptions: [
         { label: '6支', value: 6 },
         { label: '9支', value: 9 },
@@ -255,12 +261,19 @@ export default {
   },
 
   computed: {
+    ...mapGetters({ loginInfo: "getLoginInfo", dictInfo: "getDictionariesInfo" }),
     // 检查是否有活跃的筛选条件
     hasActiveFilters() {
       return this.flowerNum != 0 || this.hasStock!=-1
     }
   },
 
+  onLoad() {
+    getWeixinId().then(res => {
+      this.getAppIdList = res.data
+    })
+  },
+
   onShow() {
     // 检查是否需要刷新数据
     const shouldRefresh = uni.getStorageSync('goods_list_refresh');
@@ -384,6 +397,51 @@ export default {
     closeRightShow() {
       this.$refs.rightShowMore.close()
     },
+    shareGoods() {
+      const that = this
+      const id = this.currentInfo.id
+      this.closeRightShow()
+      const sharePath = 'pages/goods/detail?shopId=' + that.loginInfo.shopId + '&ghsShopAdminId=' + that.loginInfo.shopAdminId + '&id=' + id
+      // #ifdef MP-WEIXIN
+      uni.navigateToMiniProgram({
+        appId: that.getAppIdList.mall.miniAppId,
+        path: sharePath,
+        envVersion: process.env.NODE_ENV === 'development' ? 'develop' : 'release',
+        extraData: {
+          shopId: that.loginInfo.shopId,
+          id: 0,
+          name: ''
+        },
+        success() {}
+      })
+      // #endif
+      // #ifdef APP-PLUS
+      if (plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
+        plus.share.getServices(function(s) {
+          let sweixin
+          for (let i = 0; i < s.length; i++) {
+            if (s[i].id == 'weixin') {
+              sweixin = s[i]
+            }
+          }
+          const miniOriginalId = that.dictInfo.miniOriginalId && that.dictInfo.miniOriginalId.current && that.dictInfo.miniOriginalId.current.mall ? that.dictInfo.miniOriginalId.current.mall : ''
+          if (sweixin) {
+            sweixin.launchMiniProgram({
+              id: miniOriginalId,
+              path: sharePath,
+              type: 0
+            })
+          } else {
+            that.$msg('没有找到微信服务')
+          }
+        }, function() {
+          that.$msg('没有找到微信服务哦')
+        })
+      } else {
+        this.$msg('请安装微信,再打开小程序')
+      }
+      // #endif
+    },
     closePoster() {
       this.$refs.itemPosterPopup.close()
     },