detail.vue 8.6 KB

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