index.vue 27 KB

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