StoreVoucher.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false" ><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="代金券" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div common-popup-content">
  13. <view class="div common-voucher common-voucher02" v-for="(item,index) in voucher" :key="item.vouchertemplate_id" @click="receiveVoucher(item.vouchertemplate_id)">
  14. <view class="div par"><view class="p">订单满{{item.vouchertemplate_limit}}元</view><text class="sub sign">¥</text><text class="span">{{item.vouchertemplate_price}}</text></view>
  15. <view class="div copy">有效期至<view class="p">{{$moment.unix(item.vouchertemplate_enddate).format('YYYY年MM月DD日')}}</view><view class="p">兑换需{{item.vouchertemplate_points}}积分</view><view class="p">立即兑换</view></view>
  16. <text class="i"></text>
  17. </view>
  18. </view>
  19. </view></home-base>
  20. </template>
  21. <script>
  22. import {getFontSize} from '@/util/common'
  23. import TitleHeader from '../../TitleHeader'
  24. import HomeBase from '../HomeBase'
  25. import { mapState, mapMutations } from 'vuex'
  26. import { receiveVoucher } from '../../../api/homestoredetail'
  27. export default {
  28. name:'HomeStoreVoucher',
  29. mounted(){
  30. // #ifdef MP-WEIXIN
  31. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  32. // #endif
  33. },
  34. data(){
  35. return {
  36. navHeight: 0,
  37. }
  38. },
  39. components:{
  40. TitleHeader,
  41. HomeBase,
  42. },
  43. computed:{
  44. fontSize(){
  45. return getFontSize()
  46. },
  47. ...mapState({
  48. voucher: state => state.goodsdetail.voucher
  49. })
  50. },
  51. created () {
  52. },
  53. methods:{
  54. goBack(){uni.navigateBack({delta:1})},
  55. receiveVoucher (tid) {
  56. receiveVoucher(
  57. tid
  58. ).then((res) => {
  59. uni.showToast({icon:'none',title: res.message})
  60. }).catch(function (error) {
  61. uni.showToast({icon:'none',title: error.message})
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. .common-voucher{margin:.5rem auto}
  69. </style>