index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  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. } else {
  497. this.$api.getServicePersonTime({
  498. personId: this.serviceTeacherList[0].personId,
  499. date: this.periodDate.label,
  500. storeId:this.store.storeId
  501. }).then(res => {
  502. item.select = !item.select
  503. let selectServiceObjectList = this.orderParam.childService
  504. let periodTimeList = res.data.data
  505. if (!res.data.data || res.data.data.length==0){
  506. //这里只为了断开技师列表的应用关系
  507. let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
  508. let serviceTeacherList = JSON.parse(serviceTeacherListStr)
  509. let childService ={
  510. serviceObjectId: item.id,
  511. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  512. nickName:item.nickName, //回显需要,不做参数
  513. serviceUserId: serviceTeacherList[0].personId,
  514. fee:0,//回显需要,不做参数
  515. serviceStartTime: '',
  516. serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
  517. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  518. }
  519. this.orderParam.childService.push(childService)
  520. this.price = 0
  521. for (let childService of this.orderParam.childService) {
  522. this.price = this.price * 1 + childService.fee * 1
  523. this.price = this.price.toFixed(2)
  524. }
  525. return
  526. }
  527. //选择服务对象时,获取的排班时间为全部技师的排班时间,所以只要某个时段被选过,那么这个时段的数量-1
  528. selectServiceObjectList.forEach(selectServiceObject =>{
  529. periodTimeList.forEach(periodTime =>{
  530. if (selectServiceObject.serviceStartTime == periodTime.label ){
  531. periodTime.total = periodTime.total - 1
  532. }
  533. })
  534. })
  535. let date = null //系统为当前服务对象分配的时间
  536. for (const time of periodTimeList) {
  537. if (time.total>0){
  538. time.select = true
  539. date = time
  540. //为当前服务对象分配时间段成功时,需要将以前的服务对象的可选择的时间段的total -1
  541. selectServiceObjectList.forEach(selectServiceObject =>{
  542. if (selectServiceObject.serviceUserId === -1){
  543. //如果子订单没有指定技师,则对应的时段-1
  544. selectServiceObject.serviceTimeList.forEach(t=>{
  545. if (t.label == date.label){
  546. t.total = t.total -1
  547. }
  548. })
  549. }else {
  550. selectServiceObject.serviceTimeList.forEach(t=>{
  551. //如果子订单指定技师,且该技师的服务时段未被选中,则对应的时段-1
  552. if (t.label == date.label && !t.select){
  553. t.total = t.total -1
  554. }
  555. })
  556. }
  557. })
  558. break
  559. }
  560. }
  561. //这里只为了断开技师列表的应用关系
  562. let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
  563. let serviceTeacherList = JSON.parse(serviceTeacherListStr)
  564. //创建子订单项
  565. let childService ={
  566. serviceObjectId: item.id,
  567. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  568. nickName:item.nickName, //回显需要,不做参数
  569. serviceUserId: serviceTeacherList[0].personId,
  570. fee:serviceTeacherList[0].fee,//回显需要,不做参数
  571. serviceStartTime: date.label,
  572. serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
  573. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  574. }
  575. this.orderParam.childService.push(childService)
  576. this.price = 0
  577. for (let childService of this.orderParam.childService) {
  578. this.price = this.price * 1 + childService.fee * 1
  579. this.price = this.price.toFixed(2)
  580. }
  581. })
  582. }
  583. },
  584. selectServiceTeach(items,index,index1){
  585. items.forEach(e=>{
  586. e.select=false
  587. })
  588. items[index1].select =true
  589. this.orderParam.childService[index].fee = items[index1].fee
  590. this.orderParam.childService[index].serviceUserId = items[index1].personId
  591. this.$api.getServicePersonTime({
  592. personId: items[index1].personId,
  593. date: this.periodDate.label,
  594. storeId:this.store.storeId
  595. }).then(res => {
  596. let serviceTimeList = res.data.data
  597. if (!serviceTimeList || serviceTimeList.length == 0){
  598. this.orderParam.childService[index].serviceStartTime = ''
  599. this.orderParam.childService[index].periodTimeList = []
  600. this.orderParam.childService[index].fee = 0
  601. this.price = 0
  602. for (let childService of this.orderParam.childService) {
  603. this.price = this.price * 1 + childService.fee * 1
  604. this.price = this.price.toFixed(2)
  605. }
  606. this.$forceUpdate()
  607. }else {
  608. let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
  609. (selectServiceObject.serviceUserId === items[index1].personId
  610. && selectServiceObject.serviceObjectId !== this.orderParam.childService[index].serviceObjectId)
  611. || selectServiceObject.serviceUserId === -1
  612. )
  613. selectServiceObjectList.forEach(selectServiceObject =>{
  614. serviceTimeList.forEach(periodTime =>{
  615. if (selectServiceObject.serviceStartTime === periodTime.label ){
  616. if (selectServiceObject.serviceUserId === -1){
  617. selectServiceObject.serviceTimeList.forEach(t=>{
  618. if (t.label == periodTime.label && t.total === 1){
  619. periodTime.total = periodTime.total - 1
  620. }
  621. })
  622. }else {
  623. periodTime.total = periodTime.total - 1
  624. }
  625. }
  626. })
  627. })
  628. for (const time of serviceTimeList) {
  629. if (time.total>0){
  630. time.select = true
  631. break
  632. }
  633. }
  634. serviceTimeList[0].select = true
  635. this.orderParam.childService[index].serviceStartTime= serviceTimeList[0].label,
  636. this.orderParam.childService[index].serviceTimeList= serviceTimeList
  637. }
  638. })
  639. this.price = 0
  640. for (let childService of this.orderParam.childService) {
  641. this.price = this.price * 1 + childService.fee * 1
  642. this.price = this.price.toFixed(2)
  643. }
  644. this.$forceUpdate()
  645. },
  646. selectServiceTime(items,index,index2){
  647. items.forEach(e=>{
  648. e.select=false
  649. })
  650. items[index2].select =true // 新选中的时间
  651. // let selectServiceObject = this.orderParam.childService[index] //旧的时间
  652. // this.orderParam.childService.forEach(i=>{
  653. // if (selectServiceObject.serviceUserId === -1){
  654. // i.serviceTimeList.forEach(t=>{
  655. // if (t.label == selectServiceObject.serviceStartTime && !t.select ){
  656. // console.log('-1----------加1')
  657. // t.total +=1
  658. // }
  659. // if (t.label == items[index2].serviceStartTime && i.serviceObjectId != selectServiceObject.serviceObjectId){
  660. // console.log('-1----------减1')
  661. // t.total -=1
  662. // }
  663. // })
  664. // }else {
  665. // if (selectServiceObject.serviceUserId == i.serviceUserId){
  666. // i.serviceTimeList.forEach(t=>{
  667. // if (t.label == selectServiceObject.serviceStartTime && !t.select ){
  668. // t.total +=1
  669. // }
  670. // if (t.label == items[index2].serviceStartTime && i.serviceObjectId != selectServiceObject.serviceObjectId){
  671. // t.total -=1
  672. // }
  673. // })
  674. // }
  675. // }
  676. // })
  677. this.orderParam.childService[index].serviceStartTime = items[index2].label
  678. this.$forceUpdate()
  679. },
  680. selectChange() {
  681. this.selectIcon = !this.selectIcon
  682. },
  683. goTermsOfService() {
  684. uni.navigateTo({
  685. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  686. })
  687. },
  688. //支付组件回调
  689. payResult(e){
  690. console.log(e)
  691. if(e.payResult){
  692. uni.showToast({
  693. title: '支付成功!'
  694. });
  695. }else {
  696. uni.showToast({
  697. title: e.res.data.msg,
  698. icon: 'error'
  699. });
  700. }
  701. setTimeout(()=>{
  702. uni.switchTab({
  703. url: '/pages/order/index'
  704. })
  705. },1000)
  706. },
  707. //提交订单
  708. commitOrder() {
  709. if (this.subOrderNo){
  710. this.$refs.myPay.openPopup()
  711. }else {
  712. if (!this.selectIcon) {
  713. uni.$u.toast('请阅读并同意《预约需知》')
  714. return;
  715. }
  716. if (this.orderParam.childService.length === 0) {
  717. uni.$u.toast('请选择服务对象')
  718. return;
  719. }
  720. if (this.requestStatus) {
  721. return;
  722. }
  723. this.requestStatus = true
  724. uni.showLoading({
  725. title: '加载中'
  726. });
  727. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  728. console.log('++++++++++++++++++订单提交+++++++++++', res)
  729. if (res.data.data.subOrderNo) {
  730. uni.hideLoading();
  731. this.subOrderNo = res.data.data.subOrderNo
  732. this.$refs.myPay.openPopup()
  733. } else {
  734. uni.hideLoading();
  735. uni.$u.toast('预约成功')
  736. setTimeout(() => {
  737. uni.switchTab({
  738. url: '/pages/order/index'
  739. })
  740. }, 500)
  741. }
  742. this.requestStatus = false
  743. }).catch(err => {
  744. this.requestStatus = false
  745. })
  746. }
  747. },
  748. getSelectionRules(data){
  749. this.$api.getSelectionRules(data).then(res=>{
  750. this.takeNumberRules = res.data.rows
  751. })
  752. },
  753. }
  754. }
  755. </script>
  756. <style scoped lang="scss">
  757. @import './index.rpx.scss';
  758. .store-wrap {
  759. margin-top: 10rpx;
  760. background-color: white;
  761. .store-info {
  762. display: flex;
  763. .logo {
  764. width: 10%;
  765. text-align: center;
  766. display: flex;
  767. justify-content: center;
  768. align-items: center;
  769. image {
  770. width: 30px;
  771. height: 30px;
  772. }
  773. }
  774. .store-content {
  775. width: 90%;
  776. padding-bottom: 13px;
  777. .h-row {
  778. display: flex;
  779. align-items: center;
  780. justify-content: space-between;
  781. .store-desc {
  782. width: 90%;
  783. display: flex;
  784. line-height: 30px;
  785. font-size: 14px;
  786. .store-name {
  787. }
  788. }
  789. .arrow-right {
  790. text-align: right;
  791. margin: 0 auto;
  792. cursor: pointer;
  793. padding-top: 3px;
  794. width: 100px;
  795. display: flex;
  796. font-size: 14px;
  797. .change-store {
  798. text-align: right;
  799. color: #666;
  800. }
  801. image {
  802. width: 18px;
  803. height: 18px;
  804. }
  805. }
  806. .address {
  807. color: #999999;
  808. width: 450rpx;
  809. font-size: 24rpx;
  810. }
  811. .address1 {
  812. color: #999999;
  813. font-size: 24rpx;
  814. padding-right: 40rpx;
  815. }
  816. }
  817. }
  818. }
  819. .adress {
  820. font-size: 22rpx;
  821. white-space: nowrap;
  822. overflow: hidden;
  823. text-overflow: ellipsis;
  824. padding-left: 80rpx;
  825. color: #666;
  826. }
  827. }
  828. </style>