djqQm.vue 4.6 KB

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