activate.vue 3.53 KB
<template>
  <div class="main">
    <div class="input">
      <div class="sprite-icon icon-card"></div>
      <input
        type="text"
        placeholder="权益卡号或设备编码"
        v-model="no"
      >
    </div>
    <div
      class="tips"
      @click="jump"
    >
      <div class="title">常见疑问:</div>
      <ul>
        <li>1.如何查看您的设备编码<div class="sprite-icon icon-more"></div>
        </li>
        <li>2.如何查看您的权益卡号<div class="sprite-icon icon-more"></div>
        </li>
      </ul>
    </div>
    <div
      :class="['btn',{'disabled':disabled}]"
      @click="confirm"
    >确认</div>
  </div>
</template>

<script type='text/ecmascript-6'>
import { equity } from '@r/api.js'
export default {
  name: '',
  data () {
    return {
      no: '',
      disabled: true
    }
  },
  mounted () {
    if (this.isMiniprogram) wx.miniProgram.postMessage({})
  },
  watch: {
    'no' (nelVal) {
      this.disabled = nelVal.length < 1 ? true : false
    }
  },
  methods: {
    jump () {
       let logs = window.vm.trackConfig({
        event: "click_event",
        properties: {
          pagename: "激活权益",
          event_name: "常见疑问",
        },
      });
      window.vm.track.collect(logs);
      window.vm.$router.push({ name: 'common.explain' })
    },
    confirm () {
      let logs = window.vm.trackConfig({
        event: "click_event",
        properties: {
          pagename: "激活权益",
          event_name: "确定",
          extra_data: {
            cardNo: this.no
          }
        },
      });
      window.vm.track.collect(logs);
      let { no } = this
      if (!no) return
      let target = 'activateBySn'
      let params = {
        sn: no
      }
      if (no.length == 12) {
        target = 'activateByCardNo'
        params.cardNo = no
        delete params.sn
      }
      this.showLoading('激活中...')
      equity[target](params).then(res => {
        this.hideLoading()
        let { code, message } = res
        if (code == 0) {
          this.dialog({
            title: '提示',
            message: '激活成功',
            confirmButtonText: '知道了',
            showCancelButton: false
          }).then(() => {
            if (window.__wxjs_environment === 'miniprogram') {
              wx.miniProgram.navigateBack()
            } else {
              window.vm.$router.push({ name: 'equity.index' })
            }
          })
        } else {
          this.showToast(message)
        }
      })
    }
  }
}
</script>

<style scoped lang='scss'>
.main {
  width: auto;
  height: auto!important;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  .input {
    width: 100%;
    display: grid;
    grid-template-columns: 23px 1fr;
    gap: 0 10px;
    align-items: center;
    padding-bottom: 5px;
    border-bottom: 1px solid #e9e9e9;
    margin: 0 auto;
    img {
      height: 18px;
    }
    input {
      border: none;
      outline: none;
      background-color: rgba(0, 0, 0, 0);
    }
    ::-webkit-input-placeholder {
      color: #999;
    }
  }
  .tips {
    margin: 30px 0 0;
    color: #2c2c2c;
    .title {
      font-size: 15px;
      margin-bottom: 10px;
    }
    li {
      font-size: 13px;
      margin-bottom: 10px;
      display: flex;
      align-items: center;
    }
  }
  .btn {
    margin: 100px auto 0;
    width: 300px;
    height: 35px;
    background: #2f77f3;
    border-radius: 4px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 14px;
    transition: all 0.5s;
  }
}
</style>