index.vue 7.97 KB
Newer Older
潘琦 committed
1 2 3 4 5 6 7 8 9 10 11 12 13
<template>
  <div class="full-page">
    <div class="user-page">
      <div class="head">
        <div class="picture">
          <div class="avatar">
            <img :src="mainUserData.picture" />
          </div>
        </div>
        <div class="info">
          <div class="nickname">{{mainUserData.name}}</div>
        </div>
        <div class="more">
14
          <span class="more-btn" @click="goToMember">
潘琦 committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
            <i class="glyphicon glyphicon-home"></i> 家庭福利
          </span>
        </div>
      </div>
      <div class="user-body">
        <div class="tab-container">
          <mt-navbar v-model="active">
              <mt-tab-item v-for="(item, index) in FamilyData" :id="index" :key="index" @click.native="getAllVoucherByUserIdFn(item.userId)">
                {{item.userId === userId ? '我的福利' : item.name + '的福利'}}
              </mt-tab-item>
          </mt-navbar>
        </div>
        <div class="tab-content">
          <h4 v-if="!cardData || cardData.length <= 0" class="tips text-center">--- 暂无数据 ---</h4>
          <div class="line-list" v-if="cardData && cardData.length > 0" v-for="(item, index) in cardData" :key="index">
            <div class="label"><span>{{item.ruleName}}</span></div>
            <div class="mark">
              <span class="mark-circle">
                <span class="circle circle-default"></span>
              </span>
              <span class="line-vertical"></span>
            </div>
37
            <div class="item" @click="goToDetail(item.voucherId, item.makeId, item.voucherType, item.state)">
潘琦 committed
38 39 40 41
              <CardItem :data="item"></CardItem>
              <span class="status">
                <img src='../../assets/images/icon-failed.png' v-if="item.state==4" class="full-width"/>
                <img src='../../assets/images/icon-completed.png' v-if="item.state==2" class="full-width"/>
42
                <img src='../../assets/images/icon-end.png' v-if="item.state==3" class="full-width"/>
潘琦 committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
                <img src='../../assets/images/icon-waiting.png' v-if="item.state==0" class="full-width"/>
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import { getStore } from '@/util/store'
import { getAllVoucherByUserId, getUserInfoByUserId } from '@/api/apply/apply'
import { userRealStateById } from '@/api/basic/basic'
import CardItem from '@/components/cardItem'
import _iconMan from '@/assets/images/man.png'
import _iconWoman from '@/assets/images/woman.png'
export default {
  name: 'user',
  data () {
    return {
      userId: parseInt(this.$route.query.userId),
      active: 0,
      mainUserData: {
        name: '',
        sex: 1,
        picture: ''
      }, // 户主信息
      FamilyData: null, // 家庭成员数据
      cardData: null // 用户所有健康券数据
    }
  },
  created () {
    this.getFamilyByUserIdFn(this.userId)
  },
  mounted: function () {
  },
  computed: {
  },
  components: {
    CardItem
  },
  methods: {
    getFamilyByUserIdFn (id) { // 根据用户id获取该用户家庭成员信息
      let that = this
      getUserInfoByUserId(id).then(res => {
        if (res.code === 0) {
          that.FamilyData = res.data
          that.FamilyData.forEach(element => {
            if (element.masterMark === 1) {
              that.mainUserData.name = element.name
              that.mainUserData.sex = element.sex
              that.mainUserData.picture = element.sex === 1 ? _iconMan : element.sex === 2 ? _iconWoman : _iconMan
              that.getAllVoucherByUserIdFn(element.userId)
              return true
            }
          })
        }
      }).catch((error) => {
        this.$toast({
          message: error.message,
          position: 'center',
          duration: 3000
        })
      })
    },
    getAllVoucherByUserIdFn (id) { // 根据用户id获取该用户下所有健康券
      this.$Indicator.open()
      getAllVoucherByUserId(id).then(res => {
        this.$Indicator.close()
        if (res.code === 0) {
          this.cardData = res.data
        }
      }).catch((error) => {
        this.$toast({
          message: error.message,
          position: 'center',
          duration: 3000
        })
      })
    },
    goToMember () { // 跳转至家庭成员页
      this.$Indicator.open()
      userRealStateById(this.userId).then(res => {
        this.$Indicator.close()
        if (res.code === 0 && res.data) { // 已实名跳转至成员列表页、否则跳转至实名页
          this.$router.push({
            path: '/member/list',
            query: {
              userId: this.userId
            }
          })
        } else {
          this.$MessageBox.confirm('您还未进行实名认证,请先实名').then(action => {
            this.$router.push({ // 跳转至实名注册页
              path: '/member/addMain'
            })
          })
        }
      }).catch((error) => {
        this.$toast({
          message: error.message,
          position: 'center',
          duration: 3000
        })
      })
149
    },
150 151 152 153 154 155 156 157 158
    goToDetail (voucherId, makeId, voucherType, state) {
      if (state === 0) {
        this.$Toast({
          message: '该券还未发放,暂不可查看',
          position: 'center',
          duration: 3 * 1000
        })
        return
      }
159 160 161 162 163 164 165 166
      if (state === 3) {
        this.$Toast({
          message: '该券已过期,无法查看',
          position: 'center',
          duration: 3 * 1000
        })
        return
      }
167 168 169 170
      this.$router.push({
        path: '/voucherDetail',
        query: {
          voucherId: voucherId,
171 172
          makeId: makeId,
          voucherType: voucherType
173 174
        }
      })
潘琦 committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
    }
  }
}
</script>

