index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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"></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. this.selectDate()
  157. },
  158. onShow() {
  159. // 服务对象
  160. this.listServiceObject()
  161. },
  162. mounted(){
  163. },
  164. methods: {
  165. //获取排班日期
  166. selectDate() {
  167. console.log(this.store)
  168. this.$api.selectDate({
  169. organization: this.store.storeId
  170. }).then(res => {
  171. this.periodDate = res.data.data[0]
  172. this.date=this.periodDate.label
  173. this.orderParam.serviceDate=this.periodDate.label
  174. if (this.orderParam.childService.length === 1) {
  175. this.orderParam.childService[0].periodDate = this.periodDate.label
  176. }
  177. if (res.data.data[0]){
  178. this.getServicePerson(res.data.data[0].label);
  179. }
  180. })
  181. },
  182. // 查询服务工作人员列表
  183. getServicePerson(date) {
  184. this.$api.getServicePerson({
  185. storeld:this.store.storeId,
  186. date:date
  187. }).then((res) => {
  188. this.serviceTeacher = res.data.data[0];
  189. this.personId =this.serviceTeacher.id
  190. if (this.orderParam.childService.length === 1) {
  191. this.orderParam.childService[0].serviceUserId = res.data.data[0].personId
  192. this.orderParam.childService[0].personName = res.data.data[0].personName
  193. this.orderParam.childService[0].fee = res.data.data[0].fee
  194. this.price = res.data.data[0].fee * 1
  195. }
  196. if (res.data.data[0]){
  197. this.getServiceTime(date,res.data.data[0].personId)
  198. }
  199. })
  200. },
  201. //获取门店排班时段
  202. getServiceTime(date,personId) {
  203. this.$api.getServicePersonTime({
  204. personId: personId,
  205. date: date,
  206. storeId:this.store.storeId
  207. }).then(res => {
  208. this.periodTime = res.data.data[0]
  209. if (this.orderParam.childService.length === 1) {
  210. this.orderParam.childService[0].serviceStartTime = res.data.data[0].label
  211. }
  212. })
  213. },
  214. selectServiceObject(item) {
  215. this.subOrderNo=''
  216. console.log(item)
  217. if (item.select) {
  218. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  219. selectServiceObject.serviceObjectId !== item.id)
  220. } else {
  221. this.$api.getServicePersonTime({
  222. personId: this.serviceTeacher.personId,
  223. date: this.periodDate.label,
  224. storeId:this.store.storeId
  225. }).then(res => {
  226. let periodTimeList = res.data.data
  227. let selectServiceObjectList = this.orderParam.childService
  228. selectServiceObjectList.forEach(selectServiceObject =>{
  229. periodTimeList.forEach(periodTime =>{
  230. if (selectServiceObject.serviceStartTime === periodTime.label ){
  231. periodTime.total = periodTime.total - 1
  232. }
  233. })
  234. })
  235. periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
  236. console.log(periodTimeList)
  237. let childService ={
  238. periodDate: this.periodDate.label,
  239. serviceObjectId: item.id,
  240. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  241. nickName:item.nickName, //回显需要,不做参数
  242. serviceUserId: this.serviceTeacher.personId ,
  243. personName:this.serviceTeacher.personName ,//回显需要,不做参数
  244. fee:this.serviceTeacher.fee ,//回显需要,不做参数
  245. serviceStartTime: periodTimeList[0].label ,
  246. }
  247. this.orderParam.childService.push(childService)
  248. })
  249. }
  250. item.select = !item.select
  251. this.price = 0
  252. for (let childService of this.orderParam.childService) {
  253. this.price = this.price * 1 + childService.fee * 1
  254. }
  255. },
  256. // 查询服务对接信息列表
  257. listServiceObject() {
  258. this.$api.listServiceObject(this.reqParm).then((res) => {
  259. console.log(res)
  260. this.serviceObjectList = res.data.data
  261. this.getImgUrlByBannerOssId(this.serviceObjectList);
  262. if (this.orderParam.childService.length === 0) {
  263. let selectServiceObject = this.serviceObjectList[0]
  264. this.serviceObjectList[0].select = true
  265. let childService ={
  266. periodDate: '',
  267. serviceObjectId: selectServiceObject.id,
  268. facePhotoUrl:selectServiceObject.facePhotoUrl,
  269. nickName:selectServiceObject.nickName,
  270. serviceUserId: -1 ,
  271. fee:'' ,
  272. serviceStartTime: '' ,
  273. }
  274. this.orderParam.childService.push(childService)
  275. } else {
  276. for (let selectServiceObject of this.orderParam.childService) {
  277. for (let serviceObject of this.serviceObjectList) {
  278. if (selectServiceObject.id === serviceObject.id) {
  279. serviceObject.select = true
  280. }
  281. }
  282. }
  283. }
  284. })
  285. },
  286. // 获取图片
  287. getImgUrlByBannerOssId(items) {
  288. for (let i = 0; i < items.length; i++) {
  289. if (items[i].facePhoto) {
  290. this.$api.getImgUrlByOssId({
  291. ossId: items[i].facePhoto
  292. }).then(res => {
  293. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  294. this.$set(this.serviceObjectList, i, items[i])
  295. if (i === 0){
  296. this.orderParam.childService[0].facePhotoUrl =res.data.data[0].url.replace(/^http:/, "https:")
  297. }
  298. })
  299. }
  300. }
  301. },
  302. addServiceObject() {
  303. uni.navigateTo({
  304. url: '/myPages/ServiceObjectManagement/index'
  305. })
  306. },
  307. //选择服务人员
  308. chooseServiceTeacher(index,serviceUserId) {
  309. this.selectIndex = index
  310. this.$refs.chooseServiceTeacher.openPopup(serviceUserId)
  311. },
  312. //选择服务人员
  313. getWorkPerson(e) {
  314. if (e.personId !== this.orderParam.childService[this.selectIndex].serviceUserId){
  315. this.subOrderNo=''
  316. this.$api.getServicePersonTime({
  317. personId: e.personId,
  318. date: this.periodDate.label,
  319. storeId: this.store.storeId
  320. }).then(res => {
  321. this.orderParam.childService[this.selectIndex].serviceUserId = e.personId
  322. this.orderParam.childService[this.selectIndex].personName = e.personName
  323. this.orderParam.childService[this.selectIndex].fee = e.fee
  324. this.orderParam.childService[this.selectIndex].serviceStartTime = ''
  325. let periodTimeList = res.data.data
  326. let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
  327. selectServiceObject.serviceUserId === e.personId
  328. || selectServiceObject.serviceUserId === -1
  329. )
  330. selectServiceObjectList.forEach(selectServiceObject =>{
  331. periodTimeList.forEach(periodTime =>{
  332. if (selectServiceObject.serviceStartTime === periodTime.label){
  333. periodTime.total = periodTime.total - 1
  334. }
  335. })
  336. })
  337. periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
  338. this.orderParam.childService[this.selectIndex].serviceStartTime = periodTimeList[0].label
  339. this.price = 0
  340. for (let childService of this.orderParam.childService) {
  341. this.price = this.price * 1 + childService.fee * 1
  342. }
  343. })
  344. }
  345. },
  346. //选择服务时段
  347. chooseServiceTime(index) {
  348. this.selectIndex = index
  349. this.$refs.chooseServiceTime.openPopup(this.orderParam.childService[index].serviceUserId,
  350. this.periodDate.label,this.store.storeId,this.orderParam.childService,index,this.orderParam.childService[index].serviceStartTime)
  351. },
  352. //选择服务时段
  353. getPeriodDate(e) {
  354. console.log(e)
  355. if (e){
  356. if (this.orderParam.childService[this.selectIndex].serviceStartTime !== e.label){
  357. this.subOrderNo=''
  358. this.orderParam.childService[this.selectIndex].serviceStartTime = e.label
  359. this.$set(this.orderParam)
  360. }
  361. }
  362. },
  363. selectChange() {
  364. this.selectIcon = !this.selectIcon
  365. },
  366. goTermsOfService() {
  367. uni.navigateTo({
  368. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  369. })
  370. },
  371. //提交订单
  372. commitOrder() {
  373. if (this.subOrderNo){
  374. this.$refs.myPay.openPopup()
  375. }else {
  376. if (!this.selectIcon) {
  377. uni.$u.toast('请阅读并同意《预约需知》')
  378. return;
  379. }
  380. if (this.orderParam.childService.length === 0) {
  381. uni.$u.toast('请选择服务对象')
  382. return;
  383. }
  384. if (this.requestStatus) {
  385. return;
  386. }
  387. this.requestStatus = true
  388. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  389. console.log('++++++++++++++++++订单提交+++++++++++', res)
  390. if (res.data.data.subOrderNo) {
  391. this.orderNo = res.data.data.orderNo
  392. this.subOrderNo = res.data.data.subOrderNo
  393. this.$refs.myPay.openPopup()
  394. } else {
  395. uni.$u.toast('预约成功')
  396. setTimeout(() => {
  397. uni.switchTab({
  398. url: '/pages/order/index'
  399. })
  400. }, 1000)
  401. }
  402. this.requestStatus = false
  403. }).catch(err => {
  404. this.requestStatus = false
  405. })
  406. }
  407. },
  408. }
  409. }
  410. </script>
  411. <style scoped lang="scss">
  412. @import './index.rpx.scss';
  413. </style>