index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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.title || '请选择服务人员' }}</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.id){
  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. uni.switchTab({
  241. url:'/pages/order/index'
  242. })
  243. },
  244. fail: res => {
  245. console.log(res)
  246. uni.showModal({
  247. content: '支付失败',
  248. showCancel: false
  249. });
  250. uni.switchTab({
  251. url:'/pages/order/index'
  252. })
  253. }
  254. });
  255. }).catch(() =>{
  256. uni.showToast({
  257. title: "操作失败"
  258. })
  259. });
  260. },
  261. //余额支付
  262. balancePay(){
  263. let that = this;
  264. if(this.password.length< 6 ){
  265. uni.showToast({
  266. title: "交易密码不能小于6位"
  267. })
  268. return ;
  269. }
  270. this.$refs.passwordPopup.close()
  271. // 用户信息
  272. this.$api.balancePay({
  273. orderNo: this.subOrderNo,
  274. password: this.password
  275. }).then((res)=>{
  276. uni.switchTab({
  277. url:'/pages/order/index'
  278. })
  279. this.getUserInfo()
  280. }).catch(() =>{
  281. uni.showToast({
  282. title: "操作失败"
  283. })
  284. });
  285. },
  286. getUserInfo(){
  287. this.$api.getUserInfo().then(res=>{
  288. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  289. uni.setStorageSync('userInfo',res.data.data)
  290. this.userInfo = res.data.data
  291. })
  292. },
  293. commonGeneralOrder(){
  294. this.$refs.popup.close()
  295. this.$api.commonGeneralOrder({
  296. orderType: 1,
  297. serviceObjectId: this.serviceObject.id,
  298. serviceAttribute: 2,
  299. serviceStoreId: this.store.storeId,
  300. serviceTypeId:this.storeServiceList[this.storeServiceIndex].id,
  301. serviceDate:this.periodDateList[this.periodDateIndex].label,
  302. serviceUserId:this.serviceTeacher.id,
  303. serviceStartTime:this.periodTimeList[this.periodTimeIndex].label,
  304. timeRangeId:this.serviceTeacher.id,
  305. remark:this.remark
  306. }).then(res=>{
  307. this.orderNo=res.data.data.orderNo
  308. this.subOrderNo=res.data.data.subOrderNo
  309. if (res.data.data.subOrderNo === null){
  310. uni.switchTab({
  311. url:'/pages/order/index'
  312. })
  313. }else{
  314. if (this.curServiceTab === 1){
  315. //开启余额支付密码框
  316. this.$refs.passwordPopup.open()
  317. }
  318. if (this.curServiceTab === 2){
  319. //调微信支付
  320. this.wechatPay()
  321. }
  322. }
  323. })
  324. },
  325. //获取预约费用
  326. getAppointmentPrice(){
  327. this.$api.getAppointmentPrice({
  328. auth: true,
  329. storeId: this.store.storeId,
  330. date: this.periodDateList[this.periodDateIndex].label,
  331. timeRangeId: this.periodTimeList[this.periodTimeIndex].value,
  332. servicePersonId: this.serviceTeacher.id,
  333. serviceProjectId:this.storeServiceList[this.storeServiceIndex].id
  334. }).then(res=>{
  335. this.price= res.data.data.price
  336. })
  337. },
  338. //选择服务人员
  339. chooseServiceTeacher(){
  340. if (this.periodDateList.length <=0 || this.periodTimeList.length<=0){
  341. uni.$u.toast('请选择服务时间')
  342. }
  343. uni.navigateTo({
  344. url: '/orderPages/serviceTeacher/index?organization='+this.store.storeId + '&schedulingDate=' +this.periodDateList[this.periodTimeIndex].label + '&periodId='+this.periodTimeList[this.periodTimeIndex].value
  345. })
  346. },
  347. //获取排班日期
  348. selectDate(){
  349. console.log(this.store)
  350. this.$api.selectDate({
  351. organization:this.store.storeId
  352. }).then(res =>{
  353. this.periodDateList = res.data.data
  354. this.selectPeriodByDate(res.data.data[0].label)
  355. })
  356. },
  357. //获取门店排班时段
  358. selectPeriodByDate(date){
  359. this.$api.selectPeriodByDate({
  360. organization:this.store.storeId,
  361. schedulingDate:date
  362. }).then(res =>{
  363. this.periodTimeList = res.data.data
  364. if (this.periodTimeList.length===0){
  365. uni.$u.toast('暂无排班时段')
  366. }
  367. })
  368. },
  369. // 查询服务对像信息列表
  370. listServiceObject(){
  371. this.$api.listServiceObject(this.reqParm).then((res)=>{
  372. this.serviceObject = res.data.data[0]
  373. }).catch((err) =>{
  374. uni.showToast({
  375. title: "操作失败"
  376. })
  377. });
  378. },
  379. getServiceObject(){
  380. uni.navigateTo({
  381. url:'/orderPages/serviceObject/index'
  382. })
  383. },
  384. selectedServiceObject(e){
  385. this.serviceObject = e
  386. },
  387. selectedServiceTeacher(e){
  388. this.serviceTeacher = e
  389. this.getAppointmentPrice()
  390. },
  391. bindPickerChange(e){
  392. this.storeServiceIndex= e.detail.value
  393. console.log(e)
  394. },
  395. bindPickerChange1(e){
  396. this.periodDateIndex= e.detail.value
  397. this.selectPeriodByDate(this.periodDateList[e.detail.value].label)
  398. console.log(e)
  399. },
  400. bindPickerChange2(e){
  401. this.periodTimeIndex= e.detail.value
  402. console.log(e)
  403. },
  404. category(){
  405. this.$api.category({storeId:this.store.storeId}).then(res=>{
  406. this.storeServiceList= res.data.data
  407. })
  408. },
  409. }
  410. }
  411. </script>
  412. <style scoped lang="scss">
  413. @import '/common/css/common.css';
  414. @import './index.rpx.scss';
  415. </style>