index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <view class="page">
  3. <view class="periodDate">
  4. <text>服务日期:{{orderParam.serviceDate}}</text>
  5. </view>
  6. <view class="store-wrap">
  7. <view class="store-info">
  8. <view class="logo">
  9. <image src="../../static/index/u55.png" mode=""></image>
  10. </view>
  11. <view @click="gotoStoreChoose()" class="store-content">
  12. <view class="h-row">
  13. <view class="store-desc">
  14. <view class="store-name">
  15. <view class="">{{ storeInfo.storeName }}</view>
  16. </view>
  17. </view>
  18. <view class="arrow-right">
  19. <view class="change-store">更换门店</view>
  20. <u-icon name="arrow-right" color="#333" size="16"></u-icon>
  21. </view>
  22. </view>
  23. <view class="h-row">
  24. <text class="address">地址:{{ storeInfo.address }}</text>
  25. <text class="address1">{{storeInfo.distanceDesc}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="flex-col group">
  31. <view class="serob"><text>服务对象</text></view>
  32. <u-grid :border="false" col="4">
  33. <u-grid-item v-for="(item,index) in serviceObjectList" :key="index">
  34. <view class="serobItem flex-col">
  35. <view class="serobImgView" @click="selectServiceObject(item)">
  36. <image class="serobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'">
  37. </image>
  38. </view>
  39. <text class="serobName">{{item.nickName || '未填写'}}</text>
  40. <view class="serobV" v-if="item.select === true">
  41. <image class="serobVicon" src="/static/order/ud20.png"></image>
  42. </view>
  43. </view>
  44. </u-grid-item>
  45. </u-grid>
  46. </view>
  47. <view class="flex-col group" v-for="(item,index) in orderParam.childService">
  48. <view class="flex-row ">
  49. <image class="selectSerobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'"></image>
  50. <text class="selectSerobName">{{item.nickName || '未填写'}}</text>
  51. </view>
  52. <view class="serob" >
  53. <text>服务时段</text>
  54. </view>
  55. <view v-if="!item.serviceStartTime" class="noTime flex-row justify-center">
  56. <text>暂无可用的服务时段</text>
  57. </view>
  58. <view v-else>
  59. <u-grid :border="false" col="5">
  60. <u-grid-item v-if="item2.total > 0" v-for="(item2,index2) in item.periodTimeList" :key="index2">
  61. <view class="timeItemView">
  62. <view class="flex-col justify-center timeItem " :class="{selectBack: item2.select}" @click="selectServiceTime(item.periodTimeList,index,index2)">
  63. <view class="flex-row justify-center">
  64. <text class="time">{{item2.label}}</text>
  65. </view>
  66. <!-- <view class="flex-row justify-center">-->
  67. <!-- <text class="price">¥{{item2.price}}</text>-->
  68. <!-- </view>-->
  69. </view>
  70. </view>
  71. </u-grid-item>
  72. </u-grid>
  73. </view>
  74. </view>
  75. <view class="flex-col group ">
  76. <view class="groupItemKey">
  77. <text>取号规则</text>
  78. </view>
  79. <view v-for=" (item,index) in takeNumberRules " class="serobReminder">
  80. <text>{{index+1}}.{{item.dictValue}}。</text>
  81. </view>
  82. <!-- <view class="serobReminder">-->
  83. <!-- <text>1.你已进入不挑师傅不挑时段的单剪造型占位理发服务。</text>-->
  84. <!-- </view>-->
  85. <!-- <view class="serobReminder">-->
  86. <!-- <text>2.预约需要一人一号。</text>-->
  87. <!-- </view>-->
  88. <!-- <view class="serobReminder">-->
  89. <!-- <text>3.到门店先签到,过时没有签到占位时段失效。</text>-->
  90. <!-- </view>-->
  91. <!-- <view class="serobReminder">-->
  92. <!-- <text>4.服务费用到店享受相应服务以后在另行收取。</text>-->
  93. <!-- </view>-->
  94. </view>
  95. <view class="tabBarLineHeight "></view>
  96. <view class="tabBarView">
  97. <view class="submitButton " @click="openSetting">提交</view>
  98. </view>
  99. <uni-popup ref="sameDayQueuePopup">
  100. <uni-popup-dialog :type="msgType" cancelText="不再提示" confirmText="已知晓" title="提示" :content="configContent" @confirm="dialogConfirm"
  101. @close="dialogClose"></uni-popup-dialog>
  102. </uni-popup>
  103. <uni-popup ref="showExpireEquityCard">
  104. <view class="flex-col justify-start expirePopup" >
  105. <view class="flex-row justify-center">
  106. <text class="popupTitle">到期提醒</text>
  107. </view>
  108. <scroll-view scroll-y class="flex-col justify-start" :class="[ expireEquityCard.length > 1 ? 'scroll-y1':'scroll-y']" >
  109. <view class="flex-row listView" v-for="(item,index) in expireEquityCard">
  110. <view class="h-text flex-col justify-center ">
  111. <view class="money">
  112. <text>{{ item.faceValue }}</text>
  113. </view>
  114. </view>
  115. <view class="h-center-content flex-col justify-around">
  116. <view class="h-value">
  117. <text>{{ item.title }}</text>
  118. </view>
  119. <view class="title">
  120. 服务对象:{{ item.serviceObjectName || '' }}
  121. </view>
  122. <view class="title">
  123. 适用门店:{{ item.useStoreDesc || '' }} {{ item.use_store_desc || '' }} {{ item.useStoreDesc || '' }} {{ item.useStoreDesc || '' }}
  124. </view>
  125. <view class="title">
  126. 到期时间:{{ item.effectiveEndTime.slice(0,10) }}
  127. </view>
  128. </view>
  129. <view class="h-right-content flex-col justify-center ">
  130. <view class="btn" @click="navigateTo(item)">
  131. <text>续费</text>
  132. </view>
  133. </view>
  134. </view>
  135. </scroll-view>
  136. </view>
  137. </uni-popup>
  138. </view>
  139. </template>
  140. <script>
  141. export default {
  142. components: {
  143. },
  144. data() {
  145. return {
  146. msgType:null,
  147. configContent:'',
  148. timeoutId:null,
  149. templateId:[],
  150. periodTimeList:[],
  151. userInfo: {},
  152. store: {},
  153. serviceObjectList: [],
  154. requestStatus: false,
  155. orderParam: {
  156. orderType: 1,
  157. serviceAttribute: 1,
  158. serviceStoreId: '',
  159. remark: '',
  160. serviceDate: '',
  161. childService: [
  162. // {
  163. // periodDate:'',//回显需要,不做参数
  164. // serviceObjectId: '',
  165. // facePhotoUrl:'', //回显需要,不做参数
  166. // nickName:'', //回显需要,不做参数
  167. // serviceUserId: '',
  168. // personName:'',//回显需要,不做参数
  169. // fee:'',//回显需要,不做参数
  170. // serviceStartTime: ''
  171. // }
  172. ]
  173. },
  174. takeNumberData:{
  175. pageNum:1,
  176. pageSize:10,
  177. dictType:'today_make_rule'
  178. },
  179. takeNumberRules:[],
  180. storeInfo: {},
  181. expireEquityCard:[], //过期的权益卡
  182. }
  183. },
  184. onLoad() {
  185. this.store = uni.getStorageSync('storeInfo')
  186. this.userInfo = uni.getStorageSync('userInfo')
  187. this.orderParam.serviceStoreId = this.store.storeId
  188. let date = new Date();
  189. this.orderParam.serviceDate = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' +
  190. date.getDate()).slice(-2)
  191. this.timeoutId = setTimeout(()=>{
  192. uni.showModal({
  193. title:'温馨提示',
  194. content:'您在下单页面停留太久,请重新进入!',
  195. showCancel:false,
  196. success:res=>{
  197. if (res.confirm){
  198. uni.switchTab({
  199. url: '/pages/index/index',
  200. })
  201. }
  202. }
  203. })
  204. },1000*60*5)
  205. this.getExpireEquityCard();
  206. },
  207. onShow() {
  208. //获取弹窗设置
  209. let sameDayQueueContent = uni.getStorageSync('same_day_queue_content');
  210. if (!sameDayQueueContent){
  211. this.getConfigKey('same_day_queue_content')
  212. }
  213. // 查询门店信息
  214. const data = uni.getStorageSync('storeInfo');
  215. this.store = uni.getStorageSync('storeInfo')
  216. this.userInfo = uni.getStorageSync('userInfo')
  217. if (!data) {
  218. // 获取位置信息查询门店列表数据
  219. this.getLocation();
  220. } else {
  221. this.storeInfo = data;
  222. }
  223. this.getServicePersonTime()
  224. this.getTemplateList()
  225. this.getSelectionRules(this.takeNumberData)
  226. this.orderParam.childService = []
  227. },
  228. onUnload(){
  229. clearTimeout(this.timeoutId);
  230. },
  231. methods: {
  232. navigateTo(item){
  233. if(item.activityId){
  234. let list = item.activityId.split(',')
  235. if (list.length == 1){
  236. uni.navigateTo({
  237. url:'/orderPages/activityDetail/activityDetail?id=' + item.activityId
  238. })
  239. }else {
  240. uni.navigateTo({
  241. url:'/orderPages/activityList/activityList'
  242. })
  243. }
  244. }else{
  245. uni.navigateTo({
  246. url:'/orderPages/activityList/activityList'
  247. })
  248. }
  249. },
  250. getExpireEquityCard(){
  251. this.$api.getExpireEquityCard().then((res)=>{
  252. this.expireEquityCard = res.data.data;
  253. if (this.expireEquityCard.length > 0){
  254. this.$refs.showExpireEquityCard.open()
  255. }
  256. })
  257. },
  258. dialogConfirm(){
  259. this.configContent = '';
  260. },
  261. dialogClose(){
  262. uni.setStorageSync('same_day_queue_content',true);
  263. this.configContent = '';
  264. },
  265. getConfigKey(key){
  266. this.$api.getConfigKey({key:key}).then(res=>{
  267. console.log('获取到的配置信息',res.data.msg)
  268. if (res.data.msg){
  269. //打开弹窗
  270. this.configContent = res.data.msg
  271. this.$refs.sameDayQueuePopup.open()
  272. }
  273. })
  274. },
  275. // 获取门店列表数据
  276. getStoreListData(data) {
  277. let that = this;
  278. // 用户绑定门店
  279. this.$api.storeList(data).then((res) => {
  280. console.log(res.data.data[0])
  281. that.storeInfo = res.data.data[0]
  282. // 更新用户选择的门店信息
  283. uni.setStorageSync('storeInfo', res.data.data[0])
  284. })
  285. },
  286. // 获取经纬度信息
  287. getLocation() {
  288. let that = this
  289. console.log('+++++++++++++开始获取位置信息++++++++++++++++')
  290. uni.getLocation({
  291. type: 'gcj02',
  292. success: function (res) {
  293. console.log(res)
  294. let latitude = res.latitude; // 纬度
  295. let longitude = res.longitude; // 经度
  296. let speed = res.speed; // 速度
  297. let accuracy = res.accuracy; // 精确度
  298. // 在这里可以对位置信息进行处理
  299. console.log("纬度:" + latitude + ";经度" + longitude)
  300. that.reqParm.latitude = latitude
  301. that.reqParm.longitude = longitude
  302. uni.setStorageSync('location', that.reqParm)
  303. that.getStoreListData(that.reqParm)
  304. },
  305. fail:function (fail) {
  306. console.log('获取用户地址失败==》',fail)
  307. that.getStoreListData(that.reqParm)
  308. },
  309. complete:function (complete) {
  310. console.log('获取用户地址失败or成功==》',complete)
  311. }
  312. });
  313. },
  314. // 去选择门店
  315. gotoStoreChoose() {
  316. uni.setStorageSync('router','1')
  317. uni.navigateTo({
  318. url: '/storePages/store/store-choose?type=1',
  319. })
  320. },
  321. back(){
  322. uni.switchTab({
  323. url: '/pages/index/index',
  324. })
  325. },
  326. selectServiceTime(items,index,index2){
  327. items.forEach(e=>{
  328. e.select=false
  329. })
  330. let oidTime = this.orderParam.childService[index].serviceStartTime
  331. items[index2].select =true // 新选中的时间
  332. this.orderParam.childService[index].serviceStartTime = items[index2].label
  333. for (let i=0;i<this.orderParam.childService.length;i++){
  334. if (index != i){
  335. for (const time of this.orderParam.childService[i].periodTimeList) {
  336. if (time.label == oidTime){
  337. time.total = time.total + 1
  338. }
  339. if (time.label == items[index2].label) {
  340. time.total = time.total - 1
  341. }
  342. }
  343. }
  344. }
  345. this.$forceUpdate()
  346. },
  347. // 查询服务对象信息列表
  348. listServiceObject() {
  349. this.$api.listServiceObject(this.reqParm).then((res) => {
  350. this.serviceObjectList = res.data.data
  351. this.getImgUrlByBannerOssId(this.serviceObjectList);
  352. //不再默认选中第一个
  353. // if (this.periodTimeList.length >0){
  354. // this.orderParam.childService = [],
  355. // this.serviceObjectList[0].select = true
  356. // let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  357. // periodTimeList[0].select = true
  358. // let childService = {
  359. // periodDate: '',
  360. // serviceObjectId: this.serviceObjectList[0].id,
  361. // facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
  362. // nickName: this.serviceObjectList[0].nickName,
  363. // serviceUserId: -1,
  364. // fee: '',
  365. // serviceStartTime: periodTimeList[0].label,
  366. // periodTimeList:periodTimeList
  367. // }
  368. // this.orderParam.childService.push(childService)
  369. // }
  370. })
  371. },
  372. // 获取图片
  373. getImgUrlByBannerOssId(items) {
  374. for (let i = 0; i < items.length; i++) {
  375. if (items[i].facePhoto) {
  376. this.$api.getImgUrlByOssId({
  377. ossId: items[i].facePhoto
  378. }).then(res => {
  379. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  380. this.$set(this.serviceObjectList, i, items[i])
  381. if (i === 0) {
  382. this.orderParam.childService[0].facePhotoUrl = res.data.data[0].url.replace(
  383. /^http:/, "https:")
  384. }
  385. })
  386. }
  387. }
  388. },
  389. addServiceObject() {
  390. uni.navigateTo({
  391. url: '/myPages/ServiceObjectManagement/index'
  392. })
  393. },
  394. getServicePersonTime(){
  395. this.$api.getServicePersonTime({
  396. personId: -1,
  397. date: this.orderParam.serviceDate,
  398. storeId:this.store.storeId
  399. }).then(res=>{
  400. this.periodTimeList = res.data.data
  401. if (this.periodTimeList.length===0){
  402. uni.$u.toast('暂无可预约排班')
  403. }
  404. // 服务对象
  405. this.listServiceObject()
  406. })
  407. },
  408. selectServiceObject(item) {
  409. if (item.select) {
  410. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  411. selectServiceObject.serviceObjectId !== item.id)
  412. } else {
  413. let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  414. periodTimeList.forEach(i=>{
  415. this.orderParam.childService.forEach(i1=>{
  416. if (i.label == i1.serviceStartTime){
  417. i.total = i.total -1
  418. }
  419. })
  420. })
  421. let childService = {
  422. periodDate: '',
  423. serviceObjectId: item.id,
  424. facePhotoUrl: item.facePhotoUrl,
  425. nickName: item.nickName,
  426. serviceUserId: -1,
  427. fee: '',
  428. serviceStartTime: '',
  429. periodTimeList:periodTimeList
  430. }
  431. for (const time of periodTimeList) {
  432. if (time.total>0){
  433. time.select = true
  434. childService.serviceStartTime = time.label
  435. for (const childService of this.orderParam.childService) {
  436. for (const periodTime of childService.periodTimeList) {
  437. if (time.label == periodTime.label) {
  438. periodTime.total = periodTime.total - 1
  439. }
  440. }
  441. }
  442. break
  443. }
  444. }
  445. this.orderParam.childService.push(childService)
  446. }
  447. item.select = !item.select
  448. this.price = 0
  449. for (let childService of this.orderParam.childService) {
  450. this.price = this.price * 1 + childService.fee * 1
  451. }
  452. },
  453. getTemplateList(){
  454. this.$api.getTemplateList({
  455. type:1
  456. }).then(res=>{
  457. this.templateId=res.data.data.data.map(item=>{
  458. return item.priTmplId
  459. })
  460. })
  461. },
  462. getSelectionRules(data){
  463. this.$api.getSelectionRules(data).then(res=>{
  464. this.takeNumberRules = res.data.rows
  465. })
  466. },
  467. openSetting(){
  468. if (!this.userInfo.phone){
  469. uni.showModal({
  470. title:'温馨提示',
  471. content:'预约叫号是通过手机尾号进行查询,是否确认绑定手机号!',
  472. success:res=>{
  473. if (res.confirm){
  474. uni.navigateTo({
  475. url: '/myPages/setting/setting-telphone',
  476. })
  477. }
  478. }
  479. })
  480. return
  481. }
  482. uni.requestSubscribeMessage({
  483. tmplIds: this.templateId,
  484. success: (res) =>{
  485. let {errMsg,...param} = res
  486. console.log('+++++++++++++success+++++++++++++',param)
  487. this.$api.updateSubscribe(param).then(res=>{
  488. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  489. })
  490. },
  491. fail:(err)=>{
  492. console.log('+++++++++++++fail+++++++++++++',err)
  493. },
  494. complete:(complete)=>{
  495. console.log('+++++++++++++complete+++++++++++++',complete)
  496. this.commonGeneralOrder()
  497. }
  498. })
  499. },
  500. commonGeneralOrder() {
  501. if (!this.orderParam.childService.length) {
  502. uni.$u.toast('请选择服务对象')
  503. return
  504. }
  505. let flag = false
  506. this.orderParam.childService.forEach(i=>{
  507. if (!i.serviceStartTime){
  508. uni.$u.toast('请选择服务时段')
  509. flag= true
  510. }
  511. })
  512. if (flag){
  513. return;
  514. }
  515. if (this.requestStatus) {
  516. return;
  517. }
  518. this.requestStatus = true
  519. uni.showLoading({
  520. title: '加载中'
  521. });
  522. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  523. this.requestStatus = false
  524. uni.hideLoading();
  525. uni.$u.toast('预约成功')
  526. setTimeout(() => {
  527. uni.switchTab({
  528. url: '/pages/order/index'
  529. })
  530. }, 500)
  531. }).catch(err => {
  532. this.requestStatus = false
  533. })
  534. }
  535. }
  536. }
  537. </script>
  538. <style scoped lang="scss">
  539. @import './index.rpx.scss';
  540. .store-wrap {
  541. margin-top: 10rpx;
  542. background-color: white;
  543. .store-info {
  544. display: flex;
  545. .logo {
  546. width: 10%;
  547. text-align: center;
  548. display: flex;
  549. justify-content: center;
  550. align-items: center;
  551. image {
  552. width: 30px;
  553. height: 30px;
  554. }
  555. }
  556. .store-content {
  557. width: 90%;
  558. padding-bottom: 13px;
  559. .h-row {
  560. display: flex;
  561. align-items: center;
  562. justify-content: space-between;
  563. .store-desc {
  564. width: 90%;
  565. display: flex;
  566. line-height: 30px;
  567. font-size: 14px;
  568. .store-name {
  569. }
  570. }
  571. .arrow-right {
  572. text-align: right;
  573. margin: 0 auto;
  574. cursor: pointer;
  575. padding-top: 3px;
  576. width: 100px;
  577. display: flex;
  578. font-size: 14px;
  579. .change-store {
  580. text-align: right;
  581. color: #666;
  582. }
  583. image {
  584. width: 18px;
  585. height: 18px;
  586. }
  587. }
  588. .address {
  589. color: #999999;
  590. width: 450rpx;
  591. font-size: 24rpx;
  592. }
  593. .address1 {
  594. color: #999999;
  595. font-size: 24rpx;
  596. padding-right: 40rpx;
  597. }
  598. }
  599. }
  600. }
  601. .adress {
  602. font-size: 22rpx;
  603. white-space: nowrap;
  604. overflow: hidden;
  605. text-overflow: ellipsis;
  606. padding-left: 80rpx;
  607. color: #666;
  608. }
  609. }
  610. </style>