detail.vue 8.3 KB

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