VoucherPrivate.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="代金券" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view v-if="vouchertemplate.vouchertemplate_creator_id>0">
  14. <view class="vouchertemplate-wrapper">
  15. <image mode="aspectFit" class="img top" src="../../../static/image/member/vouchertemplate-top.png"></image>
  16. <image mode="aspectFit" class="img bottom" src="../../../static/image/member/vouchertemplate-bottom.png"></image>
  17. <view class="div vouchertemplate-info">
  18. <view class="div storename" >{{vouchertemplate.vouchertemplate_storename}}商品代金券</view>
  19. <view class="div time"><text class="left"></text><text class="middle"></text>有效期{{vouchertemplate.vouchertemplate_startdate}}-{{vouchertemplate.vouchertemplate_enddate}}<text class="right"></text></view>
  20. <view class="div price-wrapper">
  21. <view class="price">
  22. ¥<text class="number">{{vouchertemplate.vouchertemplate_price}}</text>
  23. <view class="p">满{{vouchertemplate.vouchertemplate_limit}}元使用</view>
  24. </view>
  25. <view class="store-img">
  26. <image mode="aspectFit" class="img" src="../../../static/image/member/vouchertemplate-store.png"></image>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="btn-wrapper" v-if='state == 0'><view class="div common-btn" @click="exchangeVoucher(vouchertemplate)">确认领取</view></view>
  32. <view class="btn-wrapper" v-else><view class="div common-btn" @click="goNavigate('/pages/home/storegoodslist/Goodslist',{ id: vouchertemplate.vouchertemplate_store_id })">领取成功,去使用</view></view>
  33. </view>
  34. <view class="div" v-else>
  35. <empty-record></empty-record>
  36. </view>
  37. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  38. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  39. </uni-popup>
  40. </view></member-base>
  41. </template>
  42. <script>
  43. import {getFontSize} from '@/util/common'
  44. import TitleHeader from '../../TitleHeader'
  45. import { urlencode } from '@/util/common'
  46. import MemberBase from '../MemberBase'
  47. import { getVoucherPrivate } from '../../../api/memberVoucher'
  48. import { exchangePointVoucher } from '../../../api/homePointsgoods'
  49. import EmptyRecord from '../../EmptyRecord'
  50. import { mapState } from 'vuex'
  51. export default {
  52. name: 'VoucherPrivate',
  53. components:{
  54. TitleHeader,
  55. MemberBase,
  56. EmptyRecord
  57. },
  58. computed:{
  59. fontSize(){
  60. return getFontSize()
  61. },
  62. ...mapState({
  63. token: state => state.member.token
  64. })
  65. },
  66. data(){
  67. return {
  68. navHeight: 0,
  69. dialog:{},
  70. vouchertemplate_id:0,
  71. vouchertemplate:{},
  72. state:0
  73. }
  74. },
  75. onLoad: function (option) {
  76. this.vouchertemplate_id=option.id ? option.id : '0'
  77. this.getVoucherPrivate()
  78. },
  79. methods:{
  80. closeDialog(){
  81. },
  82. confirmDialog(value){
  83. exchangePointVoucher({ vid: this.dialog.data.vouchertemplate_id, key: this.token }).then(res => {
  84. uni.showToast({icon:'none',title: res.message})
  85. this.state = 1
  86. }).catch(error => {
  87. uni.showToast({icon:'none',title: error.message})
  88. })
  89. },
  90. exchangeVoucher (vouchertemplate) {
  91. this.dialog={content:'您确定需要使用' + vouchertemplate.vouchertemplate_points + '积分兑换代金券吗?',data:vouchertemplate}
  92. this.$refs.confirm.open()
  93. },
  94. goNavigate(path,query=false){
  95. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  96. },
  97. goBack () {
  98. uni.navigateBack({delta:1})
  99. },
  100. getVoucherPrivate () {
  101. getVoucherPrivate(this.vouchertemplate_id).then(res => {
  102. this.vouchertemplate = res.result.vouchertemplate_info
  103. }).catch(function (error) {
  104. uni.hideLoading()
  105. uni.showToast({icon:'none',title: error.message})
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. .vouchertemplate-wrapper{
  113. background-color: #e6a117;
  114. position: relative;
  115. padding: 1rem $pageSpace;
  116. color: #fff;
  117. display: flex;
  118. justify-content: center;
  119. margin: .9rem;
  120. .img{
  121. position: absolute;
  122. width: 100%;
  123. height: .15rem;
  124. object-fit: cover;
  125. }
  126. .top{
  127. top: 0;
  128. left: 0;
  129. }
  130. .bottom{
  131. left: 0;
  132. bottom: 0;
  133. }
  134. .vouchertemplate-info{
  135. font-size: .7rem;
  136. .storename{
  137. text-align: center;
  138. }
  139. .time{
  140. display: flex;
  141. align-items: center;
  142. height: .8rem;
  143. margin-top: .7rem;
  144. .left{
  145. width: 2rem;
  146. height: 1px;
  147. background-color: rgba(255,255,255,.2);
  148. flex: 1 1 0%;
  149. margin-right: 1rem;
  150. }
  151. .right{
  152. width: 2rem;
  153. height: 1px;
  154. background-color: rgba(255,255,255,.2);
  155. flex: 1 1 0%;
  156. margin-left: 1rem;
  157. }
  158. }
  159. .price-wrapper{
  160. padding-top: 1rem;
  161. display: flex;
  162. .price{
  163. font-size: .9rem;
  164. .number{
  165. font-size: 1.9rem;
  166. }
  167. .p{
  168. font-size: .7rem;
  169. }
  170. }
  171. .store-img{
  172. width: 4.5rem;
  173. height: 4.5rem;
  174. margin-left: auto;
  175. margin-top: -1rem;
  176. .img{
  177. width: 4.5rem;
  178. height: 4.5rem;
  179. }
  180. }
  181. }
  182. }
  183. }
  184. .btn-wrapper{
  185. margin-top: 1rem;
  186. margin: 0 .8rem;
  187. .common-btn{
  188. background-image: linear-gradient(to right, rgb(255, 144, 0), rgb(255, 80, 0));
  189. color: #fff;
  190. font-size: .8rem;
  191. padding: .5rem 0;
  192. border-radius: .5rem;
  193. width: 100%;
  194. }
  195. }
  196. </style>