detail.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view>
  3. <u-navbar title="详情" :border="true" :placeholder="true" :autoBack="true" leftIconColor="#fff"
  4. bgColor="#E96737" />
  5. <view class="detail">
  6. <view class="detail-top">
  7. <u-swiper :list="picUrlArr" height="320" :indicator="true" :circular="true"></u-swiper>
  8. </view>
  9. <view class="flex detail-info">
  10. <view class="detail-info__left">
  11. <text class="title">{{ info.title }}</text>
  12. <text class="num">销售分佣比{{ info.saleCommRate }}%</text>
  13. </view>
  14. <view class="detail-info__right">
  15. <text class="money">¥{{ $numberFormat(info.pkgSalePrice) }}</text>
  16. <text>销量 {{ info.saleQty }}</text>
  17. </view>
  18. </view>
  19. <view class="detail-sku">
  20. <view class="detail-sku-title">参数</view>
  21. <view class="detail-sku-item">
  22. <view>规格:{{ info.pkgUnit }}张/包</view>
  23. <view>面值:{{ $numberFormat(info.facePrice) }}元</view>
  24. </view>
  25. </view>
  26. <view class="detail-goods">
  27. <view class="detail-goods-title">可获得商品</view>
  28. <view class="detail-goods-list">
  29. <view class="detail-goods-list-item" v-for="(item, index) in prizeList" :key="index">
  30. <view class="detail-goods-list-item__value">
  31. <view class="flex image-wrap">
  32. <image :src="item.picUrl" mode="scaleToFill"></image>
  33. </view>
  34. <view class="info">
  35. <text>{{ item.title }}</text>
  36. <text>价值:¥{{ $numberFormat(item.value) }}</text>
  37. <text>概率:{{ item.hitRate }}%</text>
  38. </view>
  39. <view class="name">{{ item.name }}</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="footer-fixed">
  46. <view class="flex btn">
  47. <view class="btn-left" @click="toCart">
  48. <u-icon name="shopping-cart" color="#808080" size="20"></u-icon>
  49. <view>购物车</view>
  50. </view>
  51. <view class="btn-right">
  52. <text @click="addCart">加入购物车</text>
  53. <text @click="toSettlement">立即购票</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import env from '../../config/env.js'
  61. import $http from '@/utils/request.js'
  62. export default {
  63. data() {
  64. return {
  65. boxId: '',
  66. picUrlArr: [],
  67. info: {},
  68. prizeList: [],
  69. };
  70. },
  71. onLoad(opthios) {
  72. this.getDetail(opthios.boxId)
  73. },
  74. methods: {
  75. getDetail(id) {
  76. $http.post('/api/v1/mp/channel/mall/ticket/detail', {
  77. boxId: id
  78. }).then(res => {
  79. if (res.code == 0) {
  80. this.info = res.data
  81. console.log(res.data);
  82. let picUrlArr = res.data.picUrl.split(',')
  83. picUrlArr.forEach(item => {
  84. this.picUrlArr.push(env.filePublic + item)
  85. })
  86. let prizeList = res.data.prizeList
  87. prizeList.forEach(item=>{
  88. item.picUrl = env.filePublic + item.picUrl
  89. })
  90. console.log(prizeList);
  91. this.prizeList = prizeList
  92. }
  93. })
  94. },
  95. addCart(id) {
  96. let data = {
  97. boxId: this.info.boxId,
  98. orderNum: 1
  99. }
  100. $http.post(`/api/v1/mp/channel/mall/cart/add`, data).then(res => {
  101. console.log(res);
  102. if (res.code == 0) {
  103. uni.$u.toast('加入购物车成功');
  104. }
  105. })
  106. },
  107. toCart() {
  108. uni.switchTab({
  109. url: "/pages/index/cart"
  110. })
  111. },
  112. toSettlement() {
  113. uni.navigateTo({
  114. url: `/pages/order/settlement?boxId=${ this.info.boxId }`
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. /deep/ .u-navbar__content__title.u-navbar__content__title {
  122. color: #FFFFFF;
  123. }
  124. </style>
  125. <style lang="scss" scoped>
  126. .detail {
  127. padding-bottom: 100rpx;
  128. &-top {
  129. margin-bottom: 20rpx;
  130. }
  131. &-info {
  132. justify-content: space-between;
  133. box-sizing: border-box;
  134. padding: 24rpx 16rpx;
  135. background-color: #fff;
  136. margin: 10rpx 10rpx 20rpx;
  137. border-radius: 10rpx;
  138. &__left {
  139. display: flex;
  140. flex-direction: column;
  141. justify-content: space-between;
  142. text {
  143. font-size: 24rpx;
  144. line-height: 24rpx;
  145. display: inline-block;
  146. }
  147. .title {
  148. color: rgba(16, 16, 16, 100);
  149. font-size: 32rpx;
  150. line-height: 32rpx;
  151. font-weight: bold;
  152. margin-bottom: 40rpx;
  153. }
  154. .num {
  155. width: 220rpx;
  156. height: 34rpx;
  157. color: $uni-text-color;
  158. text-align: center;
  159. line-height: 34rpx;
  160. border: 1px solid $uni-bg-color;
  161. border-radius: 6rpx;
  162. }
  163. }
  164. &__right {
  165. display: flex;
  166. flex-direction: column;
  167. align-items: flex-end;
  168. justify-content: space-between;
  169. text {
  170. color: rgba(157, 157, 157, 100);
  171. font-size: 14px;
  172. }
  173. .money {
  174. font-size: 40rpx;
  175. font-weight: bold;
  176. line-height: 40rpx;
  177. font-weight: bold;
  178. color: $uni-text-color;
  179. margin-bottom: 40rpx;
  180. }
  181. }
  182. }
  183. &-sku {
  184. background-color: #fff;
  185. border-radius: 10rpx;
  186. margin: 10rpx 10rpx 20rpx;
  187. &-title {
  188. padding: 24rpx 16rpx 12rpx;
  189. }
  190. &-item {
  191. padding-bottom: 10rpx;
  192. view {
  193. padding-left: 50rpx;
  194. line-height: 50rpx;
  195. }
  196. }
  197. }
  198. &-goods {
  199. margin: 10rpx 10rpx 20rpx;
  200. &-title {
  201. margin-bottom: 20rpx;
  202. }
  203. &-list {
  204. background-color: #FFFFFF;
  205. &-item {
  206. position: relative;
  207. margin: 16rpx 0;
  208. border-bottom: 1px solid rgba(236, 236, 236, 100);
  209. &__value {
  210. display: flex;
  211. }
  212. .image-wrap {
  213. width: 250rpx;
  214. height: 250rpx;
  215. margin-right: 30rpx;
  216. image {
  217. width: 180rpx;
  218. height: 120rpx;
  219. }
  220. }
  221. .name{
  222. position: absolute;
  223. line-height: 28rpx;
  224. padding: 6rpx 20rpx;
  225. background-color: $uni-bg-color;
  226. }
  227. .info {
  228. display: flex;
  229. flex-direction: column;
  230. font-size: 24rpx;
  231. text {
  232. margin-bottom: 10rpx;
  233. }
  234. text:first-child {
  235. font-size: 28rpx;
  236. margin-top: 24rpx;
  237. margin-bottom: 30rpx;
  238. font-weight: bold;
  239. }
  240. }
  241. }
  242. &-item:last-child {
  243. border: none;
  244. }
  245. }
  246. }
  247. }
  248. .footer-fixed {
  249. position: fixed;
  250. bottom: var(--window-bottom);
  251. left: 0;
  252. right: 0;
  253. // min-height: 120rpx;
  254. z-index: 11;
  255. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  256. background: #fff;
  257. // margin-bottom: 40rpx;
  258. // 设置ios刘海屏底部横线安全区域
  259. padding-bottom: constant(safe-area-inset-bottom);
  260. padding-bottom: env(safe-area-inset-bottom);
  261. .btn {
  262. justify-content: space-between;
  263. padding: 10rpx 40rpx;
  264. &-left {
  265. display: flex;
  266. line-height: 28rpx;
  267. flex-direction: column;
  268. align-items: center;
  269. justify-content: center;
  270. color: #808080;
  271. }
  272. &-right {
  273. display: flex;
  274. align-items: center;
  275. justify-content: flex-end;
  276. text {
  277. width: 190rpx;
  278. height: 60rpx;
  279. line-height: 60rpx;
  280. border-radius: 8rpx;
  281. text-align: center;
  282. margin-left: 40rpx;
  283. }
  284. text:first-child {
  285. background-color: rgba(236, 153, 84, 100);
  286. color: rgba(255, 255, 255, 100);
  287. }
  288. text:last-child {
  289. background-color: rgba(235, 112, 9, 100);
  290. color: rgba(255, 255, 255, 100);
  291. }
  292. }
  293. }
  294. }
  295. </style>