index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view class="page">
  3. <view class="flex-col group">
  4. <view class="flex-col justify-around groupItem1">
  5. <view class="groupItemKey">
  6. <text>请选择服务对象</text>
  7. </view>
  8. <view class="flex-row justify-between groupItemContent" @click="getServiceObject">
  9. <text>{{ serviceObject.nickName || '请选择对象' }}</text>
  10. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  11. </view>
  12. <text class="text_5">娇宝,此排队提交后只针对一个服务对象,服务对象指接受娇骄儿理发服务的儿童</text>
  13. </view>
  14. <view class="flex-col justify-around groupItem">
  15. <view class="groupItemKey">
  16. <text>请选择服务类型</text>
  17. </view>
  18. <picker @change="bindPickerChange" mode='selector' range-key="typeName" :value="storeServiceIndex"
  19. :range="storeServiceList">
  20. <view class="flex-row justify-between groupItemContent">
  21. <text>{{ storeServiceList[storeServiceIndex].typeName || '请选择服务类别' }}</text>
  22. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  23. </view>
  24. </picker>
  25. </view>
  26. </view>
  27. <view class="flex-col group marginTop">
  28. <view class="flex-row ">
  29. <view class="hint">
  30. <text>!</text>
  31. </view>
  32. <view class="hintCentent">
  33. <text>娇宝,提前10分钟到哟,一人一号过号需要重新取号排队!等你哟</text>
  34. </view>
  35. </view>
  36. <view class="flex-col justify-around groupItem">
  37. <view class="groupItemKey">
  38. <text>服务日期</text>
  39. </view>
  40. <picker @change="bindPickerChange1" mode='selector' range-key="label" :value="periodDateIndex"
  41. :range="periodDateList">
  42. <view class="flex-row justify-between groupItemContent">
  43. <text>{{ periodDateList[periodDateIndex].label || '请选择服务日期' }}</text>
  44. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  45. </view>
  46. </picker>
  47. </view>
  48. <view class="flex-col justify-around groupItem">
  49. <view class="groupItemKey">
  50. <text>服务时段</text>
  51. </view>
  52. <picker @change="bindPickerChange2" mode='selector' range-key="label" :value="periodTimeIndex"
  53. :range="periodTimeList">
  54. <view class="flex-row justify-between groupItemContent">
  55. <text>{{ periodTimeList[periodTimeIndex].label || '服务时段' }}</text>
  56. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  57. </view>
  58. </picker>
  59. </view>
  60. <view class="flex-col justify-around groupItem">
  61. <view class="groupItemKey">
  62. <text>服务人员</text>
  63. </view>
  64. <view class="flex-row justify-between groupItemContent" @click="chooseServiceTeacher">
  65. <text>{{ serviceTeacher.personName || '请选择服务人员' }}</text>
  66. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="flex-col group marginTop">
  71. <view class="groupItemKey">
  72. <text>服务定制</text>
  73. </view>
  74. <view class="textareaView">
  75. <textarea v-model="remark" placeholder-style="color:#999999;fontSize:28rpx" placeholder="如有其它特殊需求,请在此输入您的需求"/>
  76. </view>
  77. </view>
  78. <view :style="{'height':'236rpx'}"></view>
  79. <view class="flex-col group2 ">
  80. <view class="btnTitle flex-row">
  81. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  82. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  83. <text :style="{'margin-left':'10rpx'}">请阅读并同意</text>
  84. <text :style="{'color':'red'}" @click="goTermsOfService">《预约需知》</text>
  85. </view>
  86. <!-- <view class="btnTitle">-->
  87. <!-- <text>提交订单之前需支付预约服务费用</text>-->
  88. <!-- </view>-->
  89. <view class="btn flex-row justify-between">
  90. <view>
  91. <text class="title">待支付</text>
  92. <text class="num">¥{{ price }}</text>
  93. </view>
  94. <view class="btnRight" @click="commitOrder">
  95. <text>提交</text>
  96. </view>
  97. </view>
  98. </view>
  99. <uni-popup ref="passwordPopup">
  100. <view class="passwordView flex-col">
  101. <view class="h-pay-title flex-row justify-center">
  102. <text>请输入交易密码</text>
  103. </view>
  104. <view class="h-tab-bar flex-row justify-center">
  105. <u-code-input v-model="password" mode="box" dot></u-code-input>
  106. </view>
  107. <view class="flex-row justify-center">
  108. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  109. <text>确定</text>
  110. </view>
  111. </view>
  112. </view>
  113. </uni-popup>
  114. <uni-popup ref="popup" type="bottom">
  115. <view class=" payView">
  116. <view class="flex-row justify-between">
  117. <text class="payType">请选择支付方式</text>
  118. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  119. </view>
  120. <view class="payTitle">
  121. <text>选择微信支付或余额支付</text>
  122. </view>
  123. <view class="payItem flex-row justify-between" @click="payItem(1)">
  124. <view class="flex-row">
  125. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  126. <view class="payName flex-col justify-center">
  127. <text>余额支付</text>
  128. <text class="balance">可以余额¥{{ userInfo.balance || 0 }}</text>
  129. </view>
  130. </view>
  131. <view class="flex-col justify-center">
  132. <view v-if="curServiceTab === 1">
  133. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  134. </view>
  135. <view v-else>
  136. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="payItem flex-row justify-between" @click="payItem(2)">
  141. <view class="flex-row">
  142. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  143. <view class="payName flex-col justify-center">
  144. <text>微信支付</text>
  145. </view>
  146. </view>
  147. <view class="flex-col justify-center">
  148. <view v-if="curServiceTab === 2">
  149. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  150. </view>
  151. <view v-else>
  152. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  153. </view>
  154. </view>
  155. </view>
  156. <view class="commitBtn" @click="commonGeneralOrder">
  157. <text>确定</text>
  158. </view>
  159. </view>
  160. </uni-popup>
  161. </view>
  162. </template>
  163. <script>
  164. export default {
  165. data() {
  166. return {
  167. password: '',
  168. remark: '',
  169. userInfo: {},
  170. curServiceTab: 1,
  171. //服务门店
  172. store: {},
  173. //服务对象
  174. serviceObject: {},
  175. //服务技师
  176. serviceTeacher: {},
  177. //服务类型
  178. storeServiceList: [],
  179. storeServiceIndex: 0,
  180. //服务时间
  181. periodDateList: [],
  182. periodDateIndex: 0,
  183. //服务时段
  184. periodTimeList: [],
  185. periodTimeIndex: 0,
  186. //预约费用
  187. price: '0',
  188. //订单编号
  189. orderNo: '',
  190. subOrderNo: '',
  191. selectIcon:true
  192. }
  193. },
  194. onLoad() {
  195. // this.listServiceObject()
  196. this.store = uni.getStorageSync('storeInfo')
  197. this.userInfo = uni.getStorageSync('userInfo')
  198. // this.storeAllServiceList()
  199. this.category()
  200. // this.selectDate()
  201. },
  202. onShow() {
  203. // 服务对象
  204. uni.$off()
  205. uni.$on('selectedServiceObject', this.selectedServiceObject);
  206. uni.$on('selectedServiceTeacher', this.selectedServiceTeacher);
  207. },
  208. methods: {
  209. goTermsOfService(){
  210. uni.navigateTo({
  211. url:'/myPages/TermsOfService/index?name='+'预约需知'+'&type=' + 5
  212. })
  213. },
  214. selectChange(){
  215. this.selectIcon = !this.selectIcon
  216. },
  217. payItem(num) {
  218. if (this.userInfo.balance*1 < this.price*1) {
  219. return
  220. }
  221. this.curServiceTab = num
  222. },
  223. //提交订单
  224. commitOrder() {
  225. this.$api.commonGeneralOrder({
  226. orderType: 1,
  227. serviceObjectId: 1,
  228. serviceAttribute: 2,
  229. serviceStoreId: 1,
  230. serviceTypeId: 1,
  231. serviceDate: 1,
  232. serviceUserId: 1,
  233. serviceStartTime: 1,
  234. timeRangeId: 1,
  235. remark: 1
  236. }).then(res => {
  237. this.orderNo = res.data.data.orderNo
  238. this.subOrderNo = res.data.data.subOrderNo
  239. if (res.data.data.subOrderNo === null) {
  240. uni.switchTab({
  241. url: '/pages/order/index'
  242. })
  243. } else {
  244. if (this.curServiceTab === 1) {
  245. //开启余额支付密码框
  246. // this.$refs.passwordPopup.open()
  247. this.balancePay()
  248. }
  249. if (this.curServiceTab === 2) {
  250. //调微信支付
  251. this.wechatPay()
  252. }
  253. }
  254. })
  255. if(!this.selectIcon){
  256. uni.$u.toast('请阅读并同意《预约需知》')
  257. return;
  258. }
  259. if (!this.serviceObject) {
  260. uni.$u.toast('请选择服务对象')
  261. return
  262. }
  263. if (!this.serviceTeacher.personId) {
  264. uni.$u.toast('请选择服务人员')
  265. return
  266. }
  267. if (this.price*1 > 0) {
  268. this.$refs.popup.open()
  269. if (this.userInfo.balance*1 < this.price*1) {
  270. this.curServiceTab = 2
  271. }
  272. } else {
  273. this.commonGeneralOrder()
  274. }
  275. },
  276. closePayPopup() {
  277. this.$refs.popup.close()
  278. },
  279. wechatPay() {
  280. let that = this;
  281. // 发起微信支付
  282. this.$api.wechatPay({
  283. orderNo: this.subOrderNo
  284. }).then((res) => {
  285. var param = res.data.data;
  286. uni.requestPayment({
  287. appId: param.appid,
  288. timeStamp: param.timestamp + "",
  289. nonceStr: param.noncestr,
  290. package: "prepay_id=" + param.prepayid,
  291. signType: "RSA",
  292. paySign: param.sign,
  293. success: res => {
  294. uni.showToast({
  295. title: '支付成功!'
  296. });
  297. setTimeout(res => {
  298. uni.switchTab({
  299. url: '/pages/order/index'
  300. })
  301. }, 1000)
  302. },
  303. fail: res => {
  304. console.log(res)
  305. uni.showModal({
  306. content: '支付失败',
  307. showCancel: false
  308. });
  309. setTimeout(res => {
  310. uni.switchTab({
  311. url: '/pages/order/index'
  312. })
  313. }, 1000)
  314. }
  315. });
  316. }).catch(() => {
  317. uni.showToast({
  318. title: "操作失败"
  319. })
  320. });
  321. },
  322. //余额支付
  323. balancePay() {
  324. let that = this;
  325. // if(this.password.length< 6 ){
  326. // uni.showToast({
  327. // title: "交易密码不能小于6位"
  328. // })
  329. // return ;
  330. // }
  331. // this.$refs.passwordPopup.close()
  332. this.$api.balancePay({
  333. orderNo: this.subOrderNo,
  334. password: ''
  335. }).then((res) => {
  336. that.$refs.popup.close()
  337. uni.showToast({
  338. title: '支付成功!'
  339. });
  340. setTimeout(res => {
  341. uni.switchTab({
  342. url: '/pages/order/index'
  343. })
  344. }, 1000)
  345. this.getUserInfo()
  346. }).catch((res) => {
  347. console.log(res)
  348. that.$refs.popup.close()
  349. let msg = res.data.msg || '操作失败';
  350. uni.showToast({
  351. title: msg,
  352. icon: 'error'
  353. })
  354. // setTimeout(res=>{
  355. // uni.switchTab({
  356. // url:'/pages/order/index'
  357. // })
  358. // },1000)
  359. });
  360. },
  361. getUserInfo() {
  362. this.$api.getUserInfo().then(res => {
  363. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  364. uni.setStorageSync('userInfo', res.data.data)
  365. this.userInfo = res.data.data
  366. })
  367. },
  368. commonGeneralOrder() {
  369. if(this.requestStatus){
  370. return;
  371. }
  372. this.requestStatus=true
  373. this.$refs.popup.close()
  374. this.requestStatus=false
  375. this.$api.commonGeneralOrder({
  376. orderType: 1,
  377. serviceObjectId: this.serviceObject.id,
  378. serviceAttribute: 2,
  379. serviceStoreId: this.store.storeId,
  380. serviceTypeId: this.storeServiceList[this.storeServiceIndex].id,
  381. serviceDate: this.periodDateList[this.periodDateIndex].label,
  382. serviceUserId: this.serviceTeacher.personId,
  383. serviceStartTime: this.periodTimeList[this.periodTimeIndex].label,
  384. timeRangeId: this.serviceTeacher.crewPeriodId,
  385. remark: this.remark
  386. }).then(res => {
  387. this.orderNo = res.data.data.orderNo
  388. this.subOrderNo = res.data.data.subOrderNo
  389. if (res.data.data.subOrderNo === null) {
  390. uni.switchTab({
  391. url: '/pages/order/index'
  392. })
  393. } else {
  394. if (this.curServiceTab === 1) {
  395. //开启余额支付密码框
  396. // this.$refs.passwordPopup.open()
  397. this.balancePay()
  398. }
  399. if (this.curServiceTab === 2) {
  400. //调微信支付
  401. this.wechatPay()
  402. }
  403. }
  404. })
  405. },
  406. //获取预约费用
  407. getAppointmentPrice() {
  408. this.$api.getAppointmentPrice({
  409. storeId: this.store.storeId,
  410. date: this.periodDateList[this.periodDateIndex].label,
  411. timeRangeId: this.serviceTeacher.crewPeriodId,
  412. servicePersonId: this.serviceTeacher.personId,
  413. serviceProjectId: this.storeServiceList[this.storeServiceIndex].id
  414. }).then(res => {
  415. this.price = res.data.data.price
  416. })
  417. },
  418. //选择服务人员
  419. chooseServiceTeacher() {
  420. if (this.periodDateList.length <= 0 || this.periodTimeList.length <= 0) {
  421. uni.$u.toast('请选择服务时间')
  422. }
  423. console.log("a->", this.periodTimeIndex)
  424. console.log("b->", this.periodTimeList)
  425. uni.navigateTo({
  426. url: '/orderPages/serviceTeacher/index?organization=' + this.store.storeId
  427. + '&schedulingDate=' + this.periodDateList[this.periodDateIndex].label
  428. + '&time=' + this.periodTimeList[this.periodTimeIndex].value
  429. + '&serviceTypeId=' + this.storeServiceList[this.storeServiceIndex].id
  430. })
  431. },
  432. //获取排班日期
  433. selectDate() {
  434. console.log(this.store)
  435. this.$api.selectDate({
  436. organization: this.store.storeId
  437. }).then(res => {
  438. this.periodDateList = res.data.data
  439. // this.selectPeriodByDate(res.data.data[0].label)
  440. this.getServiceTime(res.data.data[0].label);
  441. })
  442. },
  443. //获取门店排班时段
  444. // selectPeriodByDate(date){
  445. // this.$api.selectPeriodByDate({
  446. // organization:this.store.storeId,
  447. // schedulingDate:date
  448. // }).then(res =>{
  449. // this.periodTimeList = res.data.data
  450. // if (this.periodTimeList.length===0){
  451. // uni.$u.toast('暂无排班时段')
  452. // }
  453. // })
  454. // },
  455. //获取门店排班时段
  456. getServiceTime(date) {
  457. this.$api.getServiceTime({
  458. storeId: this.store.storeId,
  459. date: date,
  460. serviceTypeId:this.storeServiceList[this.storeServiceIndex].id
  461. }).then(res => {
  462. this.periodTimeList = res.data.data
  463. if (this.periodTimeList.length === 0) {
  464. uni.$u.toast('暂无排班时段')
  465. }
  466. })
  467. },
  468. // 查询服务对像信息列表
  469. listServiceObject() {
  470. this.$api.listServiceObject({}).then((res) => {
  471. this.serviceObject = res.data.data[0]
  472. }).catch((err) => {
  473. uni.showToast({
  474. title: "操作失败"
  475. })
  476. });
  477. },
  478. getServiceObject() {
  479. uni.navigateTo({
  480. url: '/orderPages/serviceObject/index'
  481. })
  482. },
  483. selectedServiceObject(e) {
  484. this.serviceObject = e
  485. },
  486. selectedServiceTeacher(e) {
  487. this.serviceTeacher = e
  488. this.getAppointmentPrice()
  489. },
  490. //服务类别发生改变
  491. bindPickerChange(e) {
  492. this.serviceTeacher = {}
  493. this.storeServiceIndex = e.detail.value
  494. console.log(e)
  495. this.selectDate()
  496. },
  497. //服务日期发生改变
  498. bindPickerChange1(e) {
  499. this.periodDateIndex = e.detail.value
  500. this.getServiceTime(this.periodDateList[e.detail.value].label)
  501. this.serviceTeacher = {};
  502. console.log(e)
  503. },
  504. //服务时段发生改变
  505. bindPickerChange2(e) {
  506. this.periodTimeIndex = e.detail.value
  507. this.serviceTeacher = {}
  508. console.log(e)
  509. },
  510. category() {
  511. this.$api.category({storeId: this.store.storeId}).then(res => {
  512. this.storeServiceList = res.data.data
  513. this.selectDate()
  514. })
  515. },
  516. }
  517. }
  518. </script>
  519. <style scoped lang="scss">
  520. @import '/common/css/common.css';
  521. @import './index.rpx.scss';
  522. </style>