index.vue 30 KB

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