detail.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 appId from '@/config/appId.js'
  48. import { formatRichText } from '@/utils/util.js'
  49. export default {
  50. data() {
  51. return {
  52. boxId: '',
  53. picUrlArr: [],
  54. info: {},
  55. prizeList: [],
  56. description: '',
  57. goodsId: '',
  58. payShow: false,
  59. payInfo: {},
  60. };
  61. },
  62. onLoad(opthios) {
  63. this.getDetail(opthios.id)
  64. this.goodsId = opthios.id
  65. },
  66. methods: {
  67. getDetail(id) {
  68. uni.showLoading({
  69. title: '加载中'
  70. });
  71. $http.post('/api/v1/mp/user/exchange/goods/detail', {
  72. noToken: true,
  73. goodsId: id
  74. }).then(res => {
  75. uni.hideLoading();
  76. if (res.code == 0) {
  77. this.info = res.data
  78. let picUrlArr = res.data.picUrl.split(',')
  79. picUrlArr.forEach(item => {
  80. this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
  81. })
  82. // 处理富文本
  83. // #ifndef MP-ALIPAY
  84. const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
  85. .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
  86. ".png?imageView2/2/w/750\"");
  87. this.description = formatRichText(description);
  88. // #endif
  89. // #ifdef MP-ALIPAY
  90. res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
  91. res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
  92. res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
  93. this.description = formatRichText(res.data.description);
  94. // #endif
  95. }
  96. }).catch(() => {
  97. uni.hideLoading();
  98. })
  99. },
  100. close() {
  101. this.payShow = false
  102. },
  103. exchange() {
  104. let data = {
  105. couponIds: [],
  106. autoCoupon: 1,
  107. boxId: this.info.boxId,
  108. ticketId: this.info.ticketId,
  109. orderNum: 1,
  110. appSource: appId
  111. }
  112. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  113. if (res.code == 0) {
  114. let info = {
  115. ...res.data,
  116. ...this.info,
  117. picUrl: env.filePublic + res.data.picUrl,
  118. }
  119. this.payInfo = info
  120. this.payShow = true
  121. }
  122. })
  123. },
  124. toCompanyData(){
  125. uni.navigateTo({
  126. url:`/packageGoods/goods/company?goodsId=${ this.goodsId }`
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .detail {
  134. // 商品轮播
  135. &-swiper {
  136. background-color: #FFFFFF;
  137. }
  138. // 详情
  139. &-info {
  140. background-color: #fff;
  141. justify-content: space-between;
  142. padding: 34rpx;
  143. margin-bottom: 22rpx;
  144. &-left {
  145. flex: 1;
  146. &__title {
  147. font-size: 34rpx;
  148. line-height: 40rpx;
  149. max-height: 80rpx;
  150. overflow: hidden;
  151. // margin-bottom: 26rpx;
  152. font-weight: bold;
  153. }
  154. &__coin {
  155. display: flex;
  156. line-height: 30rpx;
  157. margin-bottom: 26rpx;
  158. .content {
  159. color: #FA822C;
  160. margin-right: 34rpx;
  161. font-weight: bold;
  162. font-size: 30rpx;
  163. image {
  164. width: 34rpx;
  165. height: 30rpx;
  166. }
  167. text {
  168. font-weight: normal;
  169. }
  170. }
  171. .txt {
  172. font-size: 26rpx;
  173. color: #666666;
  174. text-decoration: line-through;
  175. }
  176. }
  177. &__price {
  178. line-height: 24rpx;
  179. color: #666666;
  180. }
  181. }
  182. &-right {
  183. color: #666666;
  184. }
  185. }
  186. &-goods {
  187. height: 90rpx;
  188. text-align: center;
  189. line-height: 90rpx;
  190. font-weight: bold;
  191. font-size: 30rpx;
  192. background-color: #FFFFFF;
  193. }
  194. &-description {
  195. image {
  196. width: 100%;
  197. }
  198. }
  199. &-merchant {
  200. height: 88rpx;
  201. // text-align: center;
  202. line-height: 88rpx;
  203. font-weight: bold;
  204. background-color: #FFFFFF;
  205. &-warp {
  206. height: 88rpx;
  207. width: 100%;
  208. background-color: #ffffff;
  209. &-one {
  210. float: left;
  211. margin: 20rpx;
  212. font-weight: 600;
  213. }
  214. &-two {
  215. float: right;
  216. margin: 20rpx;
  217. font-weight: 600;
  218. }
  219. }
  220. }
  221. // 设置ios刘海屏底部横线安全区域
  222. padding-bottom: constant(safe-area-inset-bottom);
  223. padding-bottom: env(safe-area-inset-bottom);
  224. }
  225. </style>