index.vue 15 KB

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