index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. // 用户信息
  276. this.$api.balancePay({
  277. orderNo: this.subOrderNo,
  278. password: this.password
  279. }).then((res)=>{
  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(() =>{
  290. uni.showToast({
  291. title: "操作失败"
  292. })
  293. setTimeout(res=>{
  294. uni.switchTab({
  295. url:'/pages/order/index'
  296. })
  297. },1000)
  298. });
  299. },
  300. getUserInfo(){
  301. this.$api.getUserInfo().then(res=>{
  302. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  303. uni.setStorageSync('userInfo',res.data.data)
  304. this.userInfo = res.data.data
  305. })
  306. },
  307. commonGeneralOrder(){
  308. this.$refs.popup.close()
  309. this.$api.commonGeneralOrder({
  310. orderType: 1,
  311. serviceObjectId: this.serviceObject.id,
  312. serviceAttribute: 2,
  313. serviceStoreId: this.store.storeId,
  314. serviceTypeId:this.storeServiceList[this.storeServiceIndex].id,
  315. serviceDate:this.periodDateList[this.periodDateIndex].label,
  316. serviceUserId:this.serviceTeacher.personId,
  317. serviceStartTime:this.periodTimeList[this.periodTimeIndex].label,
  318. timeRangeId:this.serviceTeacher.crewPeriodId,
  319. remark:this.remark
  320. }).then(res=>{
  321. this.orderNo=res.data.data.orderNo
  322. this.subOrderNo=res.data.data.subOrderNo
  323. if (res.data.data.subOrderNo === null){
  324. uni.switchTab({
  325. url:'/pages/order/index'
  326. })
  327. }else{
  328. if (this.curServiceTab === 1){
  329. //开启余额支付密码框
  330. this.$refs.passwordPopup.open()
  331. }
  332. if (this.curServiceTab === 2){
  333. //调微信支付
  334. this.wechatPay()
  335. }
  336. }
  337. })
  338. },
  339. //获取预约费用
  340. getAppointmentPrice(){
  341. this.$api.getAppointmentPrice({
  342. storeId: this.store.storeId,
  343. date: this.periodDateList[this.periodDateIndex].label,
  344. timeRangeId: this.serviceTeacher.crewPeriodId,
  345. servicePersonId: this.serviceTeacher.personId,
  346. serviceProjectId:this.storeServiceList[this.storeServiceIndex].id
  347. }).then(res=>{
  348. this.price= res.data.data.price
  349. })
  350. },
  351. //选择服务人员
  352. chooseServiceTeacher(){
  353. if (this.periodDateList.length <=0 || this.periodTimeList.length<=0){
  354. uni.$u.toast('请选择服务时间')
  355. }
  356. console.log("a->", this.periodTimeIndex)
  357. console.log("b->", this.periodTimeList)
  358. uni.navigateTo({
  359. url: '/orderPages/serviceTeacher/index?organization='+this.store.storeId + '&schedulingDate=' +this.periodDateList[this.periodDateIndex].label + '&time='+this.periodTimeList[this.periodTimeIndex].value
  360. })
  361. },
  362. //获取排班日期
  363. selectDate(){
  364. console.log(this.store)
  365. this.$api.selectDate({
  366. organization:this.store.storeId
  367. }).then(res =>{
  368. this.periodDateList = res.data.data
  369. this.selectPeriodByDate(res.data.data[0].label)
  370. })
  371. },
  372. //获取门店排班时段
  373. selectPeriodByDate(date){
  374. this.$api.selectPeriodByDate({
  375. organization:this.store.storeId,
  376. schedulingDate:date
  377. }).then(res =>{
  378. this.periodTimeList = res.data.data
  379. if (this.periodTimeList.length===0){
  380. uni.$u.toast('暂无排班时段')
  381. }
  382. })
  383. },
  384. //获取门店排班时段
  385. getServiceTime(date){
  386. this.$api.getServiceTime({
  387. storeId: this.store.storeId,
  388. date: date
  389. }).then(res =>{
  390. this.periodTimeList = res.data.data
  391. if (this.periodTimeList.length===0){
  392. uni.$u.toast('暂无排班时段')
  393. }
  394. })
  395. },
  396. // 查询服务对像信息列表
  397. listServiceObject(){
  398. this.$api.listServiceObject(this.reqParm).then((res)=>{
  399. this.serviceObject = res.data.data[0]
  400. }).catch((err) =>{
  401. uni.showToast({
  402. title: "操作失败"
  403. })
  404. });
  405. },
  406. getServiceObject(){
  407. uni.navigateTo({
  408. url:'/orderPages/serviceObject/index'
  409. })
  410. },
  411. selectedServiceObject(e){
  412. this.serviceObject = e
  413. },
  414. selectedServiceTeacher(e){
  415. this.serviceTeacher = e
  416. this.getAppointmentPrice()
  417. },
  418. bindPickerChange(e){
  419. this.storeServiceIndex= e.detail.value
  420. console.log(e)
  421. },
  422. bindPickerChange1(e){
  423. this.periodDateIndex= e.detail.value
  424. this.getServiceTime(this.periodDateList[e.detail.value].label)
  425. console.log(e)
  426. },
  427. bindPickerChange2(e){
  428. this.periodTimeIndex= e.detail.value
  429. console.log(e)
  430. },
  431. category(){
  432. this.$api.category({storeId:this.store.storeId}).then(res=>{
  433. this.storeServiceList= res.data.data
  434. })
  435. },
  436. }
  437. }
  438. </script>
  439. <style scoped lang="scss">
  440. @import '/common/css/common.css';
  441. @import './index.rpx.scss';
  442. </style>