my-popup.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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="getImageStyle2(item.data.imgParam)"
  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. let width = "90px";
  242. let height = "90px";
  243. if (item != undefined && item.width != undefined) {
  244. width = item.width;
  245. }
  246. if (item != undefined && item.height != undefined) {
  247. height = item.height;
  248. }
  249. // const width = item.width ?? "90px";
  250. // const height = item.height ?? "90px";
  251. styleStr = `width: ${width}; height: ${height};`;
  252. return styleStr;
  253. },
  254. getImageStyle2(item) {
  255. let styleStr = "";
  256. let height = "237px";
  257. if (item != undefined && item.height != undefined) {
  258. height = item.height;
  259. }
  260. styleStr = `height: ${height}; margin-top: 15px; margin-bottom: 25px;`;
  261. return styleStr;
  262. },
  263. getSponsorsLogoStyle(bgurl) {
  264. return `background-image: url("${bgurl}")`;
  265. },
  266. // getTeamName(teamType, teamIndex) {
  267. // return teamName[teamType][teamIndex];
  268. // },
  269. // onItemClick(item) {
  270. // this.data.item = item
  271. // this.$emit('my-combo-list-click', this.data);
  272. // }
  273. }
  274. }
  275. </script>
  276. <style lang="scss" scoped>
  277. .swiper {
  278. width: 90vw;
  279. height: 439px;
  280. background-color: #FEFBF6;
  281. border-radius: 25px;
  282. }
  283. // ::v-deep uni-swiper-item {
  284. // overflow: auto;
  285. // }
  286. .swiper-item-view {
  287. height: 95%;
  288. padding-top: 25px;
  289. // justify-content: space-between;
  290. }
  291. .swiper-item-view-bg {
  292. background-image: url("/static/backgroud/top_colorbar.png"), url("/static/backgroud/oval.png");
  293. background-repeat: no-repeat;
  294. background-position-x: center;
  295. background-position-y: 75px, 190px;
  296. background-size: 80%, 70%;
  297. }
  298. .swiper-item-view-bg2 {
  299. // background-image: url("/static/backgroud/oval.png");
  300. // background-repeat: no-repeat;
  301. // background-position-x: center;
  302. // background-position-y: 198px;
  303. // background-size: 66%;
  304. }
  305. .swiper-item-topLogo {
  306. width: 100px;
  307. height: 100px;
  308. margin-bottom: 18px;
  309. }
  310. .swiper-item-bottomLogo {
  311. width: 100px;
  312. height: 100px;
  313. margin-bottom: 30px;
  314. }
  315. .swiper-item-title {
  316. margin-bottom: 10px;
  317. font-size: 20px;
  318. font-weight: 550;
  319. }
  320. .swiper-item-main {
  321. width: 100%;
  322. flex-grow: 1;
  323. }
  324. .swiper-item-image {
  325. height: 150px;
  326. }
  327. .swiper-item-image2 {
  328. height: 110px;
  329. // margin-top: 5px;
  330. }
  331. .swiper-item-time {
  332. height: 33px;
  333. margin-top: 10px;
  334. padding: 0 25px;
  335. justify-content: space-evenly;
  336. background-color: white;
  337. border: 0.5px solid;
  338. border-color: #e7e7e7;
  339. border-radius: 20px;
  340. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  341. }
  342. .swiper-item-content {
  343. width: 80%;
  344. margin-top: 15px;
  345. margin-bottom: 30px;
  346. justify-content: start;
  347. flex-grow: 1;
  348. }
  349. .swiper-item-content2 {
  350. width: 80%;
  351. margin-top: 60px;
  352. margin-bottom: 10px;
  353. // justify-content: center;
  354. text-align: center;
  355. font-size: 14px;
  356. line-height: 40px;
  357. flex-grow: 1;
  358. }
  359. .swiper-item-content3 {
  360. width: 80%;
  361. // margin-top: 5px;
  362. text-align: center;
  363. }
  364. .swiper-item-content4 {
  365. // width: 80%;
  366. text-align: center;
  367. font-size: 12px;
  368. }
  369. .swiper-item-content5 {
  370. width: 80%;
  371. flex-grow: 1;
  372. font-size: 14px;
  373. line-height: 21px;
  374. overflow-y: scroll;
  375. }
  376. .swiper-item-couponNum {
  377. font-size: 16px;
  378. font-weight: 500;
  379. color: #383838;
  380. }
  381. .swiper-item-desc {
  382. width: 80%;
  383. font-size: 12px;
  384. font-weight: 400;
  385. color: #818181;
  386. }
  387. ::v-deep li {
  388. margin-bottom: 5px;
  389. }
  390. .swiper-item-message {
  391. width: 80%;
  392. margin-top: 10px;
  393. margin-bottom: 10px;
  394. // justify-content: center;
  395. text-align: left;
  396. font-size: 14px;
  397. line-height: 21px;
  398. flex-grow: 1;
  399. }
  400. .swiper-item-button {
  401. width: 80%;
  402. height: 38px;
  403. margin-bottom: 25px;
  404. color: #ffffff;
  405. /* font-weight: bold; */
  406. line-height: 38px;
  407. background-color: #2e85ec;
  408. border-radius: 27px;
  409. }
  410. .acttime {
  411. font-weight: 550;
  412. color: #333333;
  413. font-size: 15px;
  414. }
  415. .clock {
  416. width: 15px;
  417. height: 15px;
  418. margin-right: 10px;
  419. }
  420. .introduce-content {
  421. color: #333333;
  422. font-size: 14px;
  423. line-height: 21px;
  424. flex-grow: 1;
  425. }
  426. .nowrap {
  427. white-space: nowrap;
  428. overflow: hidden;
  429. text-overflow: ellipsis;
  430. }
  431. .sponsorsLogo {
  432. position: absolute;
  433. width: 120px;
  434. // width: 75px;
  435. height: 75px;
  436. left: 18px;
  437. top: 8px;
  438. background-position-x: left;
  439. background-position-y: center;
  440. background-repeat: no-repeat;
  441. background-size: contain;
  442. // background-size: 100% auto;
  443. }
  444. ::v-deep .uni-swiper-dots-horizontal {
  445. bottom: 75px;
  446. }
  447. // ::v-deep .uni-swiper-dot-active {
  448. // background: #ff870e !important;
  449. // }
  450. </style>