index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="商品详情" leftIconSize="0">
  5. </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"
  25. indicatorMode="dot" indicatorActiveColor="#FA822C"></u-swiper>
  26. </view>
  27. <!-- 详情 -->
  28. <view class="detail-info">
  29. <view class="detail-info-left">
  30. <view class="detail-info-left__title ells">{{ info.title }}</view>
  31. </view>
  32. <view class="detail-infotwo flex">
  33. <view class="detail-infotwo-num">
  34. <view class="">¥{{ $numberFormat(info.value) }}</view>
  35. <view class="txt" v-if="info.originPrice">¥<text>{{ info.originPrice }}</text></view>
  36. </view>
  37. <view class="detail-info-right"></view>
  38. </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 class="footer-fixed">
  55. <view class="footer-fixed-content flex">
  56. <view class="footer-fixed-content__price" >
  57. <button @click="exchange">立即购买</button>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 支付弹框组件 -->
  62. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" v-if="payShow" />
  63. </view>
  64. </template>
  65. <script>
  66. import env from '../../config/env.js'
  67. import $http from '@/utils/request.js'
  68. import appId from '@/config/appId.js'
  69. import { formatRichText } from '@/utils/util.js'
  70. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  71. export default {
  72. components: {
  73. PayPopup,
  74. },
  75. data() {
  76. return {
  77. boxId: '',
  78. picUrlArr: [],
  79. info: {},
  80. prizeList: [],
  81. description: '',
  82. goodsId: '',
  83. payShow: false,
  84. payInfo: {},
  85. purchasePopupShow: false,
  86. pagesNum: '',
  87. };
  88. },
  89. onShow() {
  90. this.pagesNum = getCurrentPages().length
  91. },
  92. onLoad(opthios) {
  93. this.getDetail(opthios.id)
  94. this.goodsId = opthios.id
  95. this.boxId = opthios.boxId
  96. },
  97. methods: {
  98. getDetail(id) {
  99. uni.showLoading({
  100. title: '加载中'
  101. });
  102. $http.post('/api/v1/mp/user/exchange/goods/detail', {
  103. noToken: true,
  104. goodsId: id
  105. }).then(res => {
  106. uni.hideLoading();
  107. if (res.code == 0) {
  108. this.info = res.data
  109. let picUrlArr = res.data.picUrl.split(',')
  110. picUrlArr.forEach(item => {
  111. this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
  112. })
  113. // 处理富文本
  114. // #ifndef MP-ALIPAY
  115. const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
  116. .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
  117. ".png?imageView2/2/w/750\"");
  118. this.description = formatRichText(description);
  119. // #endif
  120. // #ifdef MP-ALIPAY
  121. res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
  122. res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
  123. res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
  124. this.description = formatRichText(res.data.description);
  125. // #endif
  126. }
  127. }).catch(() => {
  128. uni.hideLoading();
  129. })
  130. },
  131. close() {
  132. this.payShow = false
  133. },
  134. toProcess(id) {
  135. this.payShow = false
  136. uni.navigateTo({
  137. url: `/packagePrize/purchase/index?boxId=${ this.boxId }&orderId=${ id }&isTry=0`
  138. })
  139. },
  140. exchange() {
  141. let data = {
  142. couponIds: [],
  143. autoCoupon: 1,
  144. boxId: this.boxId,
  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.goodsPicUrl.split(',')[0],
  154. couponTitle: res.data && res.data.couponList && res.data.couponList.length &&
  155. res
  156. .data.couponList[0].title,
  157. couponId: res.data && res.data.couponList && res.data.couponList.length && res
  158. .data
  159. .couponList[0].id
  160. }
  161. this.payInfo = info
  162. this.payShow = true
  163. }
  164. })
  165. },
  166. toCompanyData() {
  167. uni.navigateTo({
  168. url: `/packageGoods/goods/company?goodsId=${ this.goodsId }`
  169. })
  170. },
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .detail {
  176. // 设置ios刘海屏底部横线安全区域
  177. // padding-bottom: constant(safe-area-inset-bottom);
  178. // padding-bottom: env(safe-area-inset-bottom);
  179. padding-bottom: 210rpx;
  180. // 商品轮播
  181. &-swiper {
  182. background-color: #FFFFFF;
  183. }
  184. // 详情
  185. &-infotwo {
  186. background-color: #fff;
  187. justify-content: space-between;
  188. &-num {
  189. view {
  190. display: inline-block;
  191. color: #F9822C;
  192. line-height: 80rpx;
  193. font-size: 32rpx;
  194. font-weight: bold;
  195. }
  196. .txt {
  197. margin-left: 14rpx;
  198. font-size: 26rpx;
  199. color: #666666;
  200. font-weight: 400;
  201. text-decoration: line-through;
  202. }
  203. }
  204. }
  205. &-info {
  206. background-color: #fff;
  207. justify-content: space-between;
  208. padding: 34rpx;
  209. margin-bottom: 22rpx;
  210. &-left {
  211. flex: 1;
  212. &__title {
  213. font-size: 34rpx;
  214. line-height: 40rpx;
  215. max-height: 80rpx;
  216. overflow: hidden;
  217. // margin-bottom: 26rpx;
  218. font-weight: bold;
  219. }
  220. &__coin {
  221. display: flex;
  222. line-height: 30rpx;
  223. margin-bottom: 26rpx;
  224. .content {
  225. color: #FA822C;
  226. margin-right: 34rpx;
  227. font-weight: bold;
  228. font-size: 30rpx;
  229. image {
  230. width: 34rpx;
  231. height: 30rpx;
  232. }
  233. text {
  234. font-weight: normal;
  235. }
  236. }
  237. .txt {
  238. font-size: 26rpx;
  239. color: #666666;
  240. text-decoration: line-through;
  241. }
  242. }
  243. &__price {
  244. line-height: 24rpx;
  245. color: #666666;
  246. }
  247. }
  248. &-right {
  249. color: #666666;
  250. }
  251. }
  252. &-goods {
  253. height: 90rpx;
  254. text-align: center;
  255. line-height: 90rpx;
  256. font-weight: bold;
  257. font-size: 30rpx;
  258. background-color: #FFFFFF;
  259. }
  260. &-description {
  261. image {
  262. width: 100%;
  263. }
  264. }
  265. &-merchant {
  266. height: 88rpx;
  267. // text-align: center;
  268. line-height: 88rpx;
  269. font-weight: bold;
  270. background-color: #FFFFFF;
  271. &-warp {
  272. height: 88rpx;
  273. width: 100%;
  274. background-color: #ffffff;
  275. &-one {
  276. float: left;
  277. margin: 20rpx;
  278. font-weight: 600;
  279. }
  280. &-two {
  281. float: right;
  282. margin: 20rpx;
  283. font-weight: 600;
  284. }
  285. }
  286. }
  287. }
  288. .footer-fixed {
  289. position: fixed;
  290. bottom: var(--window-bottom);
  291. left: 0;
  292. right: 0;
  293. z-index: 11;
  294. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  295. background: #fff;
  296. // 设置ios刘海屏底部横线安全区域
  297. padding-bottom: constant(safe-area-inset-bottom);
  298. padding-bottom: env(safe-area-inset-bottom);
  299. &-content {
  300. justify-content: space-around;
  301. height: 132rpx;
  302. background-color: #fff;
  303. &__price {
  304. button {
  305. line-height: 82rpx;
  306. width: 420rpx;
  307. height: 82rpx;
  308. font-size: 30rpx;
  309. background: #F9822C;
  310. border-radius: 20px;
  311. color: #fff;
  312. margin-right: 20rpx;
  313. }
  314. }
  315. }
  316. }
  317. </style>