index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. if(!this.selectIcon){
  226. uni.$u.toast('请阅读并同意《预约需知》')
  227. return;
  228. }
  229. if (!this.serviceObject) {
  230. uni.$u.toast('请选择服务对象')
  231. return
  232. }
  233. if (!this.serviceTeacher.personId) {
  234. uni.$u.toast('请选择服务人员')
  235. return
  236. }
  237. if (this.price*1 > 0) {
  238. this.$refs.popup.open()
  239. if (this.userInfo.balance*1 < this.price*1) {
  240. this.curServiceTab = 2
  241. }
  242. } else {
  243. this.commonGeneralOrder()
  244. }
  245. },
  246. closePayPopup() {
  247. this.$refs.popup.close()
  248. },
  249. wechatPay() {
  250. let that = this;
  251. // 发起微信支付
  252. this.$api.wechatPay({
  253. orderNo: this.subOrderNo
  254. }).then((res) => {
  255. var param = res.data.data;
  256. uni.requestPayment({
  257. appId: param.appid,
  258. timeStamp: param.timestamp + "",
  259. nonceStr: param.noncestr,
  260. package: "prepay_id=" + param.prepayid,
  261. signType: "RSA",
  262. paySign: param.sign,
  263. success: res => {
  264. uni.showToast({
  265. title: '支付成功!'
  266. });
  267. setTimeout(res => {
  268. uni.switchTab({
  269. url: '/pages/order/index'
  270. })
  271. }, 1000)
  272. },
  273. fail: res => {
  274. console.log(res)
  275. uni.showModal({
  276. content: '支付失败',
  277. showCancel: false
  278. });
  279. setTimeout(res => {
  280. uni.switchTab({
  281. url: '/pages/order/index'
  282. })
  283. }, 1000)
  284. }
  285. });
  286. }).catch(() => {
  287. uni.showToast({
  288. title: "操作失败"
  289. })
  290. });
  291. },
  292. //余额支付
  293. balancePay() {
  294. let that = this;
  295. // if(this.password.length< 6 ){
  296. // uni.showToast({
  297. // title: "交易密码不能小于6位"
  298. // })
  299. // return ;
  300. // }
  301. // this.$refs.passwordPopup.close()
  302. this.$api.balancePay({
  303. orderNo: this.subOrderNo,
  304. password: ''
  305. }).then((res) => {
  306. that.$refs.popup.close()
  307. uni.showToast({
  308. title: '支付成功!'
  309. });
  310. setTimeout(res => {
  311. uni.switchTab({
  312. url: '/pages/order/index'
  313. })
  314. }, 1000)
  315. this.getUserInfo()
  316. }).catch((res) => {
  317. console.log(res)
  318. that.$refs.popup.close()
  319. let msg = res.data.msg || '操作失败';
  320. uni.showToast({
  321. title: msg,
  322. icon: 'error'
  323. })
  324. // setTimeout(res=>{
  325. // uni.switchTab({
  326. // url:'/pages/order/index'
  327. // })
  328. // },1000)
  329. });
  330. },
  331. getUserInfo() {
  332. this.$api.getUserInfo().then(res => {
  333. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  334. uni.setStorageSync('userInfo', res.data.data)
  335. this.userInfo = res.data.data
  336. })
  337. },
  338. commonGeneralOrder() {
  339. if(this.requestStatus){
  340. return;
  341. }
  342. this.requestStatus=true
  343. this.$refs.popup.close()
  344. this.requestStatus=false
  345. this.$api.commonGeneralOrder({
  346. orderType: 1,
  347. serviceObjectId: this.serviceObject.id,
  348. serviceAttribute: 2,
  349. serviceStoreId: this.store.storeId,
  350. serviceTypeId: this.storeServiceList[this.storeServiceIndex].id,
  351. serviceDate: this.periodDateList[this.periodDateIndex].label,
  352. serviceUserId: this.serviceTeacher.personId,
  353. serviceStartTime: this.periodTimeList[this.periodTimeIndex].label,
  354. timeRangeId: this.serviceTeacher.crewPeriodId,
  355. remark: this.remark
  356. }).then(res => {
  357. this.orderNo = res.data.data.orderNo
  358. this.subOrderNo = res.data.data.subOrderNo
  359. if (res.data.data.subOrderNo === null) {
  360. uni.switchTab({
  361. url: '/pages/order/index'
  362. })
  363. } else {
  364. if (this.curServiceTab === 1) {
  365. //开启余额支付密码框
  366. // this.$refs.passwordPopup.open()
  367. this.balancePay()
  368. }
  369. if (this.curServiceTab === 2) {
  370. //调微信支付
  371. this.wechatPay()
  372. }
  373. }
  374. })
  375. },
  376. //获取预约费用
  377. getAppointmentPrice() {
  378. this.$api.getAppointmentPrice({
  379. storeId: this.store.storeId,
  380. date: this.periodDateList[this.periodDateIndex].label,
  381. timeRangeId: this.serviceTeacher.crewPeriodId,
  382. servicePersonId: this.serviceTeacher.personId,
  383. serviceProjectId: this.storeServiceList[this.storeServiceIndex].id
  384. }).then(res => {
  385. this.price = res.data.data.price
  386. })
  387. },
  388. //选择服务人员
  389. chooseServiceTeacher() {
  390. if (this.periodDateList.length <= 0 || this.periodTimeList.length <= 0) {
  391. uni.$u.toast('请选择服务时间')
  392. }
  393. console.log("a->", this.periodTimeIndex)
  394. console.log("b->", this.periodTimeList)
  395. uni.navigateTo({
  396. url: '/orderPages/serviceTeacher/index?organization=' + this.store.storeId
  397. + '&schedulingDate=' + this.periodDateList[this.periodDateIndex].label
  398. + '&time=' + this.periodTimeList[this.periodTimeIndex].value
  399. + '&serviceTypeId=' + this.storeServiceList[this.storeServiceIndex].id
  400. })
  401. },
  402. //获取排班日期
  403. selectDate() {
  404. console.log(this.store)
  405. this.$api.selectDate({
  406. organization: this.store.storeId
  407. }).then(res => {
  408. this.periodDateList = res.data.data
  409. // this.selectPeriodByDate(res.data.data[0].label)
  410. this.getServiceTime(res.data.data[0].label);
  411. })
  412. },
  413. //获取门店排班时段
  414. // selectPeriodByDate(date){
  415. // this.$api.selectPeriodByDate({
  416. // organization:this.store.storeId,
  417. // schedulingDate:date
  418. // }).then(res =>{
  419. // this.periodTimeList = res.data.data
  420. // if (this.periodTimeList.length===0){
  421. // uni.$u.toast('暂无排班时段')
  422. // }
  423. // })
  424. // },
  425. //获取门店排班时段
  426. getServiceTime(date) {
  427. this.$api.getServiceTime({
  428. storeId: this.store.storeId,
  429. date: date,
  430. serviceTypeId:this.storeServiceList[this.storeServiceIndex].id
  431. }).then(res => {
  432. this.periodTimeList = res.data.data
  433. if (this.periodTimeList.length === 0) {
  434. uni.$u.toast('暂无排班时段')
  435. }
  436. })
  437. },
  438. // 查询服务对像信息列表
  439. listServiceObject() {
  440. this.$api.listServiceObject({}).then((res) => {
  441. this.serviceObject = res.data.data[0]
  442. }).catch((err) => {
  443. uni.showToast({
  444. title: "操作失败"
  445. })
  446. });
  447. },
  448. getServiceObject() {
  449. uni.navigateTo({
  450. url: '/orderPages/serviceObject/index'
  451. })
  452. },
  453. selectedServiceObject(e) {
  454. this.serviceObject = e
  455. },
  456. selectedServiceTeacher(e) {
  457. this.serviceTeacher = e
  458. this.getAppointmentPrice()
  459. },
  460. //服务类别发生改变
  461. bindPickerChange(e) {
  462. this.serviceTeacher = {}
  463. this.storeServiceIndex = e.detail.value
  464. console.log(e)
  465. this.selectDate()
  466. },
  467. //服务日期发生改变
  468. bindPickerChange1(e) {
  469. this.periodDateIndex = e.detail.value
  470. this.getServiceTime(this.periodDateList[e.detail.value].label)
  471. this.serviceTeacher = {};
  472. console.log(e)
  473. },
  474. //服务时段发生改变
  475. bindPickerChange2(e) {
  476. this.periodTimeIndex = e.detail.value
  477. this.serviceTeacher = {}
  478. console.log(e)
  479. },
  480. category() {
  481. this.$api.category({storeId: this.store.storeId}).then(res => {
  482. this.storeServiceList = res.data.data
  483. this.selectDate()
  484. })
  485. },
  486. }
  487. }
  488. </script>
  489. <style scoped lang="scss">
  490. @import '/common/css/common.css';
  491. @import './index.rpx.scss';
  492. </style>