index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. <!-- #ifndef MP-ALIPAY || H5 -->
  8. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="商品详情"></u-navbar>
  9. <!-- #endif -->
  10. <!-- #ifdef H5 -->
  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. };
  87. },
  88. onLoad(opthios) {
  89. this.getDetail(opthios.id)
  90. this.goodsId = opthios.id
  91. this.boxId = opthios.boxId
  92. },
  93. methods: {
  94. getDetail(id) {
  95. uni.showLoading({
  96. title: '加载中'
  97. });
  98. $http.post('/api/v1/mp/user/exchange/goods/detail', {
  99. noToken: true,
  100. goodsId: id
  101. }).then(res => {
  102. uni.hideLoading();
  103. if (res.code == 0) {
  104. this.info = res.data
  105. let picUrlArr = res.data.picUrl.split(',')
  106. picUrlArr.forEach(item => {
  107. this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
  108. })
  109. // 处理富文本
  110. // #ifndef MP-ALIPAY
  111. const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
  112. .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
  113. ".png?imageView2/2/w/750\"");
  114. this.description = formatRichText(description);
  115. // #endif
  116. // #ifdef MP-ALIPAY
  117. res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
  118. res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
  119. res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
  120. this.description = formatRichText(res.data.description);
  121. // #endif
  122. }
  123. }).catch(() => {
  124. uni.hideLoading();
  125. })
  126. },
  127. close() {
  128. this.payShow = false
  129. },
  130. toProcess(id) {
  131. this.payShow = false
  132. uni.navigateTo({
  133. url: `/packagePrize/purchase/index?boxId=${ this.boxId }&orderId=${ id }&isTry=0`
  134. })
  135. },
  136. exchange() {
  137. let data = {
  138. couponIds: [],
  139. autoCoupon: 1,
  140. boxId: this.boxId,
  141. orderNum: 1,
  142. appSource: appId
  143. }
  144. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  145. if (res.code == 0) {
  146. let info = {
  147. ...res.data,
  148. ...this.info,
  149. picUrl: env.filePublic + res.data.goodsPicUrl.split(',')[0],
  150. }
  151. this.payInfo = info
  152. this.payShow = true
  153. }
  154. })
  155. },
  156. toCompanyData() {
  157. uni.navigateTo({
  158. url: `/packageGoods/goods/company?goodsId=${ this.goodsId }`
  159. })
  160. },
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .detail {
  166. // 设置ios刘海屏底部横线安全区域
  167. // padding-bottom: constant(safe-area-inset-bottom);
  168. // padding-bottom: env(safe-area-inset-bottom);
  169. padding-bottom: 210rpx;
  170. // 商品轮播
  171. &-swiper {
  172. background-color: #FFFFFF;
  173. }
  174. // 详情
  175. &-infotwo {
  176. background-color: #fff;
  177. justify-content: space-between;
  178. &-num {
  179. view {
  180. display: inline-block;
  181. color: #F9822C;
  182. line-height: 80rpx;
  183. font-size: 32rpx;
  184. font-weight: bold;
  185. }
  186. .txt {
  187. margin-left: 14rpx;
  188. font-size: 26rpx;
  189. color: #666666;
  190. font-weight: 400;
  191. text-decoration: line-through;
  192. }
  193. }
  194. }
  195. &-info {
  196. background-color: #fff;
  197. justify-content: space-between;
  198. padding: 34rpx;
  199. margin-bottom: 22rpx;
  200. &-left {
  201. flex: 1;
  202. &__title {
  203. font-size: 34rpx;
  204. line-height: 40rpx;
  205. max-height: 80rpx;
  206. overflow: hidden;
  207. // margin-bottom: 26rpx;
  208. font-weight: bold;
  209. }
  210. &__coin {
  211. display: flex;
  212. line-height: 30rpx;
  213. margin-bottom: 26rpx;
  214. .content {
  215. color: #FA822C;
  216. margin-right: 34rpx;
  217. font-weight: bold;
  218. font-size: 30rpx;
  219. image {
  220. width: 34rpx;
  221. height: 30rpx;
  222. }
  223. text {
  224. font-weight: normal;
  225. }
  226. }
  227. .txt {
  228. font-size: 26rpx;
  229. color: #666666;
  230. text-decoration: line-through;
  231. }
  232. }
  233. &__price {
  234. line-height: 24rpx;
  235. color: #666666;
  236. }
  237. }
  238. &-right {
  239. color: #666666;
  240. }
  241. }
  242. &-goods {
  243. height: 90rpx;
  244. text-align: center;
  245. line-height: 90rpx;
  246. font-weight: bold;
  247. font-size: 30rpx;
  248. background-color: #FFFFFF;
  249. }
  250. &-description {
  251. image {
  252. width: 100%;
  253. }
  254. }
  255. &-merchant {
  256. height: 88rpx;
  257. // text-align: center;
  258. line-height: 88rpx;
  259. font-weight: bold;
  260. background-color: #FFFFFF;
  261. &-warp {
  262. height: 88rpx;
  263. width: 100%;
  264. background-color: #ffffff;
  265. &-one {
  266. float: left;
  267. margin: 20rpx;
  268. font-weight: 600;
  269. }
  270. &-two {
  271. float: right;
  272. margin: 20rpx;
  273. font-weight: 600;
  274. }
  275. }
  276. }
  277. }
  278. .footer-fixed {
  279. position: fixed;
  280. bottom: var(--window-bottom);
  281. left: 0;
  282. right: 0;
  283. z-index: 11;
  284. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  285. background: #fff;
  286. // 设置ios刘海屏底部横线安全区域
  287. padding-bottom: constant(safe-area-inset-bottom);
  288. padding-bottom: env(safe-area-inset-bottom);
  289. &-content {
  290. justify-content: space-around;
  291. height: 132rpx;
  292. background-color: #fff;
  293. &__price {
  294. button {
  295. line-height: 82rpx;
  296. width: 420rpx;
  297. height: 82rpx;
  298. font-size: 30rpx;
  299. background: #F9822C;
  300. border-radius: 20px;
  301. color: #fff;
  302. margin-right: 20rpx;
  303. }
  304. }
  305. }
  306. }
  307. </style>