djqQm.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="content">
  3. <swiper :indicator-dots="list.length > 1" class="box">
  4. <swiper-item class="djq-wrap" v-for="(item, index) in list">
  5. <view>
  6. <view class="djq-top flex f-d-c f-j-c">
  7. <view class="djq-name">{{ item.coupon_title }}</view>
  8. <view class="djq-time">{{ item.end_time | showTime }}</view>
  9. </view>
  10. <view class="djq-body">
  11. <view class="used" v-if="item.status == 1">
  12. <image src="../../static/img/ysy.png" mode=""></image>
  13. </view>
  14. <view class="used" v-if="item.status == 2">
  15. <image src="../../static/img/ygq.png" mode=""></image>
  16. </view>
  17. <view class="ewm">
  18. <tki-qrcode :cid="'aaa' + index" ref="qrcode" :val="item.code" :size="size" :unit="unit"
  19. :background="background" :foreground="foreground" :pdground="pdground"
  20. :iconSize="iconSize" :lv="lv" :onval="onval" :loadMake="loadMake"
  21. :usingComponents="usingComponents" @result="qrR" />
  22. </view>
  23. <view class="ewm-code">{{ item.code }}</view>
  24. </view>
  25. </view>
  26. </swiper-item>
  27. </swiper>
  28. </view>
  29. </template>
  30. <script>
  31. import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
  32. import {
  33. view_order
  34. } from '@/api/order.js';
  35. import {
  36. getYhqDetail
  37. } from '@/api/shop.js'
  38. export default {
  39. components: {
  40. tkiQrcode
  41. },
  42. filters: {
  43. showTime(val) {
  44. let str = ''
  45. if (val == 0) {
  46. str = '永久有效'
  47. }
  48. if (val) {
  49. var time = new Date(val * 1000);
  50. var y = time.getFullYear();
  51. var m = time.getMonth() + 1;
  52. var d = time.getDate();
  53. var h = time.getHours();
  54. var mm = time.getMinutes();
  55. var s = time.getSeconds();
  56. str = '有效期至:' + y + '年' + m + '月' + d + '日'
  57. console.log(str)
  58. }
  59. return str
  60. }
  61. },
  62. data() {
  63. return {
  64. code: '',
  65. list: [],
  66. id: '',
  67. cid: 'tki-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
  68. size: 440, //生成的二维码大小
  69. unit: 'upx', //大小单位尺寸
  70. show: true, //默认使用组件中的image标签显示二维码
  71. background: '#ffffff', //二维码背景色
  72. foreground: '#333333', //二维码前景色
  73. pdground: '#333333', //二维码角标色
  74. icon: '', //二维码图标URL(必须是本地图片,网络图需要先下载至本地)
  75. iconSize: 40, //二维码图标大小
  76. lv: 3, //容错级别
  77. onval: true, //监听val值变化自动重新生成二维码
  78. loadMake: true, //组件初始化完成后自动生成二维码,val需要有值
  79. usingComponents: false, //是否使用了自定义组件模式(主要是为了修复非自定义组件模式时 v-if 无法生成二维码的问题)
  80. showLoading: false, //是否显示loading
  81. loadingText: '二维码生成中', //loading文字
  82. src: '', // 二维码生成后的图片地址或base64
  83. ratio: 1, //页面比例用于计算
  84. ctxSrc: '', //要显示的图片
  85. loading: true //是否载入图片中
  86. };
  87. },
  88. onLoad(opt) {
  89. if (opt.id) {
  90. this.id = opt.id;
  91. this.loadData();
  92. }
  93. if (opt.code) {
  94. this.code = opt.code
  95. this.getYhqDetail()
  96. }
  97. },
  98. onShow() {},
  99. onReachBottom() {},
  100. onReady() {},
  101. methods: {
  102. loadData() {
  103. const obj = this;
  104. view_order({
  105. order_id: this.id
  106. }).then(({
  107. data
  108. }) => {
  109. this.list = data.coupon;
  110. console.log(this.list);
  111. });
  112. },
  113. qrR() {},
  114. getYhqDetail() {
  115. let obj = this
  116. getYhqDetail({
  117. code: obj.code
  118. }).then(res => {
  119. console.log(res)
  120. obj.list.push(res.data)
  121. })
  122. }
  123. }
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. page {
  128. height: 100%;
  129. background-color: #f9e24f;
  130. }
  131. .box {
  132. width: 696rpx;
  133. margin: auto;
  134. height: 1060rpx;
  135. }
  136. .djq-wrap {
  137. width: 696rpx;
  138. background-color: #fff;
  139. position: relative;
  140. margin: auto;
  141. margin-top: 100rpx;
  142. .djq-top {
  143. height: 185rpx;
  144. background: #f5f5f5;
  145. overflow: hidden;
  146. .djq-name {
  147. padding: 0 60rpx;
  148. font-size: 44rpx;
  149. font-weight: bold;
  150. text-align: center;
  151. color: #222222;
  152. }
  153. .djq-time {
  154. font-size: 24rpx;
  155. font-weight: 500;
  156. color: #686868;
  157. }
  158. &::after,
  159. &::before {
  160. content: '';
  161. height: 120rpx;
  162. width: 120rpx;
  163. border-radius: 50%;
  164. position: absolute;
  165. top: -60rpx;
  166. background-color: #f9e24f;
  167. }
  168. &::before {
  169. left: -60rpx;
  170. }
  171. &::after {
  172. right: -60rpx;
  173. }
  174. }
  175. .djq-body {
  176. height: 770rpx;
  177. position: relative;
  178. padding-top: 115rpx;
  179. &::after,
  180. &::before {
  181. content: '';
  182. height: 120rpx;
  183. width: 120rpx;
  184. border-radius: 50%;
  185. position: absolute;
  186. bottom: -60rpx;
  187. background-color: #f9e24f;
  188. }
  189. &::before {
  190. left: -60rpx;
  191. }
  192. &::after {
  193. right: -60rpx;
  194. }
  195. .used {
  196. position: absolute;
  197. top: 0rpx;
  198. right: 0rpx;
  199. z-index: 99;
  200. height: 440rpx;
  201. width: 440rpx;
  202. image {
  203. width: 100%;
  204. height: 100%;
  205. }
  206. }
  207. .ewm {
  208. width: 440rpx;
  209. height: 440rpx;
  210. margin: auto;
  211. }
  212. .ewm-code {
  213. padding-top: 55rpx;
  214. font-size: 44rpx;
  215. font-weight: bold;
  216. color: #333333;
  217. text-align: center;
  218. }
  219. }
  220. }
  221. </style>