card.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="container">
  3. <view class="coupon-list">
  4. <view class="coupon-item" v-for="(item, index) in couponList" :key="index">
  5. <view class="hidden-box" v-show="item.spread">
  6. <view style="width: 100%;padding-bottom: 30rpx;" class="qrcode-box">
  7. <view style="width: 80rpx;height: 80rpx;float: left;border-radius:40rpx;text-align: center;color: #FFFFFF;">
  8. <image src="/static/images/my/thorui.png" class="tui-logo" mode="widthFix"></image>
  9. </view>
  10. <view style="margin-left: 100rpx;">
  11. <view class="code-tit">{{ item.name }}</view>
  12. <view class="code-num">ID号:{{ item.id }}</view>
  13. </view>
  14. </view>
  15. <view class="qrcode-box">
  16. <view class="qrcode">
  17. <canvas :class="{ 'my-canvas': !item.spread }" :style="{ width: qrcode_w + 'px', height: qrcode_w + 'px' }"
  18. :canvas-id="'couponQrcode' + index" :id="'couponQrcode' + index"></canvas>
  19. </view>
  20. </view>
  21. <view class="list-item">
  22. 扫一扫上面二维码,加我为好友
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. const util = require('@/utils/util.js');
  31. const qrCode = require('@/libs/weapp-qrcode.js');
  32. export default {
  33. data() {
  34. return {
  35. show: true,
  36. couponList: [{
  37. name: '哈尼克美',
  38. id: '0900100200',
  39. spread: true,
  40. }],
  41. qrcode_w: uni.upx2px(240)
  42. };
  43. },
  44. onLoad: function(options) {
  45. const W = uni.getSystemInfoSync().windowWidth;
  46. const qrcode_w = uni.upx2px(260);
  47. this.qrcode_w = qrcode_w;
  48. // #ifdef APP-PLUS || MP
  49. setTimeout(() => {
  50. this.couponQrCode(this.couponList[0].id, 'couponQrcode0');
  51. }, 60);
  52. // #endif
  53. },
  54. methods: {
  55. spread: function(index) {
  56. let couponList = this.couponList;
  57. if (!couponList[index].spread) {
  58. setTimeout(() => {
  59. this.couponQrCode(couponList[index].id, 'couponQrcode' + index);
  60. }, 60);
  61. }
  62. couponList[index].spread = !couponList[index].spread;
  63. this.couponList = couponList;
  64. },
  65. // 二维码生成工具
  66. couponQrCode(text, canvasId) {
  67. new qrCode(canvasId, {
  68. text: text,
  69. width: this.qrcode_w,
  70. height: this.qrcode_w,
  71. colorDark: '#333333',
  72. colorLight: '#FFFFFF',
  73. correctLevel: qrCode.CorrectLevel.H
  74. });
  75. if (canvasId == 'couponQrcode0') {
  76. setTimeout(() => {
  77. if (!this.show) {
  78. this.show = true;
  79. }
  80. }, 0);
  81. }
  82. }
  83. }
  84. };
  85. </script>
  86. <style>
  87. /* #ifdef MP-ALIPAY */
  88. .my-canvas {
  89. position: fixed;
  90. left: -200px;
  91. top: 0;
  92. }
  93. /* #endif */
  94. .container {
  95. width: 100%;
  96. padding-bottom: env(safe-area-inset-bottom);
  97. }
  98. .tui-logo {
  99. height: 100%;
  100. width: 100%;
  101. flex-shrink: 0;
  102. }
  103. .header {
  104. width: 100%;
  105. padding: 0 30rpx;
  106. box-sizing: border-box;
  107. font-size: 24rpx;
  108. color: #999;
  109. height: 54rpx;
  110. line-height: 54rpx;
  111. background: #fff;
  112. display: flex;
  113. align-items: center;
  114. position: fixed;
  115. top: 0;
  116. /* #ifdef H5 */
  117. top: 44px;
  118. /* #endif */
  119. z-index: 999999;
  120. }
  121. .coupon-num {
  122. color: #5677fc;
  123. }
  124. .coupon-list {
  125. width: 100%;
  126. padding: 54rpx 50rpx;
  127. box-sizing: border-box;
  128. }
  129. .coupon-item {
  130. margin-top: 20rpx;
  131. width: 100%;
  132. box-shadow: 0 8rpx 10rpx -8rpx #eaeef1;
  133. border-radius: 2rpx;
  134. }
  135. .coupon {
  136. height: 160rpx;
  137. position: relative;
  138. display: flex;
  139. align-items: center;
  140. }
  141. .coupon-img {
  142. width: 100%;
  143. height: 160rpx;
  144. position: absolute;
  145. left: 0;
  146. top: 0;
  147. z-index: 0;
  148. }
  149. .left-tit-box {
  150. width: 414rpx;
  151. padding-left: 75rpx;
  152. box-sizing: border-box;
  153. z-index: 10;
  154. }
  155. .tit {
  156. width: 290rpx;
  157. font-size: 30rpx;
  158. color: #333;
  159. line-height: 42rpx;
  160. overflow: hidden;
  161. text-overflow: ellipsis;
  162. display: -webkit-box;
  163. -webkit-line-clamp: 2;
  164. -webkit-box-orient: vertical;
  165. }
  166. .term {
  167. width: 228rpx;
  168. font-size: 24rpx;
  169. color: #999;
  170. line-height: 24rpx;
  171. padding-top: 7rpx;
  172. white-space: nowrap;
  173. }
  174. .right-detail {
  175. width: 236rpx;
  176. text-align: center;
  177. height: 160rpx;
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. z-index: 10;
  182. }
  183. .detail-txt {
  184. font-size: 24rpx;
  185. color: #fff;
  186. padding-right: 12rpx;
  187. }
  188. .arrow {
  189. width: 16rpx;
  190. height: 24rpx;
  191. transition: all 0.15s ease;
  192. }
  193. .spread {
  194. width: 24rpx;
  195. height: 16rpx;
  196. }
  197. .qrcode {
  198. width: 260rpx;
  199. height: 260rpx;
  200. margin: 45rpx auto 43rpx auto;
  201. }
  202. .hidden-box {
  203. padding: 35rpx 40rpx 27rpx 40rpx;
  204. box-sizing: border-box;
  205. color: #333;
  206. border-top: 1rpx solid #eaeef1;
  207. background: #fff;
  208. }
  209. .code-tit {
  210. font-size: 28rpx;
  211. line-height: 28rpx;
  212. }
  213. .code-num {
  214. font-size: 30rpx;
  215. line-height: 30rpx;
  216. padding-top: 23rpx;
  217. }
  218. .qrcode-box {
  219. width: 100%;
  220. border-bottom: 1rpx dashed #eaeef1;
  221. margin-bottom: 6rpx;
  222. }
  223. .list-item {
  224. text-align: center;
  225. align-items: center;
  226. justify-content: space-between;
  227. font-size: 28rpx;
  228. }
  229. .list-item::after {
  230. left: 0;
  231. }
  232. .item-tit {
  233. color: #666;
  234. }
  235. .item-con {
  236. color: #333;
  237. }
  238. .explain {
  239. font-size: 28rpx;
  240. line-height: 28rpx;
  241. color: #666;
  242. padding: 33rpx 0 25rpx 0;
  243. }
  244. .explain-text {
  245. font-size: 28rpx;
  246. line-height: 41rpx;
  247. color: #333;
  248. }
  249. .none {
  250. width: 100%;
  251. position: fixed;
  252. text-align: center;
  253. font-size: 30rpx;
  254. color: #ccc;
  255. top: 49%;
  256. }
  257. .tui-rotate_90 {
  258. transform: rotate(90deg);
  259. }
  260. </style>