index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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)">
  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" :personId="personId" :date="date" @getPeriodDate="getPeriodDate"></chooseServiceTime>
  96. <myPay ref="myPay" :blPay="false"></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. requestStatus:false,
  112. personId:'',
  113. date:'',
  114. serviceObjectList: [],
  115. userInfo: {},
  116. //服务门店
  117. store: {},
  118. //默认服务技师
  119. serviceTeacher: {},
  120. //默认服务时间
  121. periodDate: [],
  122. //默认服务时段
  123. periodTime: [],
  124. //预约费用
  125. price: '0',
  126. //订单编号
  127. orderNo: '',
  128. subOrderNo: '',
  129. selectIcon: true,
  130. orderParam:{
  131. orderType: 1,
  132. serviceAttribute: 2,
  133. serviceStoreId: '',
  134. remark: '',
  135. childService:[
  136. {
  137. periodDate:'',//回显需要,不做参数
  138. serviceObjectId: '',
  139. facePhotoUrl:'', //回显需要,不做参数
  140. nickName:'', //回显需要,不做参数
  141. serviceUserId: '',
  142. personName:'',//回显需要,不做参数
  143. fee:'',//回显需要,不做参数
  144. serviceStartTime: '',
  145. timeRangeId: ''
  146. }
  147. ]
  148. }
  149. }
  150. },
  151. onLoad() {
  152. this.store = uni.getStorageSync('storeInfo')
  153. this.userInfo = uni.getStorageSync('userInfo')
  154. this.orderParam.serviceStoreId = this.store.storeId
  155. this.selectDate()
  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. if (this.orderParam.childService.length === 1) {
  173. this.orderParam.childService[0].periodDate = this.periodDate.label
  174. }
  175. if (res.data.data[0]){
  176. this.getServicePerson(res.data.data[0].label);
  177. }
  178. })
  179. },
  180. // 查询服务工作人员列表
  181. getServicePerson(date) {
  182. this.$api.getServicePerson({
  183. storeld:this.store.storeId,
  184. date:date
  185. }).then((res) => {
  186. this.serviceTeacher = res.data.data[0];
  187. this.personId =this.serviceTeacher.id
  188. if (this.orderParam.childService.length === 1) {
  189. this.orderParam.childService[0].serviceUserId = res.data.data[0].personId
  190. this.orderParam.childService[0].personName = res.data.data[0].personName
  191. this.orderParam.childService[0].fee = res.data.data[0].fee
  192. this.price = res.data.data[0].fee * 1
  193. }
  194. if (res.data.data[0]){
  195. this.getServiceTime(date,res.data.data[0].personId)
  196. }
  197. })
  198. },
  199. //获取门店排班时段
  200. getServiceTime(date,personId) {
  201. this.$api.getServicePersonTime({
  202. personId: personId === -1 ? '' : personId,
  203. date: date,
  204. }).then(res => {
  205. this.periodTime = res.data.data[0]
  206. if (this.orderParam.childService.length === 1) {
  207. this.orderParam.childService[0].serviceStartTime = res.data.data[0].label
  208. this.orderParam.childService[0].timeRangeId = res.data.data[0].id
  209. }
  210. })
  211. },
  212. selectServiceObject(item) {
  213. console.log(item)
  214. if (item.select) {
  215. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  216. selectServiceObject.serviceObjectId !== item.id)
  217. } else {
  218. let childService ={
  219. periodDate: this.periodDate.label,
  220. serviceObjectId: item.id,
  221. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  222. nickName:item.nickName, //回显需要,不做参数
  223. serviceUserId: this.serviceTeacher.personId ,
  224. personName:this.serviceTeacher.personName ,//回显需要,不做参数
  225. fee:this.serviceTeacher.fee ,//回显需要,不做参数
  226. serviceStartTime: this.periodTime.label ,
  227. timeRangeId: this.periodTime.id
  228. }
  229. this.orderParam.childService.push(childService)
  230. for (let childService of this.orderParam.childService) {
  231. this.price = 0
  232. this.price = this.price * 1 + childService.fee * 1
  233. }
  234. }
  235. item.select = !item.select
  236. },
  237. // 查询服务对接信息列表
  238. listServiceObject() {
  239. this.$api.listServiceObject(this.reqParm).then((res) => {
  240. console.log(res)
  241. this.serviceObjectList = res.data.data
  242. this.getImgUrlByBannerOssId(this.serviceObjectList);
  243. if (this.orderParam.childService.length === 1) {
  244. let selectServiceObject = this.serviceObjectList[0]
  245. this.orderParam.childService[0].serviceObjectId = selectServiceObject.id,
  246. this.orderParam.childService[0].nickName = selectServiceObject.nickName,
  247. this.serviceObjectList[0].select = true
  248. } else {
  249. for (let selectServiceObject of this.orderParam.childService) {
  250. for (let serviceObject of this.serviceObjectList) {
  251. if (selectServiceObject.id === serviceObject.id) {
  252. serviceObject.select = true
  253. }
  254. }
  255. }
  256. }
  257. })
  258. },
  259. // 获取图片
  260. getImgUrlByBannerOssId(items) {
  261. for (let i = 0; i < items.length; i++) {
  262. if (items[i].facePhoto) {
  263. this.$api.getImgUrlByOssId({
  264. ossId: items[i].facePhoto
  265. }).then(res => {
  266. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  267. this.$set(this.serviceObjectList, i, items[i])
  268. if (i === 0){
  269. this.orderParam.childService[0].facePhotoUrl =res.data.data[0].url.replace(/^http:/, "https:")
  270. }
  271. })
  272. }
  273. }
  274. },
  275. addServiceObject() {
  276. uni.navigateTo({
  277. url: '/myPages/ServiceObjectManagement/index'
  278. })
  279. },
  280. //选择服务人员
  281. chooseServiceTeacher(index) {
  282. this.selectIndex = index
  283. this.$refs.chooseServiceTeacher.openPopup()
  284. },
  285. //选择服务人员
  286. getWorkPerson(e) {
  287. this.orderParam.childService[this.selectIndex].serviceUserId = e.personId
  288. this.orderParam.childService[this.selectIndex].personName = e.personName
  289. this.orderParam.childService[this.selectIndex].fee = e.fee
  290. for (let childService of this.orderParam.childService) {
  291. this.price = 0
  292. this.price = this.price * 1 + childService.fee * 1
  293. }
  294. },
  295. //选择服务时段
  296. chooseServiceTime(index) {
  297. this.selectIndex = index
  298. this.$refs.chooseServiceTime.openPopup()
  299. },
  300. //选择服务时段
  301. getPeriodDate(e) {
  302. this.orderParam.childService[this.selectIndex].serviceStartTime = e.label
  303. this.orderParam.childService[this.selectIndex].timeRangeId = e.id
  304. },
  305. selectChange() {
  306. this.selectIcon = !this.selectIcon
  307. },
  308. goTermsOfService() {
  309. uni.navigateTo({
  310. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  311. })
  312. },
  313. //提交订单
  314. commitOrder() {
  315. if(!this.selectIcon){
  316. uni.$u.toast('请阅读并同意《预约需知》')
  317. return;
  318. }
  319. if (this.orderParam.childService.length === 0) {
  320. uni.$u.toast('请选择服务对象')
  321. return;
  322. }
  323. if(this.requestStatus){
  324. return;
  325. }
  326. this.requestStatus=true
  327. this.$api.commonGeneralOrder(this.orderParam).then(res=>{
  328. console.log('++++++++++++++++++订单提交+++++++++++',res)
  329. this.orderNo = res.data.data.orderNo
  330. this.subOrderNo = res.data.data.subOrderNo
  331. this.$refs.myPay.openPopup()
  332. this.requestStatus=false
  333. }).catch(err =>{
  334. this.requestStatus=false
  335. })
  336. },
  337. }
  338. }
  339. </script>
  340. <style scoped lang="scss">
  341. @import './index.rpx.scss';
  342. </style>