index.vue 15 KB

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