mass.vue 6.13 KB
<template>
  <div class="container">
    <div
      class="box"
      v-if="showBox"
    >
      <div class="top">
        <div class="top-title">{{ detail.name }}直播活动</div>
        <div
          class="iconBox"
          @click="copyMessage(this.massMessage)"
        >
          <!-- <img src=".\imgs\copy.png" alt=""> -->
        </div>
      </div>
      <div class="mass-message">{{ detail.promotion }}</div>
      <div class="mass-time">直播时间:{{ date }}</div>
      <div class="imgBox">
        <img
          :src="detail.postImgUrl"
          alt=""
        />
      </div>
    </div>
    <div
      class="fixedButtom"
      v-if="showBox"
    >
      <div class="item-container">
        <div class="icon-container">
          <div
            class="icon-box"
            @click="share('wechat')"
          >
            <img
              src="@/assets/images/wechat.png"
              alt=""
            />
          </div>
        </div>
        <div class="icon-instruction">分享朋友圈</div>
      </div>
      <div
        class="item-container"
        style="margin-left: 61px"
      >
        <div
          class="icon-container"
          @click="share('customer')"
        >
          <div class="icon-box">
            <img
              src="@/assets/images/customer.png"
              alt=""
            />
          </div>
        </div>
        <div class="icon-instruction">分享客户</div>
      </div>
      <div
        class="item-container"
        style="margin-left: 61px"
      >
        <div
          class="icon-container"
          @click="share('group')"
        >
          <div class="icon-box">
            <img
              src="@/assets/images/group.png"
              alt=""
            />
          </div>
        </div>
        <div class="icon-instruction">分享客户群</div>
      </div>
    </div>
  </div>
</template>
<script type='text/ecmascript-6'>
import { liveBroadcast, wxConfig } from '@/api'
export default {
  name: 'mass',
  data() {
    return {
      detail: {},
      date: '',
      showBox: true
    }
  },
  activated() {},
  deactivated() {},
  mounted() {
    let { taskId } = this.getQuery()
    //获取界面详情数据
    liveBroadcast.getDetail({ taskId }).then(res => {
      console.log(res, '789')
      this.detail = res
      console.log(this.detail.startTime, 'this.detail.startTime')
      this.formatDate(this.detail.startTime, this.detail.endTime)
      this.showBox = res ? true : false
    })
    //初始化微信方法
    window.$wx = wxConfig
    window.$wx.init(['shareToExternalContact', 'shareToExternalChat', 'shareToExternalMoments']).then(() => {
      console.log(res, 'init')
    })
  },
  methods: {
    // 复制内容
    // closeMessage(val) {
    //   cloneText(val)
    //   Toast('复制成功')
    // }
    share(object) {
      console.log(object)
      let text = {
        content: this.detail.promotion + '\n' + '直播时间' + '  ' + this.date
      }
      let attachments = [
        {
          msgtype: 'image',
          image: {
            imgUrl: this.detail.postImgUrl
          }
        }
      ]
      //分享到朋友圈
      if (object == 'wechat') {
        window.$wx.shareToExternalMoments({ text, attachments }).then(res => {})
      }
      //分享给客户
      if (object == 'customer') {
        window.$wx.shareToExternalContact({ text, attachments }).then(res => {})
      }
      //分享给客户群
      if (object == 'group') {
        window.$wx.shareToExternalChat({ text, attachments }).then(res => {})
      }
    },
    //更改日期格式
    formatDate(startTime, endTime) {
      var endItems = endTime.split(' ')
      var items = startTime.split('-')
      var enditem = endItems[1].split(':')
      console.log(enditem, 'endTime')
      var item = items[2].split(' ')
      var time = item[1].split(':')
      var date = items[0] + '年' + items[1] + '月' + item[0] + '日' + '  ' + time[0] + ':' + time[1] + '-' + enditem[0] + ':' + enditem[1]
      this.date = date
    }
  }
}
</script>
<style scoped>
.fixedButtom {
  display: flex;
  flex-direction: row;
  position: -webkit-sticky;
  position: fixed;
  bottom: 0;
  opacity: 1;
  z-index: 99;
  box-sizing: border-box;
  text-align: center;
  padding: 20px 33px 20px 32px;
  background: #ffffff;
  box-shadow: 0px -2px 8px 0px rgba(224, 224, 224, 0.5);
  border-radius: 16px 16px 0px 0px;
  width: 100%;
}
.buttomLine {
  width: 134px;
  height: 5px;
  background: #000000;
  border-radius: 100px;
  margin-top: 21px;
}
.line-container {
  display: flex;
  height: 34px;
  border-top: 1px solid #f7f7f7;
  margin-left: 120px;
}
.container {
  background: #f7f7f7;
  padding: 16px 0px 0px 0px;
  height: 100px;
}
.box {
  margin: 0;
  padding: 14px 10px 103px 10px;
  border: 0;
  outline: 0;
  font-size: 100%;
  vertical-align: baseline;
  background: transparent;
  background: #fff;
  -webkit-box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  margin-bottom: 24px;
  margin-left: 16px;
  margin-right: 16px;
}
.top {
  display: flex;
  flex-direction: row;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}
.top-title {
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #333333;
  line-height: 20px;
}
.iconBox {
  width: 18px;
  height: 20px;
  margin-left: auto;
}
.mass-message {
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #666666;
  line-height: 16px;
  word-wrap: break-word;
  margin-top: 13px;
}
.imgBox {
  width: 169px;
  height: 300px;
  margin-top: 10px;
}
.mass-time {
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #666666;
  line-height: 16px;
  margin-top: 10px;
}
.icon-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 50px;
  height: 50px;
  background-color: #e9e8ff;
  border-radius: 50%;
  margin: 0px 5px 0px 5px;
}
.icon-box {
  width: 26px;
  height: 26px;
}
.icon-instruction {
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #424242;
  line-height: 17px;
  margin-top: 9px;
}
.item-container {
  width: 60px;
}
</style>