collect.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <template>
  2. <view class="listAll">
  3. <view class="nodata" v-if="list.length == 0">
  4. <view>暂无记录</view>
  5. </view>
  6. <view class="list" v-else>
  7. <view class="item" v-for="(item,index) in list" :key="index">
  8. <view class="hot">
  9. <image src="../../static/identify/hot.png" mode="" />
  10. </view>
  11. <view class="itemL">
  12. <!-- <view class="hot" v-if="item.nB3 == 1"> -->
  13. <view class="img">
  14. <image :src="$globalData.publicUrl + item.js.cPortrait" />
  15. </view>
  16. <!-- <view class="new" v-if="item.nB2 == 1">
  17. new
  18. </view> -->
  19. <!-- <view class="status">{{item.nStatus ===1?'服务中' :'可服务'}}</view> -->
  20. </view>
  21. <view class="itemR">
  22. <view class="title">
  23. <view class="name">{{item.js.cNickName}}</view>
  24. <view class="intro_box">
  25. <view class="intro">
  26. 简介
  27. </view>
  28. <view class="intro_content">
  29. {{item.js.cJianjie}}
  30. </view>
  31. </view>
  32. <!-- <view class="address">
  33. <image src="../../static/identify/address.png" mode="" />{{item.distance}}km
  34. </view> -->
  35. </view>
  36. <view class="mark">
  37. <!-- 评分,默认5星 -->
  38. <view class="center">
  39. <image src="../../static/identify/star.png" mode="" />{{item.js.nStar}}人
  40. </view>
  41. <!-- 收藏数量 -->
  42. <view class=" center right">
  43. <image src="../../static/identify/my1.png" mode="" />
  44. <text>{{item.js.number}}</text> 人
  45. </view>
  46. <!-- 服务数量 -->
  47. <view class="right">
  48. <!-- <image src="../../static/identify/serve.png" mode="" /> -->
  49. 已服务: <text>{{item.js.nNum}}</text> 人
  50. </view>
  51. </view>
  52. <view class="num">
  53. <!-- <view class="free_box">
  54. <view class="free" v-if="free == 1">
  55. 07:30-20:00 &nbsp; {{item.daytimeMileage}}公里免出行费
  56. </view>
  57. <view class="free" v-if="free == 1">
  58. 20:00-07:30 &nbsp; {{item.nigthMileage}}公里免出行费
  59. </view>
  60. </view> -->
  61. <view class="free_box">
  62. <image src="../../static/identify/length.png" mode="" />
  63. {{item.js.distance}}km
  64. </view>
  65. <view class="btn" @click.stop="bookNow(item)">
  66. <!-- <view class="btn" @click="bookNow" data-id="{{item.id}}" data-fuwu="{{item.nStatus}}" data-distance="{{item.distance}}"> -->
  67. <text>立即预约</text>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- <view class="itemL" @click="godetails(item.js.id)">
  72. <image :src="$globalData.publicUrl + item.js.cPortrait" mode="scaleToFill" />
  73. </view>
  74. <view class="itemR">
  75. <view class="title" @click="godetails(item.js.id)">
  76. <view class="name">{{item.js.cName}}</view>
  77. <view class="status">{{item.js.nStatus ===1?'服务中' :'可服务'}}</view>
  78. </view>
  79. <view class="items" @click="godetails(item.js.id)">
  80. <view class="">
  81. <image src="../../static/identify/star.png" mode="" />{{item.js.nStar}}
  82. </view>
  83. <view class="">
  84. <image src="../../static/identify/serve.png" mode="" />{{item.js.nNum}}
  85. </view>
  86. <view class="">
  87. <image src="../../static/identify/collect.png" mode="" />{{item.js.number || '0'}}
  88. </view>
  89. </view>
  90. <view class="btn" @click="bookNow(item.js.id,item.js.nStatus)">
  91. <text>立即预约</text>
  92. </view>
  93. </view> -->
  94. </view>
  95. </view>
  96. <view class="dialog" v-if="dialogShow">
  97. <view class="closebox" @click="closeDialog"></view>
  98. <view class="dialog_content">
  99. <view class="lists" v-for="(item,index) in projects" :key="index">
  100. <view class="imgs">
  101. <image :src="$globalData.publicUrl + item.cCover" mode="" />
  102. </view>
  103. <view class="right">
  104. <view class="list_title">
  105. <view class="title">{{item.cTitle}}</view>
  106. <view class="time">{{item.nMinute}}分钟</view>
  107. </view>
  108. <view class="price">
  109. <view class="money">¥{{item.dPrice}}</view>
  110. <view class="counter">
  111. <view @click="decrease(index)">-</view>
  112. <text>{{ item.number }}</text>
  113. <view @click="increase(index)">+</view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="now" @click="nowYuyue"><text>立即预约</text></view>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. import {
  125. getCollect,
  126. engineerDetails,
  127. addOrder
  128. } from '../.././api/index.js'
  129. export default {
  130. data() {
  131. return {
  132. list: [],
  133. imageUrl: '',
  134. publicUrl: 'https://1910ca70.r6.cpolar.top', //图片前缀
  135. projects: [],
  136. dialogShow: false,
  137. count: 0,
  138. details: '',
  139. sum: 0,
  140. }
  141. },
  142. methods: {
  143. //预约
  144. nowYuyue() {
  145. const allCountsZero = this.projects.every(item => item.number === 0);
  146. if (allCountsZero) {
  147. uni.showToast({
  148. title: '请先选择项目!',
  149. duration: 1000,
  150. icon: 'none',
  151. })
  152. return
  153. } else {
  154. // console.log(this.data.projects,"project")
  155. var list = []
  156. this.projects.forEach(element => {
  157. if (element.number > 0) {
  158. element.sum = element.number * element.dPrice
  159. list.push(element)
  160. }
  161. });
  162. var total = 0
  163. for (let i = 0; i < list.length; i++) {
  164. total += list[i].sum;
  165. }
  166. var data = {
  167. cJsId: this.details.id,
  168. cGoods: list,
  169. cOpenId: uni.getStorageSync('wx_copenid'),
  170. dTotalMoney: total,
  171. }
  172. addOrder(data).then(res => {
  173. if (res.data.code == 200) {
  174. uni.navigateTo({
  175. // url: '../identify/orderDeatails/orderDeatails?orderNo=' + res.data.data.orderNo,
  176. url: '../identify/pay_order?orderNo=' + res.data.data.orderNo,
  177. })
  178. } else {
  179. uni.showModal({
  180. title: '提示',
  181. content: '你还没有添加地址哦!是否去添加?',
  182. confirmText: '确定', // 确定按钮的文字
  183. cancelText: '取消', // 取消按钮的文字
  184. success(res) {
  185. if (res.confirm) {
  186. setTimeout(() => {
  187. uni.navigateTo({
  188. url: '../my/addAddress/addAddress?type=1'
  189. })
  190. }, 100)
  191. // 用户点击确定按钮后的操作
  192. } else if (res.cancel) {}
  193. }
  194. })
  195. }
  196. })
  197. }
  198. },
  199. //预约弹窗关闭
  200. closeDialog() {
  201. this.dialogShow = false
  202. },
  203. //预约+1
  204. increase(idx) {
  205. this.projects[idx].number++;
  206. },
  207. //预约-1
  208. decrease(idx) {
  209. if (this.projects[idx].number > 0) {
  210. this.projects[idx].number--;
  211. }
  212. },
  213. //获取收藏列表
  214. getcollectList() {
  215. var data = {
  216. cWxOpenId: uni.getStorageSync('wx_copenid')
  217. }
  218. getCollect(data).then(res => {
  219. if (res.data.code == 200) {
  220. this.list = res.data.data
  221. console.log(this.list)
  222. }
  223. })
  224. },
  225. //跳转至商户详情
  226. godetails(id) {
  227. uni.navigateTo({
  228. url: '../identify/details?id=' + id
  229. })
  230. },
  231. //立即预约
  232. bookNow(id, nStatus) {
  233. if (nStatus === 1) {
  234. uni.showToast({
  235. title: '该商户不可预约!',
  236. icon: 'none'
  237. })
  238. return
  239. }
  240. this.projects = []
  241. var id = {
  242. id: id
  243. }
  244. engineerDetails(id).then(res => {
  245. // console.log(res.data.data,"1111111111111111")
  246. res.data.data.projects.forEach(element => {
  247. element.number = 0
  248. })
  249. this.details = res.data.data,
  250. this.projects = res.data.data.projects,
  251. this.dialogShow = true
  252. })
  253. },
  254. },
  255. onLoad() {},
  256. onShow() {
  257. this.getcollectList()
  258. },
  259. onHide() {
  260. this.dialogShow = false
  261. }
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. .listAll {
  266. height: 100vh;
  267. background: linear-gradient(152deg, #DCFFF8 0%, #F1FEFF 100%);
  268. }
  269. .nodata {
  270. text-align: center;
  271. padding: 200rpx 0;
  272. }
  273. .list {
  274. height: 100%;
  275. overflow-y: auto;
  276. // height: 100%;
  277. padding: 20rpx;
  278. // background: #F7FFFF;
  279. .item {
  280. width: 100%;
  281. // height: 208rpx;
  282. background: #FFFFFF;
  283. box-shadow: 0px 4rpx 12rpx 0px rgba(88, 209, 187, 0.1);
  284. border-radius: 24rpx 24rpx 24rpx 24rpx;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. // border: 1px solid rgb(212, 211, 211);
  289. margin-bottom: 20rpx;
  290. padding: 24rpx 32rpx;
  291. box-sizing: border-box;
  292. position: relative;
  293. .hot {
  294. position: absolute;
  295. top: 0;
  296. left: 0;
  297. width: 80rpx;
  298. height: 40rpx;
  299. z-index: 9;
  300. image {
  301. width: 100%;
  302. height: 100%;
  303. }
  304. }
  305. .itemL {
  306. position: relative;
  307. width: 160rpx;
  308. height: 100%;
  309. margin-right: 30rpx;
  310. display: flex;
  311. // flex-direction: column;
  312. align-items: center;
  313. justify-content: center;
  314. .img {
  315. width: 160rpx;
  316. height: 160rpx;
  317. // border-radius: 50%;
  318. // overflow: hidden;
  319. image {
  320. width: 100%;
  321. height: 100%;
  322. }
  323. }
  324. .status {
  325. font-size: 24rpx;
  326. position: absolute;
  327. bottom: 0px;
  328. background-color: #59b7b6;
  329. color: #fff;
  330. padding: 3px 10px;
  331. border-radius: 20px;
  332. // margin: 10px 0px;
  333. }
  334. .new {
  335. position: absolute;
  336. top: -20rpx;
  337. left: -16rpx;
  338. padding: 0rpx 5rpx;
  339. background-color: #f9792d;
  340. opacity: .8;
  341. border-radius: 10rpx;
  342. color: #f3f3f3;
  343. }
  344. }
  345. .itemR {
  346. flex: 1;
  347. height: 100%;
  348. .title {
  349. width: 100%;
  350. display: flex;
  351. justify-content: space-between;
  352. align-items: center;
  353. margin-bottom: 24rpx;
  354. .name {
  355. width: 70rpx;
  356. font-size: 32rpx;
  357. font-weight: 500;
  358. overflow: hidden;
  359. white-space: nowrap;
  360. text-overflow: ellipsis;
  361. margin-right: 24rpx;
  362. }
  363. .intro_box {
  364. flex: 1;
  365. display: flex;
  366. align-items: center;
  367. .intro {
  368. width: 64rpx;
  369. height: 32rpx;
  370. background: #DCFFFD;
  371. border-radius: 4rpx 4rpx 4rpx 4rpx;
  372. font-size: 24rpx;
  373. color: #20CAC2;
  374. text-align: center;
  375. line-height: 32rpx;
  376. margin-right: 20rpx;
  377. }
  378. .intro_content {
  379. width: 280rpx;
  380. white-space: nowrap;
  381. overflow: hidden;
  382. text-overflow: ellipsis;
  383. font-size: 24rpx;
  384. color: #666666;
  385. }
  386. }
  387. .address {
  388. // width: 40%;
  389. font-size: 26rpx;
  390. color: #585858;
  391. image {
  392. width: 30rpx;
  393. height: 30rpx;
  394. vertical-align: text-bottom;
  395. }
  396. }
  397. .status {
  398. color: #fff;
  399. background-color: #0ec891;
  400. font-size: 18rpx;
  401. padding: 5rpx 15rpx;
  402. border-radius: 30px;
  403. height: 30rpx;
  404. line-height: 30rpx;
  405. }
  406. }
  407. .mark {
  408. display: flex;
  409. color: #666666;
  410. .right {
  411. font-size: 24rpx;
  412. color: #666666;
  413. text {
  414. color: #666666;
  415. margin-right: 5px;
  416. }
  417. }
  418. .center {
  419. display: flex;
  420. align-items: center;
  421. margin-right: 20rpx;
  422. font-size: 24rpx;
  423. color: #666666;
  424. image {
  425. width: 30rpx;
  426. height: 30rpx;
  427. margin-right: 4rpx;
  428. }
  429. }
  430. }
  431. .num {
  432. display: flex;
  433. align-items: center;
  434. justify-content: space-between;
  435. // padding-left: 30rpx;
  436. color: #9e9e9e;
  437. margin-top: 24rpx;
  438. .free_box {
  439. font-size: 24rpx;
  440. color: #999999;
  441. display: flex;
  442. align-items: center;
  443. image {
  444. width: 32rpx;
  445. height: 32rpx;
  446. }
  447. }
  448. .btn {
  449. font-size: 30rpx;
  450. line-height: 24rpx;
  451. padding: 16rpx 24rpx;
  452. background: linear-gradient(135deg, #FF8B66 0%, #EE5B2D 100%);
  453. border-radius: 98rpx 98rpx 98rpx 98rpx;
  454. }
  455. }
  456. .items {
  457. display: flex;
  458. justify-content: space-between;
  459. padding: 10rpx 0;
  460. image {
  461. width: 30rpx;
  462. height: 30rpx;
  463. margin-right: 10rpx;
  464. vertical-align: text-top;
  465. }
  466. view {
  467. display: flex;
  468. align-items: center;
  469. }
  470. }
  471. .btn {
  472. font-size: 26rpx;
  473. background-color: #2cb8d4;
  474. border-radius: 30px;
  475. color: #fff;
  476. text-align: center;
  477. padding: 10rpx 0;
  478. }
  479. }
  480. }
  481. }
  482. .dialog {
  483. position: fixed;
  484. top: 0;
  485. left: 0;
  486. width: 100%;
  487. height: 100%;
  488. background: rgba(0, 0, 0, .5);
  489. z-index: 10;
  490. transition: transform 0.3s ease-out;
  491. .closebox {
  492. height: calc(50vh - 60rpx);
  493. width: 100%;
  494. }
  495. .now {
  496. position: absolute;
  497. bottom: 0;
  498. left: 0;
  499. width: 100%;
  500. text-align: center;
  501. height: 100rpx;
  502. background-color: #f7f8fa;
  503. padding-top: 10rpx;
  504. text {
  505. display: inline-block;
  506. height: 80rpx;
  507. line-height: 80rpx;
  508. width: 90%;
  509. background-color: #2cb8d4;
  510. color: #fff;
  511. border-radius: 50rpx;
  512. }
  513. }
  514. .dialog_content {
  515. background-color: #fff;
  516. position: absolute;
  517. bottom: 0;
  518. width: calc(100% - 60rpx);
  519. height: 50vh;
  520. overflow-y: scroll;
  521. border-top-left-radius: 20rpx;
  522. border-top-right-radius: 20rpx;
  523. padding: 30rpx;
  524. background-color: #f3f3f3;
  525. padding-bottom: 100rpx;
  526. .lists {
  527. background-color: #fff;
  528. margin-bottom: 20rpx;
  529. display: flex;
  530. justify-content: space-between;
  531. padding: 20rpx 10rpx;
  532. border-radius: 10rpx;
  533. .imgs {
  534. width: 240rpx;
  535. height: 160rpx;
  536. border-radius: 20rpx;
  537. overflow: hidden;
  538. image {
  539. width: 100%;
  540. height: 100%;
  541. }
  542. }
  543. .right {
  544. flex: 1;
  545. padding-left: 30rpx;
  546. .list_title {
  547. display: flex;
  548. justify-content: space-between;
  549. align-items: center;
  550. .title {
  551. font-size: 34rpx;
  552. font-weight: bold;
  553. }
  554. .time {
  555. font-size: 24rpx;
  556. }
  557. }
  558. .price {
  559. padding-top: 50rpx;
  560. display: flex;
  561. justify-content: space-between;
  562. .money {
  563. font-size: 42rpx;
  564. color: #e61b1b;
  565. font-weight: bold;
  566. }
  567. .counter {
  568. display: flex;
  569. view {
  570. width: 60rpx;
  571. height: 60rpx;
  572. line-height: 60rpx;
  573. background-color: #f7f8fa;
  574. text-align: center;
  575. border-radius: 60rpx;
  576. font-size: 50rpx;
  577. }
  578. text {
  579. width: 100rpx;
  580. text-align: center;
  581. line-height: 60rpx;
  582. }
  583. }
  584. }
  585. }
  586. }
  587. }
  588. }
  589. </style>