index.vue 15 KB

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