Marketegg.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false" >
  3. <view class="div home-marketegg">
  4. <view class="div top-main" :style="'background-image:url('+marketeggbg+')'">
  5. <view class="div tops">
  6. <image mode="aspectFit" class="img" :src="marketegglogo"
  7. style="width:320px;height:179px">
  8. </view>
  9. <view class="div tops_pic">
  10. <image mode="aspectFit" class="img" :src="marketegglamp"
  11. style="width:287px;height:100px">
  12. </view>
  13. </view>
  14. <view class="div center_sta ">
  15. <section class="stage ">
  16. <view class="div wide-wrapper">
  17. <view class="div carousel">
  18. <view class="div carousel-item" @click="selectEgg(1)">
  19. <image mode="aspectFit" class="img selected" v-if="active==1"
  20. :src="marketegg1" style="width:200px;height:200px">
  21. <image mode="aspectFit" class="img" v-else :src="marketegg0"
  22. style="width:106px;height:136px">
  23. </view>
  24. <view class="div carousel-item" @click="selectEgg(2)">
  25. <image mode="aspectFit" class="img selected" v-if="active==2"
  26. :src="marketegg1" style="width:200px;height:200px">
  27. <image mode="aspectFit" class="img" v-else :src="marketegg0"
  28. style="width:106px;height:136px">
  29. </view>
  30. <view class="div carousel-item" @click="selectEgg(3)">
  31. <image mode="aspectFit" class="img selected" v-if="active==3"
  32. :src="marketegg1" style="width:200px;height:200px">
  33. <image mode="aspectFit" class="img" v-else :src="marketegg0"
  34. style="width:106px;height:136px">
  35. </view>
  36. </view>
  37. </view>
  38. </section>
  39. </view>
  40. <view class="div common-btn ds-button-large" @click="reset" v-if="canDraw">再来一次</view>
  41. <view class="div common-btn ds-button-large" v-else>机会用完了</view>
  42. <view class="div info-block">
  43. <view class="div info-area">
  44. <view class="ul activity-info" v-if="marketmanage_info">
  45. <view>活动名称:
  46. <view class="div activity-info-content">{{marketmanage_info.marketmanage_name}}</view>
  47. </view>
  48. <view>活动介绍:
  49. <view class="div activity-info-content">{{marketmanage_info.marketmanage_detail}}</view>
  50. </view>
  51. <view>活动有效时间:
  52. <view class="div activity-info-content">
  53. {{marketmanage_info.marketmanage_begintime_text}}至{{marketmanage_info.marketmanage_endtime_text}}</view>
  54. </view>
  55. <view>活动奖项设置:
  56. <view class="div activity-info-content">
  57. <view class="div" v-for="(marketmanageaward,index) in marketmanageaward_list" :key="index">
  58. {{marketmanageaward.marketmanageaward_level}}等奖{{marketmanageaward.marketmanageaward_probability}}%:{{marketmanageaward.marketmanageaward_text}}
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  67. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content"
  68. :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  69. </uni-popup>
  70. </home-base>
  71. </template>
  72. <script>
  73. import {getFontSize} from '@/util/common'
  74. import { env } from '../../../static/config'
  75. import HomeBase from '../HomeBase'
  76. import {
  77. getMarketmanageInfo,
  78. addMarketmanagelog
  79. } from '../../../api/homeMarketmanage'
  80. import {
  81. getMemberInfo
  82. } from '../../../api/member'
  83. import {
  84. mapState,
  85. mapMutations
  86. } from 'vuex'
  87. export default {
  88. name: 'Marketegg',
  89. data() {
  90. return {
  91. dialog: {},
  92. active: false,
  93. marketmanage_id: 0,
  94. marketmanage_info: false,
  95. marketmanageaward_list: false,
  96. isResult: false,
  97. drawResult: false,
  98. drawTitle: '谢谢参与',
  99. drawContent: '哎呀,肯定姿势不对!',
  100. canDraw: false,
  101. countLeft: 0,
  102. count: 0,
  103. drawInfo: false,
  104. marketeggbg:env.SITE_URL+'/uploads/home/h5/home/home-marketegg-bg.png',
  105. marketegglogo:env.SITE_URL+'/uploads/home/h5/home/home-marketegg-logo.png',
  106. marketegglamp:env.SITE_URL+'/uploads/home/h5/home/home-marketegg-lamp.gif',
  107. marketegg0: env.SITE_URL+'/uploads/home/h5/home/home-marketegg-0.png',
  108. marketegg1: env.SITE_URL+'/uploads/home/h5/home/home-marketegg-1.gif',
  109. }
  110. },
  111. components: {
  112. HomeBase,
  113. },
  114. computed:{
  115. fontSize(){
  116. return getFontSize()
  117. },
  118. ...mapState({
  119. isOnline: state => state.member.isOnline,
  120. token: state => state.member.token,
  121. info: state => state.member.info
  122. })
  123. },
  124. onLoad: function(option) {
  125. this.marketmanage_id = option.marketmanage_id
  126. if (!this.marketmanage_id) {
  127. uni.showToast({
  128. icon: 'none',
  129. title: '参数错误'
  130. })
  131. return
  132. }
  133. getMarketmanageInfo(this.marketmanage_id, this.token).then(res => {
  134. this.marketmanage_info = res.result.marketmanage_info
  135. this.marketmanageaward_list = res.result.marketmanageaward_list
  136. this.canDraw = res.result.can_draw
  137. this.countLeft = res.result.count_left
  138. this.drawContent = this.marketmanage_info.marketmanage_failed
  139. if (!this.canDraw) {
  140. uni.showToast({
  141. icon: 'none',
  142. title: res.message
  143. })
  144. }
  145. }).catch(function(error) {
  146. uni.showToast({
  147. icon: 'none',
  148. title: error.message
  149. })
  150. })
  151. },
  152. methods: {
  153. closeDialog() {},
  154. confirmDialog(value) {},
  155. ...mapMutations({
  156. memberUpdate: 'memberUpdate'
  157. }),
  158. selectEgg(index) {
  159. if (this.active) return
  160. if (!this.isOnline) {
  161. uni.navigateTo({
  162. url: '/pages/home/memberlogin/Login'
  163. })
  164. return
  165. }
  166. if (!this.canDraw) return
  167. this.active = index
  168. addMarketmanagelog(this.marketmanage_id).then(res => {
  169. this.canDraw = res.result.can_draw
  170. this.countLeft = res.result.count_left
  171. if (res.result.draw_result) { // 中奖
  172. this.drawResult = true
  173. this.drawInfo = res.result.draw_info
  174. this.drawTitle = res.result.draw_info.marketmanageaward_level + '等奖'
  175. this.drawContent = res.result.draw_info.marketmanageaward_text
  176. }
  177. this.dialog = {
  178. title: this.drawTitle,
  179. content: this.drawContent
  180. }
  181. this.$refs.confirm.open()
  182. }).catch(function(error) {
  183. uni.showToast({
  184. icon: 'none',
  185. title: error.message
  186. })
  187. })
  188. },
  189. reset() {
  190. // 重置
  191. this.active = false
  192. this.drawResult = false
  193. this.drawTitle = '谢谢参与'
  194. this.drawContent = this.marketmanage_info.marketmanage_failed
  195. }
  196. },
  197. watch: {
  198. },
  199. mounted() {
  200. }
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. .home-marketegg {
  205. position: fixed;
  206. width: 100%;
  207. height: 100%;
  208. background-color: #FFE881;
  209. overflow-y: auto;
  210. }
  211. .top-main {
  212. width: 100%;
  213. margin: 0rem auto 0;
  214. text-align: center;
  215. position: relative;
  216. z-index: 80;
  217. background-size: 100%;
  218. height: 14rem;
  219. }
  220. .tops {
  221. width: 100%;
  222. margin: 0 auto 0;
  223. text-align: center;
  224. position: absolute;
  225. top: 0%;
  226. left: 0%;
  227. z-index: 9;
  228. }
  229. .tops .img {
  230. width: 80%;
  231. margin: 15% auto 0;
  232. }
  233. .tops_pic {
  234. width: 100%;
  235. margin: 0 auto;
  236. position: absolute;
  237. top: 4%;
  238. left: 0%;
  239. z-index: 9;
  240. }
  241. .tops_pic .img {
  242. width: 60%;
  243. margin: 0 auto;
  244. }
  245. .wide-wrapper {
  246. width: 100%;
  247. margin: 0 auto;
  248. }
  249. .carousel {
  250. position: relative;
  251. overflow: hidden;
  252. padding: 5%;
  253. display: flex;
  254. .carousel-item {
  255. flex: 1;
  256. text-align: center;
  257. position: relative;
  258. height: 136px;
  259. image {
  260. position: absolute;
  261. bottom: 0;
  262. left: 50%;
  263. margin-left: -53px
  264. }
  265. .selected {
  266. margin-left: -100px
  267. }
  268. }
  269. }
  270. .large-btn {
  271. width: 80%;
  272. margin: 0 auto
  273. }
  274. .info-block {
  275. font-size: $fontSize;
  276. padding: .5rem;
  277. margin: 1rem auto;
  278. color: #e93c3d;
  279. width: 80%;
  280. border: 1px dashed #e93c3d;
  281. box-sizing: border-box
  282. }
  283. .info-block .ul.activity-info .li {
  284. padding-bottom: .5rem;
  285. }
  286. </style>