index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view class="page">
  3. <view class="flex-col group">
  4. <view class="serob"><text>服务对象</text></view>
  5. <view class="serobItems flex-row">
  6. <scroll-view class="scrollX" scroll-x>
  7. <view class="flex-row">
  8. <view class="serobItem flex-col" v-for="(item,index) in serviceObjectList" :key="index">
  9. <view class="serobImgView" @click="selectServiceObject(item)">
  10. <image class="serobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/logo.png'"></image>
  11. </view>
  12. <text class="serobName">{{item.nickName || '未填写'}}</text>
  13. <view class="serobV" v-if="item.select === true">
  14. <image class="serobVicon" src="/static/order/ud20.png"></image>
  15. </view>
  16. </view>
  17. </view>
  18. </scroll-view>
  19. <view class="addSerobImg" @click="addServiceObject">
  20. <text>+</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="flex-row hintView">
  25. <view class="flex-col justify-center">
  26. <view class="hint">
  27. <text>!</text>
  28. </view>
  29. </view>
  30. <view class="hintCentent">
  31. <text>娇宝,提前10分钟到哟,一人一号过号需要重新取号排队!等你哟</text>
  32. </view>
  33. </view>
  34. <view class="flex-col group marginTop" v-for="(item, index) in orderParam.childService">
  35. <view class="flex-row">
  36. <image class="selectSerobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/logo.png'"></image>
  37. <text class="selectSerobName">{{item.nickName || '未填写'}}</text>
  38. </view>
  39. <view class="flex-row groupItem ">
  40. <view class="groupItemKey ">
  41. <text>服务日期</text>
  42. </view>
  43. <view class="flex-row justify-between groupItemContent ">
  44. <text>{{ item.periodDate || '请选择服务日期' }}</text>
  45. </view>
  46. </view>
  47. <view class="flex-row groupItem">
  48. <view class="groupItemKey">
  49. <text>服务人员</text>
  50. </view>
  51. <view class="flex-row justify-between groupItemContent" @click="chooseServiceTeacher(index,item.serviceUserId)">
  52. <text>{{ item.personName || '请选择服务人员' }}</text>
  53. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  54. </view>
  55. </view>
  56. <view class="flex-row groupItem">
  57. <view class="groupItemKey">
  58. <text>服务时段</text>
  59. </view>
  60. <view class="flex-row justify-between groupItemContent" @click="chooseServiceTime(index)">
  61. <text>{{ item.serviceStartTime || '服务时段' }}</text>
  62. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="flex-col group marginTop">
  67. <view class="groupItemKey">
  68. <text>服务定制</text>
  69. </view>
  70. <view class="textareaView">
  71. <textarea v-model="orderParam.remark" placeholder-style="color:#999999;fontSize:28rpx"
  72. placeholder="如有其它特殊需求,请在此输入您的需求" />
  73. </view>
  74. </view>
  75. <view :style="{'height':'236rpx'}"></view>
  76. <view class="flex-col group2 ">
  77. <view class="btnTitle flex-row">
  78. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18"
  79. @click="selectChange"></u-icon>
  80. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  81. <text :style="{'margin-left':'10rpx'}">请阅读并同意</text>
  82. <text :style="{'color':'red'}" @click="goTermsOfService">《预约需知》</text>
  83. </view>
  84. <view class="btn flex-row justify-between">
  85. <view>
  86. <text class="title">待支付</text>
  87. <text class="num">¥{{ price }}</text>
  88. </view>
  89. <view class="btnRight" @click="commitOrder">
  90. <text>提交</text>
  91. </view>
  92. </view>
  93. </view>
  94. <chooseServiceTeacher ref="chooseServiceTeacher" :storeId="store.storeId" :date="date" @getWorkPerson="getWorkPerson"></chooseServiceTeacher>
  95. <chooseServiceTime ref="chooseServiceTime" @getPeriodDate="getPeriodDate"></chooseServiceTime>
  96. <myPay ref="myPay" :blPay="false" :orderNo="subOrderNo" @payResult="payResult"></myPay>
  97. </view>
  98. </template>
  99. <script>
  100. import chooseServiceTeacher from './components/chooseServiceTeacher';
  101. import chooseServiceTime from './components/chooseServiceTime';
  102. import myPay from '../../components/pay/pay';
  103. export default {
  104. components: {
  105. chooseServiceTeacher,
  106. chooseServiceTime,
  107. myPay
  108. },
  109. data() {
  110. return {
  111. selectIndex:0,
  112. requestStatus:false,
  113. personId:'',
  114. date:'',
  115. serviceObjectList: [],
  116. userInfo: {},
  117. //服务门店
  118. store: {},
  119. //默认服务技师
  120. serviceTeacher: {},
  121. //默认服务时间
  122. periodDate: [],
  123. //默认服务时段
  124. periodTime: [],
  125. //预约费用
  126. price: '0',
  127. //订单编号
  128. orderNo: '',
  129. subOrderNo: '',
  130. selectIcon: true,
  131. orderParam:{
  132. orderType: 1,
  133. serviceAttribute: 2,
  134. serviceStoreId: '',
  135. remark: '',
  136. serviceDate:'',
  137. childService:[
  138. // {
  139. // periodDate:'',//回显需要,不做参数
  140. // serviceObjectId: '',
  141. // facePhotoUrl:'', //回显需要,不做参数
  142. // nickName:'', //回显需要,不做参数
  143. // serviceUserId: '',
  144. // personName:'',//回显需要,不做参数
  145. // fee:'',//回显需要,不做参数
  146. // serviceStartTime: ''
  147. // }
  148. ]
  149. }
  150. }
  151. },
  152. onLoad() {
  153. this.store = uni.getStorageSync('storeInfo')
  154. this.userInfo = uni.getStorageSync('userInfo')
  155. this.orderParam.serviceStoreId = this.store.storeId
  156. },
  157. onShow() {
  158. // 服务对象
  159. this.listServiceObject()
  160. },
  161. mounted(){
  162. },
  163. methods: {
  164. //获取排班日期
  165. selectDate() {
  166. console.log(this.store)
  167. this.$api.selectDate({
  168. organization: this.store.storeId
  169. }).then(res => {
  170. this.periodDate = res.data.data[0]
  171. this.date=this.periodDate.label
  172. this.orderParam.serviceDate=this.periodDate.label
  173. if (res.data.data[0]){
  174. this.getServicePerson(res.data.data[0].label);
  175. }
  176. })
  177. },
  178. // 查询服务工作人员列表
  179. getServicePerson(date) {
  180. this.$api.getServicePerson({
  181. storeId:this.store.storeId,
  182. date:date
  183. }).then((res) => {
  184. this.serviceTeacher = res.data.data[0];
  185. this.personId =this.serviceTeacher.id
  186. if (res.data.data[0]){
  187. this.getServiceTime(date,res.data.data[0].personId)
  188. }
  189. })
  190. },
  191. //获取门店排班时段
  192. getServiceTime(date,personId) {
  193. this.$api.getServicePersonTime({
  194. personId: personId,
  195. date: date,
  196. storeId:this.store.storeId
  197. }).then(res => {
  198. this.periodTime = res.data.data[0]
  199. this.orderParam.childService[0].serviceStartTime = this.periodTime.label
  200. this.orderParam.childService[0].periodDate = this.periodDate.label,
  201. this.orderParam.childService[0].serviceUserId = this.serviceTeacher.personId ,
  202. this.orderParam.childService[0].personName = this.serviceTeacher.personName ,//回显需要,不做参数
  203. this.orderParam.childService[0].fee = this.serviceTeacher.fee //回显需要,不做参数
  204. })
  205. },
  206. selectServiceObject(item) {
  207. this.subOrderNo=''
  208. console.log(item)
  209. if (item.select) {
  210. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  211. selectServiceObject.serviceObjectId !== item.id)
  212. } else {
  213. this.$api.getServicePersonTime({
  214. personId: this.serviceTeacher.personId,
  215. date: this.periodDate.label,
  216. storeId:this.store.storeId
  217. }).then(res => {
  218. let periodTimeList = res.data.data
  219. let selectServiceObjectList = this.orderParam.childService
  220. selectServiceObjectList.forEach(selectServiceObject =>{
  221. periodTimeList.forEach(periodTime =>{
  222. if (selectServiceObject.serviceStartTime === periodTime.label ){
  223. periodTime.total = periodTime.total - 1
  224. }
  225. })
  226. })
  227. periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
  228. console.log(periodTimeList)
  229. let childService ={
  230. periodDate: this.periodDate.label,
  231. serviceObjectId: item.id,
  232. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  233. nickName:item.nickName, //回显需要,不做参数
  234. serviceUserId: this.serviceTeacher.personId ,
  235. personName:this.serviceTeacher.personName ,//回显需要,不做参数
  236. fee:this.serviceTeacher.fee ,//回显需要,不做参数
  237. serviceStartTime: periodTimeList[0].label ,
  238. }
  239. this.orderParam.childService.push(childService)
  240. })
  241. }
  242. item.select = !item.select
  243. this.price = 0
  244. for (let childService of this.orderParam.childService) {
  245. this.price = this.price * 1 + childService.fee * 1
  246. }
  247. },
  248. // 查询服务对接信息列表
  249. listServiceObject() {
  250. this.$api.listServiceObject(this.reqParm).then((res) => {
  251. console.log(res)
  252. this.serviceObjectList = res.data.data
  253. if (this.orderParam.childService.length === 0) {
  254. let selectServiceObject = this.serviceObjectList[0]
  255. this.serviceObjectList[0].select = true
  256. let childService ={
  257. periodDate: '',
  258. serviceObjectId: selectServiceObject.id,
  259. facePhotoUrl:selectServiceObject.facePhotoUrl,
  260. nickName:selectServiceObject.nickName,
  261. serviceUserId: -1 ,
  262. fee:'' ,
  263. serviceStartTime: '' ,
  264. }
  265. this.orderParam.childService.push(childService)
  266. this.selectDate()
  267. } else {
  268. for (let selectServiceObject of this.orderParam.childService) {
  269. for (let serviceObject of this.serviceObjectList) {
  270. if (selectServiceObject.id === serviceObject.id) {
  271. serviceObject.select = true
  272. }
  273. }
  274. }
  275. }
  276. this.getImgUrlByBannerOssId(this.serviceObjectList);
  277. })
  278. },
  279. // 获取图片
  280. getImgUrlByBannerOssId(items) {
  281. for (let i = 0; i < items.length; i++) {
  282. if (items[i].facePhoto) {
  283. this.$api.getImgUrlByOssId({
  284. ossId: items[i].facePhoto
  285. }).then(res => {
  286. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  287. this.$set(this.serviceObjectList, i, items[i])
  288. if (i === 0){
  289. this.orderParam.childService[0].facePhotoUrl =res.data.data[0].url.replace(/^http:/, "https:")
  290. }
  291. })
  292. }
  293. }
  294. },
  295. addServiceObject() {
  296. uni.navigateTo({
  297. url: '/myPages/ServiceObjectManagement/index'
  298. })
  299. },
  300. //选择服务人员
  301. chooseServiceTeacher(index,serviceUserId) {
  302. this.selectIndex = index
  303. this.$refs.chooseServiceTeacher.openPopup(serviceUserId)
  304. },
  305. //选择服务人员
  306. getWorkPerson(e) {
  307. if (e.personId !== this.orderParam.childService[this.selectIndex].serviceUserId){
  308. this.subOrderNo=''
  309. this.$api.getServicePersonTime({
  310. personId: e.personId,
  311. date: this.periodDate.label,
  312. storeId: this.store.storeId
  313. }).then(res => {
  314. this.orderParam.childService[this.selectIndex].serviceUserId = e.personId
  315. this.orderParam.childService[this.selectIndex].personName = e.personName
  316. this.orderParam.childService[this.selectIndex].fee = e.fee
  317. this.orderParam.childService[this.selectIndex].serviceStartTime = ''
  318. let periodTimeList = res.data.data
  319. let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
  320. selectServiceObject.serviceUserId === e.personId
  321. || selectServiceObject.serviceUserId === -1
  322. )
  323. selectServiceObjectList.forEach(selectServiceObject =>{
  324. periodTimeList.forEach(periodTime =>{
  325. if (selectServiceObject.serviceStartTime === periodTime.label){
  326. periodTime.total = periodTime.total - 1
  327. }
  328. })
  329. })
  330. periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
  331. this.orderParam.childService[this.selectIndex].serviceStartTime = periodTimeList[0].label
  332. this.price = 0
  333. for (let childService of this.orderParam.childService) {
  334. this.price = this.price * 1 + childService.fee * 1
  335. }
  336. })
  337. }
  338. },
  339. //选择服务时段
  340. chooseServiceTime(index) {
  341. this.selectIndex = index
  342. this.$refs.chooseServiceTime.openPopup(this.orderParam.childService[index].serviceUserId,
  343. this.periodDate.label,this.store.storeId,this.orderParam.childService,index,this.orderParam.childService[index].serviceStartTime)
  344. },
  345. //选择服务时段
  346. getPeriodDate(e) {
  347. console.log(e)
  348. if (e){
  349. if (this.orderParam.childService[this.selectIndex].serviceStartTime !== e.label){
  350. this.subOrderNo=''
  351. this.orderParam.childService[this.selectIndex].serviceStartTime = e.label
  352. this.$set(this.orderParam)
  353. }
  354. }
  355. },
  356. selectChange() {
  357. this.selectIcon = !this.selectIcon
  358. },
  359. goTermsOfService() {
  360. uni.navigateTo({
  361. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  362. })
  363. },
  364. //支付组件回调
  365. payResult(e){
  366. console.log(e)
  367. if(e.payResult){
  368. uni.showToast({
  369. title: '支付成功!'
  370. });
  371. }else {
  372. uni.showToast({
  373. title: '支付失败',
  374. icon: 'error'
  375. });
  376. }
  377. setTimeout(()=>{
  378. uni.switchTab({
  379. url: '/pages/order/index'
  380. })
  381. },1000)
  382. },
  383. //提交订单
  384. commitOrder() {
  385. if (this.subOrderNo){
  386. this.$refs.myPay.openPopup()
  387. }else {
  388. if (!this.selectIcon) {
  389. uni.$u.toast('请阅读并同意《预约需知》')
  390. return;
  391. }
  392. if (this.orderParam.childService.length === 0) {
  393. uni.$u.toast('请选择服务对象')
  394. return;
  395. }
  396. if (this.requestStatus) {
  397. return;
  398. }
  399. this.requestStatus = true
  400. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  401. console.log('++++++++++++++++++订单提交+++++++++++', res)
  402. if (res.data.data.subOrderNo) {
  403. this.orderNo = res.data.data.orderNo
  404. this.subOrderNo = res.data.data.subOrderNo
  405. this.$refs.myPay.openPopup()
  406. } else {
  407. uni.$u.toast('预约成功')
  408. setTimeout(() => {
  409. uni.switchTab({
  410. url: '/pages/order/index'
  411. })
  412. }, 1000)
  413. }
  414. this.requestStatus = false
  415. }).catch(err => {
  416. this.requestStatus = false
  417. })
  418. }
  419. },
  420. }
  421. }
  422. </script>
  423. <style scoped lang="scss">
  424. @import './index.rpx.scss';
  425. </style>