Browse Source

更新会员分享

lex 2 years ago
parent
commit
03ce011b30

+ 14 - 0
src/teacher/share-page/share-vip/index.module.less

@@ -142,6 +142,20 @@
     }
     }
   }
   }
 
 
+  .tagDiscount {
+    position: absolute;
+    top: -14px;
+    right: 55px;
+    padding: 2px 12px;
+    height: 23px;
+    background: linear-gradient(180deg, #ffb635 0%, #ff4e18 100%);
+    border-radius: 8px 8px 0px 0px;
+    font-size: 14px;
+    font-weight: 600;
+    color: #ffffff;
+    line-height: 24px;
+  }
+
   .wxpopup {
   .wxpopup {
     width: 100%;
     width: 100%;
     height: 100vh;
     height: 100vh;

+ 28 - 12
src/teacher/share-page/share-vip/index.tsx

@@ -1,13 +1,15 @@
 import ColHeader from '@/components/col-header'
 import ColHeader from '@/components/col-header'
-import { Button, Cell, Icon, Image, Popup, Toast } from 'vant'
+import { Button, Cell, Dialog, Icon, Image, Popup, Toast } from 'vant'
 import { defineComponent } from 'vue'
 import { defineComponent } from 'vue'
 import styles from './index.module.less'
 import styles from './index.module.less'
 import request from '@/helpers/request'
 import request from '@/helpers/request'
 import { state } from '@/state'
 import { state } from '@/state'
 import shareBanner from '../images/share-banner.png'
 import shareBanner from '../images/share-banner.png'
 import wxImage from '../images/wx_bg.png'
 import wxImage from '../images/wx_bg.png'
-import { shareCall } from '../share'
+import { shareCall, initJumpNativePage } from '../share'
 import { browser } from '@/helpers/utils'
 import { browser } from '@/helpers/utils'
+import { postMessage } from '@/helpers/native-message'
+import qs from 'query-string'
 
 
 export const getAssetsHomeFile = (fileName: string) => {
 export const getAssetsHomeFile = (fileName: string) => {
   const path = `../../../views/member-center/images/${fileName}`
   const path = `../../../views/member-center/images/${fileName}`
@@ -19,11 +21,16 @@ export default defineComponent({
   name: 'MemberCenter',
   name: 'MemberCenter',
   data() {
   data() {
     const query = this.$route.query
     const query = this.$route.query
+    const tmpUrl = `${location.origin}/student/#/memberCenter?${qs.stringify(
+      query
+    )}`
     return {
     return {
       activityId: query.activityId,
       activityId: query.activityId,
       recomUserId: query.recomUserId,
       recomUserId: query.recomUserId,
+      discount: 0,
       functionList: [],
       functionList: [],
-      wxStatus: false
+      wxStatus: false,
+      jumpUrl: tmpUrl
     }
     }
   },
   },
   computed: {
   computed: {
@@ -40,6 +47,9 @@ export default defineComponent({
       }
       }
     }
     }
   },
   },
+  created() {
+    initJumpNativePage(this.jumpUrl)
+  },
   async mounted() {
   async mounted() {
     try {
     try {
       const res = await request.post(
       const res = await request.post(
@@ -52,24 +62,24 @@ export default defineComponent({
           icon: getAssetsHomeFile(`${item.paramValue}.png`)
           icon: getAssetsHomeFile(`${item.paramValue}.png`)
         }
         }
       })
       })
+
+      const active = await request.post(
+        `/api-teacher/open/activity/state/${this.activityId}`
+      )
+      this.discount = active.data.check || 0
     } catch {
     } catch {
       //
       //
     }
     }
   },
   },
   methods: {
   methods: {
-    reCall() {
-      const { origin } = location
-      let str = origin + '/student/#/memberCenter'
-      const params = this.$route.query
-      str += `?recomUserId=${this.recomUserId}&activityId=${params.activityId}`
-      shareCall(str, {})
-    },
     onShare() {
     onShare() {
       if (browser().weixin) {
       if (browser().weixin) {
         this.wxStatus = true
         this.wxStatus = true
         return
         return
       }
       }
-      this.reCall()
+      // 尝试拉起app
+      shareCall(this.jumpUrl)
+      // 不管有没有拉起app则都跳转到下载app
       setTimeout(() => {
       setTimeout(() => {
         window.location.href = location.origin + '/student/#/download'
         window.location.href = location.origin + '/student/#/download'
       }, 3000)
       }, 3000)
@@ -102,7 +112,13 @@ export default defineComponent({
             </div>
             </div>
           )}
           )}
         </div>
         </div>
-        <div class={['btnGroup']} style={{ paddingTop: '12px' }}>
+        <div
+          class={['btnGroup']}
+          style={{ paddingTop: '12px', position: 'relative' }}
+        >
+          {this.discount === 1 && (
+            <div class={styles.tagDiscount}>专属优惠</div>
+          )}
           <Button
           <Button
             block
             block
             round
             round

+ 43 - 3
src/teacher/share-page/share.ts

@@ -1,11 +1,14 @@
-import { Toast } from 'vant'
+import { Toast, Dialog } from 'vant'
+import { postMessage } from '@/helpers/native-message'
+import { browser } from '@/helpers/utils'
+import { state } from '@/state'
 
 
 // share information
 // share information
 export const shareCall = (str: string, params?: any) => {
 export const shareCall = (str: string, params?: any) => {
   const query = {
   const query = {
     url: str,
     url: str,
-    action: params.action || 'h5', // app, h5
-    pageTag: params.pageTag || 1 // 页面标识
+    action: params?.action || 'h5', // app, h5
+    pageTag: params?.pageTag || 1 // 页面标识
     // params: {}
     // params: {}
   }
   }
   const iosStr = encodeURIComponent(JSON.stringify(query))
   const iosStr = encodeURIComponent(JSON.stringify(query))
@@ -51,3 +54,40 @@ export const appDownload = () => {
   }
   }
   transfer(failed)
   transfer(failed)
 }
 }
+
+// 页面跳转原生页面
+export const initJumpNativePage = (url: string) => {
+  if (browser().isApp) {
+    if (state.platformType === 'STUDENT') {
+      // 自动跳转到学生端视频课详情购买页
+      window.location.replace(url)
+      // 为了处理andoird webview的跳转问题
+      if (browser().ios) {
+        window.location.replace(url)
+      } else {
+        postMessage({
+          api: 'openWebView',
+          content: {
+            url,
+            orientation: 1,
+            isHideTitle: false
+          }
+        })
+
+        postMessage({ api: 'back' })
+      }
+      return
+    } else if (state.platformType === 'TEACHER') {
+      Dialog.alert({
+        title: '提示',
+        message: '请使用酷乐秀学生端扫码打开',
+        confirmButtonColor: '#2dc7aa'
+      }).then(() => {
+        postMessage({ api: 'back' })
+      })
+    }
+  } else {
+    // 如果不在app里面则不需要唤起操作
+    shareCall(url)
+  }
+}