index.vue 18 KB

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