index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. </view>
  104. </template>
  105. <script>
  106. export default {
  107. components: {
  108. },
  109. data() {
  110. return {
  111. msgType:null,
  112. configContent:'',
  113. timeoutId:null,
  114. templateId:[],
  115. periodTimeList:[],
  116. userInfo: {},
  117. store: {},
  118. serviceObjectList: [],
  119. requestStatus: false,
  120. orderParam: {
  121. orderType: 1,
  122. serviceAttribute: 1,
  123. serviceStoreId: '',
  124. remark: '',
  125. serviceDate: '',
  126. childService: [
  127. // {
  128. // periodDate:'',//回显需要,不做参数
  129. // serviceObjectId: '',
  130. // facePhotoUrl:'', //回显需要,不做参数
  131. // nickName:'', //回显需要,不做参数
  132. // serviceUserId: '',
  133. // personName:'',//回显需要,不做参数
  134. // fee:'',//回显需要,不做参数
  135. // serviceStartTime: ''
  136. // }
  137. ]
  138. },
  139. takeNumberData:{
  140. pageNum:1,
  141. pageSize:10,
  142. dictType:'today_make_rule'
  143. },
  144. takeNumberRules:[],
  145. storeInfo: {},
  146. }
  147. },
  148. onLoad() {
  149. this.store = uni.getStorageSync('storeInfo')
  150. this.userInfo = uni.getStorageSync('userInfo')
  151. this.orderParam.serviceStoreId = this.store.storeId
  152. let date = new Date();
  153. this.orderParam.serviceDate = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' +
  154. date.getDate()).slice(-2)
  155. this.timeoutId = setTimeout(()=>{
  156. uni.showModal({
  157. title:'温馨提示',
  158. content:'您在下单页面停留太久,请重新进入!',
  159. showCancel:false,
  160. success:res=>{
  161. if (res.confirm){
  162. uni.switchTab({
  163. url: '/pages/index/index',
  164. })
  165. }
  166. }
  167. })
  168. },1000*60*5)
  169. },
  170. onShow() {
  171. //获取弹窗设置
  172. let sameDayQueueContent = uni.getStorageSync('same_day_queue_content');
  173. if (!sameDayQueueContent){
  174. this.getConfigKey('same_day_queue_content')
  175. }
  176. // 查询门店信息
  177. const data = uni.getStorageSync('storeInfo');
  178. this.store = uni.getStorageSync('storeInfo')
  179. this.userInfo = uni.getStorageSync('userInfo')
  180. if (!data) {
  181. // 获取位置信息查询门店列表数据
  182. this.getLocation();
  183. } else {
  184. this.storeInfo = data;
  185. }
  186. this.getServicePersonTime()
  187. this.getTemplateList()
  188. this.getSelectionRules(this.takeNumberData)
  189. },
  190. onUnload(){
  191. clearTimeout(this.timeoutId);
  192. },
  193. methods: {
  194. dialogConfirm(){
  195. this.configContent = '';
  196. },
  197. dialogClose(){
  198. uni.setStorageSync('same_day_queue_content',true);
  199. this.configContent = '';
  200. },
  201. getConfigKey(key){
  202. this.$api.getConfigKey({key:key}).then(res=>{
  203. console.log('获取到的配置信息',res.data.msg)
  204. if (res.data.msg){
  205. //打开弹窗
  206. this.configContent = res.data.msg
  207. this.$refs.sameDayQueuePopup.open()
  208. }
  209. })
  210. },
  211. // 获取门店列表数据
  212. getStoreListData(data) {
  213. let that = this;
  214. // 用户绑定门店
  215. this.$api.storeList(data).then((res) => {
  216. console.log(res.data.data[0])
  217. that.storeInfo = res.data.data[0]
  218. // 更新用户选择的门店信息
  219. uni.setStorageSync('storeInfo', res.data.data[0])
  220. })
  221. },
  222. // 获取经纬度信息
  223. getLocation() {
  224. let that = this
  225. console.log('+++++++++++++开始获取位置信息++++++++++++++++')
  226. uni.getLocation({
  227. type: 'gcj02',
  228. success: function (res) {
  229. console.log(res)
  230. let latitude = res.latitude; // 纬度
  231. let longitude = res.longitude; // 经度
  232. let speed = res.speed; // 速度
  233. let accuracy = res.accuracy; // 精确度
  234. // 在这里可以对位置信息进行处理
  235. console.log("纬度:" + latitude + ";经度" + longitude)
  236. that.reqParm.latitude = latitude
  237. that.reqParm.longitude = longitude
  238. uni.setStorageSync('location', that.reqParm)
  239. that.getStoreListData(that.reqParm)
  240. },
  241. fail:function (fail) {
  242. console.log('获取用户地址失败==》',fail)
  243. that.getStoreListData(that.reqParm)
  244. },
  245. complete:function (complete) {
  246. console.log('获取用户地址失败or成功==》',complete)
  247. }
  248. });
  249. },
  250. // 去选择门店
  251. gotoStoreChoose() {
  252. uni.setStorageSync('router','1')
  253. uni.navigateTo({
  254. url: '/storePages/store/store-choose?type=1',
  255. })
  256. },
  257. back(){
  258. uni.switchTab({
  259. url: '/pages/index/index',
  260. })
  261. },
  262. selectServiceTime(items,index,index2){
  263. items.forEach(e=>{
  264. e.select=false
  265. })
  266. let oidTime = this.orderParam.childService[index].serviceStartTime
  267. items[index2].select =true // 新选中的时间
  268. this.orderParam.childService[index].serviceStartTime = items[index2].label
  269. for (let i=0;i<this.orderParam.childService.length;i++){
  270. if (index != i){
  271. for (const time of this.orderParam.childService[i].periodTimeList) {
  272. if (time.label == oidTime){
  273. time.total = time.total + 1
  274. }
  275. if (time.label == items[index2].label) {
  276. time.total = time.total - 1
  277. }
  278. }
  279. }
  280. }
  281. this.$forceUpdate()
  282. },
  283. // 查询服务对象信息列表
  284. listServiceObject() {
  285. this.$api.listServiceObject(this.reqParm).then((res) => {
  286. this.serviceObjectList = res.data.data
  287. this.getImgUrlByBannerOssId(this.serviceObjectList);
  288. //不再默认选中第一个
  289. // if (this.periodTimeList.length >0){
  290. // this.orderParam.childService = [],
  291. // this.serviceObjectList[0].select = true
  292. // let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  293. // periodTimeList[0].select = true
  294. // let childService = {
  295. // periodDate: '',
  296. // serviceObjectId: this.serviceObjectList[0].id,
  297. // facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
  298. // nickName: this.serviceObjectList[0].nickName,
  299. // serviceUserId: -1,
  300. // fee: '',
  301. // serviceStartTime: periodTimeList[0].label,
  302. // periodTimeList:periodTimeList
  303. // }
  304. // this.orderParam.childService.push(childService)
  305. // }
  306. })
  307. },
  308. // 获取图片
  309. getImgUrlByBannerOssId(items) {
  310. for (let i = 0; i < items.length; i++) {
  311. if (items[i].facePhoto) {
  312. this.$api.getImgUrlByOssId({
  313. ossId: items[i].facePhoto
  314. }).then(res => {
  315. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  316. this.$set(this.serviceObjectList, i, items[i])
  317. if (i === 0) {
  318. this.orderParam.childService[0].facePhotoUrl = res.data.data[0].url.replace(
  319. /^http:/, "https:")
  320. }
  321. })
  322. }
  323. }
  324. },
  325. addServiceObject() {
  326. uni.navigateTo({
  327. url: '/myPages/ServiceObjectManagement/index'
  328. })
  329. },
  330. getServicePersonTime(){
  331. this.$api.getServicePersonTime({
  332. personId: -1,
  333. date: this.orderParam.serviceDate,
  334. storeId:this.store.storeId
  335. }).then(res=>{
  336. this.periodTimeList = res.data.data
  337. if (this.periodTimeList.length===0){
  338. uni.$u.toast('暂无可预约排班')
  339. }
  340. // 服务对象
  341. this.listServiceObject()
  342. })
  343. },
  344. selectServiceObject(item) {
  345. if (item.select) {
  346. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  347. selectServiceObject.serviceObjectId !== item.id)
  348. } else {
  349. let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  350. periodTimeList.forEach(i=>{
  351. this.orderParam.childService.forEach(i1=>{
  352. if (i.label == i1.serviceStartTime){
  353. i.total = i.total -1
  354. }
  355. })
  356. })
  357. let childService = {
  358. periodDate: '',
  359. serviceObjectId: item.id,
  360. facePhotoUrl: item.facePhotoUrl,
  361. nickName: item.nickName,
  362. serviceUserId: -1,
  363. fee: '',
  364. serviceStartTime: '',
  365. periodTimeList:periodTimeList
  366. }
  367. for (const time of periodTimeList) {
  368. if (time.total>0){
  369. time.select = true
  370. childService.serviceStartTime = time.label
  371. for (const childService of this.orderParam.childService) {
  372. for (const periodTime of childService.periodTimeList) {
  373. if (time.label == periodTime.label) {
  374. periodTime.total = periodTime.total - 1
  375. }
  376. }
  377. }
  378. break
  379. }
  380. }
  381. this.orderParam.childService.push(childService)
  382. }
  383. item.select = !item.select
  384. this.price = 0
  385. for (let childService of this.orderParam.childService) {
  386. this.price = this.price * 1 + childService.fee * 1
  387. }
  388. },
  389. getTemplateList(){
  390. this.$api.getTemplateList({
  391. type:1
  392. }).then(res=>{
  393. this.templateId=res.data.data.data.map(item=>{
  394. return item.priTmplId
  395. })
  396. })
  397. },
  398. getSelectionRules(data){
  399. this.$api.getSelectionRules(data).then(res=>{
  400. this.takeNumberRules = res.data.rows
  401. })
  402. },
  403. openSetting(){
  404. if (!this.userInfo.phone){
  405. uni.showModal({
  406. title:'温馨提示',
  407. content:'预约叫号是通过手机尾号进行查询,是否确认绑定手机号!',
  408. success:res=>{
  409. if (res.confirm){
  410. uni.navigateTo({
  411. url: '/myPages/setting/setting-telphone',
  412. })
  413. }
  414. }
  415. })
  416. return
  417. }
  418. uni.requestSubscribeMessage({
  419. tmplIds: this.templateId,
  420. success: (res) =>{
  421. let {errMsg,...param} = res
  422. console.log('+++++++++++++success+++++++++++++',param)
  423. this.$api.updateSubscribe(param).then(res=>{
  424. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  425. })
  426. },
  427. fail:(err)=>{
  428. console.log('+++++++++++++fail+++++++++++++',err)
  429. },
  430. complete:(complete)=>{
  431. console.log('+++++++++++++complete+++++++++++++',complete)
  432. this.commonGeneralOrder()
  433. }
  434. })
  435. },
  436. commonGeneralOrder() {
  437. if (!this.orderParam.childService.length) {
  438. uni.$u.toast('请选择服务对象')
  439. return
  440. }
  441. let flag = false
  442. this.orderParam.childService.forEach(i=>{
  443. if (!i.serviceStartTime){
  444. uni.$u.toast('请选择服务时段')
  445. flag= true
  446. }
  447. })
  448. if (flag){
  449. return;
  450. }
  451. if (this.requestStatus) {
  452. return;
  453. }
  454. this.requestStatus = true
  455. uni.showLoading({
  456. title: '加载中'
  457. });
  458. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  459. this.requestStatus = false
  460. uni.hideLoading();
  461. uni.$u.toast('预约成功')
  462. setTimeout(() => {
  463. uni.switchTab({
  464. url: '/pages/order/index'
  465. })
  466. }, 500)
  467. }).catch(err => {
  468. this.requestStatus = false
  469. })
  470. }
  471. }
  472. }
  473. </script>
  474. <style scoped lang="scss">
  475. @import './index.rpx.scss';
  476. .store-wrap {
  477. margin-top: 10rpx;
  478. background-color: white;
  479. .store-info {
  480. display: flex;
  481. .logo {
  482. width: 10%;
  483. text-align: center;
  484. display: flex;
  485. justify-content: center;
  486. align-items: center;
  487. image {
  488. width: 30px;
  489. height: 30px;
  490. }
  491. }
  492. .store-content {
  493. width: 90%;
  494. padding-bottom: 13px;
  495. .h-row {
  496. display: flex;
  497. align-items: center;
  498. justify-content: space-between;
  499. .store-desc {
  500. width: 90%;
  501. display: flex;
  502. line-height: 30px;
  503. font-size: 14px;
  504. .store-name {
  505. }
  506. }
  507. .arrow-right {
  508. text-align: right;
  509. margin: 0 auto;
  510. cursor: pointer;
  511. padding-top: 3px;
  512. width: 100px;
  513. display: flex;
  514. font-size: 14px;
  515. .change-store {
  516. text-align: right;
  517. color: #666;
  518. }
  519. image {
  520. width: 18px;
  521. height: 18px;
  522. }
  523. }
  524. .address {
  525. color: #999999;
  526. width: 450rpx;
  527. font-size: 24rpx;
  528. }
  529. .address1 {
  530. color: #999999;
  531. font-size: 24rpx;
  532. padding-right: 40rpx;
  533. }
  534. }
  535. }
  536. }
  537. .adress {
  538. font-size: 22rpx;
  539. white-space: nowrap;
  540. overflow: hidden;
  541. text-overflow: ellipsis;
  542. padding-left: 80rpx;
  543. color: #666;
  544. }
  545. }
  546. </style>