index.vue 16 KB

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