eight.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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月4日前,在右下角“我的地址”中上传收货地址哦~
  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. const cardList = [];
  234. for (let i = 0; i < giftList.length; i++) {
  235. const v = giftList[i];
  236. cardList.push(
  237. <van-card
  238. num={v.winNum || 1}
  239. title={v.name || ""}
  240. thumb={v.url || ""}
  241. />
  242. );
  243. }
  244. showConfirmDialog({
  245. title: "我的奖品",
  246. confirmButtonText: "关闭",
  247. message: () => {
  248. return <div>{cardList}</div>;
  249. },
  250. showCancelButton: false,
  251. });
  252. });
  253. }
  254. function playVideo() {
  255. let url = "https://cxzx.smcic.net/topic/tool/media/ad.mp4";
  256. const random = Math.random();
  257. if (random >= 0.3 && random < 0.6)
  258. url = "https://cxzx.smcic.net/topic/tool/media/changanhua.M4V";
  259. else if (random >= 0.3)
  260. url = "https://cxzx.smcic.net/topic/tool/media/qinnongbank.mp4";
  261. emits("showVideo", url);
  262. }
  263. defineExpose({
  264. draw,
  265. });
  266. </script>
  267. <style lang="scss" scoped>
  268. .eight {
  269. width: 100%;
  270. height: 100%;
  271. padding: 0.5em 0;
  272. background-color: #fff;
  273. position: relative;
  274. .btns {
  275. margin: 0 auto;
  276. display: block;
  277. width: 8em;
  278. }
  279. .headText {
  280. text-align: center;
  281. font-size: 14px;
  282. width: 100vw;
  283. line-height: 2em;
  284. }
  285. .luckDraw {
  286. $background: #00000040;
  287. background-color: #eeeeee80;
  288. border-radius: 5px;
  289. padding: 0.5em;
  290. margin: 0.5em auto;
  291. width: 96%;
  292. .img {
  293. border-radius: 5px;
  294. display: block;
  295. margin: auto;
  296. border: 3px solid #ffffff;
  297. }
  298. .click {
  299. background-color: $background;
  300. position: absolute;
  301. border-radius: 3px;
  302. text-align: center;
  303. padding: 2px 3px;
  304. color: #fff;
  305. font-size: 14px;
  306. right: -0.5em;
  307. top: -0.5em;
  308. width: 4em;
  309. z-index: 1;
  310. }
  311. .click:before {
  312. position: absolute;
  313. display: block;
  314. content: " ";
  315. height: 0px;
  316. width: 0px;
  317. border: 3px solid $background;
  318. border-top-color: rgba($color: #000000, $alpha: 0);
  319. border-left-color: rgba($color: #000000, $alpha: 0);
  320. bottom: -3px;
  321. left: 9px;
  322. transform: rotate(45deg);
  323. }
  324. }
  325. }
  326. .shakeSlow {
  327. animation: shake-slow 1s ease-in-out;
  328. }
  329. @keyframes shake-slow {
  330. 0% {
  331. transform: rotate(0) scale(1);
  332. }
  333. 20% {
  334. transform: rotate(2.5deg);
  335. }
  336. 40% {
  337. transform: rotate(-2.5deg);
  338. }
  339. 60% {
  340. transform: rotate(2.5deg) scale(1.1);
  341. }
  342. 80% {
  343. transform: rotate(-2.5deg);
  344. }
  345. 100% {
  346. transform: rotate(0);
  347. }
  348. }
  349. </style>
  350. <style lang="scss">
  351. .van-card__title {
  352. font-size: 14px;
  353. height: 50px;
  354. line-height: 50px;
  355. }
  356. .van-card__bottom {
  357. height: 40px;
  358. line-height: 40px;
  359. }
  360. .eight {
  361. .van-col {
  362. padding: 0.2em 0;
  363. position: relative;
  364. }
  365. .van-notice-bar__wrap {
  366. background: #ffffff;
  367. color: #000000;
  368. }
  369. .vieoPlay {
  370. position: relative;
  371. font-size: 0;
  372. .play {
  373. position: absolute;
  374. top: 50%;
  375. left: 50%;
  376. transform: translate(-50%, -50%);
  377. }
  378. }
  379. }
  380. .dialogImg {
  381. width: 5em;
  382. display: block;
  383. margin: auto;
  384. }
  385. </style>