my-popup.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <uni-popup ref="popup" :mask-click="false" maskBackgroundColor="rgba(0, 0, 0, 0.6)">
  3. <swiper ref="swiper" class="swiper" :style="getSwiperStyle()" :current="swiperCurrent"
  4. @change="swiperChange" :indicator-dots="dataList.length > 1" indicator-active-color="rgba(46, 133, 236, 1)"
  5. :autoplay="false" :interval="5000">
  6. <swiper-item v-for="(item, index) in dataList" :key="index">
  7. <!-- 标题 + 图片 + 活动时间 + 活动简介 -->
  8. <view v-if="item.type == 1" class="swiper-item-view uni-column">
  9. <text class="swiper-item-title" v-html="item.data.title"></text>
  10. <view class="swiper-item-main uni-column uni-jcse">
  11. <image mode="aspectFit" class="swiper-item-image" :src="item.data.img"></image>
  12. <view class="swiper-item-time uni-row">
  13. <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
  14. <text class="acttime">{{acttime}}</text>
  15. </view>
  16. <view class="swiper-item-content uni-column">
  17. <text class="introduce-content" v-html="item.data.content"></text>
  18. </view>
  19. </view>
  20. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  21. 续</button>
  22. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  23. </view>
  24. <!-- 标题 + 图片 -->
  25. <view v-if="item.type == 2" class="swiper-item-view uni-column">
  26. <text class="swiper-item-title" v-html="item.data.title"></text>
  27. <view class="swiper-item-main uni-column">
  28. <image mode="aspectFit" style="height: 237px; margin-top: 15px; margin-bottom: 25px;"
  29. :src="item.data.img">
  30. </image>
  31. </view>
  32. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  33. 续</button>
  34. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  35. </view>
  36. <!-- 【成就-奖牌】 标题 + 图片 + 活动简介 -->
  37. <view v-if="item.type == 3" class="swiper-item-view swiper-item-view-bg uni-column">
  38. <text class="swiper-item-title" v-html="item.data.title"></text>
  39. <view class="swiper-item-main uni-column uni-jcse">
  40. <image mode="aspectFit" style="height: 140px; margin-top: 25px;" :src="item.data.img"></image>
  41. <text class="swiper-item-content2" v-html="item.data.content"></text>
  42. </view>
  43. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  44. 续</button>
  45. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  46. </view>
  47. <!-- 【成就-兑换】 标题 + 图片 + 二维码 -->
  48. <view v-if="item.type == 4" class="swiper-item-view swiper-item-view-bg2 uni-jct uni-column">
  49. <view v-if="item.data.sponsorsLogo" class="sponsorsLogo" :style="getSponsorsLogoStyle(item.data.sponsorsLogo)"></view>
  50. <text class="swiper-item-title" v-html="item.data.title"></text>
  51. <view class="swiper-item-main uni-column uni-jcse">
  52. <view class="uni-column uni-jcse" style="height: 50px;">
  53. <text class="swiper-item-content3" v-html="item.data.content"></text>
  54. <text class="swiper-item-content4">【{{item.data.sourceName}}】</text>
  55. </view>
  56. <image class="swiper-item-image2" mode="aspectFit" :src="item.data.img"></image>
  57. <template v-if="[1,3].includes(item.data.exState)">
  58. <!-- verfType: 兑换券展示类型 1 本系统核销 2 赞助商提供码核销 3 赞助商不提供码核销 -->
  59. <uv-qrcode v-if="item.data.verfType==1" ref="qrcode" size="100px" :value="item.data.qrCode">
  60. <!-- <template v-slot:loading>
  61. <text style="color: green;">loading...</text>
  62. </template> -->
  63. </uv-qrcode>
  64. <view v-if="item.data.verfType==2" class="swiper-item-couponNum">券码:{{item.data.otherSerCode}}</view>
  65. <view v-if="item.data.expireTime > 0" class="swiper-item-content4" style="color: #ED0000;">( 有效期至
  66. {{fmtTime(item.data.expireTime, 1)}}
  67. <span v-if="item.data.exState == 3" style="color: #ffaa00; font-size: bold;">已临期</span>
  68. )
  69. </view>
  70. <view v-if="item.data.cDesc.length > 0" class="swiper-item-desc" v-html="item.data.cDesc"></view>
  71. </template>
  72. <view v-if="item.data.exState == 2" class="uni-column uni-jcse" style="height: 100px;">
  73. <text style="color: red;">已兑换</text>
  74. <text class="swiper-item-content4">( 兑换时间 {{fmtTime(item.data.exTime, 3)}} )</text>
  75. </view>
  76. <view v-if="item.data.exState == 4" class="uni-column uni-jcse" style="height: 100px;">
  77. <text style="color: red;">已过期</text>
  78. <text v-if="item.data.expireTime > 0" class="swiper-item-content4">( 过期时间
  79. {{fmtTime(item.data.expireTime, 1)}} )</text>
  80. </view>
  81. </view>
  82. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  83. 续</button>
  84. <button v-else class="swiper-item-button" @click="popupClose">关 闭</button>
  85. </view>
  86. <!-- 【兑换地点 - 单点】标题 + 图片(点击图片打开地图APP进行地点定位) -->
  87. <view v-if="item.type == 5" class="swiper-item-view uni-column">
  88. <text class="swiper-item-title" v-html="item.data.title"></text>
  89. <view class="swiper-item-main uni-column">
  90. <image mode="aspectFit" style="height: 237px; margin-top: 15px; margin-bottom: 25px;"
  91. :src="item.data.img" @click="dealNavClick(item.data.point)">
  92. </image>
  93. </view>
  94. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  95. 续</button>
  96. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  97. </view>
  98. <!-- 通知 -->
  99. <view v-if="item.type == 6" class="swiper-item-view uni-column">
  100. <text class="swiper-item-title" v-html="item.data.title"></text>
  101. <view class="swiper-item-main uni-column uni-jcse">
  102. <!-- mqType 消息类型 2:卡片图片 3:卡片文字 -->
  103. <image v-if="item.data.mqType == 2" mode="aspectFit"
  104. style="height: 237px; margin-bottom: 25px;" :src="item.data.message">
  105. </image>
  106. <text v-if="item.data.mqType == 3" class="swiper-item-message"
  107. v-html="item.data.message"></text>
  108. </view>
  109. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  110. 续</button>
  111. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  112. </view>
  113. <!-- 标题 + HTML内容 + 图片(可为空) -->
  114. <view v-if="item.type == 7" class="swiper-item-view uni-column">
  115. <image v-if="item.data.topLogo" class="swiper-item-topLogo"
  116. :style="getImageStyle(item.data.topLogo)" mode="aspectFit" :src="item.data.topLogo.src"></image>
  117. <text class="swiper-item-title" v-html="item.data.title"></text>
  118. <view class="swiper-item-main uni-column uni-jcse">
  119. <view class="swiper-item-content5">
  120. <view v-if="item.data.content" v-html="item.data.content"></view>
  121. <view class="uni-row uni-jcse" style="margin-top: 20px;">
  122. <image v-for="(item, index) in item.data.imageList" :key="index" mode="aspectFit"
  123. :style="getImageStyle(item)" :src="item.src"></image>
  124. </view>
  125. <view v-if="item.data.memo" style="padding-top: 10px;" v-html="item.data.memo"></view>
  126. </view>
  127. </view>
  128. <image v-if="item.data.bottomLogo" class="swiper-item-bottomLogo" mode="aspectFit"
  129. :style="getImageStyle(item.data.bottomLogo)" :src="item.data.bottomLogo.src"></image>
  130. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  131. 续</button>
  132. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  133. </view>
  134. <!-- 【兑换地点 - 多点】标题 + 头部图片 + 头部memo + 多点导航列表 + 底部memo -->
  135. <view v-if="item.type == 8" class="swiper-item-view uni-column">
  136. <text class="swiper-item-title" v-html="item.data.title"></text>
  137. <image v-if="item.data.topImg" class="" :style="getImageStyle(item.data.topImg)" mode="aspectFit" :src="item.data.topImg.src"></image>
  138. <view v-if="item.data.topMemo" v-html="item.data.topMemo"></view>
  139. <view class="swiper-item-main uni-column uni-jcse">
  140. <view class="swiper-item-content5">
  141. <view v-if="item.data.content" v-html="item.data.content"></view>
  142. <view class="uni-column uni-jcse" style="margin-top: 20px;">
  143. <view class="uni-row uni-jcsb" style="width: 96%; line-height: 30px;" v-for="(point, index) in item.data.pointList" :key="index">
  144. <view class="uni-row uni-jct" style="width: 80%;">
  145. <!-- <text v-if="point.map" class="nowrap" v-html="point.map + ':'"></text> -->
  146. <text v-if="point.name" class="nowrap" v-html="point.map ? (point.map + ':' + point.name) : point.name"></text>
  147. </view>
  148. <view class="uni-row uni-jcsa" style="width: 20%;" @click="dealNavClick(point)">
  149. <image mode="aspectFit" style="width: 10px; height: 15px;" src="/static/common/nav2.png"></image>
  150. <text class="" style="color: #E60012; font-size: 14px;" >导航</text>
  151. </view>
  152. </view>
  153. </view>
  154. <view v-if="item.data.bottomMemo" style="padding-top: 10px;" v-html="item.data.bottomMemo" @click="dealUrlClick(item.data.bottomMemoUrl)"></view>
  155. </view>
  156. </view>
  157. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  158. 续</button>
  159. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  160. </view>
  161. </swiper-item>
  162. </swiper>
  163. </uni-popup>
  164. </template>
  165. <script>
  166. import tools from '/common/tools';
  167. // import {
  168. // teamName
  169. // } from '/common/define';
  170. export default {
  171. name: "my-popup",
  172. props: {
  173. dataList: [{}],
  174. acttime: "", // 活动时间
  175. teamType: {
  176. type: Number,
  177. default: -1
  178. },
  179. config: {
  180. type: Object,
  181. default: () => ({
  182. height: ""
  183. })
  184. }
  185. },
  186. data() {
  187. return {
  188. swiperCurrent: 0, // swiper当前所在滑块的 index
  189. isOpen: false,
  190. // item: {}
  191. };
  192. },
  193. methods: {
  194. getSwiperStyle() {
  195. let styleStr = "";
  196. if (this.config.height != undefined && this.config.height != "") {
  197. styleStr += `height: ${this.config.height};`;
  198. console.log("[getSwiperStyle] style:", styleStr);
  199. }
  200. return styleStr;
  201. },
  202. //当前轮播索引
  203. swiperChange(e) {
  204. const curIndex = e.detail.current;
  205. // console.log("swiperChange", curIndex, this.swiperCurrent);
  206. this.swiperCurrent = curIndex;
  207. },
  208. swiperNext() {
  209. this.swiperCurrent++;
  210. },
  211. popupOpen() {
  212. if (this.dataList.length == 0) {
  213. console.log("[popupOpen] dataList为空,禁止弹窗");
  214. return;
  215. }
  216. this.swiperCurrent = 0;
  217. this.$refs.popup.open();
  218. this.isOpen = true;
  219. },
  220. popupClose() {
  221. this.$refs.popup.close();
  222. this.isOpen = false;
  223. this.$emit('popup-close');
  224. },
  225. fmtTime(timestamp, type = 2) {
  226. return tools.timestampToTime(timestamp * 1000, type);
  227. },
  228. dealNavClick(navPoint) {
  229. const url =
  230. `action://to_map_app?title=${navPoint.name}&latitude=${navPoint.latitude}&longitude=${navPoint.longitude}`;
  231. // window.location.href = url;
  232. tools.appAction(url);
  233. },
  234. dealUrlClick(url) {
  235. if (url != undefined && url.length > 0) {
  236. tools.appAction(url);
  237. }
  238. },
  239. getImageStyle(item) {
  240. let styleStr = "";
  241. const width = item.width ?? "90px";
  242. const height = item.height ?? "90px";
  243. styleStr = `width: ${width}; height: ${height};`;
  244. return styleStr;
  245. },
  246. getSponsorsLogoStyle(bgurl) {
  247. return `background-image: url("${bgurl}")`;
  248. },
  249. // getTeamName(teamType, teamIndex) {
  250. // return teamName[teamType][teamIndex];
  251. // },
  252. // onItemClick(item) {
  253. // this.data.item = item
  254. // this.$emit('my-combo-list-click', this.data);
  255. // }
  256. }
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. .swiper {
  261. width: 90vw;
  262. height: 439px;
  263. background-color: #FEFBF6;
  264. border-radius: 25px;
  265. }
  266. // ::v-deep uni-swiper-item {
  267. // overflow: auto;
  268. // }
  269. .swiper-item-view {
  270. height: 95%;
  271. padding-top: 25px;
  272. // justify-content: space-between;
  273. }
  274. .swiper-item-view-bg {
  275. background-image: url("/static/backgroud/top_colorbar.png"), url("/static/backgroud/oval.png");
  276. background-repeat: no-repeat;
  277. background-position-x: center;
  278. background-position-y: 75px, 190px;
  279. background-size: 80%, 70%;
  280. }
  281. .swiper-item-view-bg2 {
  282. // background-image: url("/static/backgroud/oval.png");
  283. // background-repeat: no-repeat;
  284. // background-position-x: center;
  285. // background-position-y: 198px;
  286. // background-size: 66%;
  287. }
  288. .swiper-item-topLogo {
  289. width: 100px;
  290. height: 100px;
  291. margin-bottom: 18px;
  292. }
  293. .swiper-item-bottomLogo {
  294. width: 100px;
  295. height: 100px;
  296. margin-bottom: 30px;
  297. }
  298. .swiper-item-title {
  299. margin-bottom: 10px;
  300. font-size: 20px;
  301. font-weight: 550;
  302. }
  303. .swiper-item-main {
  304. width: 100%;
  305. flex-grow: 1;
  306. }
  307. .swiper-item-image {
  308. height: 150px;
  309. }
  310. .swiper-item-image2 {
  311. height: 110px;
  312. // margin-top: 5px;
  313. }
  314. .swiper-item-time {
  315. height: 33px;
  316. margin-top: 10px;
  317. padding: 0 25px;
  318. justify-content: space-evenly;
  319. background-color: white;
  320. border: 0.5px solid;
  321. border-color: #e7e7e7;
  322. border-radius: 20px;
  323. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  324. }
  325. .swiper-item-content {
  326. width: 80%;
  327. margin-top: 15px;
  328. margin-bottom: 30px;
  329. justify-content: start;
  330. flex-grow: 1;
  331. }
  332. .swiper-item-content2 {
  333. width: 80%;
  334. margin-top: 60px;
  335. margin-bottom: 10px;
  336. // justify-content: center;
  337. text-align: center;
  338. font-size: 14px;
  339. line-height: 40px;
  340. flex-grow: 1;
  341. }
  342. .swiper-item-content3 {
  343. width: 80%;
  344. // margin-top: 5px;
  345. text-align: center;
  346. }
  347. .swiper-item-content4 {
  348. // width: 80%;
  349. text-align: center;
  350. font-size: 12px;
  351. }
  352. .swiper-item-content5 {
  353. width: 80%;
  354. flex-grow: 1;
  355. font-size: 14px;
  356. line-height: 21px;
  357. overflow-y: scroll;
  358. }
  359. .swiper-item-couponNum {
  360. font-size: 16px;
  361. font-weight: 500;
  362. color: #383838;
  363. }
  364. .swiper-item-desc {
  365. width: 80%;
  366. font-size: 12px;
  367. font-weight: 400;
  368. color: #818181;
  369. }
  370. ::v-deep li {
  371. margin-bottom: 5px;
  372. }
  373. .swiper-item-message {
  374. width: 80%;
  375. margin-top: 10px;
  376. margin-bottom: 10px;
  377. // justify-content: center;
  378. text-align: left;
  379. font-size: 14px;
  380. line-height: 21px;
  381. flex-grow: 1;
  382. }
  383. .swiper-item-button {
  384. width: 80%;
  385. height: 38px;
  386. margin-bottom: 25px;
  387. color: #ffffff;
  388. /* font-weight: bold; */
  389. line-height: 38px;
  390. background-color: #2e85ec;
  391. border-radius: 27px;
  392. }
  393. .acttime {
  394. font-weight: 550;
  395. color: #333333;
  396. font-size: 15px;
  397. }
  398. .clock {
  399. width: 15px;
  400. height: 15px;
  401. margin-right: 10px;
  402. }
  403. .introduce-content {
  404. color: #333333;
  405. font-size: 14px;
  406. line-height: 21px;
  407. flex-grow: 1;
  408. }
  409. .nowrap {
  410. white-space: nowrap;
  411. overflow: hidden;
  412. text-overflow: ellipsis;
  413. }
  414. .sponsorsLogo {
  415. position: absolute;
  416. width: 120px;
  417. // width: 75px;
  418. height: 75px;
  419. left: 18px;
  420. top: 8px;
  421. background-position-x: left;
  422. background-position-y: center;
  423. background-repeat: no-repeat;
  424. background-size: contain;
  425. // background-size: 100% auto;
  426. }
  427. ::v-deep .uni-swiper-dots-horizontal {
  428. bottom: 75px;
  429. }
  430. // ::v-deep .uni-swiper-dot-active {
  431. // background: #ff870e !important;
  432. // }
  433. </style>