index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <view class="product-detail">
  3. <page-navbar bgColor="#fff" title="服务详情"></page-navbar>
  4. <view class="product-detail-main">
  5. <view class="u-m-b-24">
  6. <u-swiper
  7. :list="swiperList"
  8. height="440rpx"
  9. indicatorActiveColor="#215ebe"
  10. indicator
  11. indicatorMode="dot"
  12. bgColor="#215ebe"
  13. ></u-swiper>
  14. </view>
  15. <view class="u-m-b-32 prefer-status fl-flex-item">
  16. <base-img
  17. src="/static/pagesHome/preferential-status.png"
  18. height="80rpx"
  19. width="230rpx"
  20. ></base-img>
  21. <view class="prefer-recommend">优惠推荐</view>
  22. <view class="fl-flex">
  23. <view class="u-m-r-16 f-s-24 text-333">距离结束还剩</view>
  24. <view class="fl-flex">
  25. <base-text
  26. text="12"
  27. background="#f43f5e"
  28. width="40rpx"
  29. height="40rpx"
  30. color="#fff"
  31. />
  32. <text class="recommend-dot">:</text>
  33. <base-text
  34. text="12"
  35. background="#f43f5e"
  36. width="40rpx"
  37. height="40rpx"
  38. color="#fff"
  39. />
  40. <text class="recommend-dot">:</text>
  41. <base-text
  42. text="12"
  43. background="#f43f5e"
  44. width="40rpx"
  45. height="40rpx"
  46. color="#fff"
  47. />
  48. </view>
  49. </view>
  50. </view>
  51. <view class="fl-flex-item u-m-b-24">
  52. <view class="fl-flex">
  53. <view class="f-s-48 text-primary u-m-r-16">¥{{ goods.specialPrice }}</view>
  54. <view class="f-s-24 text-999 text-through u-m-t-20">
  55. 门市价:¥{{ goods.originalPrice }}
  56. </view>
  57. </view>
  58. <view class="f-s-24 text-999">销量1100</view>
  59. </view>
  60. <view class="fl-flex fl-justify-between u-m-b-24">
  61. <view class="f-s-32 text-primary text-bold"> {{ goods.name }}</view>
  62. <u-icon name="share-square" color="#333" size="26"></u-icon>
  63. </view>
  64. <view class="f-s-24 u-p-b-24" style="color: #616570; line-height: 40rpx">
  65. <view> 预约:可预约/也可直接到门店使用</view>
  66. <view> 须知:周一至周日全天可用·购买后30天内有效</view>
  67. <view> 保障:随时退,过期退</view>
  68. </view>
  69. </view>
  70. <base-tabs
  71. :list="detailList"
  72. paddingLeft="30rpx"
  73. paddingRight="30rpx"
  74. lineWidth="40"
  75. ></base-tabs>
  76. <view class="server-detail">
  77. <view class="fl-text-title u-m-b-24">网友评价</view>
  78. <view class="detail">{{ goods.description }}</view>
  79. </view>
  80. <view class="u-m-b-24">
  81. <purchase-notes></purchase-notes>
  82. </view>
  83. <div class="service-evaluation">
  84. <view class="fl-flex-item">
  85. <view class="fl-text-title">服务详情</view>
  86. <view class="fl-flex" @click="$Router.push('/pagesHome/evaluateList/index')">
  87. <text class="f-s-24 text-999">查看更多</text>
  88. <u-icon name="arrow-right" color="#999" size="15"></u-icon>
  89. </view>
  90. </view>
  91. <view class="u-m-t-24">
  92. <dynamic-list :list="list"></dynamic-list>
  93. <view class="dynamic-more" @click="$Router.push('/pagesHome/evaluateList/index')">
  94. <view>120评论 查看更多</view>
  95. <u-icon name="arrow-right" color="#999" size="12"></u-icon>
  96. </view>
  97. </view>
  98. </div>
  99. <view class="service-footer">
  100. <ServiceFooter @collect="collect" @cart="handlerAddCart"></ServiceFooter>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import ServiceFooter from './serviceFooter.vue';
  106. import {
  107. getGoodsDetailApi,
  108. addShoppingCart,
  109. addGoodsFavorite,
  110. cancelFavorite,
  111. accountToOrderGetComment,
  112. } from '@/api/client/business.js';
  113. export default {
  114. components: {
  115. ServiceFooter,
  116. },
  117. name: 'productDetail',
  118. data() {
  119. return {
  120. goods: [], //商品详情
  121. banners: [],
  122. coupons: [], //优惠券
  123. comments: [], // 评论
  124. id: '', //商品id
  125. shoopId: null, //店铺id
  126. show: false,
  127. swiperList: [
  128. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  129. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  130. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  131. ],
  132. detailList: [
  133. {
  134. id: '1',
  135. name: '服务详情',
  136. },
  137. {
  138. id: '2',
  139. name: '购买须知',
  140. },
  141. {
  142. id: '3',
  143. name: '网友评价',
  144. },
  145. ],
  146. list: [{}, {}, {}],
  147. };
  148. },
  149. onLoad(option) {
  150. // 获取商品详情接口
  151. this.shoopId = option.shopId;
  152. this.id = option.id;
  153. this.handlerInitList(this.id);
  154. },
  155. methods: {
  156. // closeCoupon(data) {
  157. // this.show = data;
  158. // this.handlerGetGoodsConcentList()
  159. // },
  160. handlerInitList(id) {
  161. getGoodsDetailApi(id).then(res => {
  162. this.goods = res.data.goods;
  163. this.comments = res.data.comments;
  164. res.data.goods.banners.map(rs => {
  165. this.banners.push(rs.url);
  166. });
  167. this.handlerGetGoodsConcentList();
  168. });
  169. },
  170. handlerGetGoodsConcentList() {
  171. // 获取商品评价列表
  172. let params = {
  173. // merchantId:this.shoopId,
  174. goodsId: this.goods.id,
  175. };
  176. accountToOrderGetComment(params).then(res => {
  177. console.log('@@@@res', res);
  178. });
  179. // 根据id获取优惠券列表
  180. // accountTotIdGetCouponList(this.shoopId,{ paging:'1,10' }).then(res=>{
  181. // this.coupons = res.data.records
  182. // })
  183. },
  184. // 点击分享
  185. handlerShare() {
  186. uni.share({
  187. provider: 'weixin',
  188. scene: 'WXSceneSession',
  189. type: 1,
  190. summary: '我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!',
  191. success: function (res) {},
  192. fail: function (err) {},
  193. });
  194. },
  195. // 选择底部tab店铺收藏咨询
  196. collect(index) {
  197. switch (index) {
  198. case 0:
  199. uni.navigateBack(-1);
  200. break;
  201. case 1:
  202. uni.showToast({
  203. title: '暂无',
  204. icon: 'none',
  205. });
  206. break;
  207. }
  208. },
  209. // 点击收藏1
  210. handlerFavorite() {
  211. if (this.goods.favorites) {
  212. cancelFavorite(this.id).then(res => {
  213. if (res.code === 'OK') {
  214. this.handlerInitList(this.id);
  215. uni.showToast({
  216. title: '取消收藏',
  217. icon: 'none',
  218. });
  219. } else {
  220. uni.showToast({
  221. title: res.msg,
  222. icon: 'none',
  223. });
  224. return;
  225. }
  226. });
  227. } else {
  228. addGoodsFavorite(this.id).then(res => {
  229. if (res.code === 'OK') {
  230. this.handlerInitList(this.id);
  231. uni.showToast({
  232. title: '收藏成功',
  233. icon: 'none',
  234. });
  235. } else {
  236. uni.showToast({
  237. title: res.msg,
  238. icon: 'none',
  239. });
  240. return;
  241. }
  242. });
  243. }
  244. },
  245. // 加入购物车
  246. handlerAddCart() {
  247. let params = {
  248. merchantId: this.shoopId,
  249. goodsId: this.goods.id,
  250. quantity: 1,
  251. price: this.goods.specialPrice,
  252. goodsName: this.goods.name,
  253. goodsPic: this.goods.logo,
  254. originalPrice: this.goods.originalPrice,
  255. };
  256. addShoppingCart(params).then(res => {
  257. if (res.code === 'OK') {
  258. uni.showToast({
  259. title: '购物车添加成功',
  260. icon: 'none',
  261. });
  262. } else {
  263. uni.showToast({
  264. title: res.message,
  265. icon: 'none',
  266. });
  267. return;
  268. }
  269. });
  270. },
  271. },
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. .product-detail {
  276. .product-detail-main {
  277. padding: 16rpx 32rpx 0;
  278. background-color: #fff;
  279. position: relative;
  280. .prefer-recommend {
  281. position: absolute;
  282. left: 7%;
  283. font-size: 36rpx;
  284. color: #fff;
  285. }
  286. .prefer-status {
  287. height: 80rpx;
  288. background-color: #fdebee;
  289. padding-right: 20rpx;
  290. }
  291. .recommend-dot {
  292. margin: 0 4rpx;
  293. color: #f43f5e;
  294. }
  295. }
  296. .server-detail {
  297. padding: 32rpx;
  298. margin: 24rpx 0;
  299. background-color: #fff;
  300. .detail {
  301. font-size: 28rpx;
  302. line-height: 44rpx;
  303. color: #616570;
  304. }
  305. }
  306. .service-evaluation {
  307. padding: 32rpx;
  308. background-color: #fff;
  309. margin-bottom: 24rpx;
  310. }
  311. .service-footer {
  312. position: fixed;
  313. bottom: 0;
  314. width: 100%;
  315. background-color: #fff;
  316. }
  317. .dynamic-more {
  318. display: flex;
  319. font-size: 24rpx;
  320. color: #999;
  321. justify-content: center;
  322. padding-bottom: 160rpx;
  323. }
  324. }
  325. </style>