index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="service">
  3. <view class="service-content">
  4. <!-- 顶部 -->
  5. <!-- <view class="flex" style="margin-top: 10rpx">
  6. <view class="flex">
  7. <u-icon name="share-square" size="24" />
  8. <text style="font-size: 24rpx; color: #666">七仔美容</text>
  9. </view>
  10. <u-icon name="share-square" size="24" @click="handlerShare" />
  11. </view> -->
  12. <!-- 标题和轮播图 -->
  13. <view>
  14. <view class="service-title">{{ goods.name }}</view>
  15. <u-swiper :list="banners" previousMargin="30" nextMargin="30" circular bgColor="#ffffff" height="190" />
  16. </view>
  17. <!-- 价格 -->
  18. <view class="flex price-content">
  19. <view>
  20. <view>
  21. <text class="price">¥</text>
  22. <text class="price-text">{{ goods.originalPrice }}</text>
  23. </view>
  24. <text class="price">券后¥{{ goods.specialPrice }}</text>
  25. </view>
  26. <view class="text_title">半售200+</view>
  27. </view>
  28. <!-- 评价 -->
  29. <view>
  30. <view class="flex evaluate">
  31. <view class="flex">
  32. <text style="margin-right: 30rpx">评价</text>
  33. <u-rate :value="5" readonly activeColor="#f3b935" />
  34. <text style="font-size: 24rpx; color: #f4b931">100%</text>
  35. </view>
  36. <view class="flex">
  37. <text class="text_title" style="margin-right: 20rpx">共40个消费评价</text>
  38. <u-icon name="arrow-right" size="16" color="#999" />
  39. </view>
  40. </view>
  41. <!-- <view class="evaluate-context">
  42. <view class="flex evaluate">
  43. <view class="flex">
  44. <text style="margin-right: 30rpx">优惠</text>
  45. <view class="text_title"> 您有2张8元无门槛券待额 </view>
  46. </view>
  47. <view class="flex" @click="openPopup">
  48. <text class="text_title" style="margin-right: 20rpx">去领取</text>
  49. <u-icon name="arrow-right" size="16" color="#999" />
  50. </view>
  51. </view>
  52. </view> -->
  53. </view>
  54. </view>
  55. <!-- 弹窗 -->
  56. <!-- <u-popup :show="show" mode="bottom" :safeAreaInsetBottom="true">
  57. <view>
  58. <GainCoupon @close="closeCoupon" :coupons="coupons"></GainCoupon>
  59. </view>
  60. </u-popup> -->
  61. <!-- 占位 -->
  62. <view class="placeholder"></view>
  63. <!-- 服务详情 -->
  64. <view class="detail">
  65. <view>
  66. <u-tabs :list="detailList" lineWidth="50" lineColor="#fdbf05" :activeStyle="{
  67. color: '#303133',
  68. fontWeight: 'bold',
  69. transform: 'scale(1.05)',
  70. }" :inactiveStyle="{
  71. color: '#606266',
  72. transform: 'scale(1)',
  73. }" itemStyle="padding-left: 15px; padding-right: 15px; height: 40px;" />
  74. </view>
  75. <view>
  76. {{ goods.description }}
  77. </view>
  78. </view>
  79. <!-- 评价内容 -->
  80. <view class="Evaluate-content">
  81. <EvaluateContent :comments="comments"></EvaluateContent>
  82. </view>
  83. <!-- 底部 -->
  84. <view class="service-footer">
  85. <view class="user-operate" v-for="(item, index) in userOperate" :key="index" @tap="collect(item, index)">
  86. <u-icon class="user-operate-icon" :name="item.icon" size="24" />
  87. <text class="user-operate-text">{{ item.name }}</text>
  88. </view>
  89. <view class="user-operate" @tap="handlerFavorite">
  90. <u-icon class="user-operate-icon" :name="goods.favorites ? favorite_list.fill : favorite_list.icon" size="24" />
  91. <text class="user-operate-text">{{ favorite_list.name }}</text>
  92. </view>
  93. <view class="buyNow">
  94. <view class="cart" @click="handlerAddCart">加入购物车</view>
  95. <!-- <view class="buy" @click="handlerImmediateBy">立即购买</view> -->
  96. </view>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import {
  102. getGoodsDetailApi,
  103. addFavorite,
  104. addShoppingCart,
  105. addGoodsFavorite,
  106. cancelFavorite,
  107. // getGoodsConcentList,
  108. accountToOrderGetComment
  109. } from '@/api/client/business.js';
  110. import { accountTotIdGetConponList } from "@/api/client/mine.js"
  111. import GainCoupon from './GainCoupon.vue';
  112. import EvaluateContent from './EvaluateContent.vue';
  113. export default {
  114. components: {
  115. GainCoupon,
  116. EvaluateContent
  117. },
  118. data() {
  119. return {
  120. userOperate: [{
  121. name: '店铺',
  122. icon: 'file-text',
  123. },
  124. {
  125. name: '立即咨询',
  126. icon: 'chat',
  127. },
  128. ],
  129. favorite_list: {
  130. name: '收藏',
  131. icon: 'heart',
  132. fill: 'heart-fill',
  133. },
  134. goods: [], //商品详情
  135. banners: [
  136. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  137. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  138. 'https://cdn.uviewui.com/uview/swiper/swiper1.png'
  139. ],
  140. coupons: [], //优惠券
  141. comments: [], // 评论
  142. id: '', //商品id
  143. shoopId: null, //店铺id
  144. show: false,
  145. detailList: [{
  146. id: '1',
  147. name: '服务详情',
  148. },
  149. {
  150. id: '2',
  151. name: '购买须知',
  152. },
  153. {
  154. id: '3',
  155. name: '网友评价',
  156. },
  157. ],
  158. };
  159. },
  160. onLoad(option) {
  161. // 获取商品详情接口
  162. this.shoopId = option.shopId
  163. this.id = option.id;
  164. this.handlerInitList(option.id);
  165. },
  166. methods: {
  167. openPopup() {
  168. this.show = true;
  169. },
  170. // closeCoupon(data) {
  171. // this.show = data;
  172. // this.handlerGetGoodsConcentList()
  173. // },
  174. handlerInitList(id) {
  175. getGoodsDetailApi(id).then(res => {
  176. console.log("@@@@res",res)
  177. this.goods = res.data.goods;
  178. this.comments = res.data.comments;
  179. this.handlerGetGoodsConcentList()
  180. });
  181. },
  182. handlerGetGoodsConcentList() {
  183. // 获取商品评价列表
  184. let params = {
  185. // merchantId:this.shoopId,
  186. goodsId:this.goods.id
  187. }
  188. accountToOrderGetComment(params).then(res => {
  189. console.log("@@@@res",res)
  190. })
  191. // 根据id获取优惠券列表
  192. // accountTotIdGetConponList(this.shoopId,{ paging:'1,10' }).then(res=>{
  193. // this.coupons = res.data.records
  194. // })
  195. },
  196. // 点击分享
  197. handlerShare() {
  198. uni.share({
  199. provider: 'weixin',
  200. scene: 'WXSceneSession',
  201. type: 1,
  202. summary: '我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!',
  203. success: function(res) {},
  204. fail: function(err) {},
  205. });
  206. },
  207. // 选择底部tab店铺收藏咨询
  208. collect(item, index) {
  209. switch (index) {
  210. case 0:
  211. uni.redirectTo({
  212. url: `/pages/client/clientPackage/storeDetail?id=${this.shoopId}`,
  213. });
  214. break;
  215. case 1:
  216. uni.showToast({
  217. title: '暂无',
  218. icon: 'none',
  219. });
  220. break;
  221. }
  222. },
  223. // 点击收藏1
  224. handlerFavorite() {
  225. if (this.goods.favorites) {
  226. cancelFavorite(this.id).then(res => {
  227. if (res.code == 200) {
  228. this.handlerInitList(this.id);
  229. uni.showToast({
  230. title: '取消收藏',
  231. icon: 'none',
  232. });
  233. } else {
  234. uni.showToast({
  235. title: res.msg,
  236. icon: 'none',
  237. });
  238. return;
  239. }
  240. });
  241. } else {
  242. addGoodsFavorite(this.id).then(res => {
  243. if (res.code == 200) {
  244. this.handlerInitList(this.id);
  245. uni.showToast({
  246. title: '收藏成功',
  247. icon: 'none',
  248. });
  249. } else {
  250. uni.showToast({
  251. title: res.msg,
  252. icon: 'none',
  253. });
  254. return;
  255. }
  256. });
  257. }
  258. },
  259. // 点击购买按钮
  260. // handlerImmediateBy() {
  261. // this.$store.commit('order/GET_ORDER_LIST', this.goods);
  262. // uni.navigateTo({
  263. // url: `/pages/client/clientPackage/uptickOrder?id=${this.id}`,
  264. // });
  265. // },
  266. // 加入购物车
  267. handlerAddCart() {
  268. let params = {
  269. // id:this.shoopId,
  270. goodsId: this.goods.id,
  271. quantity: 1,
  272. price: this.goods.originalPrice,
  273. goodsName: this.goods.name,
  274. goodsPic: '@/static/QR57a.jpg',
  275. goodsSubTitle: this.goods.description
  276. }
  277. addShoppingCart(params).then(res => {
  278. if (res.code == 200) {
  279. uni.showToast({
  280. title: '购物车添加成功',
  281. icon: 'none'
  282. })
  283. } else {
  284. uni.showToast({
  285. title: res.message,
  286. icon: 'none'
  287. })
  288. return
  289. }
  290. })
  291. },
  292. },
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. @import './index.scss';
  297. </style>