poster.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="page">
  3. <!-- 头部吸顶tab标签 -->
  4. <u-sticky bgColor="#fff">
  5. <view class="tabView">
  6. <u-tabs :list="classifyList" @click="click" :scrollable="false" lineWidth="32"
  7. :activeStyle="{ color: '#333', fontWeight: 'bold' }" :inactiveStyle="{ color: '#999' }"
  8. :itemStyle="{ height: '48rpx' }"></u-tabs>
  9. </view>
  10. </u-sticky>
  11. <!-- 海报图片列表 -->
  12. <view class="waterfallImage">
  13. <image class="poster-img" :src="item" lazy-load mode="" v-for="(item, index) in list" :key="index"
  14. @click="showLargeImage(item)"></image>
  15. </view>
  16. <!-- 大图预览弹窗 -->
  17. <u-overlay :show="showLargeImageShow" @click="showLargeImageShow = false" :opacity="0.6" class="u-overlay">
  18. <view class="close-btn dis a-c j-c" @click="showLargeImageShow = false">×</view>
  19. <view class="posterview u-overlay dis f-c" @tap.stop>
  20. <image class="promoImage" :src="sctiveimg" mode=""></image>
  21. <view class="userinfo dis a-c j-s">
  22. <view class="dis f-c">
  23. <view class="item dis mb-1">
  24. <view>业务员</view>
  25. <text>{{ userInfo.sysUser.name }}</text>
  26. </view>
  27. <view class="item dis">
  28. <view>电话</view>
  29. <text>{{ userInfo.sysUser.mobile }}</text>
  30. </view>
  31. </view>
  32. <view class="panelcanvas " id="panelcanvas">
  33. <image :src="qrcodeImg" mode="widthFix" lazy-load></image>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 分享操作栏 -->
  38. <view class="share-prop" @tap.stop>
  39. <view class="header-title dis a-c j-c">分享到</view>
  40. <view class="foo-btn dis a-c j-s">
  41. <view class="interact-item dis f-c a-c">
  42. <image src="/static/icon/tool/saveImg.png" mode=""></image>
  43. <text>保存到相册</text>
  44. </view>
  45. <view class="interact-item dis f-c a-c">
  46. <image src="/static/icon/tool/wx.png" mode=""></image>
  47. <text>微信</text>
  48. </view>
  49. <view class="interact-item dis f-c a-c">
  50. <image src="/static/icon/tool/friendsCircleLogo.png" mode=""></image>
  51. <text>朋友圈</text>
  52. </view>
  53. </view>
  54. </view>
  55. </u-overlay>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. mapState,
  61. mapMutations
  62. } from "vuex"
  63. import QR from "@/common/wxqrcode.js"
  64. import {
  65. turnBase64Image
  66. } from '@/plugins/utils.js';
  67. export default {
  68. data() {
  69. return {
  70. showLargeImageShow: false,
  71. qrcodeImg: "", //二维码图片
  72. currentTab: 'baoxian', // 当前选中分类
  73. sctiveimg: "", // 放大显示的图片
  74. classifyList: [ // 分类标签
  75. {
  76. name: '保险',
  77. key: 'baoxian'
  78. },
  79. {
  80. name: '产品',
  81. key: 'product'
  82. },
  83. {
  84. name: '节气',
  85. key: 'season'
  86. },
  87. {
  88. name: '节日',
  89. key: 'festival'
  90. },
  91. {
  92. name: '增员',
  93. key: 'recruit'
  94. }
  95. ],
  96. posterData: { // 分类图片数据
  97. baoxian: [
  98. '/static/image/poster/baoxian/poster1.jpg',
  99. '/static/image/poster/baoxian/poster2.jpg',
  100. '/static/image/poster/baoxian/poster3.jpg',
  101. '/static/image/poster/baoxian/poster4.jpg',
  102. '/static/image/poster/baoxian/poster5.jpg',
  103. '/static/image/poster/baoxian/poster6.jpg',
  104. '/static/image/poster/baoxian/poster7.jpg',
  105. '/static/image/poster/baoxian/poster8.jpg',
  106. ],
  107. product: [
  108. '/static/image/poster/product/poster1.jpg',
  109. ],
  110. season: [],
  111. festival: [
  112. '/static/image/poster/festival/poster1.jpg',
  113. '/static/image/poster/festival/poster2.jpg',
  114. '/static/image/poster/festival/poster3.jpg',
  115. '/static/image/poster/festival/poster4.jpg',
  116. '/static/image/poster/festival/poster5.jpg',
  117. '/static/image/poster/festival/poster6.jpg',
  118. ],
  119. recruit: [],
  120. // ...其他分类
  121. },
  122. imageCache: {} // 缓存已转换的Base64图片
  123. };
  124. },
  125. onLoad() {
  126. this.qrcodeImg = QR.createQrCodeImg(this.$base.h5BaseUrl + '"/#/pages/registr/h5Registr?systemCode=' + this
  127. .system_code, {
  128. size: parseInt(200) //二维码大小
  129. })
  130. },
  131. computed: {
  132. ...mapState(['userInfo', 'system_code']),
  133. // 动态获取当前分类的图片列表
  134. list() {
  135. return this.posterData[this.currentTab] || [];
  136. }
  137. },
  138. methods: {
  139. // 切换分类
  140. click(tab) {
  141. this.currentTab = tab.key;
  142. },
  143. // 显示大图(带缓存优化)
  144. async showLargeImage(item) {
  145. try {
  146. if (!this.imageCache[item]) {
  147. this.imageCache[item] = await turnBase64Image(item);
  148. }
  149. this.sctiveimg = this.imageCache[item];
  150. this.showLargeImageShow = true;
  151. } catch (error) {
  152. console.error("图片转换失败:", error);
  153. uni.showToast({
  154. title: "图片加载失败",
  155. icon: "none"
  156. });
  157. }
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. .page {
  164. background-color: #f8f8f8;
  165. height: 100vh;
  166. }
  167. .tabView {
  168. padding: 20rpx 0;
  169. box-sizing: border-box;
  170. }
  171. /* 网格布局 */
  172. .waterfallImage {
  173. background-color: #f8f8f8;
  174. padding: 30rpx;
  175. display: grid;
  176. grid-template-columns: repeat(2, 1fr);
  177. gap: 30rpx;
  178. .poster-img {
  179. border-radius: 10rpx;
  180. width: 330rpx;
  181. height: 484rpx;
  182. }
  183. }
  184. /* 大图预览弹窗 */
  185. .posterview {
  186. margin: 20% 80rpx 0;
  187. background-color: #fff;
  188. border-radius: 10rpx;
  189. position: relative;
  190. .promoImage {
  191. width: 100%;
  192. height: 860rpx;
  193. border-radius: 10rpx 10rpx 0 0;
  194. }
  195. .userinfo {
  196. padding: 25rpx 40rpx;
  197. .item {
  198. font-size: 28rpx;
  199. view:first-child {
  200. color: #666;
  201. width: 84rpx;
  202. }
  203. text:last-child {
  204. color: #333;
  205. margin-left: 36rpx;
  206. }
  207. }
  208. .panelcanvas {
  209. position: relative;
  210. image {
  211. width: 100rpx;
  212. height: 100rpx;
  213. }
  214. }
  215. }
  216. }
  217. /* 分享操作栏 */
  218. .share-prop {
  219. position: absolute;
  220. bottom: 0;
  221. left: 0;
  222. width: 100%;
  223. background-color: #fff;
  224. border-radius: 20rpx 20rpx 0 0;
  225. .header-title {
  226. padding: 24rpx;
  227. font-size: 36rpx;
  228. color: #333;
  229. font-weight: bold;
  230. border-bottom: 1rpx solid #eee;
  231. }
  232. .foo-btn {
  233. padding: 30rpx 128rpx;
  234. .interact-item {
  235. image {
  236. width: 88rpx;
  237. height: 88rpx;
  238. margin-bottom: 10rpx;
  239. }
  240. text {
  241. font-size: 24rpx;
  242. color: #333;
  243. }
  244. }
  245. }
  246. }
  247. .close-btn {
  248. position: absolute;
  249. width: 50rpx;
  250. height: 50rpx;
  251. right: 20rpx;
  252. top: 20rpx;
  253. font-size: 36rpx;
  254. line-height: 0.8;
  255. font-weight: bold;
  256. z-index: 10;
  257. background-color: #fff;
  258. border-radius: 50%;
  259. }
  260. /* 自定义tab滑块样式 */
  261. ::v-deep .u-tabs__wrapper__nav__line {
  262. background: linear-gradient(90deg, #FDE935 10%, rgba(253, 233, 53, 0.1) 100%) !important;
  263. border-radius: 6rpx;
  264. }
  265. </style>