detail.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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="`/pages/prizeGoods/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 + '_s')
  129. })
  130. let prizeList = res.data.prizeList
  131. prizeList.forEach(item => {
  132. let picUrlArr = item.picUrl.split(',')
  133. item.picUrl = env.filePublic + picUrlArr[0]
  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: `/pages/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: `/pages/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: `/pages/prizeGoods/detail?id=${ item.refId }`
  196. })
  197. }
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="scss" scoped>
  203. .nav-left {
  204. &__code {
  205. margin-left: 10rpx;
  206. }
  207. }
  208. .detail {
  209. padding-bottom: 100rpx;
  210. &-top {
  211. margin-bottom: 20rpx;
  212. }
  213. &-info {
  214. justify-content: space-between;
  215. box-sizing: border-box;
  216. padding: 24rpx 16rpx;
  217. background-color: #fff;
  218. margin: 10rpx 10rpx 20rpx;
  219. border-radius: 10rpx;
  220. &__left {
  221. display: flex;
  222. flex-direction: column;
  223. justify-content: space-between;
  224. text {
  225. line-height: 24rpx;
  226. display: inline-block;
  227. }
  228. .title {
  229. color: rgba(16, 16, 16, 100);
  230. font-size: 32rpx;
  231. line-height: 32rpx;
  232. font-weight: bold;
  233. }
  234. .num {
  235. color: $uni-text-color;
  236. font-size: 28rpx;
  237. justify-content: flex-start;
  238. margin: 20rpx 0;
  239. }
  240. .tip {
  241. font-size: 24rpx;
  242. }
  243. }
  244. &__right {
  245. display: flex;
  246. flex-direction: column;
  247. align-items: flex-end;
  248. justify-content: space-between;
  249. height: 162rpx;
  250. text {
  251. color: rgba(157, 157, 157, 100);
  252. font-size: 14px;
  253. }
  254. .money {
  255. font-size: 40rpx;
  256. font-weight: bold;
  257. line-height: 40rpx;
  258. font-weight: bold;
  259. color: $uni-text-color;
  260. margin-bottom: 40rpx;
  261. }
  262. }
  263. }
  264. &-sku {
  265. background-color: #fff;
  266. border-radius: 10rpx;
  267. margin: 10rpx 10rpx 20rpx;
  268. &-title {
  269. padding: 24rpx 16rpx 12rpx;
  270. }
  271. &-item {
  272. padding-bottom: 10rpx;
  273. view {
  274. padding-left: 50rpx;
  275. line-height: 50rpx;
  276. }
  277. }
  278. }
  279. &-goods {
  280. margin: 10rpx 10rpx 20rpx;
  281. &-title {
  282. margin-bottom: 20rpx;
  283. }
  284. &-list {
  285. padding-bottom: 100rpx;
  286. &-item {
  287. position: relative;
  288. background-color: #FFFFFF;
  289. margin-bottom: 30rpx;
  290. border-radius: 10rpx;
  291. padding: 30rpx 20rpx;
  292. &__value {
  293. display: flex;
  294. }
  295. image {
  296. width: 200rpx;
  297. height: 200rpx;
  298. }
  299. .name {
  300. position: absolute;
  301. left: 0rpx;
  302. top: 0rpx;
  303. line-height: 28rpx;
  304. padding: 10rpx 40rpx;
  305. color: #FFFFFF;
  306. border-top-left-radius: 10rpx;
  307. border-bottom-right-radius: 40rpx;
  308. background-color: $uni-bg-color;
  309. }
  310. .info {
  311. display: flex;
  312. flex-direction: column;
  313. justify-content: space-between;
  314. font-size: 30rpx;
  315. padding-left: 50rpx;
  316. .title {
  317. font-weight: bold;
  318. }
  319. .num {
  320. color: #848484;
  321. }
  322. }
  323. }
  324. &-item:last-child {
  325. border: none;
  326. }
  327. }
  328. }
  329. }
  330. .footer-fixed {
  331. position: fixed;
  332. bottom: var(--window-bottom);
  333. left: 0;
  334. right: 0;
  335. z-index: 11;
  336. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  337. background: #fff;
  338. // 设置ios刘海屏底部横线安全区域
  339. padding-bottom: constant(safe-area-inset-bottom);
  340. padding-bottom: env(safe-area-inset-bottom);
  341. .btn {
  342. position: relative;
  343. padding: 20rpx 20rpx;
  344. /deep/ button {
  345. width: 440rpx;
  346. height: 90rpx;
  347. line-height: 90rpx;
  348. font-size: 36rpx;
  349. color: #fff;
  350. background-color: $uni-bg-color;
  351. border: none;
  352. border-radius: 20rpx;
  353. }
  354. .share {
  355. position: absolute;
  356. left: 40rpx;
  357. }
  358. }
  359. }
  360. </style>