storeDetail.vue 13 KB

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