index.vue 8.14 KB
<template>
  <div class="video-wrapper" style="position: relative;">
    <div v-if="status === 'PROCESS' && detail.showStatus" class="status">
      <van-image v-if="item.status === 'ENABLE'" round width="6rem" height="6rem" style="vertical-align: bottom;"
        :src="icon_enable" />
      <van-image v-if="item.status === 'DISABLE'" round width="6rem" height="6rem" style="vertical-align: bottom;"
        :src="icon_refuse" />
      <van-image v-if="item.status === 'APPLY'" round width="6rem" height="6rem" style="vertical-align: bottom;"
        :src="icon_apply" />
    </div>
    <div class="video-div" :id="'mui-player-' + item.id">
    </div>
    <div class="control-bar">
      <div>
        <div class="video-bar">
          <van-row align="center">
            <van-col span="8">
              <van-image round width="2rem" height="2rem" style="vertical-align: middle;" :src="item.cover" />&nbsp;
              <span style="font-size: 1.05rem; vertical-align: middle;">{{ item.name }}</span>
            </van-col>
            <van-col span="16">
              <div style="color: #999999; text-align: right;">{{ item.book_name }} | {{ item.localism_type }}</div>
            </van-col>
          </van-row>
        </div>
      </div>
      <div v-if="status === 'PROCESS'" style="margin-top: 1rem;">
        <div v-if="item.status === 'DISABLE'" style="padding: 0 1rem 1rem 1rem; font-size: 0.85rem;">
          <p style="color: #999999; margin-bottom: 0.25rem;">老师留言:</p>
          <p>{{ item.check_note }}</p>
        </div>
      </div>
      <div class="book-intro">
        <div id="book-intro" :class="{ 'van-multi-ellipsis--l3': isToggle }">{{ item.note }}</div>
        <div v-if="hasToggle">
          <div v-if="isToggle" @click="onToggle(false)" class="book-toggle-icon">展开&nbsp;
            <van-icon style="vertical-align: middle;" size="0.9rem" :name="icon_down" />
          </div>
          <div v-else @click="onToggle(true)" class="book-toggle-icon">折叠&nbsp;
            <van-icon style="vertical-align: middle;" size="0.9rem" :name="icon_up" />
          </div>
        </div>
      </div>
      <div v-if="status === 'PENDING'" class="van-hairline--top" style="padding: 0 1rem;">
        <van-row>
          <van-col offset="3" style="padding: 1rem;" @click="onRefuse()">
            <div style="background: #B4B4B3; border-radius: 15px; color: #FFFFFF; padding: 0.25rem 0.8rem;">
              <van-icon name="close" />&nbsp;不通过
            </div>
          </van-col>
          <van-col style="padding: 1rem;" @click="onPass()">
            <div style="background: #F9D95C; border-radius: 15px; color: #713610; padding: 0.25rem 1.5rem;">
              <van-icon name="passed" />&nbsp;通过
            </div>
          </van-col>
        </van-row>
      </div>
    </div>
  </div>

  <van-overlay :show="showNotice" z-index="1000">
    <div class="wrapper" @click.stop>
      <div class="block">
        <div style="position: absolute; top: -2rem; right: 1rem; font-size: 1.5rem;">
          <van-icon name="close" color="#FFFFFF" @click="closeNotice" />
        </div>
        <div class="van-hairline--bottom"
          style="color: #222222; font-size: 1.25rem; font-weight: bold; text-align: center; padding-bottom: 1rem;">
          作品审核建议</div>
        <div>
          <van-field v-model="message" rows="2" autosize label="" type="textarea" maxlength="200"
            placeholder="请填写您对小朋友的温馨鼓励" show-word-limit />
        </div>
        <div style="margin: 3rem 0;">
          <my-button @on-click="handleAudit('disable')" type="primary">确定</my-button>
        </div>
      </div>
    </div>
  </van-overlay>

  <van-dialog v-model:show="show" title="温馨提示" show-cancel-button confirmButtonColor="#F9D95C" @confirm="handleAudit('enable')" @cancel="onCancel">
    <div style="padding: 1rem; text-align: center;">是否确认审核通过该视频 ?</div>
  </van-dialog>
