index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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="flex-col justify-center timeItem " :class="{selectBack: item2.select}" @click="selectServiceTime(item.periodTimeList,index,index2)">
  38. <view class="flex-row justify-center">
  39. <text class="time">{{item2.label}}</text>
  40. </view>
  41. <!-- <view class="flex-row justify-center">-->
  42. <!-- <text class="price">¥{{item2.price}}</text>-->
  43. <!-- </view>-->
  44. </view>
  45. </u-grid-item>
  46. </u-grid>
  47. </view>
  48. </view>
  49. <view class="flex-col group ">
  50. <view class="groupItemKey">
  51. <text>取号规则</text>
  52. </view>
  53. <view class="serobReminder">
  54. <text>1.你已进入不挑师傅不挑时段的单剪造型占位理发服务。</text>
  55. </view>
  56. <view class="serobReminder">
  57. <text>2.预约需要一人一号。</text>
  58. </view>
  59. <view class="serobReminder">
  60. <text>3.到门店先签到,过时没有签到占位时段失效。</text>
  61. </view>
  62. <view class="serobReminder">
  63. <text>4.服务费用到店享受相应服务以后在另行收取。</text>
  64. </view>
  65. </view>
  66. <view class="tabBarLineHeight "></view>
  67. <view class="tabBarView">
  68. <view class="submitButton " @click="openSetting">提交</view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. components: {
  75. },
  76. data() {
  77. return {
  78. timeoutId:null,
  79. periodTimeList:[],
  80. userInfo: {},
  81. store: {},
  82. serviceObjectList: [],
  83. requestStatus: false,
  84. orderParam: {
  85. orderType: 1,
  86. serviceAttribute: 1,
  87. serviceStoreId: '',
  88. remark: '',
  89. serviceDate: '',
  90. childService: [
  91. // {
  92. // periodDate:'',//回显需要,不做参数
  93. // serviceObjectId: '',
  94. // facePhotoUrl:'', //回显需要,不做参数
  95. // nickName:'', //回显需要,不做参数
  96. // serviceUserId: '',
  97. // personName:'',//回显需要,不做参数
  98. // fee:'',//回显需要,不做参数
  99. // serviceStartTime: ''
  100. // }
  101. ]
  102. }
  103. }
  104. },
  105. onLoad() {
  106. this.store = uni.getStorageSync('storeInfo')
  107. this.userInfo = uni.getStorageSync('userInfo')
  108. this.orderParam.serviceStoreId = this.store.storeId
  109. let date = new Date();
  110. this.orderParam.serviceDate = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' +
  111. date.getDate()).slice(-2)
  112. this.timeoutId = setTimeout(()=>{
  113. uni.showModal({
  114. title:'温馨提示',
  115. content:'您在下单页面停留太久,请重新进入!',
  116. showCancel:false,
  117. success:res=>{
  118. if (res.confirm){
  119. uni.switchTab({
  120. url: '/pages/index/index',
  121. })
  122. }
  123. }
  124. })
  125. },1000*60*5)
  126. },
  127. onShow() {
  128. this.getServicePersonTime()
  129. this.getTemplateList()
  130. },
  131. onUnload(){
  132. clearTimeout(this.timeoutId);
  133. },
  134. methods: {
  135. back(){
  136. uni.switchTab({
  137. url: '/pages/index/index',
  138. })
  139. },
  140. selectServiceTime(items,index,index2){
  141. items.forEach(e=>{
  142. e.select=false
  143. })
  144. let oidTime = this.orderParam.childService[index].serviceStartTime
  145. items[index2].select =true // 新选中的时间
  146. this.orderParam.childService[index].serviceStartTime = items[index2].label
  147. for (let i=0;i<this.orderParam.childService.length;i++){
  148. if (index != i){
  149. for (const time of this.orderParam.childService[i].periodTimeList) {
  150. if (time.label == oidTime){
  151. console.log('++++++++++++++++++++',oidTime)
  152. time.total = time.total + 1
  153. }
  154. if (time.label == items[index2].label) {
  155. console.log('------------------', items[index2].label)
  156. time.total = time.total - 1
  157. }
  158. }
  159. }
  160. }
  161. this.$forceUpdate()
  162. },
  163. // 查询服务对接信息列表
  164. listServiceObject() {
  165. this.$api.listServiceObject(this.reqParm).then((res) => {
  166. console.log(res)
  167. this.serviceObjectList = res.data.data
  168. this.getImgUrlByBannerOssId(this.serviceObjectList);
  169. this.orderParam.childService = [],
  170. this.serviceObjectList[0].select = true
  171. let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  172. let childService = {
  173. periodDate: '',
  174. serviceObjectId: this.serviceObjectList[0].id,
  175. facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
  176. nickName: this.serviceObjectList[0].nickName,
  177. serviceUserId: -1,
  178. fee: '',
  179. serviceStartTime: periodTimeList[0].label,
  180. periodTimeList:periodTimeList
  181. }
  182. periodTimeList[0].select = true
  183. this.orderParam.childService.push(childService)
  184. })
  185. },
  186. // 获取图片
  187. getImgUrlByBannerOssId(items) {
  188. for (let i = 0; i < items.length; i++) {
  189. if (items[i].facePhoto) {
  190. this.$api.getImgUrlByOssId({
  191. ossId: items[i].facePhoto
  192. }).then(res => {
  193. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  194. this.$set(this.serviceObjectList, i, items[i])
  195. if (i === 0) {
  196. this.orderParam.childService[0].facePhotoUrl = res.data.data[0].url.replace(
  197. /^http:/, "https:")
  198. }
  199. })
  200. }
  201. }
  202. },
  203. addServiceObject() {
  204. uni.navigateTo({
  205. url: '/myPages/ServiceObjectManagement/index'
  206. })
  207. },
  208. getServicePersonTime(){
  209. this.$api.getServicePersonTime({
  210. personId: -1,
  211. date: this.orderParam.serviceDate,
  212. storeId:this.store.storeId
  213. }).then(res=>{
  214. console.log("++++++++++++++++++res++++++++++++++++++++",res)
  215. this.periodTimeList = res.data.data
  216. if (this.periodTimeList.length===0){
  217. uni.$u.toast('暂无可预约排班')
  218. }
  219. // 服务对象
  220. this.listServiceObject()
  221. })
  222. },
  223. selectServiceObject(item) {
  224. if (item.select) {
  225. this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
  226. selectServiceObject.serviceObjectId !== item.id)
  227. } else {
  228. let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
  229. periodTimeList.forEach(i=>{
  230. this.orderParam.childService.forEach(i1=>{
  231. if (i.label == i1.serviceStartTime){
  232. i.total = i.total -1
  233. }
  234. })
  235. })
  236. let childService = {
  237. periodDate: '',
  238. serviceObjectId: item.id,
  239. facePhotoUrl: item.facePhotoUrl,
  240. nickName: item.nickName,
  241. serviceUserId: -1,
  242. fee: '',
  243. serviceStartTime: '',
  244. periodTimeList:periodTimeList
  245. }
  246. for (const time of periodTimeList) {
  247. if (time.total>0){
  248. time.select = true
  249. childService.serviceStartTime = time.label
  250. for (const childService of this.orderParam.childService) {
  251. for (const periodTime of childService.periodTimeList) {
  252. if (time.label == periodTime.label) {
  253. periodTime.total = periodTime.total - 1
  254. }
  255. }
  256. }
  257. break
  258. }
  259. }
  260. this.orderParam.childService.push(childService)
  261. }
  262. item.select = !item.select
  263. this.price = 0
  264. for (let childService of this.orderParam.childService) {
  265. this.price = this.price * 1 + childService.fee * 1
  266. }
  267. },
  268. getTemplateList(){
  269. this.$api.getTemplateList().then(res=>{
  270. this.templateId=res.data.data.data.map(item=>{
  271. return item.priTmplId
  272. })
  273. })
  274. },
  275. openSetting(){
  276. uni.requestSubscribeMessage({
  277. tmplIds: this.templateId,
  278. success: (res) =>{
  279. let {errMsg,...param} = res
  280. console.log('+++++++++++++success+++++++++++++',param)
  281. this.$api.updateSubscribe(param).then(res=>{
  282. console.log('+++++++++++++updateSubscribe+++++++++++++',res)
  283. })
  284. },
  285. fail:(err)=>{
  286. console.log('+++++++++++++fail+++++++++++++',err)
  287. },
  288. complete:(complete)=>{
  289. console.log('+++++++++++++complete+++++++++++++',complete)
  290. this.commonGeneralOrder()
  291. }
  292. })
  293. },
  294. commonGeneralOrder() {
  295. if (!this.orderParam.childService.length) {
  296. uni.$u.toast('请选择服务对象')
  297. return
  298. }
  299. let flag = false
  300. this.orderParam.childService.forEach(i=>{
  301. if (!i.serviceStartTime){
  302. uni.$u.toast('请选择服务时段')
  303. flag= true
  304. }
  305. })
  306. if (flag){
  307. return;
  308. }
  309. if (this.requestStatus) {
  310. return;
  311. }
  312. this.requestStatus = true
  313. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  314. this.requestStatus = false
  315. uni.switchTab({
  316. url: '/pages/order/index'
  317. })
  318. }).catch(err => {
  319. this.requestStatus = false
  320. })
  321. }
  322. }
  323. }
  324. </script>
  325. <style scoped lang="scss">
  326. @import './index.rpx.scss';
  327. </style>