index.vue 17 KB

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