</template>

<script setup>
import icon_up from '@images/icon-guanbi@2x.png'
import icon_down from '@images/icon-zhankai@2x.png'

import icon_refuse from '@images/icon-jujue@2x.png'
import icon_apply from '@images/icon-shenhe@2x.png'
import icon_enable from '@images/icon-tongguo@2x.png'

import MyButton from '@/components/MyButton/index.vue'
import { ref, reactive, onMounted, nextTick, watch, onUpdated } from 'vue'
import 'mui-player/dist/mui-player.min.css'
import MuiPlayer from 'mui-player'
import axios from '@/utils/axios';
import _ from 'lodash';
import tools from '@/common/tool'

import { useRoute, useRouter } from 'vue-router'
import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();

// 判断是否显示简介的展开图标
const hasToggle = ref(false); // 判断是否有展开文字,默认没有
const isToggle = ref(true); // 判断展开状态,默认展开

const onToggle = (v) => { // 展开/折叠
  isToggle.value = v
}

onMounted(() => {
  // 判断是否显示简介的展开图标
  nextTick(() => {
    hasToggle.value = tools.hasEllipsis('book-intro');
  })
})

</script>

<script>
export default {
  props: ['item', 'status'],
  data() {
    return {
      detail: {},
      mp: '',
      message: '',
      showNotice: false,
      show: false
    }
  },
  created() {
  },
  mounted() {
    setTimeout(() => {
      var mp = new MuiPlayer({
        container: '#mui-player-' + this.item.id,
        title: this.item.title,
        src: this.item.video,
        poster: this.item.cover,
        autoFit: false,
        videoAttribute: [ // 声明启用同层播放, 不让会自动全屏播放
          { attrKey: 'webkit-playsinline', attrValue: 'webkit-playsinline' },
          { attrKey: 'playsinline', attrValue: 'playsinline' },
          { attrKey: 'x5-video-player-type', attrValue: 'h5-page' },
        ]
      })
      this.mp = mp;
      this.detail = _.cloneDeep(this.item);
      this.detail.showStatus = true;
      var video = mp.video();
      // 监听原生video事件,审核状态标签显示控制
      var _this = this;
      video && video.addEventListener('play', function (event) {
        _this.detail.showStatus = false;
      });
      video && video.addEventListener('pause', function (event) {
        _this.detail.showStatus = true;
      });
    }, 500);
  },
  methods: {
    closeNotice() {
      this.showNotice = false;
    },
    onRefuse() { // 不通过审核
      this.showNotice = true;
    },
    onPass() { // 通过审核
      this.show = true;
    },
    handleAudit (status) {
      axios.post('/srv/?a=check_prod', {
        prod_id: this.detail.id,
        status,
        check_note: this.message,
      })
      .then(res => {
        if (res.data.code === 1) {
          Toast.success('操作成功');
          this.message = '';
          this.showNotice = false;
          this.show = false;
        } else {
          console.warn(res);
          if (!res.data.show) return false;
          Toast({
            icon: 'close',
            message: res.data.msg
          });
        }
      })
      .catch(err => {
        console.error(err); 
      })
    },
    onCancel () {
      this.show = false;
    }
  }
}
</script>

<style lang="less" scoped>
.video-wrapper {
  margin: 1rem;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.13);

  .status {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 999;
  }

  .video-div {
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
  }

  .video-bar {
    color: #713610;
    padding: 1rem;
    padding-bottom: 0.5rem;
  }

  .book-intro {
    padding: 1rem;
    padding-top: 0;

    .book-post {
      color: #222222;
      font-size: 1.25rem;
      font-weight: bold;
    }

    #book-intro {
      color: #333333;
      margin-top: 0.25rem;
    }

    .book-toggle-icon {
      text-align: right;
      color: #713610;
      font-size: 1rem;
    }
  }
}

.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: auto;
  text-align: center;
}

.block {
  width: 80%;
  // height: 25rem;
  background-color: #fff;
  border-radius: 10px;
  padding: 1rem;
  position: relative;
  margin-top: 1rem;
  margin-bottom: 5rem;
}
</style>