eight.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div class="eight">
  3. <img
  4. src="https://cxzx.smcic.net/topic/tool/img/ffk.png"
  5. style="width: 60vw; display: block; margin: 0 auto 6px auto"
  6. />
  7. <div class="headText">
  8. <p>2023丝路嘉年华暨丝路春晚</p>
  9. <p>携手秦农银行、长安花小榨菜籽油、长武苹果</p>
  10. <p>向你花式拜年,奖品丰厚,福利多多</p>
  11. <p>更多周边奖品欢迎你来拿!快来新年冲好运鸭!</p>
  12. </div>
  13. <van-row class="luckDraw">
  14. <van-col
  15. span="8"
  16. v-for="i in 12"
  17. :key="i + 'll'"
  18. :class="{ shakeSlow: show[i - 1] }"
  19. >
  20. <div v-if="show[i - 1]" class="click">点我</div>
  21. <van-image
  22. @click="draw"
  23. :width="img.width"
  24. :height="img.height"
  25. :class="{ img: true }"
  26. fit="contain"
  27. :src="'https://cxzx.smcic.net/topic/tool/img/silugift/' + i + '.png'"
  28. >
  29. <template v-slot:loading>
  30. <van-loading type="spinner" size="20" />
  31. </template>
  32. </van-image>
  33. </van-col>
  34. </van-row>
  35. <van-row style="background: #fff">
  36. <van-col span="8">
  37. <van-button
  38. class="btns"
  39. color="#eeb562"
  40. round
  41. plain
  42. hairline
  43. size="small"
  44. type="primary"
  45. url="https://shop97096255.m.youzan.com/v2/showcase/homepage?kdt_id=96904087&sf=qq_sm&is_share=1&shopAutoEnter=1&share_cmpt=native_wechat&from_uuid=756e1ce7-fafe-b14e-ba29-ab4dd9223ac8&is_silence_auth=1"
  46. >
  47. 进店逛逛
  48. </van-button>
  49. </van-col>
  50. <van-col span="8">
  51. <van-button
  52. color="#eeb562"
  53. class="btns"
  54. round
  55. type="primary"
  56. size="small"
  57. @click="mygift"
  58. >
  59. 我的奖品
  60. </van-button>
  61. </van-col>
  62. <van-col span="8">
  63. <van-button
  64. class="btns"
  65. color="#eeb562"
  66. round
  67. plain
  68. hairline
  69. size="small"
  70. type="primary"
  71. @click="addressObjshow"
  72. >
  73. 我的地址
  74. </van-button>
  75. </van-col>
  76. </van-row>
  77. <van-notice-bar
  78. color="#000000"
  79. background="#ffffff"
  80. wrapable
  81. :scrollable="false"
  82. text="点击下方小视频,给手气充能,增加一次抽奖机会!"
  83. />
  84. <div class="vieoPlay">
  85. <van-icon
  86. name="play-circle-o"
  87. @click="() => playVideo()"
  88. color="#ffffff"
  89. class="play"
  90. size="40"
  91. />
  92. <img
  93. style="width: 100%"
  94. src="https://cxzx.smcic.net/topic/tool/img/videoImg.jpg"
  95. />
  96. </div>
  97. <van-dialog
  98. v-model:show="addressObj.show"
  99. :before-close="upaddress"
  100. title="我的地址"
  101. teleport="#app"
  102. >
  103. <van-cell-group inset>
  104. <van-field v-model="nickName" label="昵称" />
  105. <van-field disabled v-model="phone" type="tel" label="手机号" />
  106. <van-field
  107. v-model="address"
  108. rows="1"
  109. autosize
  110. label="地址"
  111. type="textarea"
  112. placeholder="请输入地址"
  113. />
  114. </van-cell-group>
  115. </van-dialog>
  116. <van-dialog
  117. :before-close="before"
  118. v-model:show="gift.show"
  119. :title="gift.name"
  120. teleport="#app"
  121. show-cancel-button
  122. >
  123. <img
  124. :src="gift.url"
  125. style="width: 10em; display: block; margin: 1em auto"
  126. />
  127. <p
  128. style="
  129. padding: 0 1em 1em 1em;
  130. font-size: 14px;
  131. text-align: center;
  132. color: #646566;
  133. "
  134. >
  135. 恭喜你中奖,请于1月8日前,在右下角“我的地址”中上传收货地址哦~
  136. </p>
  137. </van-dialog>
  138. </div>
  139. </template>
  140. <script setup>
  141. import { reactive, ref, defineEmits, defineExpose } from "vue";
  142. import { showDialog, showToast, showConfirmDialog } from "vant";
  143. import {
  144. getDrawOri,
  145. getUpdateOri,
  146. getGiftList,
  147. } from "@/api/SilkRoadSpringGala.js";
  148. // import { onMounted, reactive } from "vue";
  149. // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
  150. /**
  151. * window.$originData.orginParames.title 页面标题
  152. * window.$originData.orginParames.parameters 固定参数值
  153. * window.$originData.urlParames url参数
  154. */
  155. let w = window.$originData.orginParames.availWidth || 0;
  156. const show = ref(Array(12).fill(false));
  157. const address = ref(localStorage.getItem("silkRoadAddress") || "");
  158. const nickName = ref(localStorage.getItem("silkRoadName") || "");
  159. const phone = ref(localStorage.getItem("silkRoadPhone") || "");
  160. const next = false;
  161. const emits = defineEmits(["showVideo", "showTitleFunc"]);
  162. let t = setInterval(() => {
  163. let index = Math.ceil(Math.random() * 12) - 1;
  164. if (index < 0) index = 0;
  165. for (let i = 0; i < show.value.length; i++) {
  166. show.value[i] = i == index;
  167. }
  168. if (next) clearInterval(t);
  169. }, 5000);
  170. w = (w / 3) * 0.8;
  171. const img = reactive({
  172. width: w,
  173. height: w,
  174. });
  175. let T = undefined;
  176. const gift = ref({});
  177. let isdraw = false;
  178. function draw() {
  179. phone.value = localStorage.getItem("silkRoadPhone") || "";
  180. if (!phone.value) return emits("showTitleFunc");
  181. if (T) clearTimeout(T);
  182. T = setTimeout(() => {
  183. getDrawOri({
  184. phone: phone.value,
  185. code: window.$shanshipin && window.$shanshipin.UserId ? 76767676 : "",
  186. }).then(res => {
  187. const r = res || {};
  188. isdraw = r.prizeId !== 1; // 接入接口后直接由接口提供是否中将
  189. if (!isdraw)
  190. return showDialog({
  191. title: r.name,
  192. message:
  193. "很遗憾哟,新年礼物擦肩而过啦!点击下方刷个小视频吧,给手气充能,获取额外抽奖机会!",
  194. });
  195. console.log(r);
  196. gift.value.url = r.url;
  197. gift.value.name = r.name;
  198. gift.value.show = true;
  199. });
  200. }, 200);
  201. }
  202. function before(type) {
  203. if (type !== "confirm" || !isdraw) return true;
  204. showToast("奖品已打包,静等您收货哦!");
  205. return true;
  206. }
  207. const addressObj = ref({ show: false });
  208. function upaddress() {
  209. if (!address.value) return;
  210. getUpdateOri({
  211. phone: phone.value,
  212. userName: nickName.value,
  213. addr: address.value,
  214. })
  215. .then(() => {
  216. localStorage.setItem("silkRoadAddress", address.value);
  217. localStorage.setItem("silkRoadName", nickName.value);
  218. addressObj.value.show = false;
  219. })
  220. .catch(() => {
  221. addressObj.value.show = false;
  222. });
  223. }
  224. function addressObjshow() {
  225. if (!phone.value) return showToast("请登录后在查看");
  226. addressObj.value.show = true;
  227. }
  228. function mygift() {
  229. getGiftList({
  230. phone: phone.value,
  231. }).then(r => {
  232. const giftList = r || [];
  233. if (!giftList.length) return showToast("暂无中奖信息");
  234. const cardList = [];
  235. for (let i = 0; i < giftList.length; i++) {
  236. const v = giftList[i];
  237. cardList.push(
  238. <van-card
  239. num={v.winNum || 1}
  240. title={v.name || ""}
  241. thumb={v.url || ""}
  242. />
  243. );
  244. }
  245. showConfirmDialog({
  246. title: "我的奖品",
  247. confirmButtonText: "关闭",
  248. message: () => {
  249. return <div>{cardList}</div>;
  250. },
  251. showCancelButton: false,
  252. });
  253. });
  254. }
  255. function playVideo() {
  256. let url = "https://cxzx.smcic.net/topic/tool/media/ad.mp4";
  257. const random = Math.random();
  258. if (random >= 0.3 && random < 0.6)
  259. url = "https://cxzx.smcic.net/topic/tool/media/changanhua.M4V";
  260. else if (random >= 0.3)
  261. url = "https://cxzx.smcic.net/topic/tool/media/qinnongbank.mp4";
  262. emits("showVideo", url);
  263. }
  264. defineExpose({
  265. draw,
  266. });
  267. </script>
  268. <style lang="scss" scoped>
  269. .eight {
  270. width: 100%;
  271. height: 100%;
  272. padding: 0.5em 0;
  273. background-color: #fff;
  274. position: relative;
  275. .btns {
  276. margin: 0 auto;
  277. display: block;
  278. width: 8em;
  279. }
  280. .headText {
  281. text-align: center;
  282. font-size: 14px;
  283. width: 100vw;
  284. line-height: 2em;
  285. }
  286. .luckDraw {
  287. $background: #00000040;
  288. background-color: #eeeeee80;
  289. border-radius: 5px;
  290. padding: 0.5em;
  291. margin: 0.5em auto;
  292. width: 96%;
  293. .img {
  294. border-radius: 5px;
  295. display: block;
  296. margin: auto;
  297. border: 3px solid #ffffff;
  298. }
  299. .click {
  300. background-color: $background;
  301. position: absolute;
  302. border-radius: 3px;
  303. text-align: center;
  304. padding: 2px 3px;
  305. color: #fff;
  306. font-size: 14px;
  307. right: -0.5em;
  308. top: -0.5em;
  309. width: 4em;
  310. z-index: 1;
  311. }
  312. .click:before {
  313. position: absolute;
  314. display: block;
  315. content: " ";
  316. height: 0px;
  317. width: 0px;
  318. border: 3px solid $background;
  319. border-top-color: rgba($color: #000000, $alpha: 0);
  320. border-left-color: rgba($color: #000000, $alpha: 0);
  321. bottom: -3px;
  322. left: 9px;
  323. transform: rotate(45deg);
  324. }
  325. }
  326. }
  327. .shakeSlow {
  328. animation: shake-slow 1s ease-in-out;
  329. }
  330. @keyframes shake-slow {
  331. 0% {
  332. transform: rotate(0) scale(1);
  333. }
  334. 20% {
  335. transform: rotate(2.5deg);
  336. }
  337. 40% {
  338. transform: rotate(-2.5deg);
  339. }
  340. 60% {
  341. transform: rotate(2.5deg) scale(1.1);
  342. }
  343. 80% {
  344. transform: rotate(-2.5deg);
  345. }
  346. 100% {
  347. transform: rotate(0);
  348. }
  349. }
  350. </style>
  351. <style lang="scss">
  352. .van-card__title {
  353. font-size: 14px;
  354. height: 50px;
  355. line-height: 50px;
  356. }
  357. .van-card__bottom {
  358. height: 40px;
  359. line-height: 40px;
  360. }
  361. .eight {
  362. .van-col {
  363. padding: 0.2em 0;
  364. position: relative;
  365. }
  366. .van-notice-bar__wrap {
  367. background: #ffffff;
  368. color: #000000;
  369. }
  370. .vieoPlay {
  371. position: relative;
  372. font-size: 0;
  373. .play {
  374. position: absolute;
  375. top: 50%;
  376. left: 50%;
  377. transform: translate(-50%, -50%);
  378. }
  379. }
  380. }
  381. .dialogImg {
  382. width: 5em;
  383. display: block;
  384. margin: auto;
  385. }
  386. </style>