detail.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view>
  3. <view v-if="pagesNum > 1">
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情"></u-navbar>
  5. </view>
  6. <view v-else>
  7. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" title="盲票详情">
  8. <view class="nav-left flex" slot="left" @click="toIndex">
  9. <u-icon name="home" size="20" color="#333"></u-icon>
  10. <view class="nav-left__code">首页</view>
  11. </view>
  12. </u-navbar>
  13. </view>
  14. <!-- 奖品轮播 -->
  15. <view class="prize">
  16. <!-- 查看规则 -->
  17. <view class="prize-rule">
  18. <view class="prize-rule-content flex">
  19. <image src="../../static/index/index_tip.png" mode=""></image>
  20. <text>查看规则</text>
  21. </view>
  22. </view>
  23. <!-- 奖品 -->
  24. <swiper class="prize-swiper" previous-margin="100px" next-margin="100px" :interval="4000" :autoplay="true" :circular="true" @change="changePrizeSwiper">
  25. <swiper-item :class="prizeIndex == index ? 'swiper-item' : 'swiper-item-side'" v-for="(item, index) in prizeList" :key="index">
  26. <view class="prize-swiper-item flex">
  27. <image :class="prizeIndex == index ? 'img' : 'img-side'" :src="item.picUrl" mode="aspectFit"></image>
  28. </view>
  29. </swiper-item>
  30. </swiper>
  31. </view>
  32. <!-- 开启盲票 -->
  33. <view class="ticket-btn">
  34. </view>
  35. <!-- 盲票奖品说明 -->
  36. <view class="explain">
  37. </view>
  38. <!-- 盲票奖品数量、概率 -->
  39. <view class="prize-total">
  40. </view>
  41. <!-- 盲票奖品列表 -->
  42. <view class="prize-list">
  43. </view>
  44. <!-- 支付弹层 -->
  45. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" />
  46. </view>
  47. </template>
  48. <script>
  49. import env from '../../config/env.js'
  50. import $http from '@/utils/request.js'
  51. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  52. export default {
  53. components: {
  54. PayPopup
  55. },
  56. data() {
  57. return {
  58. boxId: '',
  59. picUrlArr: [],
  60. info: {},
  61. prizeList: [],
  62. payShow: false,
  63. payInfo: {},
  64. pagesNum: null,
  65. sceneArr: null,
  66. prizeIndex: 0
  67. };
  68. },
  69. onLoad(opthios) {
  70. if (opthios.scene) {
  71. let sceneStr = decodeURIComponent(opthios.scene)
  72. this.sceneArr = sceneStr.split('&')
  73. this.boxId = this.sceneArr[0]
  74. uni.setStorageSync('shareUid', this.sceneArr[1])
  75. uni.setStorageSync('shareType', this.sceneArr[2])
  76. }
  77. if (opthios.boxId) {
  78. this.boxId = opthios.boxId
  79. }
  80. if (opthios.userId) {
  81. uni.setStorageSync('shareUid', opthios.userId)
  82. }
  83. if (opthios.type) {
  84. uni.setStorageSync('shareType', opthios.type)
  85. }
  86. },
  87. onShow() {
  88. this.pagesNum = getCurrentPages().length
  89. if (this.boxId) {
  90. this.getDetail()
  91. }
  92. },
  93. methods: {
  94. changePrizeSwiper({ detail }) {
  95. console.log(detail);
  96. this.prizeIndex = detail.current
  97. },
  98. getDetail() {
  99. uni.showLoading({
  100. title: '加载中'
  101. });
  102. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  103. boxId: this.boxId,
  104. noToken: true
  105. }).then(res => {
  106. uni.hideLoading();
  107. if (res.code == 0) {
  108. this.info = res.data
  109. let picUrlArr = res.data.picUrl.split(',')
  110. picUrlArr.forEach(item => {
  111. this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
  112. })
  113. let prizeList = res.data.prizeList
  114. prizeList.forEach(item => {
  115. let picUrlArr = item.picUrl.split(',')
  116. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  117. })
  118. this.prizeList = prizeList
  119. }
  120. }).catch(() => {
  121. uni.hideLoading();
  122. })
  123. },
  124. getPageNum() {
  125. let pages = getCurrentPages();
  126. },
  127. close() {
  128. this.payShow = false
  129. },
  130. toProcess(id) {
  131. this.payShow = false
  132. uni.navigateTo({
  133. url: `/packageOperate/process/index?id=${ id }`
  134. })
  135. },
  136. exchange() {
  137. let data = {
  138. userCouponIds: [],
  139. autoCoupon: 1,
  140. boxId: this.info.boxId,
  141. orderNum: 1
  142. }
  143. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  144. if (res.code == 0) {
  145. let info = {
  146. ...res.data,
  147. ...this.info,
  148. picUrl: env.filePublic + res.data.picUrl,
  149. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  150. .data.couponList[0].title,
  151. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  152. .couponList[0].id
  153. }
  154. this.payInfo = info
  155. this.payShow = true
  156. }
  157. })
  158. },
  159. toShare() {
  160. if (!uni.getStorageSync('token')) {
  161. uni.navigateTo({
  162. url: "/pages/login/index"
  163. })
  164. return
  165. }
  166. uni.navigateTo({
  167. url: `/packageOperate/share/index?boxId=${ this.info.boxId }`
  168. })
  169. },
  170. toIndex() {
  171. uni.switchTab({
  172. url: '/pages/index/index'
  173. })
  174. },
  175. toPrizeGoods(item) {
  176. if (item.prizeType == "goods") {
  177. uni.navigateTo({
  178. url: `/packagePrize/goods/detail?id=${ item.refId }`
  179. })
  180. }
  181. //门店优惠券
  182. if (item.prizeType == "coupon" || item.prizeType == "coupon_pkg") {
  183. // if (item.couponType == "1") {
  184. // uni.navigateTo({
  185. // url: `/packagePrize/goods/detail?id=426`
  186. // })
  187. // }
  188. // if (item.couponType == "2") {
  189. // uni.navigateTo({
  190. // url: `/packagePrize/goods/detail?id=425`
  191. // })
  192. // }
  193. uni.navigateTo({
  194. url: `/packagePrize/goods/detail?id=425`
  195. })
  196. }
  197. // 盲豆
  198. if (item.prizeType == "coin") {
  199. uni.navigateTo({
  200. url: `/packagePrize/goods/detail?id=424`
  201. })
  202. }
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. .nav-left {
  209. &__code {
  210. margin-left: 10rpx;
  211. }
  212. }
  213. // 奖品轮播
  214. .prize {
  215. height: 63vh;
  216. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/detail_2.png) center center no-repeat;
  217. background-size: 100vw 63vh;
  218. // 查看规则
  219. &-rule {
  220. display: flex;
  221. align-items: center;
  222. height: 34rpx;
  223. padding: 44rpx 0 0 34rpx;
  224. margin-bottom: 60rpx;
  225. &-content {
  226. image {
  227. width: 34rpx;
  228. height: 34rpx;
  229. margin-right: 14rpx;
  230. }
  231. text {
  232. font-size: 40rpx;
  233. font-family: 'YouSheBiaoTiHei';
  234. font-weight: 400;
  235. color: #FFFFFF;
  236. }
  237. }
  238. }
  239. // 奖品
  240. &-swiper {
  241. border: 1px solid #fff;
  242. height: 33vh;
  243. .swiper-item {
  244. width: 60vw;
  245. height: 80%;
  246. }
  247. .swiper-item-side {
  248. width: 60%;
  249. height: 60%;
  250. }
  251. &-item {
  252. height: 100%;
  253. .img {
  254. position: absolute;
  255. border: 1px solid #fff;
  256. width: 60vw;
  257. height: 80%;
  258. animation: prizeBig .3s;
  259. }
  260. .img-side {
  261. border: 1px solid #fff;
  262. width: 60%;
  263. height: 60%;
  264. animation: prizeMini .3s;
  265. opacity: .5;
  266. }
  267. }
  268. }
  269. }
  270. // 开启盲票
  271. .ticket-btn {
  272. height: 14vh;
  273. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/detail_1.png) center center no-repeat;
  274. background-size: 100vw 14vh;
  275. }
  276. // 盲票奖品说明
  277. .explain {
  278. }
  279. // 盲票奖品数量、概率
  280. .prize-total {
  281. }
  282. // 盲票奖品列表
  283. .prize-list {
  284. }
  285. // 奖品缩小动画
  286. @keyframes prizeMini
  287. {
  288. from {
  289. width: 60vw;
  290. height: 80%;
  291. }
  292. to {
  293. width: 50%;
  294. height: 60%;
  295. }
  296. }
  297. // 奖品放大动画
  298. @keyframes prizeBig
  299. {
  300. from {
  301. width: 50%;
  302. height: 60%;
  303. }
  304. to {
  305. width: 60vw;
  306. height: 80%;
  307. }
  308. }
  309. </style>