index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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="address">距你1.8km</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. // this.orderParam.childService = [],
  263. // this.serviceObjectList[0].select = true
  264. // let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  265. // let childService = {
  266. // periodDate: '',
  267. // serviceObjectId: this.serviceObjectList[0].id,
  268. // facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
  269. // nickName: this.serviceObjectList[0].nickName,
  270. // serviceUserId: -1,
  271. // fee: '',
  272. // serviceStartTime: periodTimeList[0].label,
  273. // periodTimeList:periodTimeList
  274. // }
  275. // periodTimeList[0].select = true
  276. // this.orderParam.childService.push(childService)
  277. })
  278. },
  279. // 获取图片
  280. getImgUrlByBannerOssId(items) {
  281. for (let i = 0; i < items.length; i++) {
  282. if (items[i].facePhoto) {
  283. this.$api.getImgUrlByOssId({
  284. ossId: items[i].facePhoto
  285. }).then(res => {
  286. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  287. this.$set(this.serviceObjectList, i, items[i])
  288. if (i === 0) {
  289. this.orderParam.childService[0].facePhotoUrl = res.data.data[0].url.replace(
  290. /^http:/, "https:")
  291. }
  292. })
  293. }
  294. }
  295. },
  296. addServiceObject() {
  297. uni.navigateTo({
  298. url: '/myPages/ServiceObjectManagement/index'
  299. })
  300. },
  301. getServicePersonTime(){
  302. this.$api.getServicePersonTime({
  303. personId: -1,
  304. date: this.orderParam.serviceDate,
  305. storeId:this.store.storeId
  306. }).then(res=>{
  307. console.log("++++++++++++++++++res++++++++++++++++++++",res)
  308. this.periodTimeList = res.data.data
  309. if (this.periodTimeList.length===0){
  310. uni.$u.toast('暂无可预约排班')
  311. }
  312. // 服务对象
  313. this.listServiceObject()
  314. })
  315. },
  316. selectServiceObject(item) {
  317. if (item.select) {
  318. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  319. selectServiceObject.serviceObjectId !== item.id)
  320. } else {
  321. let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  322. periodTimeList.forEach(i=>{
  323. this.orderParam.childService.forEach(i1=>{
  324. if (i.label == i1.serviceStartTime){
  325. i.total = i.total -1
  326. }
  327. })
  328. })
  329. let childService = {
  330. periodDate: '',
  331. serviceObjectId: item.id,
  332. facePhotoUrl: item.facePhotoUrl,
  333. nickName: item.nickName,
  334. serviceUserId: -1,
  335. fee: '',
  336. serviceStartTime: '',
  337. periodTimeList:periodTimeList
  338. }
  339. for (const time of periodTimeList) {
  340. if (time.total>0){
  341. time.select = true
  342. childService.serviceStartTime = time.label
  343. for (const childService of this.orderParam.childService) {
  344. for (const periodTime of childService.periodTimeList) {
  345. if (time.label == periodTime.label) {
  346. periodTime.total = periodTime.total - 1
  347. }
  348. }
  349. }
  350. break
  351. }
  352. }
  353. this.orderParam.childService.push(childService)
  354. }
  355. item.select = !item.select
  356. this.price = 0
  357. for (let childService of this.orderParam.childService) {
  358. this.price = this.price * 1 + childService.fee * 1
  359. }
  360. },
  361. getTemplateList(){
  362. this.$api.getTemplateList().then(res=>{
  363. this.templateId=res.data.data.data.map(item=>{
  364. return item.priTmplId
  365. })
  366. })
  367. },
  368. getSelectionRules(data){
  369. this.$api.getSelectionRules(data).then(res=>{
  370. console.log(res.data.rows,'222222222222')
  371. this.takeNumberRules = res.data.rows
  372. })
  373. },
  374. openSetting(){
  375. if (!this.userInfo.phone){
  376. uni.showModal({
  377. title:'温馨提示',
  378. content:'预约叫号是通过手机尾号进行查询,是否确认绑定手机号!',
  379. success:res=>{
  380. if (res.confirm){
  381. uni.navigateTo({
  382. url: '/myPages/setting/setting-telphone',
  383. })
  384. }
  385. }
  386. })
  387. return
  388. }
  389. uni.requestSubscribeMessage({
  390. tmplIds: this.templateId,
  391. success: (res) =>{
  392. let {errMsg,...param} = res
  393. console.log('+++++++++++++success+++++++++++++',param)
  394. this.$api.updateSubscribe(param).then(res=>{
  395. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  396. })
  397. },
  398. fail:(err)=>{
  399. console.log('+++++++++++++fail+++++++++++++',err)
  400. },
  401. complete:(complete)=>{
  402. console.log('+++++++++++++complete+++++++++++++',complete)
  403. this.commonGeneralOrder()
  404. }
  405. })
  406. },
  407. commonGeneralOrder() {
  408. if (!this.orderParam.childService.length) {
  409. uni.$u.toast('请选择服务对象')
  410. return
  411. }
  412. let flag = false
  413. this.orderParam.childService.forEach(i=>{
  414. if (!i.serviceStartTime){
  415. uni.$u.toast('请选择服务时段')
  416. flag= true
  417. }
  418. })
  419. if (flag){
  420. return;
  421. }
  422. if (this.requestStatus) {
  423. return;
  424. }
  425. this.requestStatus = true
  426. uni.showLoading({
  427. title: '加载中'
  428. });
  429. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  430. this.requestStatus = false
  431. uni.hideLoading();
  432. uni.$u.toast('预约成功')
  433. setTimeout(() => {
  434. uni.switchTab({
  435. url: '/pages/order/index'
  436. })
  437. }, 500)
  438. }).catch(err => {
  439. this.requestStatus = false
  440. })
  441. }
  442. }
  443. }
  444. </script>
  445. <style scoped lang="scss">
  446. @import './index.rpx.scss';
  447. .store-wrap {
  448. margin-top: 10rpx;
  449. background-color: white;
  450. .store-info {
  451. display: flex;
  452. .logo {
  453. width: 10%;
  454. text-align: center;
  455. display: flex;
  456. justify-content: center;
  457. align-items: center;
  458. image {
  459. width: 30px;
  460. height: 30px;
  461. }
  462. }
  463. .store-content {
  464. width: 90%;
  465. padding-bottom: 13px;
  466. .h-row {
  467. display: flex;
  468. align-items: center;
  469. justify-content: space-between;
  470. .store-desc {
  471. width: 90%;
  472. display: flex;
  473. line-height: 30px;
  474. font-size: 14px;
  475. .store-name {
  476. }
  477. }
  478. .arrow-right {
  479. text-align: right;
  480. margin: 0 auto;
  481. cursor: pointer;
  482. padding-top: 3px;
  483. width: 100px;
  484. display: flex;
  485. font-size: 14px;
  486. .change-store {
  487. text-align: right;
  488. color: #666;
  489. }
  490. image {
  491. width: 18px;
  492. height: 18px;
  493. }
  494. }
  495. .address {
  496. color: #999999;
  497. font-size: 12px;
  498. padding-right: 12px;
  499. }
  500. }
  501. }
  502. }
  503. .adress {
  504. font-size: 22rpx;
  505. white-space: nowrap;
  506. overflow: hidden;
  507. text-overflow: ellipsis;
  508. padding-left: 80rpx;
  509. color: #666;
  510. }
  511. }
  512. </style>