detail.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="奖品详情" leftIconSize="0"></u-navbar>
  5. <!-- #endif -->
  6. <!-- #ifndef MP-ALIPAY -->
  7. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="奖品详情"></u-navbar>
  8. <!-- #endif -->
  9. <view class="detail">
  10. <view class="detail-swiper">
  11. <u-swiper :list="picUrlArr" height="375" radius="0" :indicator="true" :circular="true" indicatorMode="dot" indicatorActiveColor="#FA822C"></u-swiper>
  12. </view>
  13. <!-- 详情 -->
  14. <view class="detail-info flex">
  15. <view class="detail-info-left">
  16. <view class="detail-info-left__title ells">{{ info.title }}</view>
  17. <!-- <view class="detail-info-left__coin">
  18. <view class="content flex">
  19. <image src="../../static/public/goods_coin.png" mode=""></image>
  20. <view><text>×</text>{{ info.exchangePrice }}</view>
  21. </view>
  22. <view class="txt" v-if="info.originPrice">原盲豆:<text>{{ info.originPrice }}</text></view>
  23. </view>
  24. <view class="detail-info-left__price">¥{{ $numberFormat(info.value) }}</view> -->
  25. </view>
  26. <view class="detail-info-right" v-show="false">销量:30个</view>
  27. </view>
  28. <view class="detail-goods">产品介绍</view>
  29. <view class="detail-description">
  30. <u-parse :content="description" :selectable="true"></u-parse>
  31. </view>
  32. <view style="detail-merchant" @click="toCompanyData" v-if="info.merchantInfo?true:false">
  33. <view class="detail-merchant-warp">
  34. <view class="detail-merchant-warp-one">商家信息</view>
  35. <view class="detail-merchant-warp-two">
  36. <view style="float: left;">前往查看</view>
  37. <u-icon style="float: right;" name="arrow-right" size="18"></u-icon>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import env from '../../config/env.js'
  46. import $http from '@/utils/request.js'
  47. import { formatRichText } from '@/utils/util.js'
  48. export default {
  49. data() {
  50. return {
  51. boxId: '',
  52. picUrlArr: [],
  53. info: {},
  54. prizeList: [],
  55. description: '',
  56. goodsId: '',
  57. payShow: false,
  58. payInfo: {},
  59. };
  60. },
  61. onLoad(opthios) {
  62. this.getDetail(opthios.id)
  63. this.goodsId = opthios.id
  64. },
  65. methods: {
  66. getDetail(id) {
  67. uni.showLoading({
  68. title: '加载中'
  69. });
  70. $http.post('/api/v1/mp/user/exchange/goods/detail', {
  71. noToken: true,
  72. goodsId: id
  73. }).then(res => {
  74. uni.hideLoading();
  75. if (res.code == 0) {
  76. this.info = res.data
  77. let picUrlArr = res.data.picUrl.split(',')
  78. picUrlArr.forEach(item => {
  79. this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
  80. })
  81. // 处理富文本
  82. // #ifndef MP-ALIPAY
  83. const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
  84. .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
  85. ".png?imageView2/2/w/750\"");
  86. this.description = formatRichText(description);
  87. // #endif
  88. // #ifdef MP-ALIPAY
  89. res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
  90. res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
  91. res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
  92. this.description = formatRichText(res.data.description);
  93. // #endif
  94. }
  95. }).catch(() => {
  96. uni.hideLoading();
  97. })
  98. },
  99. close() {
  100. this.payShow = false
  101. },
  102. exchange() {
  103. let data = {
  104. couponIds: [],
  105. autoCoupon: 1,
  106. boxId: this.info.boxId,
  107. ticketId: this.info.ticketId,
  108. orderNum: 1
  109. }
  110. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  111. if (res.code == 0) {
  112. let info = {
  113. ...res.data,
  114. ...this.info,
  115. picUrl: env.filePublic + res.data.picUrl,
  116. }
  117. this.payInfo = info
  118. this.payShow = true
  119. }
  120. })
  121. },
  122. toCompanyData(){
  123. uni.navigateTo({
  124. url:`/packageGoods/goods/company?goodsId=${ this.goodsId }`
  125. })
  126. },
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .detail {
  132. // 商品轮播
  133. &-swiper {
  134. background-color: #FFFFFF;
  135. }
  136. // 详情
  137. &-info {
  138. background-color: #fff;
  139. justify-content: space-between;
  140. padding: 34rpx;
  141. margin-bottom: 22rpx;
  142. &-left {
  143. flex: 1;
  144. &__title {
  145. font-size: 34rpx;
  146. line-height: 40rpx;
  147. max-height: 80rpx;
  148. overflow: hidden;
  149. // margin-bottom: 26rpx;
  150. font-weight: bold;
  151. }
  152. &__coin {
  153. display: flex;
  154. line-height: 30rpx;
  155. margin-bottom: 26rpx;
  156. .content {
  157. color: #FA822C;
  158. margin-right: 34rpx;
  159. font-weight: bold;
  160. font-size: 30rpx;
  161. image {
  162. width: 34rpx;
  163. height: 30rpx;
  164. }
  165. text {
  166. font-weight: normal;
  167. }
  168. }
  169. .txt {
  170. font-size: 26rpx;
  171. color: #666666;
  172. text-decoration: line-through;
  173. }
  174. }
  175. &__price {
  176. line-height: 24rpx;
  177. color: #666666;
  178. }
  179. }
  180. &-right {
  181. color: #666666;
  182. }
  183. }
  184. &-goods {
  185. height: 90rpx;
  186. text-align: center;
  187. line-height: 90rpx;
  188. font-weight: bold;
  189. font-size: 30rpx;
  190. background-color: #FFFFFF;
  191. }
  192. &-description {
  193. image {
  194. width: 100%;
  195. }
  196. }
  197. &-merchant {
  198. height: 88rpx;
  199. // text-align: center;
  200. line-height: 88rpx;
  201. font-weight: bold;
  202. background-color: #FFFFFF;
  203. &-warp {
  204. height: 88rpx;
  205. width: 100%;
  206. background-color: #ffffff;
  207. &-one {
  208. float: left;
  209. margin: 20rpx;
  210. font-weight: 600;
  211. }
  212. &-two {
  213. float: right;
  214. margin: 20rpx;
  215. font-weight: 600;
  216. }
  217. }
  218. }
  219. // 设置ios刘海屏底部横线安全区域
  220. padding-bottom: constant(safe-area-inset-bottom);
  221. padding-bottom: env(safe-area-inset-bottom);
  222. }
  223. </style>