index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="page">
  3. <view class="periodDate">
  4. <text>服务日期:{{orderParam.serviceDate}}</text>
  5. </view>
  6. <view class="flex-col group">
  7. <view class="serob"><text>服务对象</text></view>
  8. <u-grid :border="false" col="4">
  9. <u-grid-item v-for="(item,index) in serviceObjectList" :key="index">
  10. <view class="serobItem flex-col">
  11. <view class="serobImgView" @click="selectServiceObject(item)">
  12. <image class="serobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'">
  13. </image>
  14. </view>
  15. <text class="serobName">{{item.nickName || '未填写'}}</text>
  16. <view class="serobV" v-if="item.select === true">
  17. <image class="serobVicon" src="/static/order/ud20.png"></image>
  18. </view>
  19. </view>
  20. </u-grid-item>
  21. </u-grid>
  22. </view>
  23. <view class="flex-col group" v-for="(item,index) in orderParam.childService">
  24. <view class="flex-row ">
  25. <image class="selectSerobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'"></image>
  26. <text class="selectSerobName">{{item.nickName || '未填写'}}</text>
  27. </view>
  28. <view class="serob" >
  29. <text>服务时段</text>
  30. </view>
  31. <view v-if="!item.serviceStartTime" class="noTime flex-row justify-center">
  32. <text>暂无可用的服务时段</text>
  33. </view>
  34. <view v-else>
  35. <u-grid :border="false" col="5">
  36. <u-grid-item v-if="item2.total > 0" v-for="(item2,index2) in item.periodTimeList" :key="index2">
  37. <view class="timeItemView">
  38. <view class="flex-col justify-center timeItem " :class="{selectBack: item2.select}" @click="selectServiceTime(item.periodTimeList,index,index2)">
  39. <view class="flex-row justify-center">
  40. <text class="time">{{item2.label}}</text>
  41. </view>
  42. <!-- <view class="flex-row justify-center">-->
  43. <!-- <text class="price">¥{{item2.price}}</text>-->
  44. <!-- </view>-->
  45. </view>
  46. </view>
  47. </u-grid-item>
  48. </u-grid>
  49. </view>
  50. </view>
  51. <view class="flex-col group ">
  52. <view class="groupItemKey">
  53. <text>取号规则</text>
  54. </view>
  55. <view v-for=" (item,index) in takeNumberRules " class="serobReminder">
  56. <text>{{index+1}}.{{item.dictValue}}。</text>
  57. </view>
  58. <!-- <view class="serobReminder">-->
  59. <!-- <text>1.你已进入不挑师傅不挑时段的单剪造型占位理发服务。</text>-->
  60. <!-- </view>-->
  61. <!-- <view class="serobReminder">-->
  62. <!-- <text>2.预约需要一人一号。</text>-->
  63. <!-- </view>-->
  64. <!-- <view class="serobReminder">-->
  65. <!-- <text>3.到门店先签到,过时没有签到占位时段失效。</text>-->
  66. <!-- </view>-->
  67. <!-- <view class="serobReminder">-->
  68. <!-- <text>4.服务费用到店享受相应服务以后在另行收取。</text>-->
  69. <!-- </view>-->
  70. </view>
  71. <view class="tabBarLineHeight "></view>
  72. <view class="tabBarView">
  73. <view class="submitButton " @click="openSetting">提交</view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. export default {
  79. components: {
  80. },
  81. data() {
  82. return {
  83. timeoutId:null,
  84. templateId:[],
  85. periodTimeList:[],
  86. userInfo: {},
  87. store: {},
  88. serviceObjectList: [],
  89. requestStatus: false,
  90. orderParam: {
  91. orderType: 1,
  92. serviceAttribute: 1,
  93. serviceStoreId: '',
  94. remark: '',
  95. serviceDate: '',
  96. childService: [
  97. // {
  98. // periodDate:'',//回显需要,不做参数
  99. // serviceObjectId: '',
  100. // facePhotoUrl:'', //回显需要,不做参数
  101. // nickName:'', //回显需要,不做参数
  102. // serviceUserId: '',
  103. // personName:'',//回显需要,不做参数
  104. // fee:'',//回显需要,不做参数
  105. // serviceStartTime: ''
  106. // }
  107. ]
  108. },
  109. takeNumberData:{
  110. pageNum:1,
  111. pageSize:10,
  112. dictType:'today_make_rule'
  113. },
  114. takeNumberRules:[],
  115. }
  116. },
  117. onLoad() {
  118. this.store = uni.getStorageSync('storeInfo')
  119. this.userInfo = uni.getStorageSync('userInfo')
  120. this.orderParam.serviceStoreId = this.store.storeId
  121. let date = new Date();
  122. this.orderParam.serviceDate = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' +
  123. date.getDate()).slice(-2)
  124. this.timeoutId = setTimeout(()=>{
  125. uni.showModal({
  126. title:'温馨提示',
  127. content:'您在下单页面停留太久,请重新进入!',
  128. showCancel:false,
  129. success:res=>{
  130. if (res.confirm){
  131. uni.switchTab({
  132. url: '/pages/index/index',
  133. })
  134. }
  135. }
  136. })
  137. },1000*60*5)
  138. },
  139. onShow() {
  140. this.getServicePersonTime()
  141. this.getTemplateList()
  142. this.getSelectionRules(this.takeNumberData)
  143. },
  144. onUnload(){
  145. clearTimeout(this.timeoutId);
  146. },
  147. methods: {
  148. back(){
  149. uni.switchTab({
  150. url: '/pages/index/index',
  151. })
  152. },
  153. selectServiceTime(items,index,index2){
  154. items.forEach(e=>{
  155. e.select=false
  156. })
  157. let oidTime = this.orderParam.childService[index].serviceStartTime
  158. items[index2].select =true // 新选中的时间
  159. this.orderParam.childService[index].serviceStartTime = items[index2].label
  160. for (let i=0;i<this.orderParam.childService.length;i++){
  161. if (index != i){
  162. for (const time of this.orderParam.childService[i].periodTimeList) {
  163. if (time.label == oidTime){
  164. console.log('++++++++++++++++++++',oidTime)
  165. time.total = time.total + 1
  166. }
  167. if (time.label == items[index2].label) {
  168. console.log('------------------', items[index2].label)
  169. time.total = time.total - 1
  170. }
  171. }
  172. }
  173. }
  174. this.$forceUpdate()
  175. },
  176. // 查询服务对象信息列表
  177. listServiceObject() {
  178. this.$api.listServiceObject(this.reqParm).then((res) => {
  179. console.log(res)
  180. this.serviceObjectList = res.data.data
  181. this.getImgUrlByBannerOssId(this.serviceObjectList);
  182. //不再默认选中第一个
  183. // if (this.periodTimeList.length >0){
  184. // this.orderParam.childService = [],
  185. // this.serviceObjectList[0].select = true
  186. // let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  187. // periodTimeList[0].select = true
  188. // let childService = {
  189. // periodDate: '',
  190. // serviceObjectId: this.serviceObjectList[0].id,
  191. // facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
  192. // nickName: this.serviceObjectList[0].nickName,
  193. // serviceUserId: -1,
  194. // fee: '',
  195. // serviceStartTime: periodTimeList[0].label,
  196. // periodTimeList:periodTimeList
  197. // }
  198. // this.orderParam.childService.push(childService)
  199. // }
  200. })
  201. },
  202. // 获取图片
  203. getImgUrlByBannerOssId(items) {
  204. for (let i = 0; i < items.length; i++) {
  205. if (items[i].facePhoto) {
  206. this.$api.getImgUrlByOssId({
  207. ossId: items[i].facePhoto
  208. }).then(res => {
  209. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  210. this.$set(this.serviceObjectList, i, items[i])
  211. if (i === 0) {
  212. this.orderParam.childService[0].facePhotoUrl = res.data.data[0].url.replace(
  213. /^http:/, "https:")
  214. }
  215. })
  216. }
  217. }
  218. },
  219. addServiceObject() {
  220. uni.navigateTo({
  221. url: '/myPages/ServiceObjectManagement/index'
  222. })
  223. },
  224. getServicePersonTime(){
  225. this.$api.getServicePersonTime({
  226. personId: -1,
  227. date: this.orderParam.serviceDate,
  228. storeId:this.store.storeId
  229. }).then(res=>{
  230. console.log("++++++++++++++++++res++++++++++++++++++++",res)
  231. this.periodTimeList = res.data.data
  232. if (this.periodTimeList.length===0){
  233. uni.$u.toast('暂无可预约排班')
  234. }
  235. // 服务对象
  236. this.listServiceObject()
  237. })
  238. },
  239. selectServiceObject(item) {
  240. if (item.select) {
  241. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  242. selectServiceObject.serviceObjectId !== item.id)
  243. } else {
  244. let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  245. periodTimeList.forEach(i=>{
  246. this.orderParam.childService.forEach(i1=>{
  247. if (i.label == i1.serviceStartTime){
  248. i.total = i.total -1
  249. }
  250. })
  251. })
  252. let childService = {
  253. periodDate: '',
  254. serviceObjectId: item.id,
  255. facePhotoUrl: item.facePhotoUrl,
  256. nickName: item.nickName,
  257. serviceUserId: -1,
  258. fee: '',
  259. serviceStartTime: '',
  260. periodTimeList:periodTimeList
  261. }
  262. for (const time of periodTimeList) {
  263. if (time.total>0){
  264. time.select = true
  265. childService.serviceStartTime = time.label
  266. for (const childService of this.orderParam.childService) {
  267. for (const periodTime of childService.periodTimeList) {
  268. if (time.label == periodTime.label) {
  269. periodTime.total = periodTime.total - 1
  270. }
  271. }
  272. }
  273. break
  274. }
  275. }
  276. this.orderParam.childService.push(childService)
  277. }
  278. item.select = !item.select
  279. this.price = 0
  280. for (let childService of this.orderParam.childService) {
  281. this.price = this.price * 1 + childService.fee * 1
  282. }
  283. },
  284. getTemplateList(){
  285. this.$api.getTemplateList().then(res=>{
  286. this.templateId=res.data.data.data.map(item=>{
  287. return item.priTmplId
  288. })
  289. })
  290. },
  291. getSelectionRules(data){
  292. this.$api.getSelectionRules(data).then(res=>{
  293. console.log(res.data.rows,'222222222222')
  294. this.takeNumberRules = res.data.rows
  295. })
  296. },
  297. openSetting(){
  298. if (!this.userInfo.phone){
  299. uni.showModal({
  300. title:'温馨提示',
  301. content:'预约叫号是通过手机尾号进行查询,是否确认绑定手机号!',
  302. success:res=>{
  303. if (res.confirm){
  304. uni.navigateTo({
  305. url: '/myPages/setting/setting-telphone',
  306. })
  307. }
  308. }
  309. })
  310. return
  311. }
  312. uni.requestSubscribeMessage({
  313. tmplIds: this.templateId,
  314. success: (res) =>{
  315. let {errMsg,...param} = res
  316. console.log('+++++++++++++success+++++++++++++',param)
  317. this.$api.updateSubscribe(param).then(res=>{
  318. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  319. })
  320. },
  321. fail:(err)=>{
  322. console.log('+++++++++++++fail+++++++++++++',err)
  323. },
  324. complete:(complete)=>{
  325. console.log('+++++++++++++complete+++++++++++++',complete)
  326. this.commonGeneralOrder()
  327. }
  328. })
  329. },
  330. commonGeneralOrder() {
  331. if (!this.orderParam.childService.length) {
  332. uni.$u.toast('请选择服务对象')
  333. return
  334. }
  335. let flag = false
  336. this.orderParam.childService.forEach(i=>{
  337. if (!i.serviceStartTime){
  338. uni.$u.toast('请选择服务时段')
  339. flag= true
  340. }
  341. })
  342. if (flag){
  343. return;
  344. }
  345. if (this.requestStatus) {
  346. return;
  347. }
  348. this.requestStatus = true
  349. uni.showLoading({
  350. title: '加载中'
  351. });
  352. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  353. this.requestStatus = false
  354. uni.hideLoading();
  355. uni.$u.toast('预约成功')
  356. setTimeout(() => {
  357. uni.switchTab({
  358. url: '/pages/order/index'
  359. })
  360. }, 500)
  361. }).catch(err => {
  362. this.requestStatus = false
  363. })
  364. }
  365. }
  366. }
  367. </script>
  368. <style scoped lang="scss">
  369. @import './index.rpx.scss';
  370. </style>