index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view class="page">
  3. <view class="periodDate">
  4. <text>服务日期:{{periodDate.label}}</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/logo.png'"></image>
  13. </view>
  14. <text class="serobName">{{item.nickName || '未填写'}}</text>
  15. <view class="serobV" v-if="item.select === true">
  16. <image class="serobVicon" src="/static/order/ud20.png"></image>
  17. </view>
  18. </view>
  19. </u-grid-item>
  20. </u-grid>
  21. </view>
  22. <view class="flex-col group " v-for="(item, index) in orderParam.childService">
  23. <view class="flex-row " >
  24. <image class="selectSerobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/logo.png'"></image>
  25. <text class="selectSerobName">{{item.nickName || '未填写'}}</text>
  26. </view>
  27. <view class="serob">
  28. <text>服务人员</text>
  29. </view>
  30. <view >
  31. <u-grid col="4">
  32. <u-grid-item v-for="(item,index1) in item.serviceTeacherList" :key="index1" >
  33. <view class="serobItem flex-col " >
  34. <view class="serobImgView ">
  35. <image class="serobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/logo.png'"></image>
  36. </view>
  37. <text class="serobName ">{{item.personName || '未填写'}}</text>
  38. <view class="flex-row justify-center ">
  39. <u-icon name="rmb-circle" size="14"></u-icon>
  40. <text class="teachPrice">¥{{item.fee}}</text>
  41. </view>
  42. <view class="serobV " v-if="item.select === true">
  43. <image class="serobVicon" src="/static/order/ud20.png"></image>
  44. </view>
  45. </view>
  46. </u-grid-item>
  47. </u-grid>
  48. </view>
  49. <view class="serob" :style="{'marginTop':'32rpx'}">
  50. <text>服务时段</text>
  51. </view>
  52. <view>
  53. <u-grid :border="false" col="5">
  54. <u-grid-item v-for="(item,index2) in item.serviceTimeList" :key="index2">
  55. <view class="flex-col justify-center timeItem" :class="{selectBack: item.select}">
  56. <view class="flex-row justify-center">
  57. <text class="time">{{item.label}}</text>
  58. </view>
  59. <view class="flex-row justify-center">
  60. <text class="price">¥{{item.price}}</text>
  61. </view>
  62. </view>
  63. </u-grid-item>
  64. </u-grid>
  65. </view>
  66. </view>
  67. <view class="flex-col group ">
  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. <myPay ref="myPay" :blPay="false" :orderNo="subOrderNo" @payResult="payResult"></myPay>
  96. </view>
  97. </template>
  98. <script>
  99. import myPay from '../../components/pay/pay';
  100. export default {
  101. components: {
  102. myPay
  103. },
  104. data() {
  105. return {
  106. //服务对象列表
  107. serviceObjectList:[],
  108. //服务人员列表
  109. serviceTeacherList:[],
  110. userInfo: {},
  111. //服务门店
  112. store: {},
  113. //默认服务时间
  114. periodDate: [],
  115. //预约费用
  116. price: '0',
  117. //订单编号
  118. orderNo: '',
  119. selectIcon: true,
  120. orderParam:{
  121. orderType: 1,
  122. serviceAttribute: 2,
  123. serviceStoreId: '',
  124. remark: '',
  125. serviceDate:'',
  126. childService:[
  127. // {
  128. // serviceObjectId: '',
  129. // facePhotoUrl:'', //回显需要,不做参数
  130. // nickName:'', //回显需要,不做参数
  131. // serviceUserId: '',
  132. // personName:'',//回显需要,不做参数
  133. // fee:'',//回显需要,不做参数
  134. // serviceStartTime: '',
  135. // serviceTeacherList:[],//服务人员列表,回显需要,不做参数
  136. // serviceTimeList:[]//服务时段列表,回显需要,不做参数
  137. // }
  138. ]
  139. }
  140. }
  141. },
  142. onLoad() {
  143. this.store = uni.getStorageSync('storeInfo')
  144. this.userInfo = uni.getStorageSync('userInfo')
  145. this.orderParam.serviceStoreId = this.store.storeId
  146. //获取排班日期
  147. this.selectDate()
  148. this.listServiceObject()
  149. },
  150. onShow() {
  151. },
  152. mounted(){
  153. },
  154. methods: {
  155. //获取排班日期
  156. selectDate() {
  157. console.log(this.store)
  158. this.$api.selectDate({
  159. organization: this.store.storeId
  160. }).then(res => {
  161. this.periodDate = res.data.data[0]
  162. this.orderParam.serviceDate=this.periodDate.label
  163. this.getServicePerson(this.periodDate.label)
  164. })
  165. },
  166. // 查询服务工作人员列表
  167. getServicePerson(date) {
  168. this.$api.getServicePerson({
  169. storeId:this.store.storeId,
  170. date:date
  171. }).then((res) => {
  172. this.serviceTeacherList = res.data.data;
  173. this.serviceTeacherList[0].select = true
  174. this.getServicePersonUrl(this.serviceTeacherList);
  175. })
  176. },
  177. getServicePersonUrl(items){
  178. for (let i = 0; i < items.length; i++) {
  179. if (items[i].facePhoto) {
  180. this.$api.getImgUrlByOssId({
  181. ossId: items[i].facePhoto
  182. }).then(res => {
  183. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  184. this.$set(this.serviceTeacherList, i, items[i])
  185. })
  186. }
  187. }
  188. },
  189. // 查询服务对象信息列表
  190. listServiceObject() {
  191. this.$api.listServiceObject(this.reqParm).then((res) => {
  192. console.log(res)
  193. this.serviceObjectList = res.data.data
  194. this.getServiceObjectUrl(this.serviceObjectList);
  195. })
  196. },
  197. // 获取图片
  198. getServiceObjectUrl(items) {
  199. for (let i = 0; i < items.length; i++) {
  200. if (items[i].facePhoto) {
  201. this.$api.getImgUrlByOssId({
  202. ossId: items[i].facePhoto
  203. }).then(res => {
  204. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  205. this.$set(this.serviceObjectList, i, items[i])
  206. if (i === 0){
  207. this.selectServiceObject(items[i])
  208. }
  209. })
  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. this.$api.getServicePersonTime({
  220. personId: this.serviceTeacherList[0].personId,
  221. date: this.periodDate.label,
  222. storeId:this.store.storeId
  223. }).then(res => {
  224. let periodTimeList = res.data.data
  225. let selectServiceObjectList = this.orderParam.childService
  226. selectServiceObjectList.forEach(selectServiceObject =>{
  227. periodTimeList.forEach(periodTime =>{
  228. if (selectServiceObject.serviceStartTime === periodTime.label ){
  229. periodTime.total = periodTime.total - 1
  230. }
  231. })
  232. })
  233. periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
  234. periodTimeList[0].select = true
  235. console.log(periodTimeList)
  236. let childService ={
  237. serviceObjectId: item.id,
  238. facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
  239. nickName:item.nickName, //回显需要,不做参数
  240. serviceUserId: this.serviceTeacherList[0].personId,
  241. fee:this.serviceTeacherList[0].fee,//回显需要,不做参数
  242. serviceStartTime: periodTimeList[0].label,
  243. serviceTeacherList:this.serviceTeacherList,//服务人员列表,回显需要,不做参数
  244. serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
  245. }
  246. this.orderParam.childService.push(childService)
  247. })
  248. }
  249. item.select = !item.select
  250. this.price = 0
  251. for (let childService of this.orderParam.childService) {
  252. this.price = this.price * 1 + childService.fee * 1
  253. }
  254. },
  255. selectChange() {
  256. this.selectIcon = !this.selectIcon
  257. },
  258. goTermsOfService() {
  259. uni.navigateTo({
  260. url: '/myPages/TermsOfService/index?name=' + '预约需知' + '&type=' + 5
  261. })
  262. },
  263. //支付组件回调
  264. payResult(e){
  265. console.log(e)
  266. if(e.payResult){
  267. uni.showToast({
  268. title: '支付成功!'
  269. });
  270. }else {
  271. uni.showToast({
  272. title: '支付失败',
  273. icon: 'error'
  274. });
  275. }
  276. setTimeout(()=>{
  277. uni.switchTab({
  278. url: '/pages/order/index'
  279. })
  280. },1000)
  281. },
  282. //提交订单
  283. commitOrder() {
  284. if (this.subOrderNo){
  285. this.$refs.myPay.openPopup()
  286. }else {
  287. if (!this.selectIcon) {
  288. uni.$u.toast('请阅读并同意《预约需知》')
  289. return;
  290. }
  291. if (this.orderParam.childService.length === 0) {
  292. uni.$u.toast('请选择服务对象')
  293. return;
  294. }
  295. if (this.requestStatus) {
  296. return;
  297. }
  298. this.requestStatus = true
  299. this.$api.commonGeneralOrder(this.orderParam).then(res => {
  300. console.log('++++++++++++++++++订单提交+++++++++++', res)
  301. if (res.data.data.subOrderNo) {
  302. this.orderNo = res.data.data.orderNo
  303. this.subOrderNo = res.data.data.subOrderNo
  304. this.$refs.myPay.openPopup()
  305. } else {
  306. uni.$u.toast('预约成功')
  307. setTimeout(() => {
  308. uni.switchTab({
  309. url: '/pages/order/index'
  310. })
  311. }, 1000)
  312. }
  313. this.requestStatus = false
  314. }).catch(err => {
  315. this.requestStatus = false
  316. })
  317. }
  318. },
  319. }
  320. }
  321. </script>
  322. <style scoped lang="scss">
  323. @import './index.rpx.scss';
  324. </style>