<style scoped>
  .full-page {
    background-color: #ffffff;
  }
  .user-page .head{
    display:table;
    width:100%;
    color:#fff;
    background-color:#43d1be;
  }
  .user-page .head .picture{
    display:table-cell;
    vertical-align:middle;
    width:6em;
    padding: 1.4em 0 1.4em 1em;
  }
  .user-page .head .picture .avatar {
    border-radius: 50%;
    width: 4.2em;
    height: 4.2em;
  }
  .user-page .head .picture .avatar img {
    width: 100%;
  }
  .user-page .head .info {
    display:table-cell;
    vertical-align:middle;
    font-size: 1.1em;
  }
  .user-page .head .more {
    display:table-cell;
    vertical-align:middle;
    width:6.1em;
    text-align:right;
    padding-right: 1em;
  }
216
  .user-page .head .more > .more-btn {
潘琦 committed
217 218 219 220
    display:inline-block;
    width:6.1em;
    border-radius:10px;
    background-color:rgba(0, 0, 0, 0.2);
221
    padding:0.4em 0;
潘琦 committed
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
    text-align:center;
    border:1px solid rgba(255, 255, 255, 0.5);
    font-size: 1em;
  }

  .user-page .user-body > .tab-content .line-list {
    margin-bottom: 0.4em;
  }

  .tab-container {
    overflow-x: auto;
    width: 100%;
    padding: 15px 0;
  }
  .tab-container .mint-navbar {
    white-space: nowrap;
  }
  .tab-container .mint-navbar .mint-tab-item {
    background-color: #ffffff;
    margin-bottom: 0;
    border-radius: 15px;
    /* border: 1px solid #ccc; */
    box-shadow: 1px 1px 5px #cccccc;
    padding: 0 0.5em;
    margin: 0 0.5em;
    color: #80848f;
潘琦 committed
248
    max-width: 7em;
潘琦 committed
249 250
    height: 2em;
    font-size: 1em;
潘琦 committed
251
    flex:none;
潘琦 committed
252 253 254 255 256 257 258 259 260 261 262 263
  }

  .tab-container .mint-navbar .mint-tab-item.is-selected {
    border-bottom: 0;
    color: #fff;
    background-color: #ffa353;
    margin-bottom: 0;
    border-radius: 15px;
    box-shadow: 1px 1px 5px #ffa353;
  }

  .user-page .user-body > .tab-content {
潘琦 committed
264
    padding: 0 0.8em;
潘琦 committed
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
  }

  .user-page .user-body > .tab-content > .tips {
    font-size: 1.1em;
    padding: 1em 0;
  }

  .line-list > .item {
    position: relative;
  }
  .line-list > .item > .status{
    position:absolute;
    display:inline-block;
    right: 0;
    bottom: 1.2em;
    width: 5em;
  }
  .line-list > .item > .status > img {
    width: 100%;
  }
285 286 287 288 289 290 291

  .line-list .card-item > .card-item-content > .card-item-table > .price .label {
    font-size: 2em;
  }
  .line-list .card-item > .card-item-content > .card-item-table > .info .title {
    margin-bottom: 5px;
  }
潘琦 committed
292
</style>