Marketwheel.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false" ><view class="div home-marketwheel" :style="'background-image:url('+marketwheelbg+')'">
  3. <view class="div roulette-container l-scene__roulette" v-if="award_list.length">
  4. <view class="div c-award__container" :class="{'c-award__container--active':(active==1)}">
  5. <text class="i c-award__icon" :class="'award-type-'+award_list[1].marketmanageaward_type" />
  6. <view class="p l-general__desc c-award__desc"> {{award_list[1].marketmanageaward_text}} </view>
  7. </view>
  8. <view class="div c-award__container" :class="{'c-award__container--active':(active==2)}">
  9. <text class="i c-award__icon award-type-0" />
  10. <view class="p l-general__desc c-award__desc"> 谢谢参与 </view>
  11. </view>
  12. <view class="div c-award__container" :class="{'c-award__container--active':(active==3)}">
  13. <text class="i c-award__icon" :class="'award-type-'+award_list[3].marketmanageaward_type" />
  14. <view class="p l-general__desc c-award__desc"> {{award_list[3].marketmanageaward_text}} </view>
  15. </view>
  16. <view class="div c-award__container" :class="{'c-award__container--active':(active==4)}">
  17. <text class="i c-award__icon award-type-0" />
  18. <view class="p l-general__desc c-award__desc"> 谢谢参与 </view>
  19. </view>
  20. <view class="div c-award__container" :class="{'c-award__container--active':(active==12)}">
  21. <text class="i c-award__icon award-type-0" />
  22. <view class="p l-general__desc c-award__desc"> 谢谢参与 </view>
  23. </view>
  24. <view class="div c-award__container c-award__container--hidden"></view>
  25. <view class="div c-award__container c-award__container--hidden"></view>
  26. <view class="div c-award__container" :class="{'c-award__container--active':(active==5)}">
  27. <text class="i c-award__icon" :class="'award-type-'+award_list[5].marketmanageaward_type" />
  28. <view class="p l-general__desc c-award__desc"> {{award_list[5].marketmanageaward_text}} </view>
  29. </view>
  30. <view class="div c-award__container" :class="{'c-award__container--active':(active==11)}">
  31. <text class="i c-award__icon" :class="'award-type-'+award_list[11].marketmanageaward_type" />
  32. <view class="p l-general__desc c-award__desc"> {{award_list[11].marketmanageaward_text}} </view>
  33. </view>
  34. <view class="div c-award__container c-award__container--hidden"></view>
  35. <view class="div c-award__container c-award__container--hidden"></view>
  36. <view class="div c-award__container" :class="{'c-award__container--active':(active==6)}">
  37. <text class="i c-award__icon award-type-0" />
  38. <view class="p l-general__desc c-award__desc"> 谢谢参与 </view>
  39. </view>
  40. <view class="div c-award__container" :class="{'c-award__container--active':(active==10)}">
  41. <text class="i c-award__icon award-type-0" />
  42. <view class="p l-general__desc c-award__desc"> 谢谢参与 </view>
  43. </view>
  44. <view class="div c-award__container" :class="{'c-award__container--active':(active==9)}">
  45. <text class="i c-award__icon" :class="'award-type-'+award_list[9].marketmanageaward_type" />
  46. <view class="p l-general__desc c-award__desc"> {{award_list[9].marketmanageaward_text}} </view>
  47. </view>
  48. <view class="div c-award__container" :class="{'c-award__container--active':(active==8)}">
  49. <text class="i c-award__icon award-type-0" />
  50. <view class="p l-general__desc c-award__desc"> 谢谢参与 </view>
  51. </view>
  52. <view class="div c-award__container" :class="{'c-award__container--active':(active==7)}">
  53. <text class="i c-award__icon" :class="'award-type-'+award_list[7].marketmanageaward_type" />
  54. <view class="p l-general__desc c-award__desc"> {{award_list[7].marketmanageaward_text}} </view>
  55. </view>
  56. <view class="button l-lottery__btn" @click="goTurn" v-if="canDraw">
  57. <view class="div c-btn__action">
  58. 立即抽奖
  59. </view>
  60. <view class="div c-btn__credit"></view>
  61. <view class="div c-btn__chance" v-if="countLeft">
  62. 剩余{{countLeft}}次机会
  63. </view>
  64. </view>
  65. <view class="button l-lottery__btn l-lottery__btn--disable" v-else>
  66. <view class="div c-btn__action">
  67. 明天再来
  68. </view>
  69. <view class="div c-btn__credit"></view>
  70. <view class="div c-btn__chance">
  71. 次数用完了
  72. </view>
  73. </view>
  74. </view>
  75. <view class="div l-scene__user">
  76. <view class="p c-user__credit">我的积分:{{info?info.member_points:0}}</view>
  77. <text class="a c-user__record" @click="goLog"> 我的中奖记录 </text>
  78. </view>
  79. <uni-popup background-color="#fff" class="popup" ref="isResult">
  80. <view class="div c-result__popup" :style="'background-image:url('+marketwheelpopup+')'">
  81. <view class="div c-result__container">
  82. <view class="div c-result__title">
  83. {{drawTitle}}
  84. </view>
  85. <view class="div l-result__prize">
  86. <text class="i c-prize__icon" :class="'award-type-'+(drawResult?drawInfo.marketmanageaward_type:0)" />
  87. <view class="p c-prize__name">{{drawContent}}</view>
  88. <view class="p c-prize__expire"> </view>
  89. </view>
  90. <view class="div button-wrapper">
  91. <view class="div common-btn ds-button-large" @click="hidePopup('isResult')">
  92. 知道了
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </uni-popup>
  98. </view></home-base>
  99. </template>
  100. <script>
  101. import {getFontSize} from '@/util/common'
  102. import HomeBase from '../HomeBase'
  103. import { getMarketmanageInfo, addMarketmanagelog } from '../../../api/homeMarketmanage'
  104. import { getMemberInfo } from '../../../api/member'
  105. import { mapState, mapMutations } from 'vuex'
  106. import { env } from '../../../static/config'
  107. export default {
  108. name: 'Marketwheel',
  109. data () {
  110. return {
  111. active: false,
  112. marketmanage_id: 0,
  113. marketmanage_info: false,
  114. award_list: [],
  115. drawResult: false,
  116. drawTitle: '谢谢参与',
  117. drawContent: '哎呀,肯定姿势不对!',
  118. canDraw: false,
  119. countLeft: 0,
  120. count: 0,
  121. award_position: {},
  122. drawInfo: false,
  123. marketwheelbg: env.SITE_URL+'/uploads/home/h5/home/home-marketwheel-bg.png',
  124. marketwheelpopup: env.SITE_URL+'/uploads/home/h5/home/home-marketwheel-popup.png'
  125. }
  126. },
  127. components:{
  128. HomeBase,
  129. },
  130. computed:{
  131. fontSize(){
  132. return getFontSize()
  133. },
  134. ...mapState({
  135. isOnline: state => state.member.isOnline,
  136. token: state => state.member.token,
  137. info: state => state.member.info
  138. })
  139. },
  140. onLoad: function (option) {
  141. this.marketmanage_id = option.marketmanage_id
  142. if (!this.marketmanage_id) {
  143. uni.showToast({icon:'none',title: '参数错误'})
  144. return
  145. }
  146. if (this.isOnline) {
  147. this.getMemberInfo()
  148. }
  149. getMarketmanageInfo(this.marketmanage_id, this.token).then(res => {
  150. this.marketmanage_info = res.result.marketmanage_info
  151. let marketmanageaward_list = res.result.marketmanageaward_list
  152. let award_list = []
  153. for (var i = 1; i <= 12; i++) {
  154. if (i % 2 > 0) {
  155. award_list[i] = marketmanageaward_list[((i - 1) / 2) % marketmanageaward_list.length]
  156. if (typeof (this.award_position[award_list[i].marketmanageaward_id]) === 'undefined') {
  157. this.award_position[award_list[i].marketmanageaward_id] = []
  158. }
  159. this.award_position[award_list[i].marketmanageaward_id].push(i)
  160. } else {
  161. award_list[i] = false
  162. if (typeof (this.award_position[0]) === 'undefined') {
  163. this.award_position[0] = []
  164. }
  165. this.award_position[0].push(i)
  166. }
  167. }
  168. this.award_list = award_list
  169. this.canDraw = res.result.can_draw
  170. this.countLeft = res.result.count_left
  171. this.drawContent = this.marketmanage_info.marketmanage_failed
  172. if (!this.canDraw) {
  173. uni.showToast({icon:'none',title: res.message})
  174. }
  175. }).catch(function (error) {
  176. uni.showToast({icon:'none',title: error.message})
  177. })
  178. },
  179. methods:{
  180. showPopup(id){
  181. this.$refs[id].open()
  182. },
  183. hidePopup(id){
  184. this.$refs[id].close()
  185. },
  186. ...mapMutations({
  187. memberUpdate: 'memberUpdate'
  188. }),
  189. goLog () {
  190. uni.navigateTo({url:'/pages/member/marketmanagelog/Marketmanagelog'})
  191. },
  192. setActive (speed = 400) {
  193. if (this.count > 0) {
  194. if (!this.active) {
  195. this.active = 1
  196. } else {
  197. this.active = this.active % 12 + 1
  198. }
  199. this.count = this.count - 1
  200. let _this = this
  201. if (speed > 50) {
  202. speed = speed - 50
  203. }
  204. if (this.count < 8) {
  205. speed = 400 - 50 * this.count
  206. }
  207. setTimeout(function () {
  208. _this.setActive(speed)
  209. }, speed)
  210. } else {
  211. this.showPopup('isResult')
  212. }
  213. },
  214. goTurn () {
  215. if (!this.isOnline) {
  216. uni.navigateTo({url:'/pages/home/memberlogin/Login'})
  217. return
  218. }
  219. if (!this.canDraw) return
  220. // 重置
  221. this.active = false
  222. this.drawResult = false
  223. this.drawTitle = '谢谢参与'
  224. this.drawContent = this.marketmanage_info.marketmanage_failed
  225. addMarketmanagelog(this.marketmanage_id).then(res => {
  226. this.canDraw = res.result.can_draw
  227. this.countLeft = res.result.count_left
  228. if (this.marketmanage_info.marketmanage_point > 0) {
  229. this.getMemberInfo()
  230. }
  231. if (res.result.draw_result) { // 中奖
  232. this.drawResult = true
  233. this.drawInfo = res.result.draw_info
  234. this.drawTitle = res.result.draw_info.marketmanageaward_level + '等奖'
  235. this.drawContent = res.result.draw_info.marketmanageaward_text
  236. let award_id = res.result.draw_info.marketmanageaward_id
  237. this.count = 48 + this.award_position[award_id][parseInt(Math.random() * this.award_position[award_id].length) % this.award_position[award_id].length]
  238. } else {
  239. this.count = 48 + parseInt(Math.random() * 6) * 2
  240. }
  241. this.setActive()
  242. }).catch(function (error) {
  243. uni.showToast({icon:'none',title: error.message})
  244. })
  245. },
  246. getMemberInfo () {
  247. getMemberInfo().then(res => {
  248. this.memberUpdate({ info: res.result.member_info })
  249. }, error => {}
  250. )
  251. }
  252. },
  253. watch: {
  254. },
  255. mounted () {
  256. }
  257. }
  258. </script>
  259. <style scoped lang="scss">
  260. .home-marketwheel{position: fixed;width:100%;height:100%;background-color: #FE302F;overflow-y:auto;background-size:100%;background-repeat: no-repeat;background-position: top center}
  261. .roulette-container {
  262. display: -webkit-box;
  263. display: -webkit-flex;
  264. display: -moz-box;
  265. display: flex;
  266. -webkit-flex-wrap: wrap;
  267. flex-wrap: wrap;
  268. -webkit-user-select: none;
  269. -moz-user-select: none;
  270. user-select: none;
  271. position: relative;
  272. -moz-box-sizing: border-box;
  273. box-sizing: border-box;
  274. padding: 10px 10px 0;
  275. -webkit-box-pack: justify;
  276. -webkit-justify-content: space-between;
  277. -moz-box-pack: justify;
  278. justify-content: space-between;
  279. margin: 185px 15px 10px 15px;
  280. background: #fff;
  281. border-radius: 8px;
  282. box-shadow: 0 2px 10px 0 rgba(0,0,0,.1);
  283. }
  284. .c-award__container {
  285. background: #fff;
  286. border-radius: 4px;
  287. padding: 10px 0;
  288. margin-bottom: 10px;
  289. width: -webkit-calc(25% - 5.5px);
  290. width: -moz-calc(25% - 5.5px);
  291. width: calc(25% - 5.5px);
  292. box-shadow: inset 0 0 24px 0 #ffd6ab,0 .25em 0 rgba(248,166,131,.96)
  293. }
  294. .c-award__container--hidden {
  295. visibility: hidden
  296. }
  297. .c-award__container--active {
  298. border-radius: 4px;
  299. background: #ffceab;
  300. box-shadow: inset 0 0 8px 0 #ff9358,0 .25em 0 rgba(248,166,131,.96)
  301. }
  302. .c-award__icon {
  303. width: 32px;
  304. height: 32px;
  305. display: block;
  306. margin: 0 auto;
  307. background-size:100%;
  308. background-repeat:no-repeat;
  309. background-position: center;
  310. }
  311. .c-award__icon.award-type-0{background-image:url(../../../static/image/home/home-marketwheel-0.png)}
  312. .c-award__icon.award-type-1{background-image:url(../../../static/image/home/home-marketwheel-1.png)}
  313. .c-award__icon.award-type-2{background-image:url(../../../static/image/home/home-marketwheel-2.png)}
  314. .c-award__icon.award-type-3{background-image:url(../../../static/image/home/home-marketwheel-3.png)}
  315. .c-award__desc {
  316. opacity: .8;
  317. color: #333;
  318. margin-top: 5px;
  319. font-size:$h6;
  320. line-height: 17px;
  321. text-align: center
  322. }
  323. .l-lottery__btn {
  324. top: 50%;
  325. left: 50%;
  326. border: none;
  327. display: -webkit-box;
  328. display: -webkit-flex;
  329. display: -moz-box;
  330. display: flex;
  331. width: 140px;
  332. height: 140px;
  333. color: #fff;
  334. position: absolute;
  335. border-radius: 50%;
  336. -webkit-box-align: center;
  337. -webkit-align-items: center;
  338. -moz-box-align: center;
  339. align-items: center;
  340. -webkit-box-orient: vertical;
  341. -webkit-box-direction: normal;
  342. -webkit-flex-direction: column;
  343. -moz-box-orient: vertical;
  344. -moz-box-direction: normal;
  345. flex-direction: column;
  346. -webkit-box-pack: center;
  347. -webkit-justify-content: center;
  348. -moz-box-pack: center;
  349. justify-content: center;
  350. -webkit-transform: translate(-50%,-50%);
  351. -moz-transform: translate(-50%,-50%);
  352. transform: translate(-50%,-50%);
  353. background-color: #f44;
  354. box-shadow: inset 0 0 0 1px rgba(0,0,0,.2),inset 0 -.25em 0 rgba(0,0,0,.25),0 .25em .25em rgba(0,0,0,.05);
  355. text-decoration: none;
  356. text-shadow: 0 1px 1px hsla(0,0%,100%,.25);
  357. vertical-align: middle
  358. }
  359. .l-lottery__btn:active {
  360. box-shadow: inset 12px 12em 0 hsla(0,0%,100%,.1),inset 0 .25em .5em rgba(0,0,0,.05);
  361. margin-top: .2em;
  362. outline: none;
  363. padding-bottom: .3em
  364. }
  365. .l-lottery__btn--disable {
  366. box-shadow: 0 .25em 0 rgba(174,165,161,.96);
  367. background: #d0d0d0
  368. }
  369. .l-lottery__btn--disable:active {
  370. margin-top: 0;
  371. padding-bottom: 0
  372. }
  373. .c-btn__action {
  374. font-size:1.2rem;
  375. margin-top: 10px;
  376. line-height: 33px;
  377. letter-spacing: .43px
  378. }
  379. .c-btn__chance{
  380. font-size:$fontSize;
  381. line-height: 17px;
  382. padding: 0 8px;
  383. margin-top: 8px;
  384. border-radius: 8px;
  385. background: rgba(0,0,0,.2)
  386. }
  387. .l-scene__user {
  388. color: #fff;
  389. display: -webkit-box;
  390. display: -webkit-flex;
  391. display: -moz-box;
  392. display: flex;
  393. font-size:$subFontSize;
  394. line-height: 20px;
  395. margin: 10px 15px 0;
  396. -webkit-box-pack: justify;
  397. -webkit-justify-content: space-between;
  398. -moz-box-pack: justify;
  399. justify-content: space-between
  400. }
  401. .l-scene__user .c-user__record {
  402. color: #fff;
  403. text-decoration: underline
  404. }
  405. .c-result__popup {
  406. width: 305px;
  407. background: #fff;
  408. border-radius: 8px;
  409. overflow: visible;
  410. background-repeat:no-repeat;background-size:100%;background-position:top center;
  411. z-index: 2001;
  412. }
  413. .c-result__container {
  414. position: relative
  415. }
  416. .c-result__title {
  417. color: #fff;
  418. font-size:1.9rem;
  419. font-weight: 500;
  420. padding-top: 32px;
  421. text-align: center;
  422. letter-spacing: .63px
  423. }
  424. .l-result__prize {
  425. display: -webkit-box;
  426. display: -webkit-flex;
  427. display: -moz-box;
  428. display: flex;
  429. margin: 19px 21px;
  430. border-radius: 8px;
  431. -webkit-box-align: center;
  432. -webkit-align-items: center;
  433. -moz-box-align: center;
  434. align-items: center;
  435. -webkit-box-orient: vertical;
  436. -webkit-box-direction: normal;
  437. -webkit-flex-direction: column;
  438. -moz-box-orient: vertical;
  439. -moz-box-direction: normal;
  440. flex-direction: column;
  441. padding: 30px 0 23px;
  442. -webkit-box-pack: center;
  443. -webkit-justify-content: center;
  444. -moz-box-pack: center;
  445. justify-content: center;
  446. background-color: #fff;
  447. box-shadow: 0 0 10px 0 rgba(199,73,67,.28)
  448. }
  449. .c-prize__icon {
  450. width: 50px;
  451. height: 50px;
  452. background-size:100%;
  453. background-repeat:no-repeat;
  454. background-position: center;
  455. }
  456. .c-prize__icon.award-type-0{background-image:url(../../../static/image/home/home-marketwheel-0.png)}
  457. .c-prize__icon.award-type-1{background-image:url(../../../static/image/home/home-marketwheel-1.png)}
  458. .c-prize__icon.award-type-2{background-image:url(../../../static/image/home/home-marketwheel-2.png)}
  459. .c-prize__icon.award-type-3{background-image:url(../../../static/image/home/home-marketwheel-3.png)}
  460. .c-prize__name {
  461. color: #333;
  462. font-size:$subFontSize;
  463. margin-top: 15px;
  464. font-weight: 500;
  465. line-height: 20px
  466. }
  467. .popup{border-radius:1rem;
  468. .button-wrapper{padding:1rem;padding-top:0}
  469. }
  470. </style>