index.vue 32 KB

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