index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. <template>
  2. <view class="page">
  3. <!-- <view class="flex-row periodDate">-->
  4. <!-- <view class="flex-row">-->
  5. <!-- <text>服务日期:</text>-->
  6. <!-- </view>-->
  7. <!-- <picker @change="bindPickerChange" mode='selector' range-key="label" :value="periodDateIndex" :range="periodDateList">-->
  8. <!-- <view class="flex-row justify-between" :style="{width:'550rpx'}">-->
  9. <!-- <text>{{periodDate.label || '请选择服务日期' }}</text>-->
  10. <!-- <u-icon name="arrow-right" color="#666" size="18"></u-icon>-->
  11. <!-- </view>-->
  12. <!-- </picker>-->
  13. <!-- </view>-->
  14. <view class="dateTabs">
  15. <u-tabs :list="periodDateList" lineColor="#FFE05C" lineWidth="40" lineHeight="4" :activeStyle="{
  16. color: '#FFE05C',
  17. fontWeight: 'bold',
  18. transform: 'scale(1.05)'
  19. }" @click="clickPeriodDateList"></u-tabs>
  20. </view>
  21. <view class="store-wrap">
  22. <view class="store-info">
  23. <view class="logo">
  24. <image src="../../static/index/u55.png" mode=""></image>
  25. </view>
  26. <view @click="gotoStoreChoose()" class="store-content">
  27. <view class="h-row">
  28. <view class="store-desc">
  29. <view class="store-name">
  30. <view class="">{{ storeInfo.storeName }}</view>
  31. </view>
  32. </view>
  33. <view class="arrow-right">
  34. <view class="change-store">更换门店</view>
  35. <u-icon name="arrow-right" color="#333" size="16"></u-icon>
  36. </view>
  37. </view>
  38. <view class="h-row">
  39. <text class="address">地址:{{ storeInfo.address }}</text>
  40. <text class="address1">{{storeInfo.distanceDesc}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="flex-col group">
  46. <view class="serob"><text>服务对象</text></view>
  47. <u-grid :border="false" col="4">
  48. <u-grid-item v-for="(item,index) in serviceObjectList" :key="index">
  49. <view class="serobItem flex-col" >
  50. <view class="serobImgView" @click="selectServiceObject(item)">
  51. <image class="serobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'"></image>
  52. </view>
  53. <text class="serobName">{{item.nickName || '未填写'}}</text>
  54. <view class="serobV" v-if="item.select === true">
  55. <image class="serobVicon" src="/static/order/ud20.png"></image>
  56. </view>
  57. </view>
  58. </u-grid-item>
  59. </u-grid>
  60. <!-- <view class="serobReminder">-->
  61. <!-- <text>请注意,一人一号</text>-->
  62. <!-- </view>-->
  63. </view>
  64. <view class="flex-col group " v-for="(item, index) in orderParam.childService">
  65. <view class="flex-row " v-if="serviceObjectList.length>1">
  66. <image class="selectSerobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'"></image>
  67. <text class="selectSerobName">{{item.nickName || '未填写'}}</text>
  68. </view>
  69. <view class="serob">
  70. <text>服务人员以及预约费用</text>
  71. </view>
  72. <view>
  73. <u-grid col="4">
  74. <u-grid-item v-for="(item1,index1) in item.serviceTeacherList" :key="index1">
  75. <view class="serobItem flex-col" @click="selectServiceTeach(item.serviceTeacherList,index,index1)">
  76. <view class="serobImgView">
  77. <image class="serobImg" mode="aspectFill" :src="item1.facePhotoUrl || '/static/me/ud4.png'"></image>
  78. </view>
  79. <text class="serobName ">{{item1.personName || '未填写'}}</text>
  80. <view class="flex-row justify-center ">
  81. <!-- <u-icon name="rmb-circle" size="14"></u-icon>-->
  82. <text class="teachPrice">{{item1.fee}}</text>
  83. </view>
  84. <view class="serobV " v-if="item1.select">
  85. <image class="serobVicon" src="/static/order/ud20.png"></image>
  86. </view>
  87. </view>
  88. </u-grid-item>
  89. </u-grid>
  90. </view>
  91. <view class="serob" :style="{'marginTop':'32rpx'}">
  92. <text>服务时段</text>
  93. </view>
  94. <view v-if="!item.serviceStartTime" class="noTime flex-row justify-center">
  95. <text>暂无可用的服务时段</text>
  96. </view>
  97. <view v-else>
  98. <u-grid :border="false" col="5">
  99. <u-grid-item v-if="item2.total > 0" v-for="(item2,index2) in item.serviceTimeList" :key="index2">
  100. <view class="timeItemView">
  101. <view class="flex-col justify-center timeItem " :class="{selectBack: item2.select}" @click="selectServiceTime(item.serviceTimeList,index,index2)">
  102. <view class="flex-row justify-center">
  103. <text class="time">{{item2.label}}</text>
  104. </view>
  105. <!-- <view class="flex-row justify-center">-->
  106. <!-- <text class="price">¥{{item2.price}}</text>-->
  107. <!-- </view>-->
  108. </view>
  109. </view>
  110. </u-grid-item>
  111. </u-grid>
  112. </view>
  113. </view>
  114. <view class="flex-col group ">
  115. <view class="groupItemKey">
  116. <text>取号规则</text>
  117. </view>
  118. <view class="textareaView ">
  119. <view v-for=" (item,index) in takeNumberRules " class="serobReminder">
  120. <text>{{index+1}}.{{item.dictValue}}。</text>
  121. </view>
  122. <!-- <textarea v-model="orderParam.remark" placeholder-style="color:#999999;fontSize:28rpx"-->
  123. <!-- placeholder="如有其它特殊需求,请在此输入您的需求" />-->
  124. <!-- <view class="serobReminder">-->
  125. <!-- <text>1.预约需要一人一号。</text>-->
  126. <!-- </view>-->
  127. <!-- <view class="serobReminder">-->
  128. <!-- <text>2.目前支付费用为时段预约占位费。</text>-->
  129. <!-- </view>-->
  130. <!-- <view class="serobReminder">-->
  131. <!-- <text>3.服务费用到店享受相应服务以后在另行收取。</text>-->
  132. <!-- </view>-->
  133. <!-- <view class="serobReminder">-->
  134. <!-- <text>4.到门店先签到,过时没有签到占位时段失效。</text>-->
  135. <!-- </view>-->
  136. </view>
  137. </view>
  138. <view :style="{'height':'280rpx'}"></view>
  139. <view class="flex-col group2 ">
  140. <view v-if="recommendActivity" class="btnTitle1 flex-row justify-between">
  141. <view>
  142. <text>推荐活动:{{recommendActivity.title}}</text>
  143. <text style="margin-left: 10rpx;color: #999999" >({{recommendActivity.description}})</text>
  144. </view>
  145. <text class="btnRight1" @click="goDetail(recommendActivity)">去购买</text>
  146. </view>
  147. <view class="btnTitle flex-row">
  148. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18"
  149. @click="selectChange"></u-icon>
  150. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  151. <text :style="{'margin-left':'10rpx'}">请阅读并同意</text>
  152. <text :style="{'color':'red'}" @click="goTermsOfService">《预约需知》</text>
  153. </view>
  154. <view class="btn flex-row justify-between">
  155. <view>
  156. <text class="title">待支付</text>
  157. <text class="num">{{price}}</text>
  158. </view>
  159. <view class="btnRight" @click="openSetting">
  160. <text>提交</text>
  161. </view>
  162. </view>
  163. </view>
  164. <myPay ref="myPay" :selectBlPay="userInfo.balance *1 >= price *1" :balance="userInfo.balance" :totalAmount="price" :storeId="store.storeId"
  165. :orderNo="subOrderNo" @payResult="payResult" @improperClose="improperClose"></myPay>
  166. <uni-popup ref="reservationQueuePopup">
  167. <uni-popup-dialog :type="msgType" cancelText="不再提示" confirmText="已知晓" title="提示" :content="configContent" @confirm="dialogConfirm"
  168. @close="dialogClose"></uni-popup-dialog>
  169. </uni-popup>
  170. <uni-popup ref="showExpireEquityCard">
  171. <view class="flex-col justify-start expirePopup" >
  172. <view class="flex-row justify-center">
  173. <text class="popupTitle">到期提醒</text>
  174. </view>
  175. <scroll-view scroll-y class="flex-col justify-start" :class="[ expireEquityCard.length > 1 ? 'scroll-y1':'scroll-y']" >
  176. <view class="flex-row listView" v-for="(item,index) in expireEquityCard">
  177. <view class="h-text flex-col justify-center ">
  178. <view class="money">
  179. <text>{{ item.faceValue }}</text>
  180. </view>
  181. </view>
  182. <view class="h-center-content flex-col justify-around">
  183. <view class="h-value">
  184. <text>{{ item.title }}</text>
  185. </view>
  186. <view class="title1">
  187. 服务对象:{{ item.serviceObjectName || '' }}
  188. </view>
  189. <view class="title1">
  190. 适用门店:{{ item.useStoreDesc || '' }} {{ item.use_store_desc || '' }} {{ item.useStoreDesc || '' }} {{ item.useStoreDesc || '' }}
  191. </view>
  192. <view class="title1">
  193. 到期时间:{{ item.effectiveEndTime.slice(0,10) }}
  194. </view>
  195. </view>
  196. <view class="h-right-content flex-col justify-center ">
  197. <view class="btn1" @click="navigateTo(item)">
  198. <text>续费</text>
  199. </view>
  200. </view>
  201. </view>
  202. </scroll-view>
  203. </view>
  204. </uni-popup>
  205. </view>
  206. </template>
  207. <script>
  208. import myPay from '../../components/pay/pay';
  209. export default {
  210. components: {
  211. myPay
  212. },
  213. data() {
  214. return {
  215. recommendActivity:null,
  216. msgType:null,
  217. configContent:'',
  218. timeoutId:null,
  219. templateId:[],
  220. //服务对象列表
  221. serviceObjectList:[],
  222. //服务人员列表
  223. serviceTeacherList:[],
  224. userInfo: {},
  225. //服务门店
  226. store: {},
  227. //服务日期列表
  228. periodDateList:[],
  229. //当前选择的服务日期
  230. periodDate: {},
  231. //当前选择的日期下标
  232. periodDateIndex:0,
  233. //预约费用
  234. price: '0',
  235. //订单编号
  236. subOrderNo:'',
  237. selectIcon: true,
  238. orderParam:{
  239. orderType: 1,
  240. serviceAttribute: 2,
  241. serviceStoreId: '',
  242. remark: '',
  243. serviceDate:'',
  244. childService:[
  245. // {
  246. // serviceObjectId: '',
  247. // facePhotoUrl:'', //回显需要,不做参数
  248. // nickName:'', //回显需要,不做参数
  249. // serviceUserId: '',
  250. // personName:'',//回显需要,不做参数
  251. // fee:'',//回显需要,不做参数
  252. // serviceStartTime: '',
  253. // serviceTeacherList:[],//服务人员列表,回显需要,不做参数
  254. // serviceTimeList:[]//服务时段列表,回显需要,不做参数
  255. // }
  256. ]
  257. },
  258. takeNumberData:{
  259. pageNum:1,
  260. pageSize:10,
  261. dictType:'tomorrow_make_rule'
  262. },
  263. takeNumberRules:[],
  264. storeInfo: {},
  265. expireEquityCard:[], //过期的权益卡
  266. }
  267. },
  268. onLoad() {
  269. this.store = uni.getStorageSync('storeInfo')
  270. this.orderParam.serviceStoreId = this.store.storeId
  271. this.timeoutId = setTimeout(()=>{
  272. uni.showModal({
  273. title:'温馨提示',
  274. content:'您在下单页面停留太久,请重新进入!',
  275. showCancel:false,
  276. success:res=>{
  277. if (res.confirm){
  278. uni.switchTab({
  279. url: '/pages/index/index',
  280. })
  281. }
  282. }
  283. })
  284. },1000*60*5)
  285. this.getExpireEquityCard();
  286. this.getRecommendActivity();
  287. },
  288. onShow() {
  289. //获取弹窗设置
  290. let reservationQueueContent = uni.getStorageSync('reservation_queue_content');
  291. if (!reservationQueueContent){
  292. this.getConfigKey('reservation_queue_content')
  293. }
  294. this.userInfo = uni.getStorageSync('userInfo')
  295. // 查询门店信息
  296. const data = uni.getStorageSync('storeInfo');
  297. this.store = uni.getStorageSync('storeInfo')
  298. if (!data) {
  299. // 获取位置信息查询门店列表数据
  300. this.getLocation();
  301. } else {
  302. this.storeInfo = data;
  303. }
  304. this.orderParam.childService = []
  305. this.price = 0
  306. //获取排班日期
  307. this.selectDate()
  308. this.getTemplateList()
  309. this.getSelectionRules(this.takeNumberData)
  310. },
  311. onUnload(){
  312. clearTimeout(this.timeoutId);
  313. },
  314. methods: {
  315. goDetail(e){
  316. uni.navigateTo({
  317. url:'/orderPages/activityDetail/activityDetail?id=' + e.id
  318. })
  319. },
  320. getRecommendActivity(){
  321. this.$api.getRecommendActivity().then(res=>{
  322. this.recommendActivity = res.data.data
  323. })
  324. },
  325. navigateTo(item){
  326. if(item.activityId){
  327. let list = item.activityId.split(',')
  328. if (list.length == 1){
  329. uni.navigateTo({
  330. url:'/orderPages/activityDetail/activityDetail?id=' + item.activityId +'&renewServiceObjectId=' + item.serviceObjectId
  331. })
  332. }else {
  333. uni.navigateTo({
  334. url:'/orderPages/activityList/activityList?renewServiceObjectId=' + item.serviceObjectId + '&equityCardId=' + item.equityCardId
  335. })
  336. }
  337. }else{
  338. uni.navigateTo({
  339. url:'/orderPages/activityList/activityList'
  340. })
  341. }
  342. },
  343. getExpireEquityCard(){
  344. this.$api.getExpireEquityCard({
  345. serviceObjectId:0
  346. }).then((res)=>{
  347. this.expireEquityCard = res.data.data;
  348. // if (this.expireEquityCard.length > 0){
  349. // uni.showModal({
  350. // title:'温馨提示',
  351. // content:'您有' + this.expireEquityCard.length + '张权益卡即将到期',
  352. // confirmText:'立即续费',
  353. // success:(res)=>{
  354. // if (res.confirm) {
  355. // console.log('用户点击确定');
  356. // uni.navigateTo({
  357. // url:'/storePages/myRights/index'
  358. // })
  359. // } else if (res.cancel) {
  360. // console.log('用户点击取消');
  361. // }
  362. // }
  363. // })
  364. // }
  365. if (this.expireEquityCard.length > 0){
  366. this.$refs.showExpireEquityCard.open()
  367. }
  368. })
  369. },
  370. dialogConfirm(){
  371. this.configContent = '';
  372. },
  373. dialogClose(){
  374. uni.setStorageSync('reservation_queue_content',true);
  375. this.configContent = '';
  376. },
  377. getConfigKey(key){
  378. this.$api.getConfigKey({key:key}).then(res=>{
  379. console.log('获取到的配置信息',res.data.msg)
  380. if (res.data.msg){
  381. //打开弹窗
  382. this.configContent = res.data.msg
  383. this.$refs.reservationQueuePopup.open()
  384. }
  385. })
  386. },
  387. // 获取门店列表数据
  388. getStoreListData(data) {
  389. let that = this;
  390. // 用户绑定门店
  391. this.$api.storeList(data).then((res) => {
  392. that.storeInfo = res.data.data[0]
  393. // 更新用户选择的门店信息
  394. uni.setStorageSync('storeInfo', res.data.data[0])
  395. })
  396. },
  397. // 获取经纬度信息
  398. getLocation() {
  399. let that = this
  400. uni.getLocation({
  401. type: 'gcj02',
  402. success: function (res) {
  403. let latitude = res.latitude; // 纬度
  404. let longitude = res.longitude; // 经度
  405. let speed = res.speed; // 速度
  406. let accuracy = res.accuracy; // 精确度
  407. // 在这里可以对位置信息进行处理
  408. console.log("纬度:" + latitude + ";经度" + longitude)
  409. that.reqParm.latitude = latitude
  410. that.reqParm.longitude = longitude
  411. uni.setStorageSync('location', that.reqParm)
  412. that.getStoreListData(that.reqParm)
  413. },
  414. fail:function (fail) {
  415. that.getStoreListData(that.reqParm)
  416. },
  417. complete:function (complete) {
  418. console.log('获取用户地址失败or成功==》',complete)
  419. }
  420. });
  421. },
  422. // 去选择门店
  423. gotoStoreChoose() {
  424. uni.setStorageSync('router','2')
  425. uni.navigateTo({
  426. url: '/storePages/store/store-choose?type=1',
  427. })
  428. },
  429. back(){
  430. uni.switchTab({
  431. url: '/pages/index/index',
  432. })
  433. },
  434. clickPeriodDateList(e){
  435. this.periodDateIndex = e.index
  436. this.periodDate = e
  437. this.orderParam.serviceDate=this.periodDate.label
  438. //对所有子订单的服务人员及服务时段重新赋值
  439. this.getServicePerson(this.periodDate.label,true)
  440. },
  441. openSetting(){
  442. if (!this.userInfo.phone){
  443. uni.showModal({
  444. title:'温馨提示',
  445. content:'预约叫号是通过手机尾号进行查询,是否确认绑定手机号',
  446. success:res=>{
  447. if (res.confirm){
  448. uni.navigateTo({
  449. url: '/myPages/setting/setting-telphone',
  450. })
  451. }
  452. }
  453. })
  454. return
  455. }
  456. let flag = false
  457. this.orderParam.childService.forEach(i=>{
  458. if (!i.serviceStartTime || i.serviceStartTime == ''){
  459. uni.$u.toast('有服务对象没有选择服务时段')
  460. flag=true
  461. return
  462. }
  463. })
  464. if (flag){
  465. return;
  466. }
  467. uni.requestSubscribeMessage({
  468. tmplIds: this.templateId,
  469. success: (res) =>{
  470. let {errMsg,...param} = res
  471. this.$api.updateSubscribe(param).then(res=>{
  472. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  473. })
  474. },
  475. fail:(err)=>{
  476. console.log('+++++++++++++fail+++++++++++++',err)
  477. },
  478. complete:(complete)=>{
  479. this.commitOrder()
  480. }
  481. })
  482. },
  483. getTemplateList(){
  484. this.$api.getTemplateList({
  485. type:1
  486. }).then(res=>{
  487. this.templateId=res.data.data.data.map(item=>{
  488. return item.priTmplId
  489. })
  490. })
  491. },
  492. improperClose(){
  493. uni.switchTab({
  494. url: '/pages/order/index'
  495. })
  496. },
  497. bindPickerChange(e){
  498. if (e.detail.value == this.periodDateIndex){
  499. return
  500. }
  501. this.periodDateIndex = e.detail.value
  502. this.periodDate = this.periodDateList[e.detail.value]
  503. this.orderParam.serviceDate=this.periodDate.label
  504. //对所有子订单的服务人员及服务时段重新赋值
  505. this.getServicePerson(this.periodDate.label,true)
  506. },
  507. //获取排班日期
  508. selectDate() {
  509. this.$api.selectDate({
  510. organization: this.store.storeId
  511. }).then(res => {
  512. this.periodDate = res.data.data[0]
  513. this.periodDateList = res.data.data
  514. for (const argument of this.periodDateList) {
  515. let month = argument.label.substring(5,6) == 0 ? argument.label.substring(6,7) : argument.label.substring(5,7)
  516. let day = argument.label.substring(8,9) == 0 ? argument.label.substring(9,10) : argument.label.substring(8,10)
  517. argument.name =month + '月' + day +'日'
  518. }
  519. this.orderParam.serviceDate=this.periodDate.label
  520. this.getServicePerson(this.periodDate.label,false)
  521. })
  522. },
  523. // 查询服务工作人员列表
  524. getServicePerson(date,bindPickerChange) {
  525. this.$api.getServicePerson({
  526. storeId:this.store.storeId,
  527. date:date
  528. }).then((res) => {
  529. this.serviceTeacherList = res.data.data;
  530. if (this.serviceTeacherList.length > 0){
  531. this.serviceTeacherList[0].select = true
  532. this.getServicePersonUrl(this.serviceTeacherList);
  533. }
  534. if (bindPickerChange){
  535. if (this.orderParam.childService.length === 0){
  536. // this.selectServiceObject(this.serviceObjectList[0])
  537. }else {
  538. this.serviceObjectList.forEach(i=>{
  539. if (i.select){
  540. this.orderParam.childService=[]
  541. i.select = false
  542. this.selectServiceObject(i)
  543. }
  544. })
  545. }
  546. }else {
  547. this.listServiceObject()
  548. }
  549. })
  550. },
  551. getServicePersonUrl(items){
  552. for (let i = 0; i < items.length; i++) {
  553. if (items[i].facePhoto) {
  554. this.$api.getImgUrlByOssId({
  555. ossId: items[i].facePhoto
  556. }).then(res => {
  557. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  558. this.$set(this.serviceTeacherList, i, items[i])
  559. })
  560. }
  561. }
  562. },
  563. // 查询服务对象信息列表
  564. listServiceObject() {
  565. this.$api.listServiceObject(this.reqParm).then((res) => {
  566. this.serviceObjectList = res.data.data
  567. this.getServiceObjectUrl(this.serviceObjectList);
  568. })
  569. },
  570. // 获取图片
  571. getServiceObjectUrl(items) {
  572. for (let i = 0; i < items.length; i++) {
  573. if (items[i].facePhoto) {
  574. this.$api.getImgUrlByOssId({
  575. ossId: items[i].facePhoto
  576. }).then(res => {
  577. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  578. this.$set(this.serviceObjectList, i, items[i])
  579. })
  580. }
  581. if (i === 0){
  582. // this.selectServiceObject(items[i])
  583. }
  584. }
  585. },
  586. selectServiceObject(item) {
  587. if (!this.serviceTeacherList || this.serviceTeacherList.length==0){
  588. uni.showToast({
  589. icon: 'none',
  590. duration: 2000,
  591. title: '暂无可预约排班'
  592. });
  593. return
  594. }
  595. if (item.select) {
  596. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  597. selectServiceObject.serviceObjectId !== item.id)
  598. item.select = !item.select
  599. this.price = 0
  600. for (let childService of this.orderParam.childService) {
  601. this.price = this.price * 1 + childService.fee * 1
  602. this.price = this.price.toFixed(2)
  603. }
  604. } else {
  605. uni.showModal({
  606. title:"温馨提示",
  607. content:"当前默认门店为" + this.storeInfo.storeName + "是否需要更换",
  608. showCancel:false
  609. })
  610. this.$api.getServicePersonTime({
  611. personId: this.serviceTeacherList[0].personId,
  612. date: this.periodDate.label,
  613. storeId:this.store.storeId
  614. }).then(res => {
  615. item.select = !item.select
  616. let selectServiceObjectList = this.orderParam.childService
  617. let periodTimeList = res.data.data
  618. if (!res.data.data || res.data.data.length==0){
  619. //这里只为了断开技师列表的应用关系
  620. let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
  621. let serviceTeacherList = JSON.parse(serviceTeacherListStr)
  622. let childService ={
  623. serviceObjectId: item.id,
  624. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  625. nickName:item.nickName, //回显需要,不做参数
  626. serviceUserId: serviceTeacherList[0].personId,
  627. fee:0,//回显需要,不做参数
  628. serviceStartTime: '',
  629. serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
  630. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  631. }
  632. this.orderParam.childService.push(childService)
  633. this.price = 0
  634. for (let childService of this.orderParam.childService) {
  635. this.price = this.price * 1 + childService.fee * 1
  636. this.price = this.price.toFixed(2)
  637. }
  638. return
  639. }
  640. //选择服务对象时,获取的排班时间为全部技师的排班时间,所以只要某个时段被选过,那么这个时段的数量-1
  641. selectServiceObjectList.forEach(selectServiceObject =>{
  642. periodTimeList.forEach(periodTime =>{
  643. if (selectServiceObject.serviceStartTime == periodTime.label ){
  644. periodTime.total = periodTime.total - 1
  645. }
  646. })
  647. })
  648. let date = null //系统为当前服务对象分配的时间
  649. for (const time of periodTimeList) {
  650. if (time.total>0){
  651. time.select = true
  652. date = time
  653. //为当前服务对象分配时间段成功时,需要将以前的服务对象的可选择的时间段的total -1
  654. selectServiceObjectList.forEach(selectServiceObject =>{
  655. if (selectServiceObject.serviceUserId === -1){
  656. //如果子订单没有指定技师,则对应的时段-1
  657. selectServiceObject.serviceTimeList.forEach(t=>{
  658. if (t.label == date.label){
  659. t.total = t.total -1
  660. }
  661. })
  662. }else {
  663. selectServiceObject.serviceTimeList.forEach(t=>{
  664. //如果子订单指定技师,且该技师的服务时段未被选中,则对应的时段-1
  665. if (t.label == date.label && !t.select){
  666. t.total = t.total -1
  667. }
  668. })
  669. }
  670. })
  671. break
  672. }
  673. }
  674. //这里只为了断开技师列表的应用关系
  675. let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
  676. let serviceTeacherList = JSON.parse(serviceTeacherListStr)
  677. //创建子订单项
  678. let childService ={
  679. serviceObjectId: item.id,
  680. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  681. nickName:item.nickName, //回显需要,不做参数
  682. serviceUserId: serviceTeacherList[0].personId,
  683. fee:serviceTeacherList[0].fee,//回显需要,不做参数
  684. serviceStartTime: date.label,
  685. serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
  686. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  687. }
  688. this.orderParam.childService.push(childService)
  689. this.price = 0
  690. for (let childService of this.orderParam.childService) {
  691. this.price = this.price * 1 + childService.fee * 1
  692. this.price = this.price.toFixed(2)
  693. }
  694. })
  695. }
  696. },
  697. selectServiceTeach(items,index,index1){
  698. items.forEach(e=>{
  699. e.select=false
  700. })
  701. items[index1].select =true
  702. this.orderParam.childService[index].fee = items[index1].fee
  703. this.orderParam.childService[index].serviceUserId = items[index1].personId
  704. this.$api.getServicePersonTime({
  705. personId: items[index1].personId,
  706. date: this.periodDate.label,
  707. storeId:this.store.storeId
  708. }).then(res => {
  709. let serviceTimeList = res.data.data
  710. if (!serviceTimeList || serviceTimeList.length == 0){
  711. this.orderParam.childService[index].serviceStartTime = ''
  712. this.orderParam.childService[index].periodTimeList = []
  713. this.orderParam.childService[index].fee = 0
  714. this.price = 0
  715. for (let childService of this.orderParam.childService) {
  716. this.price = this.price * 1 + childService.fee * 1
  717. this.price = this.price.toFixed(2)
  718. }
  719. this.$forceUpdate()
  720. }else {
  721. let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
  722. (selectServiceObject.serviceUserId === items[index1].personId
  723. && selectServiceObject.serviceObjectId !== this.orderParam.childService[index].serviceObjectId)
  724. || selectServiceObject.serviceUserId === -1
  725. )
  726. selectServiceObjectList.forEach(selectServiceObject =>{
  727. serviceTimeList.forEach(periodTime =>{
  728. if (selectServiceObject.serviceStartTime === periodTime.label ){
  729. if (selectServiceObject.serviceUserId === -1){
  730. selectServiceObject.serviceTimeList.forEach(t=>{
  731. if (t.label == periodTime.label && t.total === 1){
  732. periodTime.total = periodTime.total - 1
  733. }
  734. })
  735. }else {
  736. periodTime.total = periodTime.total - 1
  737. }
  738. }
  739. })
  740. })
  741. for (const time of serviceTimeList) {
  742. if (time.total>0){
  743. time.select = true
  744. break
  745. }
  746. }
  747. serviceTimeList[0].select = true
  748. this.orderParam.childService[index].serviceStartTime= serviceTimeList[0].label,
  749. this.orderParam.childService[index].serviceTimeList= serviceTimeList
  750. }
  751. })
  752. this.price = 0
  753. for (let childService of this.orderParam.childService) {
  754. this.price = this.price * 1 + childService.fee * 1
  755. this.price = this.price.toFixed(2)
  756. }
  757. this.$forceUpdate()
  758. },
  759. selectServiceTime(items,index,index2){
  760. items.forEach(e=>{
  761. e.select=false
  762. })
  763. items[index2].select =true // 新选中的时间
  764. // let selectServiceObject = this.orderParam.childService[index] //旧的时间
  765. // this.orderParam.childService.forEach(i=>{
  766. // if (selectServiceObject.serviceUserId === -1){
  767. // i.serviceTimeList.forEach(t=>{
  768. // if (t.label == selectServiceObject.serviceStartTime && !t.select ){
  769. // console.log('-1----------加1')
  770. // t.total +=1
  771. // }
  772. // if (t.label == items[index2].serviceStartTime && i.serviceObjectId != selectServiceObject.serviceObjectId){
  773. // console.log('-1----------减1')
  774. // t.total -=1
  775. // }
  776. // })
  777. // }else {
  778. // if (selectServiceObject.serviceUserId == i.serviceUserId){
  779. // i.serviceTimeList.forEach(t=>{
  780. // if (t.label == selectServiceObject.serviceStartTime && !t.select ){
  781. // t.total +=1
  782. // }
  783. // if (t.label == items[index2].serviceStartTime && i.serviceObjectId != selectServiceObject.serviceObjectId){
  784. // t.total -=1
  785. // }
  786. // })
  787. // }
  788. // }
  789. // })
  790. this.orderParam.childService[index].serviceStartTime = items[index2].label
  791. this.$forceUpdate()
  792. },
  793. selectChange() {
  794. this.selectIcon = !this.selectIcon
  795. },
  796. goTermsOfService() {
  797. uni.navigateTo({
  798. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  799. })
  800. },
  801. //支付组件回调
  802. payResult(e){
  803. console.log(e)
  804. if(e.payResult){
  805. uni.showToast({
  806. title: '支付成功!'
  807. });
  808. }else {
  809. uni.showToast({
  810. title: e.res.data.msg,
  811. icon: 'error'
  812. });
  813. }
  814. setTimeout(()=>{
  815. uni.switchTab({
  816. url: '/pages/order/index'
  817. })
  818. },1000)
  819. },
  820. //提交订单
  821. commitOrder() {
  822. if (this.subOrderNo){
  823. this.$refs.myPay.openPopup()
  824. }else {
  825. if (!this.selectIcon) {
  826. uni.$u.toast('请阅读并同意《预约需知》')
  827. return;
  828. }
  829. if (this.orderParam.childService.length === 0) {
  830. uni.$u.toast('请选择服务对象')
  831. return;
  832. }
  833. if (this.requestStatus) {
  834. return;
  835. }
  836. this.requestStatus = true
  837. uni.showLoading({
  838. title: '加载中'
  839. });
  840. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  841. console.log('++++++++++++++++++订单提交+++++++++++', res)
  842. if (res.data.data.subOrderNo) {
  843. uni.hideLoading();
  844. this.subOrderNo = res.data.data.subOrderNo
  845. this.$refs.myPay.openPopup()
  846. } else {
  847. uni.hideLoading();
  848. uni.$u.toast('预约成功')
  849. setTimeout(() => {
  850. uni.switchTab({
  851. url: '/pages/order/index'
  852. })
  853. }, 500)
  854. }
  855. this.requestStatus = false
  856. }).catch(err => {
  857. this.requestStatus = false
  858. })
  859. }
  860. },
  861. getSelectionRules(data){
  862. this.$api.getSelectionRules(data).then(res=>{
  863. this.takeNumberRules = res.data.rows
  864. })
  865. },
  866. }
  867. }
  868. </script>
  869. <style scoped lang="scss">
  870. @import './index.rpx.scss';
  871. .store-wrap {
  872. margin-top: 10rpx;
  873. background-color: white;
  874. .store-info {
  875. display: flex;
  876. .logo {
  877. width: 10%;
  878. text-align: center;
  879. display: flex;
  880. justify-content: center;
  881. align-items: center;
  882. image {
  883. width: 30px;
  884. height: 30px;
  885. }
  886. }
  887. .store-content {
  888. width: 90%;
  889. padding-bottom: 13px;
  890. .h-row {
  891. display: flex;
  892. align-items: center;
  893. justify-content: space-between;
  894. .store-desc {
  895. width: 90%;
  896. display: flex;
  897. line-height: 30px;
  898. font-size: 14px;
  899. .store-name {
  900. }
  901. }
  902. .arrow-right {
  903. text-align: right;
  904. margin: 0 auto;
  905. cursor: pointer;
  906. padding-top: 3px;
  907. width: 100px;
  908. display: flex;
  909. font-size: 14px;
  910. .change-store {
  911. text-align: right;
  912. color: #666;
  913. }
  914. image {
  915. width: 18px;
  916. height: 18px;
  917. }
  918. }
  919. .address {
  920. color: #999999;
  921. width: 450rpx;
  922. font-size: 24rpx;
  923. }
  924. .address1 {
  925. color: #999999;
  926. font-size: 24rpx;
  927. padding-right: 40rpx;
  928. }
  929. }
  930. }
  931. }
  932. .adress {
  933. font-size: 22rpx;
  934. white-space: nowrap;
  935. overflow: hidden;
  936. text-overflow: ellipsis;
  937. padding-left: 80rpx;
  938. color: #666;
  939. }
  940. }
  941. </style>