index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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" :src="item.facePhotoUrl || '/static/logo.png'"
  11. mode="aspectFill"></image>
  12. </view>
  13. <text class="serobName">{{item.nickName || '未填写'}}</text>
  14. <view class="serobV" v-if="item.select === true">
  15. <image class="serobVicon" src="/static/order/ud20.png"></image>
  16. </view>
  17. </view>
  18. </view>
  19. </scroll-view>
  20. <view class="addSerobImg" @click="addServiceObject">
  21. <text>+</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="flex-row hintView">
  26. <view class="flex-col justify-center">
  27. <view class="hint">
  28. <text>!</text>
  29. </view>
  30. </view>
  31. <view class="hintCentent">
  32. <text>娇宝,提前10分钟到哟,一人一号过号需要重新取号排队!等你哟</text>
  33. </view>
  34. </view>
  35. <view class="flex-col group marginTop" v-for="(item, index) in orderParam.childService">
  36. <view class="flex-row">
  37. <image class="selectSerobImg" :src="item.facePhotoUrl || '/static/logo.png'"></image>
  38. <text class="selectSerobName">{{item.nickName || '未填写'}}</text>
  39. </view>
  40. <view class="flex-row groupItem ">
  41. <view class="groupItemKey ">
  42. <text>服务日期</text>
  43. </view>
  44. <view class="flex-row justify-between groupItemContent ">
  45. <text>{{ item.periodDate || '请选择服务日期' }}</text>
  46. </view>
  47. </view>
  48. <view class="flex-row groupItem">
  49. <view class="groupItemKey">
  50. <text>服务人员</text>
  51. </view>
  52. <view class="flex-row justify-between groupItemContent" @click="chooseServiceTeacher(index)">
  53. <text>{{ item.personName || '请选择服务人员' }}</text>
  54. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  55. </view>
  56. </view>
  57. <view class="flex-row groupItem">
  58. <view class="groupItemKey">
  59. <text>服务时段</text>
  60. </view>
  61. <view class="flex-row justify-between groupItemContent" @click="chooseServiceTime(index)">
  62. <text>{{ item.serviceStartTime || '服务时段' }}</text>
  63. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="flex-col group marginTop">
  68. <view class="groupItemKey">
  69. <text>服务定制</text>
  70. </view>
  71. <view class="textareaView">
  72. <textarea v-model="orderParam.remark" placeholder-style="color:#999999;fontSize:28rpx"
  73. placeholder="如有其它特殊需求,请在此输入您的需求" />
  74. </view>
  75. </view>
  76. <view :style="{'height':'236rpx'}"></view>
  77. <view class="flex-col group2 ">
  78. <view class="btnTitle flex-row">
  79. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18"
  80. @click="selectChange"></u-icon>
  81. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  82. <text :style="{'margin-left':'10rpx'}">请阅读并同意</text>
  83. <text :style="{'color':'red'}" @click="goTermsOfService">《预约需知》</text>
  84. </view>
  85. <view class="btn flex-row justify-between">
  86. <view>
  87. <text class="title">待支付</text>
  88. <text class="num">¥{{ price }}</text>
  89. </view>
  90. <view class="btnRight" @click="commitOrder">
  91. <text>提交</text>
  92. </view>
  93. </view>
  94. </view>
  95. <chooseServiceTeacher ref="chooseServiceTeacher" :storeId="store.storeId" :date="date" @getWorkPerson="getWorkPerson"></chooseServiceTeacher>
  96. <chooseServiceTime ref="chooseServiceTime" :personId="personId" :date="date" @getPeriodDate="getPeriodDate"></chooseServiceTime>
  97. <myPay ref="myPay" :blPay="false"></myPay>
  98. </view>
  99. </template>
  100. <script>
  101. import chooseServiceTeacher from './components/chooseServiceTeacher';
  102. import chooseServiceTime from './components/chooseServiceTime';
  103. import myPay from '../../components/pay/pay';
  104. export default {
  105. components: {
  106. chooseServiceTeacher,
  107. chooseServiceTime,
  108. myPay
  109. },
  110. data() {
  111. return {
  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. childService:[
  137. {
  138. periodDate:'',//回显需要,不做参数
  139. serviceObjectId: '',
  140. facePhotoUrl:'', //回显需要,不做参数
  141. nickName:'', //回显需要,不做参数
  142. serviceUserId: '',
  143. personName:'',//回显需要,不做参数
  144. fee:'',//回显需要,不做参数
  145. serviceStartTime: '',
  146. timeRangeId: ''
  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. if (this.orderParam.childService.length === 1) {
  174. this.orderParam.childService[0].periodDate = this.periodDate.label
  175. }
  176. if (res.data.data[0]){
  177. this.getServicePerson(res.data.data[0].label);
  178. }
  179. })
  180. },
  181. // 查询服务工作人员列表
  182. getServicePerson(date) {
  183. this.$api.getServicePerson({
  184. storeld:this.store.storeId,
  185. date:date
  186. }).then((res) => {
  187. this.serviceTeacher = res.data.data[0];
  188. this.personId =this.serviceTeacher.id
  189. if (this.orderParam.childService.length === 1) {
  190. this.orderParam.childService[0].serviceUserId = res.data.data[0].personId
  191. this.orderParam.childService[0].personName = res.data.data[0].personName
  192. this.orderParam.childService[0].fee = res.data.data[0].fee
  193. this.price = res.data.data[0].fee * 1
  194. }
  195. if (res.data.data[0]){
  196. this.getServiceTime(date,res.data.data[0].personId)
  197. }
  198. })
  199. },
  200. //获取门店排班时段
  201. getServiceTime(date,personId) {
  202. this.$api.getServicePersonTime({
  203. personId: personId === -1 ? '' : personId,
  204. date: date,
  205. }).then(res => {
  206. this.periodTime = res.data.data[0]
  207. if (this.orderParam.childService.length === 1) {
  208. this.orderParam.childService[0].serviceStartTime = res.data.data[0].label
  209. this.orderParam.childService[0].timeRangeId = res.data.data[0].id
  210. }
  211. })
  212. },
  213. selectServiceObject(item) {
  214. console.log(item)
  215. if (item.select) {
  216. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  217. selectServiceObject.serviceObjectId !== item.id)
  218. } else {
  219. let childService ={
  220. periodDate: this.periodDate.label,
  221. serviceObjectId: item.id,
  222. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  223. nickName:item.nickName, //回显需要,不做参数
  224. serviceUserId: this.serviceTeacher.personId ,
  225. personName:this.serviceTeacher.personName ,//回显需要,不做参数
  226. fee:this.serviceTeacher.fee ,//回显需要,不做参数
  227. serviceStartTime: this.periodTime.label ,
  228. timeRangeId: this.periodTime.id
  229. }
  230. this.orderParam.childService.push(childService)
  231. for (let childService of this.orderParam.childService) {
  232. this.price = 0
  233. this.price = this.price * 1 + childService.fee * 1
  234. }
  235. }
  236. item.select = !item.select
  237. },
  238. // 查询服务对接信息列表
  239. listServiceObject() {
  240. this.$api.listServiceObject(this.reqParm).then((res) => {
  241. console.log(res)
  242. this.serviceObjectList = res.data.data
  243. this.getImgUrlByBannerOssId(this.serviceObjectList);
  244. if (this.orderParam.childService.length === 1) {
  245. let selectServiceObject = this.serviceObjectList[0]
  246. this.orderParam.childService[0].serviceObjectId = selectServiceObject.id,
  247. this.orderParam.childService[0].nickName = selectServiceObject.nickName,
  248. this.serviceObjectList[0].select = true
  249. } else {
  250. for (let selectServiceObject of this.orderParam.childService) {
  251. for (let serviceObject of this.serviceObjectList) {
  252. if (selectServiceObject.id === serviceObject.id) {
  253. serviceObject.select = true
  254. }
  255. }
  256. }
  257. }
  258. })
  259. },
  260. // 获取图片
  261. getImgUrlByBannerOssId(items) {
  262. for (let i = 0; i < items.length; i++) {
  263. if (items[i].facePhoto) {
  264. this.$api.getImgUrlByOssId({
  265. ossId: items[i].facePhoto
  266. }).then(res => {
  267. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  268. this.$set(this.serviceObjectList, i, items[i])
  269. if (i === 0){
  270. this.orderParam.childService[0].facePhotoUrl =res.data.data[0].url.replace(/^http:/, "https:")
  271. }
  272. })
  273. }
  274. }
  275. },
  276. addServiceObject() {
  277. uni.navigateTo({
  278. url: '/myPages/ServiceObjectManagement/index'
  279. })
  280. },
  281. //选择服务人员
  282. chooseServiceTeacher(index) {
  283. this.selectIndex = index
  284. this.$refs.chooseServiceTeacher.openPopup()
  285. },
  286. //选择服务人员
  287. getWorkPerson(e) {
  288. this.orderParam.childService[this.selectIndex].serviceUserId = e.personId
  289. this.orderParam.childService[this.selectIndex].personName = e.personName
  290. this.orderParam.childService[this.selectIndex].fee = e.fee
  291. for (let childService of this.orderParam.childService) {
  292. this.price = 0
  293. this.price = this.price * 1 + childService.fee * 1
  294. }
  295. },
  296. //选择服务时段
  297. chooseServiceTime(index) {
  298. this.selectIndex = index
  299. this.$refs.chooseServiceTime.openPopup()
  300. },
  301. //选择服务时段
  302. getPeriodDate(e) {
  303. this.orderParam.childService[this.selectIndex].serviceStartTime = e.label
  304. this.orderParam.childService[this.selectIndex].timeRangeId = e.id
  305. },
  306. selectChange() {
  307. this.selectIcon = !this.selectIcon
  308. },
  309. goTermsOfService() {
  310. uni.navigateTo({
  311. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  312. })
  313. },
  314. //提交订单
  315. commitOrder() {
  316. if(!this.selectIcon){
  317. uni.$u.toast('请阅读并同意《预约需知》')
  318. return;
  319. }
  320. if (this.orderParam.childService.length === 0) {
  321. uni.$u.toast('请选择服务对象')
  322. return;
  323. }
  324. if(this.requestStatus){
  325. return;
  326. }
  327. this.requestStatus=true
  328. this.$api.commonGeneralOrder(this.orderParam).then(res=>{
  329. console.log('++++++++++++++++++订单提交+++++++++++',res)
  330. this.orderNo = res.data.data.orderNo
  331. this.subOrderNo = res.data.data.subOrderNo
  332. this.$refs.myPay.openPopup()
  333. this.requestStatus=false
  334. }).catch(err =>{
  335. this.requestStatus=false
  336. })
  337. },
  338. }
  339. }
  340. </script>
  341. <style scoped lang="scss">
  342. @import './index.rpx.scss';
  343. </style>