index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <template>
  2. <view class="page">
  3. <view class="flex-col group">
  4. <view class="flex-col justify-around groupItem">
  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" :range="storeServiceList">
  19. <view class="flex-row justify-between groupItemContent">
  20. <text>{{storeServiceList[storeServiceIndex].typeName || '请选择服务类别' }}</text>
  21. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  22. </view>
  23. </picker>
  24. </view>
  25. </view>
  26. <view class="flex-col group marginTop">
  27. <view class="flex-row ">
  28. <view class="hint">
  29. <text>!</text>
  30. </view>
  31. <view class="hintCentent">
  32. <text>需提前一天起预约,取消订单服务需服务前一天取消</text>
  33. </view>
  34. </view>
  35. <view class="flex-col justify-around groupItem">
  36. <view class="groupItemKey">
  37. <text>服务日期</text>
  38. </view>
  39. <picker @change="bindPickerChange1" mode='selector' range-key="label" :value="periodDateIndex" :range="periodDateList">
  40. <view class="flex-row justify-between groupItemContent">
  41. <text>{{periodDateList[periodDateIndex].label || '请选择服务日期' }}</text>
  42. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  43. </view>
  44. </picker>
  45. </view>
  46. <view class="flex-col justify-around groupItem">
  47. <view class="groupItemKey">
  48. <text>服务时段</text>
  49. </view>
  50. <picker @change="bindPickerChange2" mode='selector' range-key="label" :value="periodTimeIndex" :range="periodTimeList">
  51. <view class="flex-row justify-between groupItemContent">
  52. <text>{{periodTimeList[periodTimeIndex].label || '服务时段' }}</text>
  53. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  54. </view>
  55. </picker>
  56. </view>
  57. <view class="flex-col justify-around groupItem">
  58. <view class="groupItemKey">
  59. <text>服务人员</text>
  60. </view>
  61. <view class="flex-row justify-between groupItemContent" @click="chooseServiceTeacher">
  62. <text>{{serviceTeacher.personName || '请选择服务人员' }}</text>
  63. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="flex-col group marginTop">
  68. <view class="groupItemKey">
  69. <text>服务定制</text>
  70. </view>
  71. <view class="textareaView">
  72. <textarea v-model="remark" placeholder-style="color:#999999;fontSize:28rpx" placeholder="如有其它特殊需求,请在此输入您的需求"/>
  73. </view>
  74. </view>
  75. <view :style="{'height':'236rpx'}"></view>
  76. <view class="flex-col group2 ">
  77. <view class="btnTitle">
  78. <text>提交订单之前需支付预约服务费用</text>
  79. </view>
  80. <view class="btn flex-row justify-between">
  81. <view>
  82. <text class="title">待支付</text>
  83. <text class="num">¥{{price}}</text>
  84. </view>
  85. <view class="btnRight" @click="commitOrder">
  86. <text>提交</text>
  87. </view>
  88. </view>
  89. </view>
  90. <uni-popup ref="passwordPopup">
  91. <view class="passwordView flex-col">
  92. <view class="h-pay-title flex-row justify-center">
  93. <text>请输入交易密码</text>
  94. </view>
  95. <view class="h-tab-bar flex-row justify-center">
  96. <u-code-input v-model="password" mode="box" dot></u-code-input>
  97. </view>
  98. <view class="flex-row justify-center">
  99. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  100. <text>确定</text>
  101. </view>
  102. </view>
  103. </view>
  104. </uni-popup>
  105. <uni-popup ref="popup" type="bottom">
  106. <view class=" payView">
  107. <view class="flex-row justify-between">
  108. <text class="payType">请选择支付方式</text>
  109. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  110. </view>
  111. <view class="payTitle">
  112. <text>选择微信支付或余额支付</text>
  113. </view>
  114. <view class="payItem flex-row justify-between" @click="payItem(1)">
  115. <view class="flex-row">
  116. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  117. <view class="payName flex-col justify-center">
  118. <text>余额支付</text>
  119. <text class="balance">可以余额¥{{userInfo.balance || 0}}</text>
  120. </view>
  121. </view>
  122. <view class="flex-col justify-center">
  123. <view v-if="curServiceTab === 1" >
  124. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  125. </view>
  126. <view v-else>
  127. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  128. </view>
  129. </view>
  130. </view>
  131. <view class="payItem flex-row justify-between" @click="payItem(2)">
  132. <view class="flex-row">
  133. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  134. <view class="payName flex-col justify-center">
  135. <text>微信支付</text>
  136. </view>
  137. </view>
  138. <view class="flex-col justify-center">
  139. <view v-if="curServiceTab === 2" >
  140. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  141. </view>
  142. <view v-else>
  143. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  144. </view>
  145. </view>
  146. </view>
  147. <view class="commitBtn" @click="commonGeneralOrder">
  148. <text>确定</text>
  149. </view>
  150. </view>
  151. </uni-popup>
  152. </view>
  153. </template>
  154. <script>
  155. export default {
  156. data() {
  157. return {
  158. password:'',
  159. remark:'',
  160. userInfo:{},
  161. curServiceTab:1,
  162. //服务门店
  163. store:{},
  164. //服务对象
  165. serviceObject:{},
  166. //服务技师
  167. serviceTeacher:{},
  168. //服务类型
  169. storeServiceList:[],
  170. storeServiceIndex:0,
  171. //服务时间
  172. periodDateList:[],
  173. periodDateIndex:0,
  174. //服务时段
  175. periodTimeList:[],
  176. periodTimeIndex:0,
  177. //预约费用
  178. price:'0',
  179. //订单编号
  180. orderNo:'',
  181. subOrderNo:''
  182. }
  183. },
  184. onLoad() {
  185. // this.listServiceObject()
  186. this.store = uni.getStorageSync('storeInfo')
  187. this.userInfo = uni.getStorageSync('userInfo')
  188. // this.storeAllServiceList()
  189. this.category()
  190. this.selectDate()
  191. if (!this.userInfo.phone){
  192. uni.showModal({
  193. title:'温馨提示',
  194. content:'请绑定手机号,以便为你提供服务',
  195. success:res=>{
  196. if (res.confirm){
  197. uni.navigateTo({
  198. url: '/myPages/setting/setting-telphone',
  199. })
  200. }
  201. }
  202. })
  203. }
  204. },
  205. onShow(){
  206. // 服务对象
  207. uni.$off()
  208. uni.$on('selectedServiceObject', this.selectedServiceObject);
  209. uni.$on('selectedServiceTeacher', this.selectedServiceTeacher);
  210. },
  211. methods: {
  212. payItem(num){
  213. if (this.userInfo.balance < this.price){
  214. return
  215. }
  216. this.curServiceTab = num
  217. },
  218. //提交订单
  219. commitOrder(){
  220. if (!this.userInfo.phone){
  221. uni.showModal({
  222. title:'温馨提示',
  223. content:'请绑定手机号,以便为你提供服务',
  224. success:res=>{
  225. if (res.confirm){
  226. uni.navigateTo({
  227. url: '/myPages/setting/setting-telphone',
  228. })
  229. }
  230. }
  231. })
  232. return;
  233. }
  234. if(!this.serviceObject){
  235. uni.$u.toast('请选择服务对象')
  236. return
  237. }
  238. if (!this.serviceTeacher.personId){
  239. uni.$u.toast('请选择服务人员')
  240. return
  241. }
  242. if (this.price > 0){
  243. this.$refs.popup.open()
  244. if (this.userInfo.balance < this.price){
  245. this.curServiceTab=2
  246. }
  247. }else {
  248. this.commonGeneralOrder()
  249. }
  250. },
  251. closePayPopup(){
  252. this.$refs.popup.close()
  253. },
  254. wechatPay(){
  255. let that = this;
  256. // 发起微信支付
  257. this.$api.wechatPay({
  258. orderNo:this.subOrderNo
  259. }).then((res)=>{
  260. var param = res.data.data;
  261. uni.requestPayment({
  262. appId: param.appid,
  263. timeStamp: param.timestamp+"",
  264. nonceStr: param.noncestr,
  265. package: "prepay_id="+param.prepayid,
  266. signType: "RSA",
  267. paySign: param.sign,
  268. success: res => {
  269. uni.showToast({
  270. title: '支付成功!'
  271. });
  272. setTimeout(res=>{
  273. uni.switchTab({
  274. url:'/pages/order/index'
  275. })
  276. },1000)
  277. },
  278. fail: res => {
  279. console.log(res)
  280. uni.showModal({
  281. content: '支付失败',
  282. showCancel: false
  283. });
  284. setTimeout(res=>{
  285. uni.switchTab({
  286. url:'/pages/order/index'
  287. })
  288. },1000)
  289. }
  290. });
  291. }).catch(() =>{
  292. uni.showToast({
  293. title: "操作失败"
  294. })
  295. });
  296. },
  297. //余额支付
  298. balancePay(){
  299. let that = this;
  300. // if(this.password.length< 6 ){
  301. // uni.showToast({
  302. // title: "交易密码不能小于6位"
  303. // })
  304. // return ;
  305. // }
  306. // this.$refs.passwordPopup.close()
  307. this.$api.balancePay({
  308. orderNo: this.subOrderNo,
  309. password: ''
  310. }).then((res)=>{
  311. that.$refs.popup.close()
  312. uni.showToast({
  313. title: '支付成功!'
  314. });
  315. setTimeout(res=>{
  316. uni.switchTab({
  317. url:'/pages/order/index'
  318. })
  319. },1000)
  320. this.getUserInfo()
  321. }).catch((res) =>{
  322. console.log(res)
  323. that.$refs.popup.close()
  324. let msg = res.data.msg || '操作失败';
  325. uni.showToast({
  326. title: msg,
  327. icon:'error'
  328. })
  329. // setTimeout(res=>{
  330. // uni.switchTab({
  331. // url:'/pages/order/index'
  332. // })
  333. // },1000)
  334. });
  335. },
  336. getUserInfo(){
  337. this.$api.getUserInfo().then(res=>{
  338. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  339. uni.setStorageSync('userInfo',res.data.data)
  340. this.userInfo = res.data.data
  341. })
  342. },
  343. commonGeneralOrder(){
  344. this.$refs.popup.close()
  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 + '&schedulingDate=' +this.periodDateList[this.periodDateIndex].label + '&time='+this.periodTimeList[this.periodTimeIndex].value
  397. })
  398. },
  399. //获取排班日期
  400. selectDate(){
  401. console.log(this.store)
  402. this.$api.selectDate({
  403. organization:this.store.storeId
  404. }).then(res =>{
  405. this.periodDateList = res.data.data
  406. // this.selectPeriodByDate(res.data.data[0].label)
  407. this.getServiceTime(res.data.data[0].label);
  408. })
  409. },
  410. //获取门店排班时段
  411. // selectPeriodByDate(date){
  412. // this.$api.selectPeriodByDate({
  413. // organization:this.store.storeId,
  414. // schedulingDate:date
  415. // }).then(res =>{
  416. // this.periodTimeList = res.data.data
  417. // if (this.periodTimeList.length===0){
  418. // uni.$u.toast('暂无排班时段')
  419. // }
  420. // })
  421. // },
  422. //获取门店排班时段
  423. getServiceTime(date){
  424. this.$api.getServiceTime({
  425. storeId: this.store.storeId,
  426. date: date
  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. bindPickerChange(e){
  457. this.storeServiceIndex= e.detail.value
  458. console.log(e)
  459. },
  460. bindPickerChange1(e){
  461. this.periodDateIndex= e.detail.value
  462. this.getServiceTime(this.periodDateList[e.detail.value].label)
  463. this.serviceTeacher = {};
  464. console.log(e)
  465. },
  466. bindPickerChange2(e){
  467. this.periodTimeIndex= e.detail.value
  468. this.serviceTeacher = {}
  469. console.log(e)
  470. },
  471. category(){
  472. this.$api.category({storeId:this.store.storeId}).then(res=>{
  473. this.storeServiceList= res.data.data
  474. })
  475. },
  476. }
  477. }
  478. </script>
  479. <style scoped lang="scss">
  480. @import '/common/css/common.css';
  481. @import './index.rpx.scss';
  482. </style>