detail.vue 6.3 KB

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