Browse Source

Merge branch 'other-app-home' into jenkins

lex 2 years ago
parent
commit
fc1c760e4c

+ 11 - 0
package-lock.json

@@ -16,6 +16,7 @@
         "clean-deep": "^3.4.0",
         "dayjs": "^1.10.7",
         "echarts": "^5.3.3",
+        "eventemitter3": "^5.0.0",
         "html-to-image": "^1.9.0",
         "html2canvas": "^1.4.1",
         "loaders.css": "^0.1.2",
@@ -4747,6 +4748,11 @@
         "node": ">=0.10.0"
       }
     },
+    "node_modules/eventemitter3": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-5.0.0.tgz",
+      "integrity": "sha512-riuVbElZZNXLeLEoprfNYoDSwTBRR44X3mnhdI1YcnENpWTCsTTVZ2zFuqQcpoyqPQIUXdiPEU0ECAq0KQRaHg=="
+    },
     "node_modules/execa": {
       "version": "5.1.1",
       "resolved": "https://registry.npmmirror.com/execa/-/execa-5.1.1.tgz",
@@ -13007,6 +13013,11 @@
       "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
       "dev": true
     },
+    "eventemitter3": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-5.0.0.tgz",
+      "integrity": "sha512-riuVbElZZNXLeLEoprfNYoDSwTBRR44X3mnhdI1YcnENpWTCsTTVZ2zFuqQcpoyqPQIUXdiPEU0ECAq0KQRaHg=="
+    },
     "execa": {
       "version": "5.1.1",
       "resolved": "https://registry.npmmirror.com/execa/-/execa-5.1.1.tgz",

+ 1 - 0
package.json

@@ -28,6 +28,7 @@
     "clean-deep": "^3.4.0",
     "dayjs": "^1.10.7",
     "echarts": "^5.3.3",
+    "eventemitter3": "^5.0.0",
     "html-to-image": "^1.9.0",
     "html2canvas": "^1.4.1",
     "loaders.css": "^0.1.2",

+ 25 - 7
src/student/home-layout-orchestra/auth-login.tsx

@@ -8,6 +8,7 @@ import logo from '@common/images/logo.png'
 import ColPopup from '@/components/col-popup'
 import InviteCode from './invite-code'
 import { state } from '@/state'
+import request from '@/student/home-layout-orchestra/request-home'
 
 export default defineComponent({
   name: 'login-music',
@@ -23,7 +24,6 @@ export default defineComponent({
   },
   methods: {
     onLoginSuccess() {
-      // console.log('1111111---1-1-')
       // 调用原生api去关联账号
       postMessage({ api: 'bindUserAccount', content: { phone: this.username } })
       // 登录成功
@@ -37,6 +37,26 @@ export default defineComponent({
         window.location.reload()
         // }, 100)
       }, 1000)
+    },
+    async onLogin() {
+      try {
+        const res = await request.post('/api-auth/smsLogin', {
+          requestType: 'form',
+          data: {
+            clientId: 'student',
+            clientSecret: 'student',
+            phone: this.username,
+            token: state.orchestraInfo.token,
+            isSurportRegister: true
+          }
+        })
+
+        const { authentication } = res.data
+        setAuth(authentication.token_type + ' ' + authentication.access_token)
+        this.onLoginSuccess()
+      } catch {
+        //
+      }
     }
   },
   render() {
@@ -63,11 +83,9 @@ export default defineComponent({
             round
             color="#FF8057"
             class={styles.btn}
-            onClick={() => {
-              this.imgCodeStatus = true
-            }}
+            onClick={this.onLogin}
           >
-            登录
+            授权登录
           </Button>
 
           <span
@@ -80,14 +98,14 @@ export default defineComponent({
           </span>
         </div>
 
-        <ColPopup v-model={this.imgCodeStatus}>
+        {/* <ColPopup v-model={this.imgCodeStatus}>
           {this.imgCodeStatus && (
             <InviteCode
               phone={this.username}
               onLoginSuccess={this.onLoginSuccess}
             />
           )}
-        </ColPopup>
+        </ColPopup> */}
       </div>
     )
   }

+ 20 - 1
src/student/home-layout-orchestra/auth.tsx

@@ -1,6 +1,6 @@
 import { defineComponent } from 'vue'
 import styles from './index.module.less'
-import { state, setLogin, setLogout, setLoginError } from './state-orchestra'
+import { state, setLogin, setLogout, setLoginError } from '@/state'
 import { browser } from '@/helpers/utils'
 import { setAuth } from './utils'
 import { RouterView } from 'vue-router'
@@ -47,7 +47,26 @@ export default defineComponent({
       console.log('state.user', state.user)
       if (state.user.status === 'init' || state.user.status === 'error') {
         this.loading = true
+
         try {
+          // 判断是否已经有关联编号
+          if (state.orchestraInfo.unionId) {
+            const res = await request.post('/api-auth/smsLogin', {
+              requestType: 'form',
+              data: {
+                clientId: 'student',
+                clientSecret: 'student',
+                phone: state.orchestraInfo.phone,
+                token: state.orchestraInfo.token,
+                isSurportRegister: true
+              }
+            })
+            const { authentication } = res.data
+            setAuth(
+              authentication.token_type + ' ' + authentication.access_token
+            )
+          }
+
           const res = await request.get('/api-student/student/queryUserInfo', {
             initRequest: true, // 初始化接口
             requestType: 'form'

+ 15 - 12
src/student/home/components/hot-album/index.tsx

@@ -6,6 +6,7 @@ import IconXinActive from '@/common/images/icon-xin-active.png'
 import TheTitle from '../the-title'
 import { openDefaultWebView } from '@/student/home-layout-orchestra/state-orchestra'
 import { useRouter } from 'vue-router'
+import event from '../../event'
 
 export default defineComponent({
   name: 'hot-album',
@@ -23,10 +24,11 @@ export default defineComponent({
           <TheTitle
             title="热门专辑"
             onDetail={() => {
-              const url = location.origin + location.pathname + '#/music-album'
-              openDefaultWebView(url, () => {
-                router.push('/music-album')
-              })
+              // const url = location.origin + location.pathname + '#/music-album'
+              // openDefaultWebView(url, () => {
+              //   router.push('/music-album')
+              // })
+              event.emit('downloadApp')
             }}
           />
         )}
@@ -37,14 +39,15 @@ export default defineComponent({
               class={styles.album}
               key={item.id}
               onClick={() => {
-                const url =
-                  location.origin +
-                  location.pathname +
-                  '#/music-album-detail/' +
-                  item.id
-                openDefaultWebView(url, () => {
-                  router.push('/music-album-detail/' + item.id)
-                })
+                // const url =
+                //   location.origin +
+                //   location.pathname +
+                //   '#/music-album-detail/' +
+                //   item.id
+                // openDefaultWebView(url, () => {
+                //   router.push('/music-album-detail/' + item.id)
+                // })
+                event.emit('downloadApp')
               }}
             >
               <div class={styles.main}>

+ 21 - 19
src/student/home/components/info-list/index.tsx

@@ -7,6 +7,7 @@ import { Cell, CellGroup, Image, List } from 'vant'
 import { defineComponent, reactive } from 'vue'
 import { useRouter } from 'vue-router'
 import styles from './index.module.less'
+import event from '../../event'
 
 export default defineComponent({
   name: 'info-list',
@@ -65,26 +66,27 @@ export default defineComponent({
                 <Cell
                   valueClass={styles.valueContent}
                   onClick={() => {
-                    let url =
-                      location.origin +
-                      location.pathname +
-                      '#/specialDetail?id=' +
-                      item.id
+                    // let url =
+                    //   location.origin +
+                    //   location.pathname +
+                    //   '#/specialDetail?id=' +
+                    //   item.id
 
-                    if (verifyUrl(item.linkUrl)) {
-                      openDefaultWebView(item.linkUrl, () => {
-                        window.location.href = item.linkUrl
-                      })
-                    } else {
-                      openDefaultWebView(url, () => {
-                        router.push({
-                          path: '/specialDetail',
-                          query: {
-                            id: item.id
-                          }
-                        })
-                      })
-                    }
+                    // if (verifyUrl(item.linkUrl)) {
+                    //   openDefaultWebView(item.linkUrl, () => {
+                    //     window.location.href = item.linkUrl
+                    //   })
+                    // } else {
+                    //   openDefaultWebView(url, () => {
+                    //     router.push({
+                    //       path: '/specialDetail',
+                    //       query: {
+                    //         id: item.id
+                    //       }
+                    //     })
+                    //   })
+                    // }
+                    event.emit('downloadApp')
                   }}
                 >
                   {{

+ 7 - 5
src/student/home/components/menu-list/index.tsx

@@ -2,6 +2,7 @@ import { verifyUrl } from '@/helpers/toolsValidate'
 import { openDefaultWebView } from '@/student/home-layout-orchestra/state-orchestra'
 import { Swipe, SwipeItem, Image } from 'vant'
 import { defineComponent } from 'vue'
+import event from '../../event'
 import styles from './index.module.less'
 
 export default defineComponent({
@@ -33,11 +34,12 @@ export default defineComponent({
               <div
                 class={styles.typeItem}
                 onClick={() => {
-                  if (verifyUrl(item.linkUrl)) {
-                    openDefaultWebView(item.linkUrl, () => {
-                      window.location.href = item.linkUrl
-                    })
-                  }
+                  // if (verifyUrl(item.linkUrl)) {
+                  //   openDefaultWebView(item.linkUrl, () => {
+                  //     window.location.href = item.linkUrl
+                  //   })
+                  // }
+                  event.emit('downloadApp')
                 }}
               >
                 <Image

+ 20 - 17
src/student/home/components/music/index.tsx

@@ -6,6 +6,7 @@ import TheSong from '../TheSong'
 import TheTitle from '../the-title'
 import { openDefaultWebView } from '@/student/home-layout-orchestra/state-orchestra'
 import item from '@/views/coupons/item'
+import event from '../../event'
 
 export default defineComponent({
   name: 'music-list',
@@ -42,10 +43,11 @@ export default defineComponent({
           <TheTitle
             title={props.title}
             onDetail={() => {
-              const url = location.origin + location.pathname + '#/music-list'
-              openDefaultWebView(url, () => {
-                router.push('/music-list')
-              })
+              // const url = location.origin + location.pathname + '#/music-list'
+              // openDefaultWebView(url, () => {
+              //   router.push('/music-list')
+              // })
+              event.emit('downloadApp')
             }}
           />
         )}
@@ -58,19 +60,20 @@ export default defineComponent({
                     <TheSong
                       list={n}
                       onDetail={(item: any) => {
-                        const url =
-                          location.origin +
-                          location.pathname +
-                          '#/music-detail?id=' +
-                          item.id
-                        openDefaultWebView(url, () => {
-                          router.push({
-                            path: '/music-detail',
-                            query: {
-                              id: item.id
-                            }
-                          })
-                        })
+                        // const url =
+                        //   location.origin +
+                        //   location.pathname +
+                        //   '#/music-detail?id=' +
+                        //   item.id
+                        // openDefaultWebView(url, () => {
+                        //   router.push({
+                        //     path: '/music-detail',
+                        //     query: {
+                        //       id: item.id
+                        //     }
+                        //   })
+                        // })
+                        event.emit('downloadApp')
                       }}
                     />
                   </div>

+ 23 - 19
src/student/home/components/recommend-sage/index.tsx

@@ -6,6 +6,7 @@ import bars from '../../images/bars.svg'
 import TheTitle from '../the-title'
 import { useRouter } from 'vue-router'
 import { openDefaultWebView } from '@/student/home-layout-orchestra/state-orchestra'
+import event from '../../event'
 
 export default defineComponent({
   name: 'recommend-sage',
@@ -46,11 +47,12 @@ export default defineComponent({
           <TheTitle
             title={props.title}
             onDetail={() => {
-              const url =
-                location.origin + location.pathname + '#/teacherElegant'
-              openDefaultWebView(url, () => {
-                router.push('/teacherElegant')
-              })
+              // const url =
+              //   location.origin + location.pathname + '#/teacherElegant'
+              // openDefaultWebView(url, () => {
+              //   router.push('/teacherElegant')
+              // })
+              event.emit('downloadApp')
             }}
           />
         )}
@@ -62,19 +64,20 @@ export default defineComponent({
               key={item.id}
               onClick={() => {
                 // 是否要跳转到直播间
-                const url =
-                  location.origin +
-                  location.pathname +
-                  '#/teacherHome?teacherId=' +
-                  item.userId
-                openDefaultWebView(url, () => {
-                  router.push({
-                    path: '/teacherHome',
-                    query: {
-                      teacherId: item.userId
-                    }
-                  })
-                })
+                // const url =
+                //   location.origin +
+                //   location.pathname +
+                //   '#/teacherHome?teacherId=' +
+                //   item.userId
+                // openDefaultWebView(url, () => {
+                //   router.push({
+                //     path: '/teacherHome',
+                //     query: {
+                //       teacherId: item.userId
+                //     }
+                //   })
+                // })
+                event.emit('downloadApp')
               }}
             >
               {item.living && <Image src={bars} class={styles.animation} />}
@@ -93,7 +96,8 @@ export default defineComponent({
                 type={item.watch ? 'default' : 'primary'}
                 disabled={item.watch}
                 onClick={() => {
-                  onStart(item)
+                  // onStart(item)
+                  event.emit('downloadApp')
                 }}
               >
                 {item.watch ? '已关注' : '关注'}

+ 29 - 26
src/student/home/components/talent-style/index.tsx

@@ -7,6 +7,7 @@ import bars from '../../images/bars2.svg'
 import iconVideoPlay from '../../images/icon_video_play.png'
 import { openDefaultWebView } from '@/student/home-layout-orchestra/state-orchestra'
 import { useRouter } from 'vue-router'
+import event from '../../event'
 
 export default defineComponent({
   name: 'talent-list',
@@ -66,19 +67,20 @@ export default defineComponent({
                       <div
                         class={styles.styleItem}
                         onClick={() => {
-                          const url =
-                            location.origin +
-                            location.pathname +
-                            '#/teacherHome?teacherId=' +
-                            item.userId
-                          openDefaultWebView(url, () => {
-                            router.push({
-                              path: '/teacherHome',
-                              query: {
-                                teacherId: item.userId
-                              }
-                            })
-                          })
+                          // const url =
+                          //   location.origin +
+                          //   location.pathname +
+                          //   '#/teacherHome?teacherId=' +
+                          //   item.userId
+                          // openDefaultWebView(url, () => {
+                          //   router.push({
+                          //     path: '/teacherHome',
+                          //     query: {
+                          //       teacherId: item.userId
+                          //     }
+                          //   })
+                          // })
+                          event.emit('downloadApp')
                         }}
                       >
                         <div class={styles.styleImg}>
@@ -124,19 +126,20 @@ export default defineComponent({
                       <div
                         class={styles.styleItem}
                         onClick={() => {
-                          const url =
-                            location.origin +
-                            location.pathname +
-                            '#/teacherHome?teacherId=' +
-                            item.userId
-                          openDefaultWebView(url, () => {
-                            router.push({
-                              path: '/teacherHome',
-                              query: {
-                                teacherId: item.userId
-                              }
-                            })
-                          })
+                          // const url =
+                          //   location.origin +
+                          //   location.pathname +
+                          //   '#/teacherHome?teacherId=' +
+                          //   item.userId
+                          // openDefaultWebView(url, () => {
+                          //   router.push({
+                          //     path: '/teacherHome',
+                          //     query: {
+                          //       teacherId: item.userId
+                          //     }
+                          //   })
+                          // })
+                          event.emit('downloadApp')
                         }}
                       >
                         <div class={styles.styleImg}>

+ 20 - 17
src/student/home/components/video-class/index.tsx

@@ -4,6 +4,7 @@ import { defineComponent } from 'vue'
 import { useRouter } from 'vue-router'
 import TheTitle from '../the-title'
 import styles from './index.module.less'
+import event from '../../event'
 
 export default defineComponent({
   name: 'video-class',
@@ -23,10 +24,11 @@ export default defineComponent({
           <TheTitle
             title="精品视频课"
             onDetail={() => {
-              const url = location.origin + location.pathname + '#/videoClass'
-              openDefaultWebView(url, () => {
-                router.push('/videoClass')
-              })
+              // const url = location.origin + location.pathname + '#/videoClass'
+              // openDefaultWebView(url, () => {
+              //   router.push('/videoClass')
+              // })
+              event.emit('downloadApp')
             }}
           />
         )}
@@ -36,19 +38,20 @@ export default defineComponent({
             <div
               class={styles.videoItem}
               onClick={() => {
-                const url =
-                  location.origin +
-                  location.pathname +
-                  '#/videoDetail?groupId=' +
-                  item.videoGroupId
-                openDefaultWebView(url, () => {
-                  router.push({
-                    path: '/videoDetail',
-                    query: {
-                      groupId: item.videoGroupId
-                    }
-                  })
-                })
+                // const url =
+                //   location.origin +
+                //   location.pathname +
+                //   '#/videoDetail?groupId=' +
+                //   item.videoGroupId
+                // openDefaultWebView(url, () => {
+                //   router.push({
+                //     path: '/videoDetail',
+                //     query: {
+                //       groupId: item.videoGroupId
+                //     }
+                //   })
+                // })
+                event.emit('downloadApp')
               }}
             >
               <div style={{ position: 'relative' }}>

+ 8 - 0
src/student/home/event.ts

@@ -0,0 +1,8 @@
+import EventEmitter from "eventemitter3"
+
+export default new EventEmitter()
+
+/**
+ * 事件列表
+ * downloadApp 下载app
+ */

+ 26 - 14
src/student/home/index.tsx

@@ -17,6 +17,7 @@ import popupClose from './images/popup-close.png'
 import { postMessage } from '@/helpers/native-message'
 import { browser } from '@/helpers/utils'
 import { state } from '@/state'
+import event from './event'
 
 export default defineComponent({
   name: 'home-index',
@@ -49,6 +50,10 @@ export default defineComponent({
   mounted() {
     this.headerHeight = (this as any).$refs.header?.getHeadeHeight()
     this.init()
+
+    event.on('downloadApp', () => {
+      this.downloadStatus = true
+    })
   },
   methods: {
     async init() {
@@ -121,18 +126,14 @@ export default defineComponent({
         <TheHomeHeader
           ref="header"
           onCart={() => {
-            //
+            this.downloadStatus = true
           }}
           onSearch={() => {
             // 搜索详情
-            const url =
-              location.origin + location.pathname + '#/music-songbook/search'
-            openDefaultWebView(url, () => {
-              this.$router.push('/music-songbook/search')
-            })
+            this.downloadStatus = true
           }}
           onMore={() => {
-            //
+            this.downloadStatus = true
           }}
         />
 
@@ -148,11 +149,12 @@ export default defineComponent({
                 <SwipeItem
                   onClick={() => {
                     // 判断url是否正常
-                    if (verifyUrl(item.linkUrl)) {
-                      openDefaultWebView(item.linkUrl, () => {
-                        window.location.href = item.linkUrl
-                      })
-                    }
+                    // if (verifyUrl(item.linkUrl)) {
+                    //   openDefaultWebView(item.linkUrl, () => {
+                    //     window.location.href = item.linkUrl
+                    //   })
+                    // }
+                    this.downloadStatus = true
                   }}
                 >
                   <Image
@@ -209,13 +211,23 @@ export default defineComponent({
             onConfirm={() => {
               const type = browser().orchestraAndroid
                 ? 'com.cooleshow.student'
-                : 'ColexiuStudent'
+                : 'ColexiuStudent://'
               if (state.orchestraInfo.installStatus) {
                 postMessage({ api: 'openApp', content: { type: type } })
               } else {
+                // const urlIos =
+                //   'https://itunes.apple.com/cn/app/id1626971695?mt=8'
+                // const urlAndroid =
+                //   'https://appstore.ks3-cn-beijing.ksyuncs.com/clx-student-domain.apk'
+
+                const url = browser().orchestraAndroid
+                  ? window.location.origin +
+                    window.location.pathname +
+                    '#/download'
+                  : 'https://itunes.apple.com/cn/app/id1626971695?mt=8'
                 postMessage({
                   api: 'downloadApp',
-                  content: { type: type, url: '' }
+                  content: { type: type, url: url }
                 })
               }
             }}

+ 5 - 2
src/student/main.ts

@@ -46,9 +46,12 @@ if (browser().isOrchestraStudent) {
   })
 
   // 管乐团里面,获取是否已安装酷乐秀
-  promisefiyPostMessage({ api: 'isInstall' }).then((res: any) => {
+  const type = browser().orchestraAndroid
+    ? 'com.cooleshow.student'
+    : 'ColexiuStudent://'
+  promisefiyPostMessage({ api: 'isInstall', content: { type: type } }).then((res: any) => {
     const content = res.content
-    state.orchestraInfo.isInstall = content.installStatus
+    state.orchestraInfo.installStatus = content.installStatus
   })
 
   // 从缓存里面获取token

+ 5 - 0
yarn.lock

@@ -2398,6 +2398,11 @@
   "resolved" "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz"
   "version" "2.0.3"
 
+"eventemitter3@^5.0.0":
+  "integrity" "sha512-riuVbElZZNXLeLEoprfNYoDSwTBRR44X3mnhdI1YcnENpWTCsTTVZ2zFuqQcpoyqPQIUXdiPEU0ECAq0KQRaHg=="
+  "resolved" "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-5.0.0.tgz"
+  "version" "5.0.0"
+
 "execa@^0.8.0":
   "integrity" "sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA=="
   "resolved" "https://registry.npmmirror.com/execa/-/execa-0.8.0.tgz"