student-item.tsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import { defineComponent, reactive, ref, watch } from 'vue'
  2. import styles from './student-item.module.less'
  3. import defaultIcon from '@/school/images/student-icon.png'
  4. import msgIcon from '@/school/images/msg-icon.png'
  5. import sendmsgIcon from '@/school/images/sendmsg-icon.png'
  6. import phoneIcon from '@/school/images/phone-icon.png'
  7. import { postMessage } from '@/helpers/native-message'
  8. import { Icon, ActionSheet, showToast, Image, Cell } from 'vant'
  9. import { useRouter } from 'vue-router'
  10. const myForms = ref({}) as any
  11. export default defineComponent({
  12. props: ['item', 'forms'],
  13. name: 'student-item',
  14. setup(props) {
  15. const router = useRouter()
  16. const showContact = ref(false)
  17. const startContact = () => {
  18. showContact.value = true
  19. }
  20. const closeSheet = () => {
  21. showContact.value = false
  22. }
  23. watch(
  24. () => props.forms,
  25. (val) => {
  26. myForms.value = val
  27. },
  28. {
  29. deep: true
  30. }
  31. )
  32. const postMsg = async () => {
  33. try {
  34. await postMessage({
  35. api: 'joinChatGroup',
  36. content: {
  37. type: 'single', // single 单人 multi 多人
  38. id: props.item.imUserId
  39. }
  40. })
  41. closeSheet()
  42. } catch (e) {
  43. showToast('发起聊天失败')
  44. closeSheet()
  45. }
  46. }
  47. const callPhone = async () => {
  48. try {
  49. await postMessage({
  50. api: 'callPhone',
  51. content: {
  52. phone: props.item.phone
  53. }
  54. })
  55. closeSheet()
  56. } catch (e) {
  57. showToast('发起聊天失败')
  58. closeSheet()
  59. }
  60. }
  61. const gotoDetail = () => {
  62. console.log(myForms.value.practiceMonth, myForms.value.practiceMonthName)
  63. console.log(props.item)
  64. router.push({
  65. path: '/exercis-detail',
  66. query: {
  67. id: props.item.userId,
  68. practiceMonth: myForms.value.practiceMonth,
  69. practiceMonthName: myForms.value.practiceMonthName
  70. }
  71. })
  72. }
  73. return () => (
  74. <>
  75. <Cell isLink class={styles.recordItem} center onClick={gotoDetail}>
  76. {{
  77. icon: () => (
  78. <div class={styles.imgContainer}>
  79. <Image
  80. class={styles.img}
  81. src={props.item.avatar ? props.item.avatar : defaultIcon}
  82. alt=""
  83. />
  84. {props.item.memberFlag ? <i class={styles.iconMember}></i> : ''}
  85. </div>
  86. ),
  87. title: () => (
  88. <div class={styles.userInfo}>
  89. <div class={styles.userItem}>
  90. <p class={styles.topText} style="font-weight: bold;">
  91. {props.item.nickname}
  92. </p>
  93. <p class={styles.bottomText}>
  94. {props.item.subjectNames ? props.item.subjectNames : '暂无声部'}
  95. </p>
  96. </div>
  97. <div class={styles.userItem}>
  98. <p class={styles.topText}>
  99. <span>{props.item.trainingTime ? props.item.trainingTime : 0}</span>分钟
  100. </p>
  101. <p class={styles.bottomText}>练习时长</p>
  102. </div>
  103. <div class={styles.userItem}>
  104. <p class={styles.topText}>
  105. <span>{props.item.trainingDays ? props.item.trainingDays : 0}</span>天
  106. </p>
  107. <p class={styles.bottomText}>练习天数</p>
  108. </div>
  109. </div>
  110. )
  111. }}
  112. </Cell>
  113. {/* <div>
  114. <div class={styles.itemWrap} onClick={gotoDetail}>
  115. <div class={styles.itemTop}>
  116. <div class={styles.itemTopLeft}>
  117. <div class={styles.headIcon}>
  118. <img src={props.item.avatar ? props.item.avatar : defaultIcon} alt="" />
  119. </div>
  120. <p class={styles.name}>{props.item.nickname}</p>
  121. <div class={styles.tag}>
  122. {props.item.subjectNames ? props.item.subjectNames : '暂无声部'}
  123. </div>
  124. </div>
  125. <div class={styles.itemTopRight}>
  126. <div
  127. class={styles.msgIcon}
  128. onClick={(e: any) => {
  129. e.stopPropagation()
  130. e.preventDefault()
  131. startContact()
  132. }}
  133. >
  134. <img src={msgIcon} alt="" />
  135. </div>
  136. </div>
  137. </div>
  138. <div class={styles.itemBottom}>
  139. <div class={styles.itemBottomLeft}>
  140. <p class={styles.msgMain}>
  141. {props.item.practiceDays ? props.item.practiceDays : 0} <span>天</span>
  142. </p>
  143. <p class={styles.msgsub}>练习天数</p>
  144. </div>
  145. <div class={styles.itemBottomRight}>
  146. <p class={styles.msgMain}>
  147. {props.item.practiceTimes ? props.item.practiceTimes : 0}
  148. <span>分钟</span>
  149. </p>
  150. <p class={styles.msgsub}>练习时长</p>
  151. <Icon class={styles.arrow} name="arrow"></Icon>
  152. </div>
  153. </div>
  154. </div>
  155. </div> */}
  156. <ActionSheet
  157. class="bottomSheet"
  158. v-model:show={showContact.value}
  159. v-slots={{
  160. description: () => (
  161. <div class={styles.bottomTitle}>
  162. <div class={styles.bottomTitleLeft}>
  163. <span></span>
  164. <p>联系方式</p>
  165. </div>
  166. <div
  167. class={styles.bottomTitleRight}
  168. onClick={(e: any) => {
  169. e.stopPropagation()
  170. e.preventDefault()
  171. closeSheet()
  172. }}
  173. >
  174. <Icon class={styles.cross} name="cross"></Icon>
  175. </div>
  176. </div>
  177. )
  178. }}
  179. >
  180. <div class={styles.bottomConent}>
  181. <div
  182. class={styles.bottomConentLeft}
  183. onClick={(e: any) => {
  184. e.stopPropagation()
  185. e.preventDefault()
  186. postMsg()
  187. }}
  188. >
  189. <div class={styles.bottomImgWrap}>
  190. <img src={sendmsgIcon} alt="" />
  191. </div>
  192. <p>发送消息</p>
  193. </div>
  194. <div
  195. class={styles.bottomConentRight}
  196. onClick={(e: any) => {
  197. e.stopPropagation()
  198. e.preventDefault()
  199. callPhone()
  200. }}
  201. >
  202. <div class={styles.bottomImgWrap}>
  203. <img src={phoneIcon} alt="" />
  204. </div>
  205. <p>拨打电话</p>
  206. </div>
  207. </div>
  208. </ActionSheet>
  209. </>
  210. )
  211. }
  212. })