sudoku.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="box">
  3. <view class="lottery-box">
  4. <navigator class="my-list" url="/cloud/winningNews/index">
  5. 我的奖品
  6. </navigator>
  7. <image
  8. class="bg-image"
  9. src="https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405281716860202553Be55ba55.webp"
  10. />
  11. <view class="lottery" v-if="prizes.length && showPrizes">
  12. <view>
  13. <LuckyGrid
  14. ref="myLucky"
  15. width="590rpx"
  16. height="590rpx"
  17. :prizes="prizes"
  18. :buttons="buttons"
  19. :defaultStyle="defaultStyle"
  20. @start="startCallBack"
  21. @end="endCallBack"
  22. />
  23. </view>
  24. </view>
  25. <view class="usable-count">
  26. 您还有<text class="count">{{ usableCount }}</text
  27. >抽奖机会
  28. </view>
  29. </view>
  30. <view class="winners-list" v-if="winningList.length">
  31. <image
  32. class="image"
  33. src="https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405281716863577428B1faf5081.webp"
  34. mode="widthFix"
  35. />
  36. <view class="content">
  37. <view class="title">
  38. <view class="text"> 抽奖名单 </view>
  39. </view>
  40. <swiper
  41. class="swiper"
  42. autoplay
  43. easing-function="linear"
  44. interval="1000"
  45. duration="1000"
  46. circular
  47. vertical
  48. :display-multiple-items="7"
  49. >
  50. <swiper-item v-for="item in winningList" :key="item.sa_awardmxid">
  51. <view v-if="item.createuserid" class="swiper-item u-line-2">
  52. {{ item.name ? item.name : "用户" + item.createuserid }}
  53. <text style="padding: 0 5px">抽中了</text>{{ item.awardname }}
  54. </view>
  55. <view v-else></view>
  56. </swiper-item>
  57. </swiper>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import LuckyGrid from "@/components/@lucky-canvas/uni/lucky-grid";
  64. export default {
  65. components: { LuckyGrid },
  66. props: {
  67. detail: {
  68. type: Object,
  69. },
  70. sa_awardid: {
  71. type: [Number || String],
  72. },
  73. shareuserid: {
  74. type: [Number || String],
  75. },
  76. },
  77. data() {
  78. return {
  79. prizes: [],
  80. buttons: [
  81. {
  82. background: "rgba(0,0,0,0)",
  83. x: 1,
  84. y: 1,
  85. imgs: [
  86. {
  87. src: "https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405281716861339513B3a575413.webp",
  88. width: "183.34rpx",
  89. height: "183.34rpx",
  90. },
  91. ],
  92. },
  93. ],
  94. defaultStyle: {
  95. background: "#FFFFFF",
  96. width: "183.34rpx",
  97. height: "183.34rpx",
  98. },
  99. usableCount: 0,
  100. loading: false,
  101. winningList: [],
  102. tips: "",
  103. showPrizes: true,
  104. };
  105. },
  106. methods: {
  107. init() {
  108. console.log("this.sa_awardid", this.sa_awardid);
  109. try {
  110. this.$Http
  111. .basic({
  112. id: 20240514131402,
  113. content: {
  114. sa_awardid: this.sa_awardid,
  115. where: {
  116. condition: "",
  117. type: "",
  118. },
  119. },
  120. })
  121. .then((res) => {
  122. console.log("奖品列表", res);
  123. if (this.cutoff(res.msg)) return;
  124. let prizes = [
  125. { index: 0, x: 0, y: 0 },
  126. { index: 2, x: 2, y: 0 },
  127. { index: 6, x: 0, y: 2 },
  128. { index: 4, x: 2, y: 2 },
  129. { index: 1, x: 1, y: 0 },
  130. { index: 3, x: 2, y: 1 },
  131. { index: 5, x: 1, y: 2 },
  132. { index: 7, x: 0, y: 1 },
  133. ].map((v) => {
  134. v.borderRadius = "20rpx";
  135. v.imgs = [
  136. {
  137. src: "https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405291716965428111B4602d616.webp",
  138. width: "50%",
  139. top: "20%",
  140. },
  141. ];
  142. return v;
  143. });
  144. res.data.forEach((v, i) => {
  145. v.imgs = v.attinfos.map((img) => {
  146. return {
  147. src: img.url,
  148. width: "50%",
  149. top: "25%",
  150. };
  151. });
  152. prizes[i] = Object.assign(prizes[i], v);
  153. });
  154. this.prizes = prizes.sort((a, b) => {
  155. return a.index - b.index;
  156. });
  157. });
  158. } catch (error) {}
  159. this.queryAwardCount();
  160. this.getWinningList();
  161. },
  162. startCallBack() {
  163. let that = this;
  164. if (this.detail.begdate > this.formatTime())
  165. this.tips = `活动开始时间为“${this.detail.begdate}”敬请期待!`;
  166. if (this.detail.enddate < this.formatTime())
  167. this.tips = `活动已在“${this.detail.enddate}”结束!`;
  168. if (this.tips)
  169. return uni.showToast({
  170. title: this.tips,
  171. icon: "none",
  172. duration: 1500,
  173. });
  174. if (this.loading || this.usableCount == 0) return;
  175. this.loading = true;
  176. this.$refs.myLucky.play();
  177. that.$Http
  178. .basic({
  179. content: {
  180. sa_awardid: that.sa_awardid,
  181. shareuserid: that.shareuserid,
  182. },
  183. id: 20240514134002,
  184. })
  185. .then((res) => {
  186. console.log("抽奖结果", res);
  187. if (this.cutoff(res.msg)) {
  188. this.showPrizes = false;
  189. setTimeout(() => {
  190. this.showPrizes = true;
  191. });
  192. that.queryAwardCount();
  193. that.getWinningList();
  194. return;
  195. }
  196. const index = that.prizes.findIndex(
  197. (v) => v.sa_awarditemsid == res.data.sa_awarditemsid
  198. );
  199. that.$refs.myLucky.stop(index);
  200. that.queryAwardCount();
  201. setTimeout(() => {
  202. that.loading = false;
  203. that.showWinningResult(res.data, index);
  204. }, 5000);
  205. });
  206. },
  207. showWinningResult(data, index) {
  208. console.log("中奖结果", data);
  209. let that = this;
  210. that.getWinningList();
  211. uni.showModal({
  212. title: "恭喜您抽中",
  213. content: data.awardname,
  214. showCancel: false,
  215. confirmText: "选择地址",
  216. success: function ({ confirm }) {
  217. if (confirm) {
  218. uni.navigateTo({
  219. url: "/store/deliveryAddress/index?tips=奖项根据收货信息发放,请选择并提交收货地址",
  220. });
  221. that.$Http.selectAddress = (item) => {
  222. uni.showModal({
  223. title: "提示",
  224. content: `是否确定选择“${item.address}”作为收货地址?`,
  225. success: (success) => {
  226. if (success.confirm)
  227. that.$Http
  228. .basic({
  229. id: "2024052910464202",
  230. content: {
  231. sa_awardmxid: data.sa_awardmxid,
  232. name: item.name,
  233. phonenumber: item.phonenumber,
  234. province: item.province,
  235. city: item.city,
  236. county: item.county,
  237. address: item.address,
  238. },
  239. })
  240. .then((s) => {
  241. if (that.cutoff(s.msg, "设置成功", true, "1000"))
  242. return;
  243. });
  244. },
  245. });
  246. };
  247. }
  248. },
  249. fail: (err) => {
  250. console.log(err);
  251. },
  252. });
  253. },
  254. getWinningList() {
  255. this.$Http
  256. .basic({
  257. content: {
  258. sa_awardid: this.sa_awardid,
  259. pageNumber: 1,
  260. pageSize: 20,
  261. },
  262. id: 20240514133902,
  263. })
  264. .then((res) => {
  265. console.log("中奖人员", res);
  266. if (this.cutoff(res.msg)) return;
  267. if (res.data.length < 7) {
  268. let len = res.data.length;
  269. for (let index = 0; index < 7 - len; index++) {
  270. res.data.push({});
  271. }
  272. }
  273. this.winningList = res.data;
  274. });
  275. },
  276. queryAwardCount() {
  277. if (uni.getStorageSync("userMsg").usertype == 99) {
  278. this.$Http
  279. .basic({
  280. classname: "sysmanage.develop.datafunction.datafunction",
  281. method: "execute",
  282. content: {
  283. functionname: "queryAwardCount",
  284. parameter: {
  285. sa_awardid: this.sa_awardid,
  286. },
  287. },
  288. })
  289. .then((res) => {
  290. console.log("抽奖可用次数", res);
  291. if (this.cutoff(res.msg)) return;
  292. this.usableCount = res.data.length ? res.data[0].count : 0;
  293. });
  294. } else {
  295. this.tips = "内部人员不可参与抽奖";
  296. }
  297. },
  298. endCallBack(prize) {
  299. console.log("抽到的奖品", prize);
  300. },
  301. },
  302. };
  303. </script>
  304. <style lang="scss" scoped>
  305. .box {
  306. width: 100vw;
  307. min-height: 100vh;
  308. background: linear-gradient(90deg, #fe5a46 0%, #f11f46 100%);
  309. .lottery-box {
  310. position: relative;
  311. width: 100vw;
  312. height: 511px;
  313. .my-list {
  314. position: absolute;
  315. top: 20px;
  316. left: 0;
  317. width: 86px;
  318. height: 40px;
  319. line-height: 40px;
  320. text-align: center;
  321. background: linear-gradient(
  322. 180deg,
  323. #fad96d 0%,
  324. #ffc300 4%,
  325. #ffcd2b 16%,
  326. #ffdf77 42%,
  327. #ffd241 70%,
  328. #ffc300 94%,
  329. #fc9228 100%
  330. );
  331. border-radius: 0px 20px 20px 0px;
  332. font-family: Source Han Sans SC, Source Han Sans SC;
  333. font-weight: bold;
  334. font-size: 14px;
  335. color: #c30d23;
  336. z-index: 2;
  337. }
  338. .bg-image {
  339. position: absolute;
  340. width: 100vw;
  341. height: 511px;
  342. top: 0;
  343. left: 0;
  344. z-index: 1;
  345. vertical-align: bottom;
  346. }
  347. .lottery {
  348. position: absolute;
  349. width: 100%;
  350. z-index: 2;
  351. top: 140px;
  352. }
  353. .usable-count {
  354. position: absolute;
  355. bottom: 15px;
  356. width: 100vw;
  357. text-align: center;
  358. font-family: Source Han Sans SC, Source Han Sans SC;
  359. font-weight: bold;
  360. font-size: 14px;
  361. color: #ffffff;
  362. .count {
  363. height: 29px;
  364. font-family: Source Han Sans SC, Source Han Sans SC;
  365. font-weight: 800;
  366. font-size: 20px;
  367. color: #fad96d;
  368. padding: 0 10px;
  369. }
  370. }
  371. }
  372. .winners-list {
  373. width: 100vw;
  374. display: flex;
  375. flex-direction: column;
  376. align-items: center;
  377. padding-bottom: 20px;
  378. .image {
  379. width: 355px;
  380. }
  381. .title {
  382. position: relative;
  383. width: 80px;
  384. height: 29px;
  385. margin: 0 auto;
  386. .text {
  387. position: absolute;
  388. top: 0px;
  389. left: 0;
  390. width: 80px;
  391. line-height: 29px;
  392. text-align: center;
  393. font-family: Source Han Sans SC, Source Han Sans SC;
  394. font-weight: bold;
  395. font-size: 20px;
  396. color: #333333;
  397. z-index: 2;
  398. }
  399. }
  400. .title::after {
  401. content: "";
  402. position: absolute;
  403. bottom: 0px;
  404. left: 0;
  405. width: 80px;
  406. height: 8px;
  407. background: #fad96d;
  408. border-radius: 5px;
  409. z-index: 1;
  410. }
  411. .content {
  412. background: #fff;
  413. padding: 0 15px 20px;
  414. width: 669.7672675rpx;
  415. box-sizing: border-box;
  416. .swiper {
  417. width: 100%;
  418. height: 300px;
  419. margin-top: 20px;
  420. .swiper-item {
  421. width: 100%;
  422. height: 40px;
  423. text-align: center;
  424. line-height: 20px;
  425. font-family: Source Han Sans SC, Source Han Sans SC;
  426. font-size: 14px;
  427. color: #666666;
  428. overflow: hidden;
  429. }
  430. }
  431. }
  432. }
  433. }
  434. </style>