coupon.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="content">
  3. <!-- 二维码 -->
  4. <tki-qrcode v-if="info.store&&info.status==0" :cid="cid" ref="qrcode" :val="info.code" :size="size" :unit="unit" :background="background"
  5. :foreground="foreground" :pdground="pdground" :iconSize="iconSize" :lv="lv" :onval="onval"
  6. :loadMake="loadMake" :usingComponents="usingComponents" @result="qrR" />
  7. <view class="text" v-if="info.store&&info.status==0">
  8. {{info.code}}
  9. </view>
  10. <view class="text" v-if="info.store&&info.status==0">
  11. 请向核销员出示
  12. </view>
  13. <view class="store" v-if="info.store">
  14. <view class="">
  15. 商家名称: <text class="item">{{info.store.name}}</text>
  16. </view>
  17. <view class="">
  18. 商家电话: <text class="item">{{info.store.phone}}</text>
  19. </view>
  20. <view class="">
  21. 商家地址:<text class="item">{{info.store.address}}{{info.store.detailed_address}}</text>
  22. </view>
  23. </view>
  24. <view class="title">
  25. 优惠券名称: <text class="item">{{info.coupon_title}}</text>
  26. </view>
  27. <view class="title">
  28. 优惠: <text class="red item">{{info.coupon_price}}¥</text>
  29. </view>
  30. <view class="title" v-if="info.use_min_price!='0.00'">
  31. 使用条件:<text class="item">满{{info.use_min_price}}¥可使用</text>
  32. </view>
  33. <view class="title" v-else>
  34. 使用条件: <text class="item">无门槛</text>
  35. </view>
  36. <view class="title">
  37. 有效期:<text class="item"> {{info._add_time}}至{{info._end_time}}</text>
  38. </view>
  39. <view class="title">
  40. 优惠券状态:<text class="item">{{info._msg}}</text>
  41. </view>
  42. <view class="" v-if="info.store">
  43. <!-- #ifdef H5 -->
  44. <button class="dh"@click.stop="toGaodeMap(info.store.latitude,info.store.longitude,info.store.name)">导航到商家</button>
  45. <!-- #endif -->
  46. <!-- #ifdef MP -->
  47. <button class="dh"@click.stop="dh(info.store)">导航到商家</button>
  48. <!-- #endif -->
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
  54. import {CouponsDetails } from '@/api/order.js';
  55. export default{
  56. components: {
  57. tkiQrcode
  58. },
  59. data() {
  60. return {
  61. info:'',
  62. id:0,
  63. cid: 'tki-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
  64. size: 362, //生成的二维码大小
  65. unit: 'upx', //大小单位尺寸
  66. show: true, //默认使用组件中的image标签显示二维码
  67. background: '#ffffff', //二维码背景色
  68. foreground: '#333333', //二维码前景色
  69. pdground: '#333333', //二维码角标色
  70. icon: '', //二维码图标URL(必须是本地图片,网络图需要先下载至本地)
  71. iconSize: 40, //二维码图标大小
  72. lv: 3, //容错级别
  73. onval: true, //监听val值变化自动重新生成二维码
  74. loadMake: true, //组件初始化完成后自动生成二维码,val需要有值
  75. usingComponents: false, //是否使用了自定义组件模式(主要是为了修复非自定义组件模式时 v-if 无法生成二维码的问题)
  76. showLoading: false, //是否显示loading
  77. loadingText: '二维码生成中', //loading文字
  78. src: '', // 二维码生成后的图片地址或base64
  79. ratio: 1, //页面比例用于计算
  80. ctxSrc: '', //要显示的图片
  81. loading: true, //是否载入图片中
  82. canHeight: '', //画布高度
  83. canWeidth: '' //画布宽度
  84. };
  85. },
  86. onLoad(options) {
  87. this.id=options.id
  88. this.loadData();
  89. },
  90. methods: {
  91. // 核销码事件
  92. qrR(){},
  93. // 导航事件
  94. dh(){
  95. uni.openLocation({
  96. latitude:this.info.store.latitude,
  97. longitude:this.info.store.longitude,
  98. success: function () {
  99. console.log('success');
  100. }
  101. });
  102. },
  103. //返回首页
  104. navTo(){
  105. uni.switchTab({
  106. url: '/pages/index/index'
  107. });
  108. },
  109. //获取优惠券详情
  110. loadData() {
  111. let t=this
  112. console.log(0)
  113. CouponsDetails({
  114. id:this.id,
  115. })
  116. .then(({ data }) => {
  117. console.log(data,'909090')
  118. t.info=data[0]
  119. })
  120. .catch(e => {
  121. console.log(e);
  122. })
  123. },
  124. // 导航
  125. dh(item) {
  126. wx.openLocation({
  127. latitude: item.latitude * 1,
  128. longitude: item.longitude * 1,
  129. name: item.name,
  130. address: item.detailed_address
  131. })
  132. },
  133. // 调用高德
  134. toGaodeMap(latitude, longitude, address) {
  135. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  136. },
  137. }
  138. };
  139. </script>
  140. <style lang="scss">
  141. // 卡卷可用时颜色
  142. $card-color-action: #fc4141;
  143. page,
  144. .content {
  145. padding: 40rpx;
  146. text-align: center;
  147. border-radius: 20rpx;
  148. margin: 2%;
  149. background:#fff;
  150. width: 96%;
  151. height: 94%;
  152. }
  153. .title,.store{
  154. letter-spacing:8rpx;
  155. margin: 20rpx;
  156. font-size: 32rpx;
  157. text-align: left;
  158. }
  159. .red{
  160. color:$card-color-action ;
  161. }
  162. .item{
  163. letter-spacing:4rpx;
  164. font-size: 24rpx;
  165. }
  166. .dh{
  167. margin-top: 60rpx;
  168. color: #fff;
  169. background-color: $card-color-action;
  170. }
  171. .text{
  172. font-size: 24rpx;
  173. letter-spacing:4rpx;
  174. margin-top: 20rpx;
  175. }
  176. </style>