detail.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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. <view class="detail">
  15. <view class="detail-top">
  16. <u-swiper :list="picUrlArr" height="375" imgMode="aspectFit" bgColor="#fff" radius="0" :indicator="true"
  17. :circular="true"></u-swiper>
  18. </view>
  19. <view class="flex detail-info">
  20. <view class="detail-info__left">
  21. <text class="title">{{ info.title }}</text>
  22. <view class="flex num">
  23. <u-icon name="gift" size="25" color="#EB7009"></u-icon>
  24. <text>100%抽中,奖品多多</text>
  25. </view>
  26. <view class="tip">图片仅供参考,请以实物为准</view>
  27. </view>
  28. <view class="detail-info__right">
  29. <text class="money">¥{{ $numberFormat(info.salePrice) }}</text>
  30. <text>销量 {{ info.saleQty }}</text>
  31. </view>
  32. </view>
  33. <view class="detail-goods">
  34. <view class="detail-goods-title">可获得奖品</view>
  35. <view class="detail-goods-list">
  36. <!-- <navigator :url="`/packagePrize/goods/detail?id=${ item.prizeId }`" class="detail-goods-list-item"
  37. hover-class="navigator-hover" v-for="(item, index) in prizeList" :key="index"> -->
  38. <view class="detail-goods-list-item" v-for="(item, index) in prizeList" :key="index"
  39. @click="toPrizeGoods(item)">
  40. <view class="detail-goods-list-item__value">
  41. <view class="flex image-wrap">
  42. <image :src="item.picUrl" mode="scaleToFill"></image>
  43. </view>
  44. <view class="info">
  45. <text class="title">{{ item.title }}</text>
  46. <text class="num"
  47. v-if="item.prizeType != 'coin'">价值:¥{{ $numberFormat(item.value) }}</text>
  48. <text class="num" v-else>数量:{{ item.value }}颗</text>
  49. <text class="num">概率:{{ item.hitRate }}%</text>
  50. </view>
  51. <view class="name">{{ item.name }}</view>
  52. </view>
  53. </view>
  54. <!-- </navigator> -->
  55. </view>
  56. </view>
  57. </view>
  58. <view class="footer-fixed">
  59. <view class="flex btn">
  60. <button type="default" @click="exchange">{{ info.salePrice / 100 }}元 立即开刮</button>
  61. <view class="share " @click="toShare">
  62. <u-icon name="share-square" color="#E96737" size="30"></u-icon>
  63. <view style="color: #E96737;text-align: center;">分享</view>
  64. </view>
  65. </view>
  66. </view>
  67. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" />
  68. </view>
  69. </template>
  70. <script>
  71. import env from '../../config/env.js'
  72. import $http from '@/utils/request.js'
  73. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  74. export default {
  75. components: {
  76. PayPopup
  77. },
  78. data() {
  79. return {
  80. boxId: '',
  81. picUrlArr: [],
  82. info: {},
  83. prizeList: [],
  84. payShow: false,
  85. payInfo: {},
  86. pagesNum: null,
  87. sceneArr: null
  88. };
  89. },
  90. onLoad(opthios) {
  91. if (opthios.scene) {
  92. let sceneStr = decodeURIComponent(opthios.scene)
  93. this.sceneArr = sceneStr.split('&')
  94. this.boxId = this.sceneArr[0]
  95. uni.setStorageSync('shareUid', this.sceneArr[1])
  96. uni.setStorageSync('shareType', this.sceneArr[2])
  97. }
  98. if (opthios.boxId) {
  99. this.boxId = opthios.boxId
  100. }
  101. if (opthios.userId) {
  102. uni.setStorageSync('shareUid', opthios.userId)
  103. }
  104. if (opthios.type) {
  105. uni.setStorageSync('shareType', opthios.type)
  106. }
  107. },
  108. onShow() {
  109. this.pagesNum = getCurrentPages().length
  110. if (this.boxId) {
  111. this.getDetail()
  112. }
  113. },
  114. methods: {
  115. getDetail() {
  116. uni.showLoading({
  117. title: '加载中'
  118. });
  119. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  120. boxId: this.boxId,
  121. noToken: true
  122. }).then(res => {
  123. uni.hideLoading();
  124. if (res.code == 0) {
  125. this.info = res.data
  126. let picUrlArr = res.data.picUrl.split(',')
  127. picUrlArr.forEach(item => {
  128. this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
  129. })
  130. let prizeList = res.data.prizeList
  131. prizeList.forEach(item => {
  132. let picUrlArr = item.picUrl.split(',')
  133. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  134. })
  135. this.prizeList = prizeList
  136. }
  137. }).catch(() => {
  138. uni.hideLoading();
  139. })
  140. },
  141. getPageNum() {
  142. let pages = getCurrentPages();
  143. },
  144. close() {
  145. this.payShow = false
  146. },
  147. toProcess(id) {
  148. this.payShow = false
  149. uni.navigateTo({
  150. url: `/packageOperate/process/index?id=${ id }`
  151. })
  152. },
  153. exchange() {
  154. let data = {
  155. userCouponIds: [],
  156. autoCoupon: 1,
  157. boxId: this.info.boxId,
  158. orderNum: 1
  159. }
  160. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  161. if (res.code == 0) {
  162. let info = {
  163. ...res.data,
  164. ...this.info,
  165. picUrl: env.filePublic + res.data.picUrl,
  166. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  167. .data.couponList[0].title,
  168. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  169. .couponList[0].id
  170. }
  171. this.payInfo = info
  172. this.payShow = true
  173. }
  174. })
  175. },
  176. toShare() {
  177. if (!uni.getStorageSync('token')) {
  178. uni.navigateTo({
  179. url: "/pages/login/index"
  180. })
  181. return
  182. }
  183. uni.navigateTo({
  184. url: `/packageOperate/share/index?boxId=${ this.info.boxId }`
  185. })
  186. },
  187. toIndex() {
  188. uni.switchTab({
  189. url: '/pages/index/index'
  190. })
  191. },
  192. toPrizeGoods(item) {
  193. if (item.prizeType == "goods") {
  194. uni.navigateTo({
  195. url: `/packagePrize/goods/detail?id=${ item.refId }`
  196. })
  197. }
  198. //门店优惠券
  199. if (item.prizeType == "coupon" || item.prizeType == "coupon_pkg") {
  200. // if (item.couponType == "1") {
  201. // uni.navigateTo({
  202. // url: `/packagePrize/goods/detail?id=426`
  203. // })
  204. // }
  205. // if (item.couponType == "2") {
  206. // uni.navigateTo({
  207. // url: `/packagePrize/goods/detail?id=425`
  208. // })
  209. // }
  210. uni.navigateTo({
  211. url: `/packagePrize/goods/detail?id=425`
  212. })
  213. }
  214. // 盲豆
  215. if (item.prizeType == "coin") {
  216. uni.navigateTo({
  217. url: `/packagePrize/goods/detail?id=424`
  218. })
  219. }
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .nav-left {
  226. &__code {
  227. margin-left: 10rpx;
  228. }
  229. }
  230. .detail {
  231. padding-bottom: 100rpx;
  232. &-top {
  233. margin-bottom: 20rpx;
  234. }
  235. &-info {
  236. justify-content: space-between;
  237. box-sizing: border-box;
  238. padding: 24rpx 16rpx;
  239. background-color: #fff;
  240. margin: 10rpx 10rpx 20rpx;
  241. border-radius: 10rpx;
  242. &__left {
  243. display: flex;
  244. flex-direction: column;
  245. justify-content: space-between;
  246. text {
  247. line-height: 24rpx;
  248. display: inline-block;
  249. }
  250. .title {
  251. color: rgba(16, 16, 16, 100);
  252. font-size: 32rpx;
  253. line-height: 32rpx;
  254. font-weight: bold;
  255. }
  256. .num {
  257. color: $uni-text-color;
  258. font-size: 28rpx;
  259. justify-content: flex-start;
  260. margin: 20rpx 0;
  261. }
  262. .tip {
  263. font-size: 24rpx;
  264. }
  265. }
  266. &__right {
  267. display: flex;
  268. flex-direction: column;
  269. align-items: flex-end;
  270. justify-content: space-between;
  271. height: 162rpx;
  272. text {
  273. color: rgba(157, 157, 157, 100);
  274. font-size: 14px;
  275. }
  276. .money {
  277. font-size: 40rpx;
  278. font-weight: bold;
  279. line-height: 40rpx;
  280. font-weight: bold;
  281. color: $uni-text-color;
  282. margin-bottom: 40rpx;
  283. }
  284. }
  285. }
  286. &-sku {
  287. background-color: #fff;
  288. border-radius: 10rpx;
  289. margin: 10rpx 10rpx 20rpx;
  290. &-title {
  291. padding: 24rpx 16rpx 12rpx;
  292. }
  293. &-item {
  294. padding-bottom: 10rpx;
  295. view {
  296. padding-left: 50rpx;
  297. line-height: 50rpx;
  298. }
  299. }
  300. }
  301. &-goods {
  302. margin: 10rpx 10rpx 20rpx;
  303. &-title {
  304. margin-bottom: 20rpx;
  305. }
  306. &-list {
  307. padding-bottom: 100rpx;
  308. &-item {
  309. position: relative;
  310. background-color: #FFFFFF;
  311. margin-bottom: 30rpx;
  312. border-radius: 10rpx;
  313. padding: 30rpx 20rpx;
  314. &__value {
  315. display: flex;
  316. }
  317. image {
  318. width: 200rpx;
  319. height: 200rpx;
  320. }
  321. .name {
  322. position: absolute;
  323. left: 0rpx;
  324. top: 0rpx;
  325. line-height: 28rpx;
  326. padding: 10rpx 40rpx;
  327. color: #FFFFFF;
  328. border-top-left-radius: 10rpx;
  329. border-bottom-right-radius: 40rpx;
  330. background-color: $uni-bg-color;
  331. }
  332. .info {
  333. display: flex;
  334. flex-direction: column;
  335. justify-content: space-between;
  336. font-size: 30rpx;
  337. padding-left: 50rpx;
  338. .title {
  339. font-weight: bold;
  340. }
  341. .num {
  342. color: #848484;
  343. }
  344. }
  345. }
  346. &-item:last-child {
  347. border: none;
  348. }
  349. }
  350. }
  351. }
  352. .footer-fixed {
  353. position: fixed;
  354. bottom: var(--window-bottom);
  355. left: 0;
  356. right: 0;
  357. z-index: 11;
  358. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  359. background: #fff;
  360. // 设置ios刘海屏底部横线安全区域
  361. padding-bottom: constant(safe-area-inset-bottom);
  362. padding-bottom: env(safe-area-inset-bottom);
  363. .btn {
  364. position: relative;
  365. padding: 20rpx 20rpx;
  366. /deep/ button {
  367. width: 440rpx;
  368. height: 90rpx;
  369. line-height: 90rpx;
  370. font-size: 36rpx;
  371. color: #fff;
  372. background-color: $uni-bg-color;
  373. border: none;
  374. border-radius: 20rpx;
  375. }
  376. .share {
  377. position: absolute;
  378. left: 40rpx;
  379. }
  380. }
  381. }
  382. </style>