detail.vue 6.4 KB

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