index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <view class="common">
  3. <view class="body">
  4. <view class="top-class"></view>
  5. <view class="title">
  6. 梅山古镇
  7. </view>
  8. <view class="head">
  9. <u-swiper :list="list1"></u-swiper>
  10. </view>
  11. <view class="text">
  12. <image src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/text.png"
  13. class="textImage"></image>
  14. </view>
  15. <view class="content">
  16. <view class="chouka" style="width: 100%;">
  17. <view class="" style="margin-bottom: 10px;" >
  18. <u-row justify="space-between" customStyle="margin-bottom: 5px;display: flex; align-items: center;">
  19. <u-col span="4">
  20. </u-col>
  21. <u-col span="4" class="center-col">
  22. <view class="text-1">翻卡抽盲盒</view>
  23. </u-col>
  24. <u-col span="4" class="right-col">
  25. <view class="text-2" @click="openDetail()">活动规则</view>
  26. </u-col>
  27. </u-row>
  28. </view>
  29. <template>
  30. <!-- 卡片区 -->
  31. <view class="cards">
  32. <view
  33. class="card"
  34. v-for="(item, idx) in cards"
  35. :key="idx"
  36. @click="flipCard(idx)"
  37. :class="{ 'flipping': item.isFlipping, 'flipped': item.flipped }"
  38. >
  39. <view v-if="item.checkStauts" class="select-tag">
  40. 已选
  41. </view>
  42. <view class="card-inner">
  43. <view class="card-front">
  44. <image class="card-img" :src="item.front" mode="scaleToFill"></image>
  45. </view>
  46. <view class="card-back">
  47. <image class="card-img" :src="item.prizeType == 2 ? item.img : item.back" mode="scaleToFill"></image>
  48. <view class="card-back-text">
  49. <view v-show="item.prizeType == 0" class="card-text">很遗憾</view>
  50. <view v-show="item.prizeType == 1" class="card-text">{{item.money/100}}元红包</view>
  51. <view v-show="item.prizeType == 0" class="card-text">下次继续</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. </view>
  59. </view>
  60. </view>
  61. <u-popup :show="showWin" :round="10" mode="center" @close="close" @open="open" closeable="true">
  62. <view class="popup-flex">
  63. <view class="popup-content-scroll">
  64. <!-- 这里放原来的内容部分(除返回按钮) -->
  65. <view class="popup-view">
  66. <image src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/win.png"
  67. class="winImgClss"></image>
  68. </view>
  69. <view class="popup-content">
  70. <u-row customStyle="margin-bottom: 5px">
  71. <u-col span="6">
  72. <image :src="prizeJson.img" class="prize"></image>
  73. </u-col>
  74. <u-col span="6">
  75. <view>{{prizeJson.prize_name}}</view>
  76. </u-col>
  77. </u-row>
  78. <view class="popup-text">
  79. 请留下联系方式,稍后工作人员会联系您!
  80. </view>
  81. <u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm">
  82. <u-form-item label="姓名" prop="userInfo.name" ref="item1">
  83. <u--input v-model="model1.userInfo.name" border="none"></u--input>
  84. </u-form-item>
  85. <u-form-item label="电话" prop="userInfo.tel" ref="item1">
  86. <u--input v-model="model1.userInfo.tel" border="none"></u--input>
  87. </u-form-item>
  88. </u--form>
  89. </view>
  90. </view>
  91. <view class="popup-footer">
  92. <view class="save-button" @click="addWinDetail()">领取</view>
  93. </view>
  94. </view>
  95. </u-popup>
  96. <u-popup :show="showUnWin" :round="10" mode="center" @close="close" @open="open" closeable="true">
  97. <view class="popup-flex">
  98. <view class="popup-content-scroll">
  99. <!-- 这里放原来的内容部分(除返回按钮) -->
  100. <view class="popup-view">
  101. <image src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/unWin.png"
  102. class="winImgClss"></image>
  103. </view>
  104. <view class="popup-content">
  105. <view class="">
  106. <image class="productImg" mode="widthFix"
  107. src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/product.png ">
  108. </image>
  109. </view>
  110. <view class="">
  111. 你比我大,
  112. 为什么我出生那天你没来看我!
  113. </view>
  114. </view>
  115. </view>
  116. <view class="popup-footer">
  117. <view class="save-button unWin" @click="close()">我知道了</view>
  118. </view>
  119. </view>
  120. </u-popup>
  121. <CustomTabbar />
  122. </view>
  123. </template>
  124. <script>
  125. import CustomTabbar from '@/components/tabbar.vue';
  126. import {
  127. addWinDetail,saveCardData
  128. } from '@/api/scan'
  129. export default {
  130. components: {
  131. CustomTabbar
  132. },
  133. data() {
  134. return {
  135. rules: {
  136. 'userInfo.name': {
  137. type: 'string',
  138. required: true,
  139. message: '请填写姓名',
  140. trigger: ['blur', 'change']
  141. },
  142. 'userInfo.tel': {
  143. type: 'string',
  144. required: true,
  145. message: '请填写手机号',
  146. trigger: ['blur', 'change']
  147. },
  148. },
  149. model1: {
  150. userInfo: {
  151. name: '',
  152. tel: '',
  153. qrcodeId:''
  154. },
  155. },
  156. showUnWin: false,
  157. showWin: false,
  158. list1: [
  159. "https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/commodity/1.jpg",
  160. "https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/commodity/2.jpg",
  161. "https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/commodity/3.jpg",
  162. "https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/commodity/4.jpg",
  163. "https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/commodity/5.jpg",
  164. ],
  165. cards: [{
  166. front: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/one.png',
  167. back: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiCard.png',
  168. flipped: false,
  169. prizeName: '',
  170. title: '',
  171. checkStauts: false,
  172. img:'',
  173. money:'',
  174. prizeType:'',
  175. isFlipping: false
  176. },
  177. {
  178. front: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/two.png',
  179. back: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiCard.png',
  180. flipped: false,
  181. prizeName: '',
  182. title: '',
  183. checkStauts: false,
  184. img:'',
  185. money:'',
  186. prizeType:'',
  187. isFlipping: false
  188. },
  189. {
  190. front: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/three.png',
  191. back: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiCard.png',
  192. flipped: false,
  193. prizeName: '',
  194. title: '',
  195. checkStauts: false,
  196. img:'',
  197. money:'',
  198. prizeType:'',
  199. isFlipping: false
  200. },
  201. {
  202. front: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/four.png',
  203. back: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiCard.png',
  204. flipped: false,
  205. prizeName: '',
  206. title: '',
  207. checkStauts: false,
  208. img:'',
  209. money:'',
  210. prizeType:'',
  211. isFlipping: false
  212. },
  213. {
  214. front: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/five.png',
  215. back: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiCard.png',
  216. flipped: false,
  217. prizeName: '',
  218. title: '',
  219. checkStauts: false,
  220. img:'',
  221. money:'',
  222. prizeType:'',
  223. isFlipping: false
  224. },
  225. {
  226. front: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/six.png',
  227. back: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiCard.png',
  228. flipped: false,
  229. prizeName: '',
  230. title: '',
  231. checkStauts: false,
  232. img:'',
  233. money:'',
  234. prizeType:'',
  235. isFlipping: false
  236. }
  237. ],
  238. totalDetail: '',
  239. prizeJson: {},
  240. saveData: {},
  241. scanCode:'',
  242. saveStatus: true,
  243. }
  244. },
  245. onLoad() {
  246. let scanDetail = uni.getStorageSync('scanDetail');
  247. this.scanCode = uni.getStorageSync('scanCode');
  248. this.model1.userInfo.qrcodeId = this.scanCode;
  249. this.prizeJson = scanDetail.prizeJson;
  250. let planDetail = JSON.parse(scanDetail.planDetail);
  251. while (planDetail.length < 5) {
  252. planDetail.push({
  253. 'prizeType': 0,
  254. 'money': 0
  255. })
  256. }
  257. this.totalDetail = planDetail;
  258. console.log(planDetail);
  259. if(scanDetail.result.click){
  260. this.initCardData(scanDetail.clickJson);
  261. }
  262. },
  263. methods: {
  264. initCardData(clickJson){
  265. let list = JSON.parse(clickJson);
  266. for (let i = 0; i < this.cards.length; i++) {
  267. if(i == list.index){
  268. this.cards[i].checkStauts = true
  269. }
  270. this.cards[i].img = list['card'+i].img;
  271. this.cards[i].flipped = true;
  272. this.cards[i].prizeType = list['card'+i].prize_type == undefined ? list['card'+i].prizeType :list['card'+i].prize_type;
  273. this.cards[i].money =list['card'+i].money;
  274. this.cards[i].prizeName = list['card'+i].prizeName == undefined ? list['card'+i].prize_name :list['card'+i].prizeName;
  275. }
  276. this.$forceUpdate();
  277. },
  278. addWinDetail(){
  279. let that = this;
  280. this.$refs.uForm.validate().then(res => {
  281. addWinDetail(that.model1.userInfo).then(data => {
  282. this.showWin = false;
  283. if(data.code == 0){
  284. that.saveStatus = false;
  285. // uni.redirectTo({
  286. // url: '/pages/lgz/index/claim' // 目标页面路径
  287. // })
  288. let params = {
  289. type: "success",
  290. title: "成功主题(带图标)",
  291. message: "提交成功",
  292. iconUrl: "https://uviewui.com/demo/toast/success.png",
  293. }
  294. that.$refs.uToast.show({
  295. ...params
  296. });
  297. }else{
  298. }
  299. })
  300. }).catch(errors => {
  301. })
  302. },
  303. open() {
  304. // console.log('open');
  305. },
  306. close() {
  307. this.showUnWin = false;
  308. this.showWin = false
  309. },
  310. flipCard(idx) {
  311. if (this.cards[idx].flipped) {
  312. return;
  313. }
  314. setTimeout(() => {
  315. if (this.prizeJson.prizeType == 0 || this.prizeJson.prize_type == 0) {
  316. this.showUnWin = true;
  317. }
  318. if ((this.prizeJson.prizeType == 2 || this.prizeJson.prize_type == 2) && this.saveStatus) {
  319. this.showWin = true;
  320. }
  321. }, 2500); //弹框延迟3.5秒后显示弹框
  322. // 标记被点击的卡牌正在翻转
  323. this.cards[idx].isFlipping = true;
  324. this.cards[idx].checkStauts = true;
  325. let that = this;
  326. // 延迟翻转其他卡牌
  327. setTimeout(() => {
  328. that.cards[idx].flipped = true;
  329. that.cards[idx].isFlipping = false;
  330. // 其他未翻转的卡牌延迟2秒后同时翻转
  331. setTimeout(() => {
  332. that.cards.forEach((card, index) => {
  333. if (index !== idx && !card.flipped) {
  334. card.isFlipping = true;
  335. that.$forceUpdate();
  336. }
  337. });
  338. // 所有其他卡牌同时翻转
  339. setTimeout(() => {
  340. that.cards.forEach((card, index) => {
  341. if (index !== idx && !card.flipped) {
  342. card.flipped = true;
  343. card.isFlipping = false;
  344. that.$forceUpdate();
  345. }
  346. });
  347. }, 300); // 与其他卡牌翻转动画保持一致
  348. }, 1000); // 延迟2秒翻转其他卡牌
  349. // 处理数据逻辑
  350. that.totalDetail.splice(idx, 0, this.prizeJson);
  351. that.saveData.index = idx;
  352. for (let i = 0; i < that.totalDetail.length; i++) {
  353. that.saveData['card' + i] = that.totalDetail[i];
  354. that.cards[i].prizeType = that.totalDetail[i].prize_type == undefined ?
  355. that.totalDetail[i].prizeType :
  356. that.totalDetail[i].prize_type;
  357. that.cards[i].img = that.totalDetail[i].img;
  358. that.cards[i].money = that.totalDetail[i].money;
  359. that.cards[i].prizeName = that.totalDetail[i].prizeName == undefined ?
  360. that.totalDetail[i].prize_name :
  361. that.totalDetail[i].prizeName;
  362. }
  363. that.saveAllCardData();
  364. }, 100);
  365. },
  366. saveAllCardData(){
  367. let jsonStr = JSON.stringify(this.saveData);
  368. saveCardData(this.scanCode,jsonStr).then(res => {
  369. console.log(res)
  370. })
  371. },
  372. openDetail(){
  373. uni.navigateTo({
  374. url: '/pages/lgz/index/rules'
  375. });
  376. }
  377. }
  378. }
  379. </script>
  380. <style>
  381. @import url('../../../static/scss/common.css');
  382. .common {
  383. background-image:
  384. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgi-two.png");
  385. }
  386. .head {
  387. background-image:
  388. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/zhanshi.png");
  389. background-size: cover;
  390. background-position: center;
  391. background-repeat: no-repeat;
  392. height: 23vh;
  393. margin: 0px 40rpx;
  394. display: flex;
  395. justify-content: center;
  396. /* 水平居中 */
  397. align-items: center;
  398. /* 垂直居中 */
  399. }
  400. .text {
  401. height: 10vh;
  402. text-align: center;
  403. line-height: 13vh;
  404. margin-bottom: 10rpx;
  405. }
  406. .textImage {
  407. height: 80rpx;
  408. width: 400rpx;
  409. }
  410. .content {
  411. height: 42vh;
  412. background: rgba(131, 100, 71, 0.5);
  413. border-radius: 10rpx;
  414. margin: 0rpx 40rpx;
  415. padding: 10rpx 24rpx;
  416. overflow: auto;
  417. display: flex;
  418. align-items: center;
  419. justify-content: center;
  420. }
  421. .text-1 {
  422. text-align: center;
  423. font-size: 24rpx;
  424. font-weight: 600;
  425. color: white;
  426. background-color: #9A1712;
  427. width: 160rpx;
  428. border-radius: 4rpx;
  429. height: 40rpx;
  430. line-height: 40rpx;
  431. }
  432. .text-2 {
  433. text-align: center;
  434. font-size: 24rpx;
  435. font-weight: 600;
  436. color: #F9D395;
  437. background-color: #9A1712;
  438. width: 120rpx;
  439. border-radius: 4rpx;
  440. height: 40rpx;
  441. line-height: 40rpx;
  442. margin-left: 80rpx;
  443. }
  444. .cards {
  445. display: grid;
  446. grid-template-columns: repeat(3, 1fr);
  447. gap: 30rpx;
  448. width: 100%;
  449. }
  450. .card {
  451. width: 100%;
  452. height: 250rpx;
  453. position: relative;
  454. background: none;
  455. border-radius: 16rpx;
  456. margin: 0;
  457. perspective: 1000px;
  458. }
  459. .card-inner {
  460. position: relative;
  461. width: 100%;
  462. height: 100%;
  463. transition: transform 0.8s cubic-bezier(0.5, 1.5, 0.5, 1);
  464. transform-style: preserve-3d;
  465. }
  466. .card.flipping .card-inner {
  467. transform: rotateY(180deg);
  468. }
  469. .card.flipped .card-inner {
  470. transform: rotateY(180deg);
  471. }
  472. .card-front, .card-back {
  473. position: absolute;
  474. width: 100%;
  475. height: 100%;
  476. backface-visibility: hidden;
  477. }
  478. .card-back {
  479. transform: rotateY(180deg);
  480. }
  481. .card-back-text {
  482. position: absolute;
  483. top: 50%;
  484. left: 0;
  485. width: 100%;
  486. text-align: center;
  487. color: #9A1712;
  488. font-weight: bold;
  489. font-size: 28rpx;
  490. transform: translateY(-50%);
  491. z-index: 2;
  492. pointer-events: none;
  493. }
  494. .card-img {
  495. width: 100%;
  496. height: 100%;
  497. display: block;
  498. }
  499. ::v-deep .u-popup__content {
  500. height: 720rpx;
  501. width: 600rpx;
  502. background-color: rgba(0, 0, 0, 0) !important;
  503. background-image:
  504. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/bgiPopup.png");
  505. background-size: cover;
  506. background-position: center;
  507. background-repeat: no-repeat;
  508. }
  509. ::v-deep .u-popup__content__close--top-right {
  510. top: 720rpx !important;
  511. right: 288rpx !important;
  512. }
  513. .winImgClss {
  514. height: 60rpx;
  515. width: 320rpx;
  516. }
  517. .popup-view {
  518. text-align: center;
  519. margin-top: 100rpx;
  520. }
  521. .popup-content {
  522. margin: 15px 54px;
  523. overflow: auto;
  524. }
  525. .popup-text {
  526. font-weight: 400;
  527. font-size: 20rpx;
  528. color: #9B0000;
  529. }
  530. .prize {
  531. height: 130rpx;
  532. width: 130rpx;
  533. }
  534. ::v-deep .u-form-item__body {
  535. padding: 8rpx;
  536. }
  537. ::v-deep uni-view.u-form-item__body__left {
  538. background: #AD7F55;
  539. border-radius: 5px 0px 0px 5px;
  540. border: 2px solid #63462B;
  541. border-right: none;
  542. }
  543. ::v-deep .u-form-item__body__right {
  544. background-color: #fff;
  545. border-radius: 0px 5px 5px 0px;
  546. border: 2px solid #63462B;
  547. }
  548. ::v-deep uni-text.u-form-item__body__left__content__label {
  549. color: #fff !important;
  550. padding-left: 4px;
  551. letter-spacing: 2px;
  552. }
  553. .popup-flex {
  554. display: flex;
  555. flex-direction: column;
  556. height: 100%;
  557. /* 或具体高度如340px,确保撑满弹窗 */
  558. min-width: 600rpx;
  559. }
  560. .popup-content-scroll {
  561. flex: 1;
  562. }
  563. .popup-footer {
  564. flex-shrink: 0;
  565. padding: 0rpx 0 60rpx 0px;
  566. text-align: center;
  567. background: transparent;
  568. /* 可选,确保无背景遮挡 */
  569. }
  570. .save-button {
  571. width: 90rpx;
  572. margin: 0 auto;
  573. background: #b22222;
  574. color: #F9D395;
  575. border-radius: 12rpx;
  576. padding: 18rpx 0;
  577. font-size: 24rpx;
  578. font-weight: bold;
  579. height: 16rpx;
  580. line-height: 16rpx;
  581. letter-spacing: 4rpx;
  582. }
  583. .unWin {
  584. width: 130rpx !important;
  585. }
  586. .productImg {
  587. width: 400rpx;
  588. }
  589. ::v-deep .u-swiper {
  590. background-color: rgba(0, 0, 0, 0) !important;
  591. padding: 0px 20rpx !important;
  592. width: 90%;
  593. }
  594. ::v-deep .u-col-4 {
  595. display: flex !important;
  596. justify-content: center !important;
  597. /* 水平居中 */
  598. align-items: center !important;
  599. /* 垂直居中 */
  600. }
  601. ::v-deep .right-col .u-col-4 {
  602. display: flex !important;
  603. justify-content: flex-end !important;
  604. /* 水平居中 */
  605. align-items: center !important;
  606. /* 垂直居中 */
  607. }
  608. .card-img-f{
  609. height: 100rpx;
  610. width: 100rpx;
  611. }
  612. .card-text{
  613. font-size: 26rpx;
  614. }
  615. .select-tag{
  616. position: absolute;
  617. right: 0px;
  618. font-weight: 400;
  619. font-size: 20rpx;
  620. color: #FFFFFF;
  621. width: 40px;
  622. text-align: center;
  623. background-color: #11BC64;
  624. height: 15px;
  625. border-radius: 3px;
  626. line-height: 15px;
  627. z-index: 5;
  628. }
  629. </style>