my-popup.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <uni-popup ref="popup" :mask-click="false" maskBackgroundColor="rgba(0, 0, 0, 0.6)">
  3. <view class="popup">
  4. <swiper ref="swiper" class="swiper" :current="swiperCurrent" @change="swiperChange"
  5. :indicator-dots="dataList.length > 1" indicator-active-color="rgba(46, 133, 236, 1)" :autoplay="false"
  6. :interval="5000">
  7. <swiper-item v-for="(item, index) in dataList" :key="index">
  8. <!-- 标题 + 图片 + 活动时间 + 活动简介 -->
  9. <view v-if="item.type == 1" class="swiper-item-view uni-column">
  10. <text class="swiper-item-title" v-html="item.data.title"></text>
  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. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  20. 续</button>
  21. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  22. </view>
  23. <!-- 标题 + 图片 -->
  24. <view v-if="item.type == 2" class="swiper-item-view uni-column">
  25. <text class="swiper-item-title" v-html="item.data.title"></text>
  26. <image mode="aspectFit" style="height: 474rpx; margin-bottom: 50rpx;" :src="item.data.img">
  27. </image>
  28. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  29. 续</button>
  30. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  31. </view>
  32. <!-- 标题 + 图片 + 活动简介 -->
  33. <view v-if="item.type == 3" class="swiper-item-view swiper-item-view-bg uni-column">
  34. <text class="swiper-item-title" v-html="item.data.title"></text>
  35. <image mode="aspectFit" style="height: 280rpx; margin-top: 50rpx;" :src="item.data.img"></image>
  36. <text class="swiper-item-content2" v-html="item.data.content"></text>
  37. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  38. 续</button>
  39. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  40. </view>
  41. <!-- 标题 + 图片 + 二维码 -->
  42. <view v-if="item.type == 4" class="swiper-item-view swiper-item-view-bg2 uni-jct uni-column">
  43. <text class="swiper-item-title" v-html="item.data.title"></text>
  44. <image mode="aspectFit" style="height: 220rpx; margin-top: 10rpx;" :src="item.data.img"></image>
  45. <text class="swiper-item-content3" v-html="item.data.content"></text>
  46. <text class="swiper-item-content4">【{{item.data.sourceName}}】</text>
  47. <template v-if="[1,3].includes(item.data.exState)">
  48. <view v-if="item.data.expireTime > 0" class="swiper-item-content4">( 有效期至 {{fmtTime(item.data.expireTime, 3)}}
  49. <span v-if="item.data.exState == 3" style="color: #ffaa00;">已临期</span>
  50. )</view>
  51. <uv-qrcode ref="qrcode" size="200rpx"
  52. :value="item.data.qrCode">
  53. <!-- <template v-slot:loading>
  54. <text style="color: green;">loading...</text>
  55. </template> -->
  56. </uv-qrcode>
  57. </template>
  58. <view v-if="item.data.exState == 2" class="uni-column uni-jcse" style="height: 200rpx;">
  59. <text style="color: red;">已兑换</text>
  60. <text class="swiper-item-content4">( 兑换时间 {{fmtTime(item.data.exTime, 3)}} )</text>
  61. </view>
  62. <view v-if="item.data.exState == 4" class="uni-column uni-jcse" style="height: 200rpx;">
  63. <text style="color: red;">已过期</text>
  64. <text v-if="item.data.expireTime > 0" class="swiper-item-content4">( 过期时间 {{fmtTime(item.data.expireTime, 3)}} )</text>
  65. </view>
  66. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  67. 续</button>
  68. <button v-else class="swiper-item-button" @click="popupClose">关 闭</button>
  69. </view>
  70. <!-- 标题 + 图片(点击图片打开地图APP进行地点定位) -->
  71. <view v-if="item.type == 5" class="swiper-item-view uni-column">
  72. <text class="swiper-item-title" v-html="item.data.title"></text>
  73. <image mode="aspectFit" style="height: 474rpx; margin-bottom: 50rpx;" :src="item.data.img" @click="dealNavClick(item.data.point)">
  74. </image>
  75. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  76. 续</button>
  77. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  78. </view>
  79. <!-- 通知 -->
  80. <view v-if="item.type == 6" class="swiper-item-view uni-column">
  81. <text class="swiper-item-title" v-html="item.data.title"></text>
  82. <!-- mqType 消息类型 2:卡片图片 3:卡片文字 -->
  83. <image v-if="item.data.mqType == 2" mode="aspectFit" style="height: 474rpx; margin-bottom: 50rpx;" :src="item.data.message">
  84. </image>
  85. <text v-if="item.data.mqType == 3" class="swiper-item-message" v-html="item.data.message"></text>
  86. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  87. 续</button>
  88. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  89. </view>
  90. <!-- 标题 + HTML内容 + 图片(可为空) -->
  91. <view v-if="item.type == 7" class="swiper-item-view uni-column">
  92. <text class="swiper-item-title" v-html="item.data.title"></text>
  93. <view class="swiper-item-content5">
  94. <text v-html="item.data.content"></text>
  95. <view class="uni-row uni-jcse" style="margin-top: 20px;">
  96. <image v-for="(item, index) in item.data.imageList" :key="index" mode="aspectFit"
  97. :style="getImageStyle(item)" :src="item.src"></image>
  98. </view>
  99. </view>
  100. <button v-if="index < dataList.length - 1" class="swiper-item-button" @click="swiperNext">继
  101. 续</button>
  102. <button v-else class="swiper-item-button" @click="popupClose">确 定</button>
  103. </view>
  104. </swiper-item>
  105. </swiper>
  106. </view>
  107. </uni-popup>
  108. </template>
  109. <script>
  110. import tools from '/common/tools';
  111. // import {
  112. // teamName
  113. // } from '/common/define';
  114. export default {
  115. name: "my-popup",
  116. props: {
  117. dataList: [{}],
  118. acttime: "", // 活动时间
  119. teamType: {
  120. type: Number,
  121. default: -1
  122. }
  123. },
  124. data() {
  125. return {
  126. swiperCurrent: 0, // swiper当前所在滑块的 index
  127. isOpen: false,
  128. // item: {}
  129. };
  130. },
  131. methods: {
  132. //当前轮播索引
  133. swiperChange(e) {
  134. const curIndex = e.detail.current;
  135. // console.log("swiperChange", curIndex, this.swiperCurrent)
  136. this.swiperCurrent = curIndex;
  137. },
  138. swiperNext() {
  139. this.swiperCurrent++;
  140. },
  141. popupOpen() {
  142. if (this.dataList.length == 0) {
  143. console.log("[popupOpen] dataList为空,禁止弹窗");
  144. return;
  145. }
  146. this.swiperCurrent = 0;
  147. this.$refs.popup.open();
  148. this.isOpen = true;
  149. },
  150. popupClose() {
  151. this.$refs.popup.close();
  152. this.isOpen = false;
  153. this.$emit('popup-close');
  154. },
  155. fmtTime(timestamp, type = 2) {
  156. return tools.timestampToTime(timestamp * 1000, type);
  157. },
  158. dealNavClick(navPoint) {
  159. const url =
  160. `action://to_map_app?title=${navPoint.name}&latitude=${navPoint.latitude}&longitude=${navPoint.longitude}`;
  161. // window.location.href = url;
  162. tools.appAction(url);
  163. },
  164. getImageStyle(item) {
  165. let styleStr = "";
  166. const width = item.width ?? "180rpx";
  167. const height = item.height ?? "180rpx";
  168. styleStr = `width: ${width}; height: ${height};`;
  169. return styleStr;
  170. },
  171. // getTeamName(teamType, teamIndex) {
  172. // return teamName[teamType][teamIndex];
  173. // },
  174. // onItemClick(item) {
  175. // this.data.item = item
  176. // this.$emit('my-combo-list-click', this.data);
  177. // }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .acttime {
  183. font-weight: 550;
  184. color: #333333;
  185. font-size: 30rpx;
  186. }
  187. .clock {
  188. width: 30rpx;
  189. height: 30rpx;
  190. margin-right: 20rpx;
  191. }
  192. .introduce-content {
  193. color: #333333;
  194. font-size: 25rpx;
  195. line-height: 36rpx;
  196. }
  197. .popup {
  198. width: 90vw;
  199. // height: 720rpx;
  200. height: 920rpx;
  201. background-color: #FEFBF6;
  202. border-radius: 50rpx;
  203. }
  204. .swiper {
  205. height: 100%;
  206. }
  207. // .swiper-item {
  208. // justify-content: space-between;
  209. // /* background-color: lightblue; */
  210. // }
  211. .swiper-item-view {
  212. height: 100%;
  213. justify-content: space-between;
  214. }
  215. .swiper-item-view-bg {
  216. background-image: url("/static/backgroud/top_colorbar.png"), url("/static/backgroud/oval.png");
  217. background-repeat: no-repeat;
  218. background-position-x: center;
  219. background-position-y: 150rpx, 380rpx;
  220. background-size: 80%, 70%;
  221. }
  222. .swiper-item-view-bg2 {
  223. background-image: url("/static/backgroud/oval.png");
  224. background-repeat: no-repeat;
  225. background-position-x: center;
  226. background-position-y: 276rpx;
  227. background-size: 66%;
  228. }
  229. .swiper-item-title {
  230. margin-top: 60rpx;
  231. margin-bottom: 20rpx;
  232. font-size: 40rpx;
  233. font-weight: 550;
  234. }
  235. .swiper-item-image {
  236. height: 300rpx;
  237. }
  238. .swiper-item-time {
  239. height: 65rpx;
  240. margin-top: 20rpx;
  241. padding: 0 50rpx;
  242. justify-content: space-evenly;
  243. background-color: white;
  244. border: 0.5px solid;
  245. border-color: #e7e7e7;
  246. border-radius: 40rpx;
  247. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
  248. }
  249. .swiper-item-content {
  250. width: 80%;
  251. /* height: 100rpx; */
  252. margin-top: 30rpx;
  253. margin-bottom: 60rpx;
  254. justify-content: start;
  255. }
  256. .swiper-item-content2 {
  257. width: 80%;
  258. /* height: 100rpx; */
  259. margin-top: 30rpx;
  260. margin-bottom: 20rpx;
  261. // justify-content: center;
  262. text-align: center;
  263. font-size: 28rpx;
  264. line-height: 80rpx;
  265. }
  266. .swiper-item-content3 {
  267. width: 80%;
  268. margin-top: 10rpx;
  269. text-align: center;
  270. }
  271. .swiper-item-content4 {
  272. // width: 80%;
  273. // margin-top: 10rpx;
  274. text-align: center;
  275. font-size: 24rpx;
  276. }
  277. .swiper-item-content5 {
  278. width: 80%;
  279. margin-top: 30rpx;
  280. margin-bottom: 20rpx;
  281. flex-grow: 1;
  282. font-size: 26rpx;
  283. line-height: 46rpx;
  284. }
  285. ::v-deep li {
  286. margin-bottom: 10rpx;
  287. }
  288. .swiper-item-message {
  289. width: 80%;
  290. /* height: 100rpx; */
  291. margin-top: 20rpx;
  292. margin-bottom: 20rpx;
  293. // justify-content: center;
  294. text-align: left;
  295. font-size: 28rpx;
  296. // line-height: 80rpx;
  297. flex-grow: 1;
  298. }
  299. .swiper-item-button {
  300. width: 80%;
  301. height: 76rpx;
  302. margin-bottom: 50rpx;
  303. color: #ffffff;
  304. /* font-weight: bold; */
  305. line-height: 76rpx;
  306. background-color: #2e85ec;
  307. border-radius: 27px;
  308. }
  309. ::v-deep .uni-swiper-dots-horizontal {
  310. bottom: 155rpx;
  311. }
  312. // ::v-deep .uni-swiper-dot-active {
  313. // background: #ff870e !important;
  314. // }
  315. </style>