index.vue 16 KB

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