index.vue 15 KB

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