student-item.tsx 5.5 KB

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