detail.vue 7.5 KB

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