lex-xin 10 månader sedan
förälder
incheckning
03d7232544

BIN
src/teacher/my-fans/images/icon-svip.png


BIN
src/teacher/my-fans/images/icon-vip.png


+ 43 - 3
src/teacher/my-fans/index.module.less

@@ -1,7 +1,7 @@
 .piNameSubject {
   display: flex;
   align-items: center;
-  margin-bottom: 12px;
+  // margin-bottom: 12px;
 
   .subject {
     margin-left: 5px;
@@ -17,20 +17,60 @@
   }
 }
 
+.myFansContainer {
+  overflow: hidden;
+}
 .myFans {
   margin: 12px 14px 0;
   width: auto;
+  background: #ffffff;
+  border-radius: 10px;
+  padding: 15px 12px;
 }
 
 .userName {
   font-size: 16px;
   font-weight: 500;
   color: #1a1a1a;
-  line-height: 28px;
+  line-height: 24px;
 }
 
 .userImg {
   width: 46px;
   height: 46px;
-  border-radius: 23px;
+  border-radius: 50%;
+  overflow: hidden;
+  flex-shrink: 0;
+  border: 2px solid #fff;
+}
+
+.userImgSection {
+  position: relative;
+  margin-right: 12px;
+  .VIP {
+    border: 2px solid #fada9b;
+  }
+  .SVIP {
+    border: 2px solid #f0af88;
+  }
+  .imgTag {
+    position: absolute;
+    width: 39px;
+    height: 18px;
+    bottom: -2px;
+    left: 50%;
+    margin-left: -19.5px;
+  }
+}
+
+.removeBtn {
+  display: inline-block;
+  font-weight: 500;
+  font-size: 14px;
+  color: #1e2022;
+  line-height: 1;
+  padding: 8px 19px;
+  background: #f2f2f2;
+  border-radius: 50px;
+  cursor: pointer;
 }

+ 71 - 23
src/teacher/my-fans/index.tsx

@@ -1,7 +1,9 @@
-import { Cell, Image, List } from 'vant'
+import { Button, Cell, Dialog, Image, List, Toast } from 'vant'
 import { defineComponent } from 'vue'
 import styles from './index.module.less'
 import iconStudent from '@common/images/icon_student.png'
+import iconSvip from './images/icon-svip.png'
+import iconVip from './images/icon-vip.png'
 import request from '@/helpers/request'
 import ColResult from '@/components/col-result'
 import ColHeader from '@/components/col-header'
@@ -44,11 +46,46 @@ export default defineComponent({
         this.dataShow = false
         this.finished = true
       }
+    },
+    formatVipImg(vipType: string) {
+      if (vipType === 'VIP') {
+        return {
+          img: iconVip,
+          vip: 'VIP'
+        }
+      } else if (['SVIP', 'PERMANENT_SVIP'].includes(vipType)) {
+        return {
+          img: iconSvip,
+          vip: 'SVIP'
+        }
+      } else {
+        return {
+          img: null,
+          vip: ''
+        }
+      }
+    },
+    async onRemove(item: any) {
+      try {
+        Dialog.confirm({
+          title: '提示',
+          message: '确定删除该粉丝吗?',
+          confirmButtonColor: 'var(--van-primary)'
+        }).then(async () => {
+          await request.post('/api-teacher/teacher/delFans/' + item.userId)
+          Toast('课程删除成功')
+
+          this.params.page = 1;
+          this.list = []
+          this.getList()
+        })
+      } catch {
+      }
     }
   },
   render() {
     return (
-      <div>
+      <div class={styles.myFansContainer}>
         <ColHeader />
         {this.dataShow ? (
           <List
@@ -58,29 +95,40 @@ export default defineComponent({
             class={[styles.liveList, 'mb12']}
             onLoad={this.getList}
           >
-            {this.list.map((item: any) => (
-              <Cell
-                class={styles.myFans}
-                titleStyle={{ paddingLeft: '8px' }}
-                v-slots={{
-                  icon: () => (
-                    <Image
-                      class={styles.userImg}
-                      src={item.avatar || iconStudent}
-                      fit="cover"
-                    />
-                  ),
-                  title: () => (
-                    <div class={styles.userInfo}>
-                      <div class={styles.userName}> {item.userName} </div>
-                      <div class={styles.piNameSubject}>
-                        <span class={styles.subject}>{item.subjectName}</span>
+            {this.list.map((item: any) => {
+              const formatImg = this.formatVipImg(item.vipType)
+              return (
+                <Cell
+                  class={styles.myFans}
+                  center
+                  v-slots={{
+                    icon: () => (
+                      <div class={[styles.userImgSection]}>
+                        <Image
+                          class={[styles.userImg, formatImg.vip && styles[formatImg.vip]]}
+                          src={item.avatar || iconStudent}
+                          fit="cover"
+                        />
+                        {formatImg.img && (
+                          <img class={styles.imgTag} src={formatImg.img} />
+                        )}
+                      </div>
+                    ),
+                    title: () => (
+                      <div class={styles.userInfo}>
+                        <div class={styles.userName}> {item.userName} </div>
+                        <div class={styles.piNameSubject}>
+                          <span class={styles.subject}>{item.subjectName}</span>
+                        </div>
                       </div>
+                    ),
+                    value: () => <div class={styles.btnGroup}>
+                      <span class={styles.removeBtn} onClick={() => this.onRemove(item)}>移除</span>
                     </div>
-                  )
-                }}
-              />
-            ))}
+                  }}
+                />
+              )
+            })}
           </List>
         ) : (
           <ColResult btnStatus={false} classImgSize="SMALL" tips="暂无粉丝" />