single.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import SectionDetail from '@/business-components/section-detail'
  2. import ColVideo from '@/components/col-video'
  3. import request from '@/helpers/request'
  4. import { Button, Cell, Icon, Image, Popup } from 'vant'
  5. import { defineComponent } from 'vue'
  6. import styles from './single.module.less'
  7. import { postMessage } from '@/helpers/native-message'
  8. import JoinChat from '../model/join-chat'
  9. import iconUploadPoster from '@common/images/icon_upload_poster.png'
  10. export const getAssetsHomeFile = (fileName: string) => {
  11. const path = `../images/${fileName}`
  12. const modules = import.meta.globEager('../images/*')
  13. return modules[path].default
  14. }
  15. export default defineComponent({
  16. name: 'single',
  17. props: {
  18. userInfo: {
  19. type: Object,
  20. default: {}
  21. }
  22. },
  23. data() {
  24. const query = this.$route.query
  25. return {
  26. videoStatus: false,
  27. chatStatus: false,
  28. teacherId: query.teacherId,
  29. fansList: [],
  30. chatItem: {},
  31. videoItem: {}
  32. }
  33. },
  34. async mounted() {
  35. try {
  36. const res = await request.post('/api-student/imGroup/queryTeacherGroup', {
  37. data: {
  38. type: 'FAN',
  39. createUserId: this.teacherId
  40. }
  41. })
  42. this.fansList = res.data || []
  43. } catch {}
  44. },
  45. methods: {
  46. async onDetail(item: any) {
  47. // 申请入群
  48. if (!item.hasWaitAuditFlag && !item.existFlag) {
  49. this.chatStatus = true
  50. this.chatItem = item
  51. return
  52. }
  53. // 进入群聊天
  54. if (item.existFlag) {
  55. postMessage({
  56. api: 'joinChatGroup',
  57. content: {
  58. type: 'multi', // single 单人 multi 多人
  59. id: item.id
  60. }
  61. })
  62. }
  63. }
  64. },
  65. render() {
  66. const userInfo = this.userInfo
  67. return (
  68. <div class={styles.single}>
  69. <SectionDetail
  70. icon="personal"
  71. title="个人风采"
  72. size={24}
  73. border={false}
  74. >
  75. <p class={styles.introduction}>{userInfo.introduction}</p>
  76. </SectionDetail>
  77. {userInfo.styleVideo && userInfo.styleVideo.length > 0 && (
  78. <SectionDetail
  79. icon="elegant"
  80. title="老师风采"
  81. size={24}
  82. border={false}
  83. >
  84. <div class={styles.videoList}>
  85. {userInfo.styleVideo.map((item: any) => (
  86. <div
  87. class={styles.videoItem}
  88. onClick={() => {
  89. this.videoStatus = true
  90. this.videoItem = item
  91. }}
  92. >
  93. <Image src={iconUploadPoster} fit="cover" />
  94. <Icon
  95. class={styles['icon-upload']}
  96. name={getAssetsHomeFile('icon_video.png')}
  97. size={26}
  98. />
  99. </div>
  100. ))}
  101. </div>
  102. </SectionDetail>
  103. )}
  104. {this.fansList && this.fansList.length > 0 && (
  105. <SectionDetail icon="fans" title="粉丝群" size={24} border={false}>
  106. {this.fansList.map((item: any) => (
  107. <Cell
  108. center
  109. class={styles.fansGroup}
  110. v-slots={{
  111. icon: () => (
  112. <Image
  113. src={item.img || getAssetsHomeFile('icon_fans.png')}
  114. fit="cover"
  115. class={styles.fansImage}
  116. />
  117. ),
  118. title: () => (
  119. <div class={styles.fansTitle}>
  120. <div class={styles.title}>{item.name}</div>
  121. <p class="van-ellipsis">{item.introduce}</p>
  122. </div>
  123. ),
  124. default: () => (
  125. <Button
  126. type="primary"
  127. size="small"
  128. round
  129. disabled={item.hasWaitAuditFlag}
  130. onClick={() => this.onDetail(item)}
  131. >
  132. {item.existFlag ? '去聊天' : ''}
  133. {item.hasWaitAuditFlag ? '审核中' : ''}
  134. {!item.hasWaitAuditFlag && !item.existFlag
  135. ? '申请入群'
  136. : ''}
  137. </Button>
  138. )
  139. }}
  140. />
  141. ))}
  142. </SectionDetail>
  143. )}
  144. <Popup
  145. show={this.chatStatus}
  146. position="bottom"
  147. round
  148. closeable
  149. safe-area-inset-bottom
  150. onClose={() => (this.chatStatus = false)}
  151. >
  152. <JoinChat
  153. item={this.chatItem}
  154. onClose={() => (this.chatStatus = false)}
  155. />
  156. </Popup>
  157. <Popup
  158. show={this.videoStatus}
  159. round
  160. class={styles.videoGroup}
  161. closeable
  162. onClose={() => (this.videoStatus = false)}
  163. >
  164. <ColVideo />
  165. </Popup>
  166. </div>
  167. )
  168. }
  169. })