postcard.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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;background-color: #E6B728;text-align: center;color: #FFFFFF;">
  8. <view style="font-size: 32rpx;margin-top: 15rpx;">余</view>
  9. </view>
  10. <view style="margin-left: 100rpx;">
  11. <view class="code-tit">{{ item.familtname }}</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. familtname: '陕西凤翔-余姓',
  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. .header {
  99. width: 100%;
  100. padding: 0 30rpx;
  101. box-sizing: border-box;
  102. font-size: 24rpx;
  103. color: #999;
  104. height: 54rpx;
  105. line-height: 54rpx;
  106. background: #fff;
  107. display: flex;
  108. align-items: center;
  109. position: fixed;
  110. top: 0;
  111. /* #ifdef H5 */
  112. top: 44px;
  113. /* #endif */
  114. z-index: 999999;
  115. }
  116. .coupon-num {
  117. color: #5677fc;
  118. }
  119. .coupon-list {
  120. width: 100%;
  121. padding: 54rpx 50rpx;
  122. box-sizing: border-box;
  123. }
  124. .coupon-item {
  125. margin-top: 20rpx;
  126. width: 100%;
  127. box-shadow: 0 8rpx 10rpx -8rpx #eaeef1;
  128. border-radius: 2rpx;
  129. }
  130. .coupon {
  131. height: 160rpx;
  132. position: relative;
  133. display: flex;
  134. align-items: center;
  135. }
  136. .coupon-img {
  137. width: 100%;
  138. height: 160rpx;
  139. position: absolute;
  140. left: 0;
  141. top: 0;
  142. z-index: 0;
  143. }
  144. .left-tit-box {
  145. width: 414rpx;
  146. padding-left: 75rpx;
  147. box-sizing: border-box;
  148. z-index: 10;
  149. }
  150. .tit {
  151. width: 290rpx;
  152. font-size: 30rpx;
  153. color: #333;
  154. line-height: 42rpx;
  155. overflow: hidden;
  156. text-overflow: ellipsis;
  157. display: -webkit-box;
  158. -webkit-line-clamp: 2;
  159. -webkit-box-orient: vertical;
  160. }
  161. .term {
  162. width: 228rpx;
  163. font-size: 24rpx;
  164. color: #999;
  165. line-height: 24rpx;
  166. padding-top: 7rpx;
  167. white-space: nowrap;
  168. }
  169. .right-detail {
  170. width: 236rpx;
  171. text-align: center;
  172. height: 160rpx;
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. z-index: 10;
  177. }
  178. .detail-txt {
  179. font-size: 24rpx;
  180. color: #fff;
  181. padding-right: 12rpx;
  182. }
  183. .arrow {
  184. width: 16rpx;
  185. height: 24rpx;
  186. transition: all 0.15s ease;
  187. }
  188. .spread {
  189. width: 24rpx;
  190. height: 16rpx;
  191. }
  192. .qrcode {
  193. width: 260rpx;
  194. height: 260rpx;
  195. margin: 45rpx auto 43rpx auto;
  196. }
  197. .hidden-box {
  198. padding: 35rpx 40rpx 27rpx 40rpx;
  199. box-sizing: border-box;
  200. color: #333;
  201. border-top: 1rpx solid #eaeef1;
  202. background: #fff;
  203. }
  204. .code-tit {
  205. font-size: 28rpx;
  206. line-height: 28rpx;
  207. }
  208. .code-num {
  209. font-size: 30rpx;
  210. line-height: 30rpx;
  211. padding-top: 23rpx;
  212. }
  213. .qrcode-box {
  214. width: 100%;
  215. border-bottom: 1rpx dashed #eaeef1;
  216. margin-bottom: 6rpx;
  217. }
  218. .list-item {
  219. text-align: center;
  220. align-items: center;
  221. justify-content: space-between;
  222. font-size: 28rpx;
  223. }
  224. .list-item::after {
  225. left: 0;
  226. }
  227. .item-tit {
  228. color: #666;
  229. }
  230. .item-con {
  231. color: #333;
  232. }
  233. .explain {
  234. font-size: 28rpx;
  235. line-height: 28rpx;
  236. color: #666;
  237. padding: 33rpx 0 25rpx 0;
  238. }
  239. .explain-text {
  240. font-size: 28rpx;
  241. line-height: 41rpx;
  242. color: #333;
  243. }
  244. .none {
  245. width: 100%;
  246. position: fixed;
  247. text-align: center;
  248. font-size: 30rpx;
  249. color: #ccc;
  250. top: 49%;
  251. }
  252. .tui-rotate_90 {
  253. transform: rotate(90deg);
  254. }
  255. </style>