storeDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view class="detail">
  3. <!-- 轮播图 -->
  4. <view class="carousel-map">
  5. <u-swiper :list="swiperList" previousMargin="0" nextMargin="100" circular :autoplay="false"
  6. bgColor="#ffffff" />
  7. <view class="carousel-item">
  8. <view class="mark">
  9. <view class="mark-item">{{ merchant.score }}分</view>
  10. <u-rate :count="count" v-model="value" active-color="#fff" inactive-color="#fff" :size="12" />
  11. </view>
  12. <view class="good-item">近期有6266个购买者给了给好评</view>
  13. </view>
  14. </view>
  15. <!-- 商家信息 -->
  16. <view class="merchant-info">
  17. <view class="info-title">
  18. <view>{{ merchant.name }}</view>
  19. <text class="info-mark">{{ merchant.sale / 10000 }}w+单</text>
  20. </view>
  21. <view class="info-tag">商家信息</view>
  22. <view class="info-item">
  23. <view class="info-text">
  24. <view>营业时间:{{ merchant.opening }}</view>
  25. <view>电话号码:{{ merchant.mobile }}</view>
  26. <view>{{ merchant.address }}</view>
  27. <view class="distance">{{ (merchant.distance / 1000).toFixed(2) }}km</view>
  28. </view>
  29. <view class="info-icon">
  30. <view class="info-map">
  31. <u-icon name="map" size="20"></u-icon>
  32. <view style="font-size: 20rpx; margin-top: 5rpx">导航</view>
  33. </view>
  34. <view class="info-map" @click="handlerMakeCall">
  35. <u-icon name="phone" size="20"></u-icon>
  36. <view style="font-size: 20rpx; margin-top: 5rpx">电话</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 商家分类 -->
  42. <view class="categoryList">
  43. <u-tabs :list="categoryList"></u-tabs>
  44. </view>
  45. <view>
  46. <view class="list" :key="index" v-for="(item, index) of goods" @click="handlerSkipGoodsDetail(item, index)">
  47. <!-- <image class="img" :src="
  48. error || !loaded
  49. ? 'https://cdn.uviewui.com/uview/album/10.jpg'
  50. : goods.logo
  51. " mode="scaleToFill" @click="$Router.push(`/pages/client/clientPackage/storeDetail?id=${item.id}`)"></image> -->
  52. <image class="img" src="@/static/logo.png"></image>
  53. <view class="listDetail">
  54. <view class="item-text">{{ item.name }}</view>
  55. <view class="item-flex">
  56. <view class="star">
  57. <u-rate :count="item.score" :size="14" />
  58. <text class="line">|</text>
  59. <text class="points">{{ item.score }}分</text>
  60. </view>
  61. <view>{{ item.score }}单</view>
  62. </view>
  63. <view class="list-item">
  64. <view class="list-price">
  65. <view class="item-l">
  66. 券后价 <span>¥{{ item.originalPrice.toFixed(2) }}</span>
  67. </view>
  68. <view class="item-r">
  69. 门市价 <span>¥{{ item.specialPrice.toFixed(2) }}</span>
  70. </view>
  71. </view>
  72. <view class="btn-box">
  73. <button class="btn btn1" @click.stop="handlerService(item, index)">预约</button>
  74. <button class="btn btn2" @click.stop="handlerSkipBuy(item, index)">购买</button>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <u-empty v-if="goods.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
  80. </u-empty>
  81. </view>
  82. <!-- 弹窗 -->
  83. <u-popup :show="reserve_show" @close="reserve_show = false" @open="open" round="20" mode="center">
  84. <view class="draw-box">
  85. <view class="draw-title"> 预约服务 </view>
  86. <view class="draw-item">
  87. <view class="item-text">时间</view>
  88. <view class="time-box" @click="handlerSelectTime" :class="template_time == '' ? 'time-text' : ''">
  89. {{ template_time == '' ? '请选择时间' : template_time }}
  90. </view>
  91. </view>
  92. <view class="draw-item">
  93. <view class="item-text">联系方式</view>
  94. <u--input placeholder="请输入联系方式" border="surround" type="number"
  95. v-model="addParams.mobile"></u--input>
  96. </view>
  97. <button class="draw-btn" @click="handlerDrawConfirmBtn">确定</button>
  98. </view>
  99. </u-popup>
  100. <!-- 时间 -->
  101. <u-datetime-picker :show="time_show" :minDate="Number(new Date())" :formatter="formatter"
  102. v-model="addParams.appointTime" @change="handlerTimeChange" @confirm="time_show = false"
  103. @cancel="time_show = false" mode="datetime">
  104. </u-datetime-picker>
  105. </view>
  106. </template>
  107. <script>
  108. import { getSellsDetail, addReservation } from '@/api/client/business.js';
  109. import { getCurrentLocation,hotMerchant } from '@/api/client/home';
  110. export default {
  111. data() {
  112. return {
  113. merchant: {},
  114. goods: [],
  115. count: 5,
  116. value: 3,
  117. swiperList: [],
  118. categoryList: [{
  119. id: 1,
  120. name: '全部'
  121. },
  122. {
  123. id: 2,
  124. name: '养车'
  125. },
  126. {
  127. id: 2,
  128. name: '维修'
  129. },
  130. {
  131. id: 2,
  132. name: '改装'
  133. },
  134. {
  135. id: 2,
  136. name: '补胎'
  137. },
  138. {
  139. id: 2,
  140. name: '其他'
  141. },
  142. ],
  143. queryParams: {
  144. //请求参数
  145. id: null, //商家ID
  146. region: null, //地区编码
  147. longitude: null, //经度
  148. latitude: null, //纬度
  149. },
  150. template_value: '',
  151. time_show: false,
  152. reserve_show: false,
  153. value: '',
  154. addParams: {
  155. merchantId: '',
  156. mobile: '',
  157. appointTime: '',
  158. },
  159. template_time: '',
  160. };
  161. },
  162. onLoad(option) {
  163. this.queryParams.id = option.id;
  164. this.handlerInitLocation();
  165. },
  166. watch: {
  167. reserve_show(newValue) {
  168. if (!newValue) {
  169. this.addParams.mobile = '';
  170. this.addParams.appointTime = '';
  171. this.template_time = '';
  172. }
  173. },
  174. },
  175. methods: {
  176. // 获取当前经纬度
  177. handlerInitLocation() {
  178. uni.getLocation({
  179. type: 'gcj02',
  180. success: res => {
  181. this.queryParams.longitude = res.longitude;
  182. this.queryParams.latitude = res.latitude;
  183. let point = {
  184. latitude: res.latitude,
  185. longitude: res.longitude,
  186. };
  187. getCurrentLocation(point).then(rc => {
  188. this.queryParams.region = rc.data.id;
  189. this.handlerInitList();
  190. });
  191. },
  192. fail: rs => {
  193. uni.showToast({
  194. title: rs,
  195. icon: 'none',
  196. });
  197. },
  198. });
  199. },
  200. // 初始化列表
  201. handlerInitList() {
  202. getSellsDetail(this.queryParams.id, this.queryParams).then(res => {
  203. this.merchant = res.data.merchant;
  204. this.goods = res.data.goods;
  205. this.swiperList = res.data.merchant.banners.map(h => h.url);
  206. });
  207. // 获取锚点
  208. hotMerchant(this.queryParams.id).then()
  209. },
  210. // 点击拨打电话
  211. handlerMakeCall() {
  212. uni.makePhoneCall({
  213. phoneNumber: this.merchant.mobile,
  214. });
  215. },
  216. // 点击跳转到商品详情
  217. handlerSkipGoodsDetail(item, index) {
  218. uni.navigateTo({
  219. url: `/pages/client/clientPackage/serviceDetail?id=${item.id}`,
  220. });
  221. },
  222. // 预约
  223. handlerService(item, index) {
  224. this.addParams.merchantId = item.id;
  225. this.reserve_show = true;
  226. },
  227. // 购买
  228. handlerSkipBuy(item, index) {
  229. this.$store.commit('order/GET_ORDER_LIST',item)
  230. uni.navigateTo({
  231. url: `/pages/client/clientPackage/uptickOrder?id=${item.id}`,
  232. });
  233. },
  234. // 点击选择时间
  235. handlerSelectTime() {
  236. this.time_show = true;
  237. },
  238. // 点击预约确定按钮
  239. handlerDrawConfirmBtn() {
  240. if (this.addParams.appointTime == '') {
  241. uni.showToast({
  242. title: '请选择时间',
  243. icon: 'none',
  244. });
  245. return;
  246. } else if (this.addParams.mobile == '') {
  247. uni.showToast({
  248. title: '请填写手机号',
  249. icon: 'none',
  250. });
  251. return;
  252. } else if (!/^1[34578]\d{9}$/.test(this.addParams.mobile)) {
  253. uni.showToast({
  254. title: '请填写正确的手机号',
  255. icon: 'none',
  256. });
  257. return false;
  258. } else {
  259. addReservation(this.addParams.merchantId, this.addParams).then(res => {
  260. if (res.code == 200) {
  261. this.handlerInitList();
  262. this.reserve_show = false;
  263. uni.showToast({
  264. title: '预约成功',
  265. icon: 'success',
  266. });
  267. } else {
  268. uni.showToast({
  269. title: res.msg,
  270. icon: 'none',
  271. });
  272. return;
  273. }
  274. });
  275. }
  276. },
  277. formatter(type, value) {
  278. if (type === 'minute') {
  279. return `00`;
  280. }
  281. return value;
  282. },
  283. // 选择时间
  284. handlerTimeChange(e) {
  285. if (e) {
  286. this.addParams.appointTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
  287. this.template_time = this.addParams.appointTime;
  288. }
  289. },
  290. },
  291. };
  292. </script>
  293. <style lang="scss" scoped>
  294. .detail {
  295. min-height: 100vh;
  296. background-color: #efefef;
  297. }
  298. // 轮播图
  299. .carousel-map {
  300. background-color: #fff;
  301. padding: 0 20rpx;
  302. .carousel-item {
  303. height: 90rpx;
  304. display: flex;
  305. background-color: #fff7e0;
  306. border-radius: 0 0 10rpx 10rpx;
  307. .mark {
  308. background-color: #ff4b04;
  309. color: #fff;
  310. padding: 20rpx;
  311. border-radius: 0 0 0 10rpx;
  312. box-sizing: border-box;
  313. .mark-item {
  314. text-align: center;
  315. }
  316. }
  317. .good-item {
  318. font-size: 24rpx;
  319. color: #a39c85;
  320. line-height: 90rpx;
  321. margin-left: 40rpx;
  322. }
  323. }
  324. }
  325. // 商家信息
  326. .merchant-info {
  327. padding: 20rpx;
  328. background-color: #fff;
  329. margin-bottom: 20rpx;
  330. .info-title {
  331. display: flex;
  332. justify-content: center;
  333. font-size: 36rpx;
  334. font-weight: bold;
  335. margin: 20rpx 0;
  336. .info-mark {
  337. font-size: 12px;
  338. font-weight: normal;
  339. color: #999;
  340. margin: 20rpx 0 20rpx 30rpx;
  341. }
  342. }
  343. .info-tag {
  344. width: 140rpx;
  345. padding: 10rpx;
  346. text-align: center;
  347. border: 1px solid #5992bb;
  348. color: #5992bb;
  349. margin-bottom: 10rpx;
  350. }
  351. .info-item {
  352. display: flex;
  353. justify-content: space-between;
  354. .info-text {
  355. font-size: 28rpx;
  356. line-height: 58rpx;
  357. color: #212020;
  358. margin-left: 20rpx;
  359. .distance {
  360. font-size: 26rpx;
  361. color: #555252;
  362. font-weight: normal;
  363. }
  364. }
  365. .info-icon {
  366. display: flex;
  367. align-items: center;
  368. }
  369. .info-map {
  370. padding: 10rpx;
  371. font-size: 28rpx;
  372. margin-top: 120rpx;
  373. }
  374. }
  375. }
  376. .list {
  377. height: 220rpx;
  378. background-color: #fff;
  379. padding: 20rpx;
  380. margin-bottom: 20rpx;
  381. display: flex;
  382. .img {
  383. width: 140px;
  384. height: 100%;
  385. display: block;
  386. margin-right: 10rpx;
  387. }
  388. .listDetail {
  389. width: calc(100% - 160rpx);
  390. }
  391. .item-text {
  392. font-weight: bold;
  393. margin: 10rpx 0 10rpx;
  394. color: #333;
  395. }
  396. .item-flex {
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. font-size: 28rpx;
  401. margin: 0 20rpx 10rpx 0;
  402. color: #0d0d0d66;
  403. .star {
  404. display: flex;
  405. .line {
  406. margin-left: 16rpx;
  407. margin-top: 5rpx;
  408. font-size: 22rpx;
  409. }
  410. .points {
  411. color: #ff4b04;
  412. font-size: 22rpx;
  413. margin-top: 6rpx;
  414. margin-left: 10rpx;
  415. }
  416. }
  417. }
  418. .list-item {
  419. margin-top: 40rpx;
  420. display: flex;
  421. justify-content: space-between;
  422. align-items: center;
  423. .list-price {
  424. .item-l {
  425. color: #e35240;
  426. font-weight: bold;
  427. font-size: 32rpx;
  428. span {
  429. font-size: 40rpx;
  430. }
  431. }
  432. .item-r {
  433. color: #a8a8a8;
  434. margin-top: 10rpx;
  435. span {
  436. text-decoration: line-through;
  437. }
  438. }
  439. }
  440. .btn-box {
  441. display: flex;
  442. margin-left: 30rpx;
  443. .btn {
  444. font-size: 28rpx;
  445. height: 70rpx;
  446. }
  447. .btn1 {
  448. border-radius: 40rpx 0 0 40rpx;
  449. border: 2rpx solid #ec5729;
  450. color: #ec5729;
  451. background-color: #fff;
  452. }
  453. .btn2 {
  454. color: #fff;
  455. background-color: #ec5729;
  456. border-radius: 0 40rpx 40rpx 0;
  457. }
  458. }
  459. }
  460. }
  461. .draw-box {
  462. width: 560rpx;
  463. padding: 20rpx;
  464. .draw-title {
  465. font-size: 30rpx;
  466. font-weight: bold;
  467. color: #000;
  468. margin-bottom: 30rpx;
  469. }
  470. .draw-item {
  471. margin-bottom: 20rpx;
  472. .item-text {
  473. font-size: 28rpx;
  474. color: #000;
  475. padding-left: 20rpx;
  476. }
  477. .time-box {
  478. margin: 10rpx 20rpx;
  479. }
  480. }
  481. .draw-btn {
  482. width: 90%;
  483. background-color: #5992bb !important;
  484. color: #fff;
  485. font-size: 28rpx;
  486. border-radius: 20rpx;
  487. }
  488. }
  489. .time-text {
  490. color: #d4d6dc;
  491. }
  492. /* 分类 */
  493. .categoryList {
  494. background-color: #fff;
  495. }
  496. </style>