index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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({
  384. type:1
  385. }).then(res=>{
  386. this.templateId=res.data.data.data.map(item=>{
  387. return item.priTmplId
  388. })
  389. })
  390. },
  391. improperClose(){
  392. uni.switchTab({
  393. url: '/pages/order/index'
  394. })
  395. },
  396. bindPickerChange(e){
  397. if (e.detail.value == this.periodDateIndex){
  398. return
  399. }
  400. this.periodDateIndex = e.detail.value
  401. this.periodDate = this.periodDateList[e.detail.value]
  402. this.orderParam.serviceDate=this.periodDate.label
  403. //对所有子订单的服务人员及服务时段重新赋值
  404. this.getServicePerson(this.periodDate.label,true)
  405. },
  406. //获取排班日期
  407. selectDate() {
  408. this.$api.selectDate({
  409. organization: this.store.storeId
  410. }).then(res => {
  411. this.periodDate = res.data.data[0]
  412. this.periodDateList = res.data.data
  413. for (const argument of this.periodDateList) {
  414. let month = argument.label.substring(5,6) == 0 ? argument.label.substring(6,7) : argument.label.substring(5,7)
  415. let day = argument.label.substring(8,9) == 0 ? argument.label.substring(9,10) : argument.label.substring(8,10)
  416. argument.name =month + '月' + day +'日'
  417. }
  418. this.orderParam.serviceDate=this.periodDate.label
  419. this.getServicePerson(this.periodDate.label,false)
  420. })
  421. },
  422. // 查询服务工作人员列表
  423. getServicePerson(date,bindPickerChange) {
  424. this.$api.getServicePerson({
  425. storeId:this.store.storeId,
  426. date:date
  427. }).then((res) => {
  428. this.serviceTeacherList = res.data.data;
  429. if (this.serviceTeacherList.length > 0){
  430. this.serviceTeacherList[0].select = true
  431. this.getServicePersonUrl(this.serviceTeacherList);
  432. }
  433. if (bindPickerChange){
  434. if (this.orderParam.childService.length === 0){
  435. // this.selectServiceObject(this.serviceObjectList[0])
  436. }else {
  437. this.serviceObjectList.forEach(i=>{
  438. if (i.select){
  439. this.orderParam.childService=[]
  440. i.select = false
  441. this.selectServiceObject(i)
  442. }
  443. })
  444. }
  445. }else {
  446. this.listServiceObject()
  447. }
  448. })
  449. },
  450. getServicePersonUrl(items){
  451. for (let i = 0; i < items.length; i++) {
  452. if (items[i].facePhoto) {
  453. this.$api.getImgUrlByOssId({
  454. ossId: items[i].facePhoto
  455. }).then(res => {
  456. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  457. this.$set(this.serviceTeacherList, i, items[i])
  458. })
  459. }
  460. }
  461. },
  462. // 查询服务对象信息列表
  463. listServiceObject() {
  464. this.$api.listServiceObject(this.reqParm).then((res) => {
  465. this.serviceObjectList = res.data.data
  466. this.getServiceObjectUrl(this.serviceObjectList);
  467. })
  468. },
  469. // 获取图片
  470. getServiceObjectUrl(items) {
  471. for (let i = 0; i < items.length; i++) {
  472. if (items[i].facePhoto) {
  473. this.$api.getImgUrlByOssId({
  474. ossId: items[i].facePhoto
  475. }).then(res => {
  476. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  477. this.$set(this.serviceObjectList, i, items[i])
  478. })
  479. }
  480. if (i === 0){
  481. // this.selectServiceObject(items[i])
  482. }
  483. }
  484. },
  485. selectServiceObject(item) {
  486. if (!this.serviceTeacherList || this.serviceTeacherList.length==0){
  487. uni.showToast({
  488. icon: 'none',
  489. duration: 2000,
  490. title: '暂无可预约排班'
  491. });
  492. return
  493. }
  494. if (item.select) {
  495. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  496. selectServiceObject.serviceObjectId !== item.id)
  497. item.select = !item.select
  498. this.price = 0
  499. for (let childService of this.orderParam.childService) {
  500. this.price = this.price * 1 + childService.fee * 1
  501. this.price = this.price.toFixed(2)
  502. }
  503. } else {
  504. this.$api.getServicePersonTime({
  505. personId: this.serviceTeacherList[0].personId,
  506. date: this.periodDate.label,
  507. storeId:this.store.storeId
  508. }).then(res => {
  509. item.select = !item.select
  510. let selectServiceObjectList = this.orderParam.childService
  511. let periodTimeList = res.data.data
  512. if (!res.data.data || res.data.data.length==0){
  513. //这里只为了断开技师列表的应用关系
  514. let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
  515. let serviceTeacherList = JSON.parse(serviceTeacherListStr)
  516. let childService ={
  517. serviceObjectId: item.id,
  518. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  519. nickName:item.nickName, //回显需要,不做参数
  520. serviceUserId: serviceTeacherList[0].personId,
  521. fee:0,//回显需要,不做参数
  522. serviceStartTime: '',
  523. serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
  524. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  525. }
  526. this.orderParam.childService.push(childService)
  527. this.price = 0
  528. for (let childService of this.orderParam.childService) {
  529. this.price = this.price * 1 + childService.fee * 1
  530. this.price = this.price.toFixed(2)
  531. }
  532. return
  533. }
  534. //选择服务对象时,获取的排班时间为全部技师的排班时间,所以只要某个时段被选过,那么这个时段的数量-1
  535. selectServiceObjectList.forEach(selectServiceObject =>{
  536. periodTimeList.forEach(periodTime =>{
  537. if (selectServiceObject.serviceStartTime == periodTime.label ){
  538. periodTime.total = periodTime.total - 1
  539. }
  540. })
  541. })
  542. let date = null //系统为当前服务对象分配的时间
  543. for (const time of periodTimeList) {
  544. if (time.total>0){
  545. time.select = true
  546. date = time
  547. //为当前服务对象分配时间段成功时,需要将以前的服务对象的可选择的时间段的total -1
  548. selectServiceObjectList.forEach(selectServiceObject =>{
  549. if (selectServiceObject.serviceUserId === -1){
  550. //如果子订单没有指定技师,则对应的时段-1
  551. selectServiceObject.serviceTimeList.forEach(t=>{
  552. if (t.label == date.label){
  553. t.total = t.total -1
  554. }
  555. })
  556. }else {
  557. selectServiceObject.serviceTimeList.forEach(t=>{
  558. //如果子订单指定技师,且该技师的服务时段未被选中,则对应的时段-1
  559. if (t.label == date.label && !t.select){
  560. t.total = t.total -1
  561. }
  562. })
  563. }
  564. })
  565. break
  566. }
  567. }
  568. //这里只为了断开技师列表的应用关系
  569. let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
  570. let serviceTeacherList = JSON.parse(serviceTeacherListStr)
  571. //创建子订单项
  572. let childService ={
  573. serviceObjectId: item.id,
  574. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  575. nickName:item.nickName, //回显需要,不做参数
  576. serviceUserId: serviceTeacherList[0].personId,
  577. fee:serviceTeacherList[0].fee,//回显需要,不做参数
  578. serviceStartTime: date.label,
  579. serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
  580. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  581. }
  582. this.orderParam.childService.push(childService)
  583. this.price = 0
  584. for (let childService of this.orderParam.childService) {
  585. this.price = this.price * 1 + childService.fee * 1
  586. this.price = this.price.toFixed(2)
  587. }
  588. })
  589. }
  590. },
  591. selectServiceTeach(items,index,index1){
  592. items.forEach(e=>{
  593. e.select=false
  594. })
  595. items[index1].select =true
  596. this.orderParam.childService[index].fee = items[index1].fee
  597. this.orderParam.childService[index].serviceUserId = items[index1].personId
  598. this.$api.getServicePersonTime({
  599. personId: items[index1].personId,
  600. date: this.periodDate.label,
  601. storeId:this.store.storeId
  602. }).then(res => {
  603. let serviceTimeList = res.data.data
  604. if (!serviceTimeList || serviceTimeList.length == 0){
  605. this.orderParam.childService[index].serviceStartTime = ''
  606. this.orderParam.childService[index].periodTimeList = []
  607. this.orderParam.childService[index].fee = 0
  608. this.price = 0
  609. for (let childService of this.orderParam.childService) {
  610. this.price = this.price * 1 + childService.fee * 1
  611. this.price = this.price.toFixed(2)
  612. }
  613. this.$forceUpdate()
  614. }else {
  615. let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
  616. (selectServiceObject.serviceUserId === items[index1].personId
  617. && selectServiceObject.serviceObjectId !== this.orderParam.childService[index].serviceObjectId)
  618. || selectServiceObject.serviceUserId === -1
  619. )
  620. selectServiceObjectList.forEach(selectServiceObject =>{
  621. serviceTimeList.forEach(periodTime =>{
  622. if (selectServiceObject.serviceStartTime === periodTime.label ){
  623. if (selectServiceObject.serviceUserId === -1){
  624. selectServiceObject.serviceTimeList.forEach(t=>{
  625. if (t.label == periodTime.label && t.total === 1){
  626. periodTime.total = periodTime.total - 1
  627. }
  628. })
  629. }else {
  630. periodTime.total = periodTime.total - 1
  631. }
  632. }
  633. })
  634. })
  635. for (const time of serviceTimeList) {
  636. if (time.total>0){
  637. time.select = true
  638. break
  639. }
  640. }
  641. serviceTimeList[0].select = true
  642. this.orderParam.childService[index].serviceStartTime= serviceTimeList[0].label,
  643. this.orderParam.childService[index].serviceTimeList= serviceTimeList
  644. }
  645. })
  646. this.price = 0
  647. for (let childService of this.orderParam.childService) {
  648. this.price = this.price * 1 + childService.fee * 1
  649. this.price = this.price.toFixed(2)
  650. }
  651. this.$forceUpdate()
  652. },
  653. selectServiceTime(items,index,index2){
  654. items.forEach(e=>{
  655. e.select=false
  656. })
  657. items[index2].select =true // 新选中的时间
  658. // let selectServiceObject = this.orderParam.childService[index] //旧的时间
  659. // this.orderParam.childService.forEach(i=>{
  660. // if (selectServiceObject.serviceUserId === -1){
  661. // i.serviceTimeList.forEach(t=>{
  662. // if (t.label == selectServiceObject.serviceStartTime && !t.select ){
  663. // console.log('-1----------加1')
  664. // t.total +=1
  665. // }
  666. // if (t.label == items[index2].serviceStartTime && i.serviceObjectId != selectServiceObject.serviceObjectId){
  667. // console.log('-1----------减1')
  668. // t.total -=1
  669. // }
  670. // })
  671. // }else {
  672. // if (selectServiceObject.serviceUserId == i.serviceUserId){
  673. // i.serviceTimeList.forEach(t=>{
  674. // if (t.label == selectServiceObject.serviceStartTime && !t.select ){
  675. // t.total +=1
  676. // }
  677. // if (t.label == items[index2].serviceStartTime && i.serviceObjectId != selectServiceObject.serviceObjectId){
  678. // t.total -=1
  679. // }
  680. // })
  681. // }
  682. // }
  683. // })
  684. this.orderParam.childService[index].serviceStartTime = items[index2].label
  685. this.$forceUpdate()
  686. },
  687. selectChange() {
  688. this.selectIcon = !this.selectIcon
  689. },
  690. goTermsOfService() {
  691. uni.navigateTo({
  692. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  693. })
  694. },
  695. //支付组件回调
  696. payResult(e){
  697. console.log(e)
  698. if(e.payResult){
  699. uni.showToast({
  700. title: '支付成功!'
  701. });
  702. }else {
  703. uni.showToast({
  704. title: e.res.data.msg,
  705. icon: 'error'
  706. });
  707. }
  708. setTimeout(()=>{
  709. uni.switchTab({
  710. url: '/pages/order/index'
  711. })
  712. },1000)
  713. },
  714. //提交订单
  715. commitOrder() {
  716. if (this.subOrderNo){
  717. this.$refs.myPay.openPopup()
  718. }else {
  719. if (!this.selectIcon) {
  720. uni.$u.toast('请阅读并同意《预约需知》')
  721. return;
  722. }
  723. if (this.orderParam.childService.length === 0) {
  724. uni.$u.toast('请选择服务对象')
  725. return;
  726. }
  727. if (this.requestStatus) {
  728. return;
  729. }
  730. this.requestStatus = true
  731. uni.showLoading({
  732. title: '加载中'
  733. });
  734. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  735. console.log('++++++++++++++++++订单提交+++++++++++', res)
  736. if (res.data.data.subOrderNo) {
  737. uni.hideLoading();
  738. this.subOrderNo = res.data.data.subOrderNo
  739. this.$refs.myPay.openPopup()
  740. } else {
  741. uni.hideLoading();
  742. uni.$u.toast('预约成功')
  743. setTimeout(() => {
  744. uni.switchTab({
  745. url: '/pages/order/index'
  746. })
  747. }, 500)
  748. }
  749. this.requestStatus = false
  750. }).catch(err => {
  751. this.requestStatus = false
  752. })
  753. }
  754. },
  755. getSelectionRules(data){
  756. this.$api.getSelectionRules(data).then(res=>{
  757. this.takeNumberRules = res.data.rows
  758. })
  759. },
  760. }
  761. }
  762. </script>
  763. <style scoped lang="scss">
  764. @import './index.rpx.scss';
  765. .store-wrap {
  766. margin-top: 10rpx;
  767. background-color: white;
  768. .store-info {
  769. display: flex;
  770. .logo {
  771. width: 10%;
  772. text-align: center;
  773. display: flex;
  774. justify-content: center;
  775. align-items: center;
  776. image {
  777. width: 30px;
  778. height: 30px;
  779. }
  780. }
  781. .store-content {
  782. width: 90%;
  783. padding-bottom: 13px;
  784. .h-row {
  785. display: flex;
  786. align-items: center;
  787. justify-content: space-between;
  788. .store-desc {
  789. width: 90%;
  790. display: flex;
  791. line-height: 30px;
  792. font-size: 14px;
  793. .store-name {
  794. }
  795. }
  796. .arrow-right {
  797. text-align: right;
  798. margin: 0 auto;
  799. cursor: pointer;
  800. padding-top: 3px;
  801. width: 100px;
  802. display: flex;
  803. font-size: 14px;
  804. .change-store {
  805. text-align: right;
  806. color: #666;
  807. }
  808. image {
  809. width: 18px;
  810. height: 18px;
  811. }
  812. }
  813. .address {
  814. color: #999999;
  815. width: 450rpx;
  816. font-size: 24rpx;
  817. }
  818. .address1 {
  819. color: #999999;
  820. font-size: 24rpx;
  821. padding-right: 40rpx;
  822. }
  823. }
  824. }
  825. }
  826. .adress {
  827. font-size: 22rpx;
  828. white-space: nowrap;
  829. overflow: hidden;
  830. text-overflow: ellipsis;
  831. padding-left: 80rpx;
  832. color: #666;
  833. }
  834. }
  835. </style>