index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. this.userInfo = uni.getStorageSync('userInfo')
  169. if (!data) {
  170. // 获取位置信息查询门店列表数据
  171. this.getLocation();
  172. } else {
  173. this.storeInfo = data;
  174. }
  175. this.getServicePersonTime()
  176. this.getTemplateList()
  177. this.getSelectionRules(this.takeNumberData)
  178. },
  179. onUnload(){
  180. clearTimeout(this.timeoutId);
  181. },
  182. methods: {
  183. // 获取门店列表数据
  184. getStoreListData(data) {
  185. let that = this;
  186. // 用户绑定门店
  187. this.$api.storeList(data).then((res) => {
  188. console.log(res.data.data[0])
  189. that.storeInfo = res.data.data[0]
  190. // 更新用户选择的门店信息
  191. uni.setStorageSync('storeInfo', res.data.data[0])
  192. })
  193. },
  194. // 获取经纬度信息
  195. getLocation() {
  196. let that = this
  197. console.log('+++++++++++++开始获取位置信息++++++++++++++++')
  198. uni.getLocation({
  199. type: 'gcj02',
  200. success: function (res) {
  201. console.log(res)
  202. let latitude = res.latitude; // 纬度
  203. let longitude = res.longitude; // 经度
  204. let speed = res.speed; // 速度
  205. let accuracy = res.accuracy; // 精确度
  206. // 在这里可以对位置信息进行处理
  207. console.log("纬度:" + latitude + ";经度" + longitude)
  208. that.reqParm.latitude = latitude
  209. that.reqParm.longitude = longitude
  210. uni.setStorageSync('location', that.reqParm)
  211. that.getStoreListData(that.reqParm)
  212. },
  213. fail:function (fail) {
  214. console.log('获取用户地址失败==》',fail)
  215. that.getStoreListData(that.reqParm)
  216. },
  217. complete:function (complete) {
  218. console.log('获取用户地址失败or成功==》',complete)
  219. }
  220. });
  221. },
  222. // 去选择门店
  223. gotoStoreChoose() {
  224. uni.setStorageSync('router','1')
  225. uni.navigateTo({
  226. url: '/storePages/store/store-choose?type=1',
  227. })
  228. },
  229. back(){
  230. uni.switchTab({
  231. url: '/pages/index/index',
  232. })
  233. },
  234. selectServiceTime(items,index,index2){
  235. items.forEach(e=>{
  236. e.select=false
  237. })
  238. let oidTime = this.orderParam.childService[index].serviceStartTime
  239. items[index2].select =true // 新选中的时间
  240. this.orderParam.childService[index].serviceStartTime = items[index2].label
  241. for (let i=0;i<this.orderParam.childService.length;i++){
  242. if (index != i){
  243. for (const time of this.orderParam.childService[i].periodTimeList) {
  244. if (time.label == oidTime){
  245. time.total = time.total + 1
  246. }
  247. if (time.label == items[index2].label) {
  248. time.total = time.total - 1
  249. }
  250. }
  251. }
  252. }
  253. this.$forceUpdate()
  254. },
  255. // 查询服务对象信息列表
  256. listServiceObject() {
  257. this.$api.listServiceObject(this.reqParm).then((res) => {
  258. this.serviceObjectList = res.data.data
  259. this.getImgUrlByBannerOssId(this.serviceObjectList);
  260. //不再默认选中第一个
  261. // if (this.periodTimeList.length >0){
  262. // this.orderParam.childService = [],
  263. // this.serviceObjectList[0].select = true
  264. // let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  265. // periodTimeList[0].select = true
  266. // let childService = {
  267. // periodDate: '',
  268. // serviceObjectId: this.serviceObjectList[0].id,
  269. // facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
  270. // nickName: this.serviceObjectList[0].nickName,
  271. // serviceUserId: -1,
  272. // fee: '',
  273. // serviceStartTime: periodTimeList[0].label,
  274. // periodTimeList:periodTimeList
  275. // }
  276. // this.orderParam.childService.push(childService)
  277. // }
  278. })
  279. },
  280. // 获取图片
  281. getImgUrlByBannerOssId(items) {
  282. for (let i = 0; i < items.length; i++) {
  283. if (items[i].facePhoto) {
  284. this.$api.getImgUrlByOssId({
  285. ossId: items[i].facePhoto
  286. }).then(res => {
  287. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  288. this.$set(this.serviceObjectList, i, items[i])
  289. if (i === 0) {
  290. this.orderParam.childService[0].facePhotoUrl = res.data.data[0].url.replace(
  291. /^http:/, "https:")
  292. }
  293. })
  294. }
  295. }
  296. },
  297. addServiceObject() {
  298. uni.navigateTo({
  299. url: '/myPages/ServiceObjectManagement/index'
  300. })
  301. },
  302. getServicePersonTime(){
  303. this.$api.getServicePersonTime({
  304. personId: -1,
  305. date: this.orderParam.serviceDate,
  306. storeId:this.store.storeId
  307. }).then(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. this.takeNumberRules = res.data.rows
  371. })
  372. },
  373. openSetting(){
  374. if (!this.userInfo.phone){
  375. uni.showModal({
  376. title:'温馨提示',
  377. content:'预约叫号是通过手机尾号进行查询,是否确认绑定手机号!',
  378. success:res=>{
  379. if (res.confirm){
  380. uni.navigateTo({
  381. url: '/myPages/setting/setting-telphone',
  382. })
  383. }
  384. }
  385. })
  386. return
  387. }
  388. uni.requestSubscribeMessage({
  389. tmplIds: this.templateId,
  390. success: (res) =>{
  391. let {errMsg,...param} = res
  392. console.log('+++++++++++++success+++++++++++++',param)
  393. this.$api.updateSubscribe(param).then(res=>{
  394. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  395. })
  396. },
  397. fail:(err)=>{
  398. console.log('+++++++++++++fail+++++++++++++',err)
  399. },
  400. complete:(complete)=>{
  401. console.log('+++++++++++++complete+++++++++++++',complete)
  402. this.commonGeneralOrder()
  403. }
  404. })
  405. },
  406. commonGeneralOrder() {
  407. if (!this.orderParam.childService.length) {
  408. uni.$u.toast('请选择服务对象')
  409. return
  410. }
  411. let flag = false
  412. this.orderParam.childService.forEach(i=>{
  413. if (!i.serviceStartTime){
  414. uni.$u.toast('请选择服务时段')
  415. flag= true
  416. }
  417. })
  418. if (flag){
  419. return;
  420. }
  421. if (this.requestStatus) {
  422. return;
  423. }
  424. this.requestStatus = true
  425. uni.showLoading({
  426. title: '加载中'
  427. });
  428. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  429. this.requestStatus = false
  430. uni.hideLoading();
  431. uni.$u.toast('预约成功')
  432. setTimeout(() => {
  433. uni.switchTab({
  434. url: '/pages/order/index'
  435. })
  436. }, 500)
  437. }).catch(err => {
  438. this.requestStatus = false
  439. })
  440. }
  441. }
  442. }
  443. </script>
  444. <style scoped lang="scss">
  445. @import './index.rpx.scss';
  446. .store-wrap {
  447. margin-top: 10rpx;
  448. background-color: white;
  449. .store-info {
  450. display: flex;
  451. .logo {
  452. width: 10%;
  453. text-align: center;
  454. display: flex;
  455. justify-content: center;
  456. align-items: center;
  457. image {
  458. width: 30px;
  459. height: 30px;
  460. }
  461. }
  462. .store-content {
  463. width: 90%;
  464. padding-bottom: 13px;
  465. .h-row {
  466. display: flex;
  467. align-items: center;
  468. justify-content: space-between;
  469. .store-desc {
  470. width: 90%;
  471. display: flex;
  472. line-height: 30px;
  473. font-size: 14px;
  474. .store-name {
  475. }
  476. }
  477. .arrow-right {
  478. text-align: right;
  479. margin: 0 auto;
  480. cursor: pointer;
  481. padding-top: 3px;
  482. width: 100px;
  483. display: flex;
  484. font-size: 14px;
  485. .change-store {
  486. text-align: right;
  487. color: #666;
  488. }
  489. image {
  490. width: 18px;
  491. height: 18px;
  492. }
  493. }
  494. .address {
  495. color: #999999;
  496. width: 450rpx;
  497. font-size: 24rpx;
  498. }
  499. .address1 {
  500. color: #999999;
  501. font-size: 24rpx;
  502. padding-right: 40rpx;
  503. }
  504. }
  505. }
  506. }
  507. .adress {
  508. font-size: 22rpx;
  509. white-space: nowrap;
  510. overflow: hidden;
  511. text-overflow: ellipsis;
  512. padding-left: 80rpx;
  513. color: #666;
  514. }
  515. }
  516. </style>