You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

332 lines
7.7 KiB

1 week ago
1 week ago
  1. <template>
  2. <view class="container">
  3. <view class="details-container">
  4. <uni-swiper-dot class="uni-swiper-dot-box" field="content">
  5. <swiper style="height: 245px;" indicator-dots indicator-color="rgba(255, 255, 255, 0.50)"
  6. indicator-active-color="#ffffff" autoplay interval="3000">
  7. <swiper-item class="swiper-box" v-for="(item,index) in slideshow" :key="index">
  8. <img :src="item"
  9. style="width: 100%; height:100%" />
  10. </swiper-item class="swiper-box">
  11. </swiper>
  12. </uni-swiper-dot>
  13. <view class="details-price">
  14. <view class="details-price1">
  15. <view class="details-price-normal">
  16. <text class="details-price-big">{{detailInfo.price}}.00</text>
  17. <text>{{detailInfo.unit}}</text>
  18. </view>
  19. <button open-type="share" @click="sharePage" class="share-btn">
  20. <img src="../../static/images/details/share.svg" style="width: 14px;height: 14px; margin-right:5px" alt="share"
  21. srcset="">
  22. </button>
  23. </view>
  24. <view class="details-price2">
  25. <text class="details-price-item">{{detailInfo.name}}</text>
  26. <button class="details-price-share share-btn" open-type="share" @click="sharePage">分享</button>
  27. </view>
  28. </view>
  29. <view class="details-banner">
  30. <view class="details-banner-item">
  31. <!-- <img src="../../static/images/details/right.svg" alt="right">
  32. <text>全程直播</text> -->
  33. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/second_stage/spzb.png"
  34. style="width: 96px;" mode="widthFix" alt="">
  35. </view>
  36. <view class="details-banner-item">
  37. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/second_stage/fwdj.png"
  38. style="width: 109px;" mode="widthFix" alt="">
  39. <!-- <img src="../../static/images/details/right.svg" alt="right">
  40. <text>1v1服务</text> -->
  41. </view>
  42. <view class="details-banner-item">
  43. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/second_stage/kspp.png"
  44. style="width: 96px;" mode="widthFix" alt="">
  45. <!-- <img src="../../static/images/details/right.svg" alt="right">
  46. <text>及时匹配</text> -->
  47. </view>
  48. </view>
  49. <view class="details-img">
  50. <img :src="detailInfo.detailPic" style="width: 100%;" mode="widthFix" show-menu-by-longpress />
  51. </view>
  52. </view>
  53. <view class="details-subscribe">
  54. <button v-if="isMember" class="details-btn" @click="goSubscribe">去预约</button>
  55. <button v-else class="details-btn" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">去预约</button>
  56. </view>
  57. <Kefu></Kefu>
  58. </view>
  59. </template>
  60. <script>
  61. import { setToken,getToken,getOpenIdKey } from '@/utils/auth'
  62. import Kefu from '../common/kefu.vue'
  63. import {
  64. getProductDetails,
  65. getPhoneNumber
  66. } from '@/api/system/user.js'
  67. export default {
  68. data() {
  69. return {
  70. currentProductId: '',
  71. isAgree: false,
  72. code: '',
  73. detailInfo: {},
  74. skus: null,
  75. slideshow: [],
  76. isMember:false
  77. };
  78. },
  79. components:{
  80. Kefu
  81. },
  82. mounted() {
  83. // this.currentProductId = this.$globalData.selectedProductId;
  84. console.log(this.currentProductId);
  85. this.getDetailInfo();
  86. },
  87. methods: {
  88. getDetailInfo() {
  89. getProductDetails(this.currentProductId).then(response => {
  90. this.detailInfo = response.product
  91. this.skus = response.skus
  92. if(response.product&&response.product.albumPics){
  93. this.slideshow = response.product.albumPics.split(",")
  94. }
  95. })
  96. },
  97. sharePage() {
  98. uni.shareAppMessage({
  99. title: '猫妈狗爸',
  100. path: `/pages/details/detail?id=${this.currentProductId}`,
  101. imageUrl: this.detailInfo.pic
  102. })
  103. },
  104. changeAgree() {
  105. console.log(this.isAgree);
  106. if (this.isAgree) {
  107. this.isAgree = false
  108. } else {
  109. this.isAgree = true
  110. }
  111. },
  112. goSubscribe() {
  113. if (this.skus) {
  114. let productSku = {
  115. "skuId": this.skus[0].id,
  116. "quantity": 1
  117. }
  118. this.$store.commit('setPosition', {})
  119. this.buyInfo.teacher = null
  120. this.$globalData.newOrderData={
  121. currentAddress:{},
  122. currentPets:[],
  123. totalPrice:0,
  124. needPreFamiliarize:[]
  125. }
  126. this.$globalData.mainSku = [productSku]
  127. uni.navigateTo({
  128. url: `/pages/newOrder/serviceNew`
  129. // url: `/pages/details/service?price=${this.detailInfo.price}`
  130. });
  131. }else{
  132. this.$modal.showToast('产品SKU有误,请联系系统管理员');
  133. }
  134. },
  135. init() {
  136. this.$globalData.itemPrice = []
  137. this.$globalData.submitData = {
  138. "phone": "",
  139. "wechatId": "",
  140. "note": "",
  141. "totalPrice": "",
  142. "address": {
  143. "province": "上海市",
  144. "city": "上海市",
  145. "district": "",
  146. "detailAddress": ""
  147. },
  148. "skuList": [],
  149. "service": {
  150. "serviceFrequency": "once_a_day",
  151. "serviceDate": [],
  152. "serviceTimeFirst": "",
  153. "serviceTimeSecond": "",
  154. "pet": []
  155. }
  156. }
  157. },
  158. onGetPhoneNumber(e){
  159. if(e.detail.errMsg=="getPhoneNumber:fail user deny"){ //用户拒绝授权
  160. //拒绝授权后弹出一些提示
  161. }else{ //允许授权
  162. if(getOpenIdKey()){
  163. this.getPhoneNumber({"openId":getOpenIdKey(),"code":e.detail.code})
  164. }
  165. }
  166. },
  167. getPhoneNumber(data){
  168. getPhoneNumber(data).then(res=>{
  169. if(res&&res.code==200){
  170. let token = res.data.token
  171. setToken(token)
  172. this.isMember=true
  173. this.goSubscribe()
  174. } else{
  175. uni.showToast({
  176. icon:'error',
  177. title:'获取手机号失败'
  178. })
  179. }
  180. })
  181. }
  182. },
  183. onLoad: function(option) {
  184. this.init();
  185. this.currentProductId = option.id || 63;
  186. this.isMember= getToken()?true:false
  187. },
  188. onShareAppMessage(res) {
  189. if (res.from === 'button') { // 来自页面内分享按钮
  190. console.log(res.target)
  191. }
  192. return {
  193. title: '猫妈狗爸',
  194. path: `/pages/details/detail?id=${this.currentProductId}`,
  195. imageUrl: this.detailInfo.pic
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss">
  201. .container {
  202. position: relative;
  203. height: 100%;
  204. padding-bottom: 58px;
  205. .details-subscribe {
  206. background-color: #FFFFFF;
  207. padding: 10px;
  208. width: 100%;
  209. height: 58px;
  210. position: fixed;
  211. bottom: 0;
  212. z-index: 100;
  213. .details-btn {
  214. width: 100%;
  215. border-radius: 6px;
  216. background: #FFB13F;
  217. font-size: 16px;
  218. color: #FFFFFF;
  219. }
  220. }
  221. }
  222. .details-container {
  223. .share-btn {
  224. margin: 0;
  225. border: 0;
  226. padding: 0 !important;
  227. background: #fff;
  228. border-color: #fff;
  229. display: flex;
  230. border-radius: 0px;
  231. }
  232. .share-btn::after {
  233. border: none;
  234. }
  235. .details-price {
  236. background: #FFFFFF;
  237. padding: 10px 19px 15px;
  238. margin-top: -5px;
  239. .details-price1 {
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: baseline;
  243. .details-price-normal {
  244. color: #FF530A;
  245. font-size: 16px;
  246. font-style: normal;
  247. font-weight: bold;
  248. line-height: normal;
  249. .details-price-big {
  250. font-size: 24px;
  251. }
  252. }
  253. }
  254. .details-price2 {
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. margin-top: 5px;
  259. .details-price-item {
  260. color: #333;
  261. font-size: 18px;
  262. font-weight: bold;
  263. line-height: 16px;
  264. /* 100% */
  265. margin-left: 5px;
  266. }
  267. .details-price-share {
  268. color: #666;
  269. font-size: 14px;
  270. font-weight: 400;
  271. line-height: 13px;
  272. /* 92.857% */
  273. }
  274. }
  275. }
  276. .details-banner {
  277. width: 100%;
  278. height: 36px;
  279. background-color: #FFF8DF;
  280. display: flex;
  281. justify-content: space-around;
  282. .details-banner-item {
  283. display: flex;
  284. justify-content: space-between;
  285. align-items: center;
  286. font-size: 12px;
  287. line-height: 13px;
  288. color: #A94F20;
  289. img {
  290. width: 13px;
  291. }
  292. }
  293. }
  294. .details-img {
  295. background: #F5F5F7;
  296. padding: 10px;
  297. }
  298. }
  299. </style>