1
0

index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. ·
  2. <template>
  3. <view class="page">
  4. <uni-nav-bar :fixed="true" background-color="#FFE05C" :border="false" :statusBar="true" title="首页"/>
  5. <view class="flex-row tuni ">
  6. <image class="profile" :src="userInfo.avatarUrl || '/static/ud4.png'"></image>
  7. <view class="tuniMsg">
  8. <view class="name ">
  9. <text>{{ userInfo.name }}</text>
  10. </view>
  11. <view>
  12. <text class="biaoqian ">{{ userInfo.post }}</text>
  13. </view>
  14. </view>
  15. <view class="flex-row justify-around tuni-right ">
  16. <view class="flex-col">
  17. <view class="flex-row justify-center dakaIcon ">
  18. <text>{{ userInfo.subNumber }}</text>
  19. </view>
  20. <view class="flex-row justify-center dakaText ">
  21. <text>今日预约</text>
  22. </view>
  23. </view>
  24. <view class="flex-col" @click="promotion">
  25. <view class="flex-row justify-center dakaIcon ">
  26. <u-icon name="/static/index/erweima.png" size="35"></u-icon>
  27. </view>
  28. <!-- <view class="flex-row justify-center dakaText " >-->
  29. <!-- <text>拓客码</text>-->
  30. <!-- </view>-->
  31. </view>
  32. <view class="flex-col " @click="userScanCode">
  33. <view class="flex-row justify-center dakaIcon ">
  34. <u-icon name="/static/index/saoma.png" size="25"></u-icon>
  35. </view>
  36. <view class="flex-row justify-center dakaText ">
  37. <text>报到打卡</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="flex-row justify-around buttons">
  43. <!-- <view class="buttonItem" @click="call" v-if="currService && currService.callState == '2'">-->
  44. <!-- <text>叫号</text>-->
  45. <!-- </view>-->
  46. <view class="buttonItem" :class="{buttonState:buttonState[0]}" @click="next">
  47. <text>下一位</text>
  48. </view>
  49. <view class="buttonItem" :class="{buttonState:buttonState[1]}" @click="takePlace">
  50. <text>已就位</text>
  51. </view>
  52. <view class="buttonItem" :class="{buttonState:buttonState[2]}" @click="settle">
  53. <text>结算</text>
  54. </view>
  55. <view class="buttonItem" :class="{buttonState:buttonState[3]}" @click="addService">
  56. <text>添加服务</text>
  57. </view>
  58. </view>
  59. <view class="flex-row justify-center ">
  60. <view class="serviceMsg " v-if="currService">
  61. <view class="flex-row serviceInfo ">
  62. <image class="serviceProfile" :src="currService.avatar || '/static/ud4.png'" @click="avatarOpen">
  63. </image>
  64. <view class="flex-col justify-end serviceInfo-rigth ">
  65. <view class="flex-row justify-between ">
  66. <view class="">
  67. <view class="flex-row">
  68. <text class="servicename">{{ currService.serviceObjectName }}</text>
  69. <text v-if="currService.isVip" class="biaoqian">会员客户</text>
  70. <text v-else class="biaoqian">现金客户</text>
  71. </view>
  72. <view class="">
  73. <text class="servicename">{{ currService.no }}</text>
  74. </view>
  75. </view>
  76. <view class="flex-col justify-center ">
  77. <view class="flex-row justify-center tag" @click="openSelectServiceObjectPopup">
  78. <text>切换</text>
  79. <u-icon name="/static/index/qiehuan.png" size="18"></u-icon>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <view :style="{'height':'120rpx'}"></view>
  86. <view class="flex-row justify-center" v-if="!currService.balanceFlag">
  87. <view class="flex-row justify-center hintView">
  88. <view class="hint">
  89. <text>!</text>
  90. </view>
  91. <view class="hintCentent">
  92. <text>娇宝余额不足哟~</text>
  93. </view>
  94. </view>
  95. </view>
  96. <view class="flex-row justify-center" v-if="currService.balanceFlag && currService.balance *1 <= 200">
  97. <view class="flex-row justify-center hintView" :class="{hintViewBgColor2: currService.balance *1 <= 100,
  98. hintViewBgColor3: currService.balance *1 > 100 && currService.balance *1 <= 200}">
  99. <view class="hint">
  100. <text>!</text>
  101. </view>
  102. <view class="hintCentent">
  103. <text>娇宝余额充足~</text>
  104. </view>
  105. </view>
  106. </view>
  107. <view class="flex-col orderMsg">
  108. <view class="flex-row justify-between">
  109. <view class="flex-row">
  110. <u-icon name="/static/index/quhao.png" size="20"></u-icon>
  111. <text class="key">排号:</text>
  112. <text class="value">{{ currService.planNumber }}</text>
  113. </view>
  114. <view class="flex-col justify-center stateStr">
  115. <text>{{ currService.statusDesc }}</text>
  116. </view>
  117. </view>
  118. <view class="flex-row">
  119. <u-icon name="/static/index/orderNo1.png" size="20"></u-icon>
  120. <text class="key">订单编号:</text>
  121. <text class="value">{{ currService.orderNo }}</text>
  122. </view>
  123. <view class="flex-row">
  124. <u-icon name="/static/index/jiandao.png" size="20"></u-icon>
  125. <text class="key">服务项目:</text>
  126. <text class="value">{{ currService.serviceProject }}</text>
  127. </view>
  128. <view class="flex-row">
  129. <u-icon name="/static/index/tel.png" size="18"></u-icon>
  130. <text class="key">手机尾号:</text>
  131. <text class="value">{{ currService.phone.substring(7, 11) }}</text>
  132. </view>
  133. <view class="flex-row justify-start">
  134. <view class="flex-col justify-start" style="padding-top: 4rpx">
  135. <u-icon name="/static/index/quanyika.png" size="16"></u-icon>
  136. </view>
  137. <view style="min-width: 150rpx">
  138. <text class="key">权益卡:</text>
  139. </view>
  140. <view>
  141. <text class="biaoqian1" v-for="(card,index) in currService.cardList" :key="index" v-if="currService.cardList && currService.cardList.length">{{ card.title }}</text>
  142. <text class="value" v-else>无</text>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="flex-row justify-center">
  147. <view class="imgs">
  148. <view class="mmImgView" :class="{floatRight: (index+1) % 2==0,marginTop:index>1}"
  149. v-for="(i,index) in 0" :key="index">
  150. <image class="mmImg" mode="widthFix" src="/static/mn1.webp"></image>
  151. </view>
  152. </view>
  153. </view>
  154. <view class="flex-row justify-center" v-if="currService.status!==12">
  155. <view class="like">
  156. <text>{{ currService.preference || '暂无' }}</text>
  157. </view>
  158. </view>
  159. </view>
  160. <view class="flex-col" :style="{'height':sysHeight}" v-else>
  161. <view class="flex-row justify-center">
  162. <image class="dataNull" src="/static/index/dataNull.png"></image>
  163. </view>
  164. <view class="flex-row justify-center dataNullText">
  165. <text>暂无服务项目,请点击下一位刷新页面</text>
  166. </view>
  167. </view>
  168. </view>
  169. <view v-if="currServiceList.length > 0" class="flex-col justify-start" style="background: #FFFFFF;border-radius: 24rpx;padding: 20rpx 0;">
  170. <view class="flex-row justify-center">
  171. <view :class="[serviceTabIndex === item.label ? 'serviceTab1' : 'serviceTab']" v-for="(item ,index) in serviceTabs" :key="index" @click="currServiceInfoList(item.label)">
  172. {{item.value}}<text v-if="item.label === 0">({{ myServiceFeeSum }})</text><text v-if="item.label === 1">({{ customerServiceFeeSum }})</text>
  173. </view>
  174. </view>
  175. <view class="flex-col orderMsg1" style="margin-bottom: 20rpx" v-for="(item,index) in currServiceList" :key="index">
  176. <view class="flex-row justify-between">
  177. <view class="flex-row">
  178. <u-icon name="/static/index/quhao.png" size="20"></u-icon>
  179. <text class="key">排号:</text>
  180. <text class="value">{{ item.planNumber }}</text>
  181. </view>
  182. <view class="flex-col justify-center stateStr">
  183. <text>{{ item.statusDesc }}</text>
  184. </view>
  185. </view>
  186. <view class="flex-row">
  187. <u-icon name="/static/index/orderNo1.png" size="20"></u-icon>
  188. <text class="key">订单编号:</text>
  189. <text class="value">{{ item.orderNo }}</text>
  190. </view>
  191. <view class="flex-row">
  192. <u-icon name="/static/index/jiandao.png" size="20"></u-icon>
  193. <text class="key">服务项目:</text>
  194. <text class="value">{{ item.serviceProject }}</text>
  195. </view>
  196. <view class="flex-row">
  197. <u-icon name="/static/index/tel.png" size="18"></u-icon>
  198. <text class="key">手机尾号:</text>
  199. <text class="value">{{ item.phone.substring(7, 11) }}</text>
  200. </view>
  201. </view>
  202. </view>
  203. <uni-popup ref="avatarPopup" type="center">
  204. <view class="avatarView " v-if="currService">
  205. <view class="flex-row justify-center">
  206. <image class="avatarOpen" mode="widthFix" :src="currService.avatar || '/static/ud4.png'"></image>
  207. </view>
  208. <view class="flex-row justify-center" :style="{'marginTop':'20rpx'}">
  209. <text>服务对象:{{ currService.serviceObjectName }}</text>
  210. </view>
  211. </view>
  212. </uni-popup>
  213. <uni-popup ref="reminderPopup" type="center">
  214. <view class="reminderView ">
  215. <view class="reminderTitle">
  216. <text>保存用户喜好</text>
  217. </view>
  218. <view class="textareaView flex-row justify-center">
  219. <textarea class="textarea" v-model="content" placeholder-style="color:#999999;fontSize:28rpx"
  220. placeholder="请输入用户喜好"/>
  221. </view>
  222. <view class="flex-row justify-around " :style="{'marginTop':'20rpx'}">
  223. <view class="cancelButton " @click="closeReminderPopup">
  224. <text>取消</text>
  225. </view>
  226. <view class="confirmButton " @click="preference">
  227. <text>确定</text>
  228. </view>
  229. </view>
  230. </view>
  231. </uni-popup>
  232. <uni-popup ref="addServicePopup" @change="popupChange" type="bottom">
  233. <view class="addService">
  234. <scroll-view class="scrollY1 " scroll-y>
  235. <view class="flex-col">
  236. <view class="popupTitle">
  237. <text>选择服务项目</text>
  238. </view>
  239. <view class="flex-row justify-center">
  240. <view class="serviceItems " v-if="serviceProjectList.length > 0">
  241. <view class="serviceItem "
  242. :class="{vBackGround: serviceProjectListIndex === index,marginLeft16: (index+3) % 3!==0,marginTop24:index>2}"
  243. v-for="(item,index) in serviceProjectList" :key="index"
  244. @click="selectProject(item,index)">
  245. <text>{{ item.serviceName }}</text>
  246. </view>
  247. </view>
  248. <view class="flex-row justify-center emptyDataView" v-else>
  249. <text class="emptyDataText">暂无服务项目</text>
  250. </view>
  251. </view>
  252. <view class="popupTitle marginTop24">
  253. <text>选择服务技师</text>
  254. </view>
  255. <view class="flex-row justify-center">
  256. <view class="serviceItems " v-if="servicePersonList.length > 0">
  257. <view class="flex-col serviceTeach "
  258. :class="{marginLeft28: (index+4) % 4!==0,marginTop24:index>3}"
  259. v-for="(item,index) in servicePersonList" :key="index"
  260. @click="servicePersonListIndex = index">
  261. <image class="serviceTeachImg" :src="item.facePhotoUrl ||'/static/ud4.png'"
  262. :class="{vBackGround: servicePersonListIndex === index}"></image>
  263. <view class="serviceTeachName">
  264. <text>{{ item.personName }}</text>
  265. </view>
  266. <image v-if="servicePersonListIndex === index" class="vImage"
  267. src="/static/index/xuanzhong.png"></image>
  268. </view>
  269. </view>
  270. <view class="flex-row justify-center emptyDataView" v-else>
  271. <text class="emptyDataText">暂无服务技师</text>
  272. </view>
  273. </view>
  274. </view>
  275. </scroll-view>
  276. <view class="flex-row justify-around">
  277. <view class="cancelButton " @click="closeAddServicePopup">
  278. <text>取消</text>
  279. </view>
  280. <view class="confirmButton" @click="addServiceProject">
  281. <text>确定</text>
  282. </view>
  283. </view>
  284. </view>
  285. </uni-popup>
  286. <uni-popup ref="selectServiceObjectPopup" @change="popupChange" type="bottom">
  287. <view class="addService">
  288. <view class="popupTitle">
  289. <text>切换服务对象</text>
  290. </view>
  291. <scroll-view class="scrollY" scroll-y>
  292. <view class="flex-row objectItem" :class="{'vBackGround': selectServiceObjectIndex === index}"
  293. v-for="(item,index) in selectServiceObjectList" :key="index"
  294. @click="selectServiceObjectIndex = index">
  295. <image class="objectImage" :src="item.facePhotoUrl || '/static/ud4.png'"></image>
  296. <view class="flex-col objectName ">
  297. <text>{{ item.nickName }}</text>
  298. </view>
  299. <image v-if="selectServiceObjectIndex === index" class="vImage"
  300. src="/static/index/xuanzhong.png"></image>
  301. </view>
  302. </scroll-view>
  303. <view class="flex-row justify-around">
  304. <view class="cancelButton" @click="closeSelectServiceObjectPopup">
  305. <text>取消</text>
  306. </view>
  307. <view class="confirmButton" @click="switchServiceObject">
  308. <text>确定</text>
  309. </view>
  310. </view>
  311. </view>
  312. </uni-popup>
  313. <uni-popup ref="promotionPopup" type="center">
  314. <view class="promotionView">
  315. <view class="flex-row justify-center">
  316. <text>娇骄儿造型</text>
  317. </view>
  318. <view class="flex-row justify-center qrcodeView">
  319. <uv-qrcode ref="qrcode" size="400rpx" :value="codeUrl" :options="options"></uv-qrcode>
  320. </view>
  321. <view class="flex-row justify-center">
  322. <text>{{ this.userInfo.name }}({{ this.userInfo.workStoreName }})</text>
  323. </view>
  324. <view class="flex-row justify-center">
  325. <text>{{ codeTime }}</text>
  326. </view>
  327. </view>
  328. </uni-popup>
  329. </view>
  330. </template>
  331. <script>
  332. import MescrollItem from "./module/mescrollUni-item.vue";
  333. import QQMapWX from '../../common/js/qqmap/myqqmap-sdk.js'
  334. import {date} from "../../uni_modules/uv-ui-tools/libs/function/test";
  335. export default {
  336. components: {
  337. MescrollItem
  338. },
  339. data() {
  340. return {
  341. buttonState: [0, 0, 0, 0], //0:不禁用按钮,1:禁用按钮。
  342. previousServiceOrderId: '',
  343. content: '',
  344. selectServiceObjectList: [],
  345. selectServiceObjectIndex: -1,
  346. servicePersonList: [],
  347. servicePersonListIndex: 0,
  348. serviceProjectList: [],
  349. serviceProjectListIndex: 0,
  350. tabIndex: 0,
  351. sysHeight: '',
  352. readerHeight: '',
  353. readerWidth: '',
  354. userInfo: {},
  355. storeId: '',
  356. storeName: '',
  357. currService: null,
  358. qqMap: new QQMapWX({
  359. key: 'ZIABZ-543WB-747UM-JL5Y7-NDS4E-HWB4M',
  360. vm: this
  361. }),
  362. codeUrl:'',
  363. qrcodeUrl: 'https://jje.admin.xinyuekj.com.cn/recharge/recharge?storeId={promotionStoreId}&techNo={techNo}',
  364. options: {
  365. // 指定二维码前景,一般可在中间放logo
  366. foregroundImagePadding: 2,
  367. foregroundImageBorderRadius: 5,
  368. foregroundImageSrc: '/static/logo.png'
  369. },
  370. codeTime: null,
  371. serviceTabs:[{
  372. label:0,
  373. value: "我的"
  374. },
  375. {
  376. label:1,
  377. value: "客户"
  378. }],
  379. serviceTabIndex: 0,
  380. currServiceList:[],
  381. // 分别存储两个列表的数据
  382. myServiceList: [],
  383. customerServiceList: [],
  384. // 两个列表的serviceFee总和
  385. myServiceFeeSum: 0,
  386. customerServiceFeeSum: 0
  387. }
  388. },
  389. onLoad() {
  390. let sysInfo = uni.getSystemInfoSync()
  391. this.sysHeight = sysInfo.windowHeight - (sysInfo.windowWidth / 750) * 400 + 'px'
  392. this.readerHeight = sysInfo.windowHeight + 'px'
  393. this.readerWidth = sysInfo.windowWidth + 'px'
  394. },
  395. onShow() {
  396. this.getUserInfo()
  397. // this.userInfo = uni.getStorageSync('userInfo')
  398. // if (this.userInfo.signIn){
  399. // this.currServiceInfo()
  400. // }
  401. },
  402. methods: {
  403. avatarOpen() {
  404. this.$refs.avatarPopup.open()
  405. },
  406. async promotion() {
  407. await this.getUserInfo()
  408. console.log('------', this.userInfo)
  409. if (!this.userInfo.workStoreId || !this.userInfo.techNo) {
  410. uni.showToast({
  411. icon: 'error',
  412. duration: 2000,
  413. title: '请刷新页面重试'
  414. });
  415. return
  416. }
  417. let date = new Date();
  418. this.codeTime = date.toLocaleString();
  419. let data = {
  420. promotionStoreId: this.userInfo.workStoreId,
  421. techNo: this.userInfo.techNo
  422. };
  423. console.log(data)
  424. this.codeUrl = this.qrcodeUrl
  425. for (let key in data) {
  426. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  427. this.codeUrl = this.codeUrl.replace(regexp, data[key]); // 执行替换操作
  428. }
  429. console.log('++++qrcodeUrl+++++', this.codeUrl)
  430. this.$refs.promotionPopup.open()
  431. },
  432. closeReminderPopup() {
  433. this.previousServiceOrderId = ''
  434. this.$refs.reminderPopup.close()
  435. },
  436. openSelectServiceObjectPopup() {
  437. this.$api.service.getServiceObjectList({
  438. orderServiceId: this.currService.orderServiceId,
  439. }).then(res => {
  440. this.selectServiceObjectList = res.data.data
  441. this.getServiceObjectUrl(this.selectServiceObjectList)
  442. uni.hideTabBar()
  443. this.$refs.selectServiceObjectPopup.open()
  444. })
  445. },
  446. // 获取图片
  447. getServiceObjectUrl(items) {
  448. for (let i = 0; i < items.length; i++) {
  449. let ptoto = items[i].facePhoto || items[i].personPhoto
  450. if (ptoto) {
  451. this.$api.service.getImgUrlByOssId({
  452. ossId: ptoto
  453. }).then(res => {
  454. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  455. this.$forceUpdate()
  456. })
  457. }
  458. }
  459. },
  460. closeSelectServiceObjectPopup() {
  461. this.serviceProjectListIndex = -1
  462. this.$refs.selectServiceObjectPopup.close()
  463. },
  464. switchServiceObject() {
  465. if (this.selectServiceObjectIndex === -1) {
  466. uni.showToast({
  467. icon: 'none',
  468. duration: 2000,
  469. title: '请选择服务对象'
  470. });
  471. return
  472. }
  473. this.$api.service.switchServiceObject({
  474. orderServiceId: this.currService.orderServiceId,
  475. serviceObjectId: this.selectServiceObjectList[this.selectServiceObjectIndex].id
  476. }).then(res => {
  477. this.currServiceInfo()
  478. this.closeSelectServiceObjectPopup()
  479. })
  480. },
  481. addService() {
  482. if (!this.currService) {
  483. uni.showToast({
  484. icon: 'error',
  485. duration: 2000,
  486. title: '没有服务对象'
  487. });
  488. return
  489. }
  490. this.serviceProjectListIndex = 0
  491. this.$api.service.serviceProjectList().then(res => {
  492. this.serviceProjectList = res.data.data
  493. this.serviceUserList(res.data.data[0])
  494. uni.hideTabBar()
  495. this.$refs.addServicePopup.open()
  496. })
  497. },
  498. selectProject(item, index) {
  499. this.serviceProjectListIndex = index
  500. this.serviceUserList(item)
  501. },
  502. serviceUserList(item) {
  503. this.$api.service.serviceUserList({
  504. serviceProjectId: item.id,
  505. storeId: this.storeId
  506. }).then(res => {
  507. this.servicePersonListIndex = 0
  508. this.servicePersonList = res.data.data
  509. this.getServiceObjectUrl(this.servicePersonList)
  510. })
  511. },
  512. closeAddServicePopup() {
  513. this.serviceProjectListIndex = 0
  514. this.$refs.addServicePopup.close()
  515. },
  516. addServiceProject() {
  517. this.previousServiceOrderId = this.currService.serviceObjectId
  518. this.$api.service.addServiceProject({
  519. orderServiceId: this.currService.orderServiceId,
  520. serviceProjectId: this.serviceProjectList[this.serviceProjectListIndex].id,
  521. serviceUserId: this.servicePersonList[this.servicePersonListIndex].personId
  522. }).then(res => {
  523. this.closeAddServicePopup()
  524. this.currServiceInfo()
  525. this.$refs.reminderPopup.open()
  526. })
  527. },
  528. popupChange(e) {
  529. if (!e.show) {
  530. uni.showTabBar()
  531. }
  532. },
  533. takePlace() {
  534. if (!this.currService) {
  535. uni.showToast({
  536. icon: 'error',
  537. duration: 2000,
  538. title: '没有服务对象'
  539. });
  540. return
  541. }
  542. this.$api.service.takePlace({
  543. orderServiceId: this.currService.orderServiceId
  544. }).then(res => {
  545. uni.showToast({
  546. icon: 'success',
  547. duration: 2000,
  548. title: '操作成功'
  549. });
  550. this.currServiceInfo()
  551. })
  552. },
  553. preference() {
  554. this.$refs.reminderPopup.close()
  555. this.$api.service.preference({
  556. serviceObjectId: this.previousServiceOrderId,
  557. preference: this.content
  558. }).then(res => {
  559. if (this.currService) {
  560. if (this.currService.serviceObjectId == this.previousServiceOrderId) {
  561. this.currService.preference = this.content
  562. }
  563. }
  564. this.previousServiceOrderId = ''
  565. this.content = ''
  566. uni.showToast({
  567. icon: 'success',
  568. duration: 2000,
  569. title: '保存成功'
  570. });
  571. })
  572. },
  573. settle() {
  574. let that = this
  575. if (!that.currService) {
  576. uni.showToast({
  577. icon: 'error',
  578. duration: 2000,
  579. title: '没有服务对象'
  580. });
  581. return
  582. }
  583. uni.showModal({
  584. title: '温馨提示',
  585. content: '是否确定结算',
  586. editable: false,
  587. success: (e) => {
  588. console.log(e)
  589. if (e.confirm) {
  590. that.previousServiceOrderId = that.currService.serviceObjectId
  591. uni.showLoading({
  592. title: '结算中...'
  593. });
  594. that.$api.service.settle({
  595. orderServiceId: that.currService.orderServiceId
  596. }).then(res => {
  597. uni.hideLoading();
  598. that.currServiceInfo()
  599. that.$refs.reminderPopup.open()
  600. }).catch(err => {
  601. uni.hideLoading();
  602. })
  603. }
  604. }
  605. })
  606. },
  607. start() {
  608. this.$api.service.start({
  609. orderServiceId: this.currService.orderServiceId
  610. }).then(res => {
  611. this.currServiceInfo()
  612. })
  613. },
  614. end() {
  615. this.$api.service.end({
  616. orderServiceId: this.currService.orderServiceId
  617. }).then(res => {
  618. this.currServiceInfo()
  619. })
  620. },
  621. call() {
  622. this.$api.service.call({
  623. orderServiceId: this.currService.orderServiceId
  624. }).then(res => {
  625. this.currServiceInfo()
  626. })
  627. },
  628. next() {
  629. if (!this.userInfo.signIn) {
  630. uni.showToast({
  631. icon: 'error',
  632. duration: 2000,
  633. title: '请先扫码签到'
  634. });
  635. return
  636. }
  637. uni.showModal({
  638. title: '温馨提示',
  639. content: '是否确定下一位',
  640. editable: false,
  641. success: (e) => {
  642. if (e.confirm) {
  643. console.log(e.confirm)
  644. uni.showLoading({
  645. title: '叫号中...'
  646. });
  647. this.$api.service.next({
  648. orderServiceId: this.currService ? this.currService.orderServiceId :
  649. null,
  650. storeId: this.storeId
  651. }).then(res => {
  652. this.currServiceInfo(true)
  653. }).catch(err => {
  654. uni.hideLoading();
  655. })
  656. }
  657. }
  658. })
  659. },
  660. currServiceInfo(e) {
  661. if (!this.userInfo.signIn) {
  662. uni.showToast({
  663. icon: 'error',
  664. duration: 2000,
  665. title: '请先扫码签到'
  666. });
  667. return
  668. }
  669. uni.showLoading({
  670. title: '叫号中...'
  671. });
  672. this.$api.service.currServiceInfo({
  673. storeId: this.userInfo.workStoreId
  674. }).then(res => {
  675. if (e) {
  676. if (res.data.data === null) {
  677. uni.showModal({
  678. title: '温馨提示',
  679. content: '暂无需要服务的客户',
  680. editable: false,
  681. showCancel: false,
  682. success: (e) => {
  683. if (e.confirm) {
  684. }
  685. }
  686. })
  687. }
  688. }
  689. uni.hideLoading();
  690. this.currService = res.data.data
  691. console.log('当前服务对象============》', this.currService)
  692. this.setButtomState(this.currService)
  693. if (!this.currService) {
  694. this.currServiceList = []
  695. return
  696. }
  697. // 同时请求两个列表的数据
  698. this.currServiceInfoList(0)
  699. this.currServiceInfoList(1)
  700. this.equityCard(this.currService)
  701. this.currService.avatar = this.currService.avatar.replace(/^http:/, "https:")
  702. }).catch(err => {
  703. uni.hideLoading();
  704. console.log("出错了+++++++++++出错了+++++++", err)
  705. })
  706. },
  707. currServiceInfoList(isAll){
  708. this.serviceTabIndex = isAll
  709. this.$api.service.currServiceInfoList({
  710. storeId: this.userInfo.workStoreId,
  711. orderNo: this.currService.orderNo,
  712. isAll:isAll
  713. }).then(res=>{
  714. this.currServiceList = res.data.data
  715. // 分别存储并计算两个列表的serviceFee总和
  716. if (isAll === 0) {
  717. this.myServiceList = res.data.data
  718. this.myServiceFeeSum = this.calculateServiceFeeSum(this.myServiceList)
  719. } else {
  720. this.customerServiceList = res.data.data
  721. this.customerServiceFeeSum = this.calculateServiceFeeSum(this.customerServiceList)
  722. }
  723. })
  724. },
  725. // 计算serviceFee总和
  726. calculateServiceFeeSum(list) {
  727. if (!list || list.length === 0) {
  728. return 0
  729. }
  730. return list.reduce((sum, item) => {
  731. return sum + (parseFloat(item.serviceFee) || 0)
  732. }, 0)
  733. },
  734. //查询是否是有权益卡的服务对象
  735. equityCard(data) {
  736. if (!data || !data.serviceObjectId) {
  737. return
  738. }
  739. this.$api.service.equityCard({
  740. serviceObjectId: data.serviceObjectId,
  741. memberId: data.userId,
  742. serviceStoreId: data.serviceStoreId
  743. }).then(res => {
  744. // data.cardList = res.data.data
  745. this.$set(data, 'cardList', res.data.data)
  746. })
  747. },
  748. setButtomState(currService) {
  749. if (currService) {
  750. if (currService.status == 12) {
  751. //叫号中
  752. this.buttonState = [0, 0, 1, 1]
  753. } else if (currService.status == 8 || currService.status == 1) {
  754. //服务中
  755. this.buttonState = [1, 1, 0, 0]
  756. }
  757. } else {
  758. this.buttonState = [0, 1, 1, 1]
  759. }
  760. },
  761. getUserInfo() {
  762. return this.$api.user.getUserInfo().then(res => {
  763. this.userInfo = res.data.data
  764. this.storeId = res.data.data.workStoreId
  765. uni.setStorageSync('userInfo', this.userInfo)
  766. if (this.userInfo.avatar) {
  767. this.getImgUrlByOssId(this.userInfo.avatar)
  768. }
  769. if (this.userInfo.signIn) {
  770. this.buttonState = [0, 1, 1, 1]
  771. this.currServiceInfo()
  772. }
  773. this.$forceUpdate()
  774. console.log('获取个人信息完毕')
  775. })
  776. },
  777. getImgUrlByOssId(ossId) {
  778. this.$api.service.getImgUrlByOssId({
  779. ossId: ossId
  780. }).then(res => {
  781. this.$set(this.userInfo, 'avatarUrl', res.data.data[0].url.replace(/^http:/, "https:"))
  782. uni.setStorageSync('userInfo', this.userInfo)
  783. })
  784. },
  785. userScanCode() {
  786. let that = this
  787. uni.navigateTo({
  788. url: '/pages/scanCode/scanCode',
  789. events: {
  790. getScancode: function (data) {
  791. let param = {
  792. storeId: JSON.parse(data).storeId,
  793. timestamp: JSON.parse(data).timestamp
  794. }
  795. that.$api.service.clockIn(param).then(res => {
  796. uni.showToast({
  797. icon: 'success',
  798. duration: 2000,
  799. title: '签到成功'
  800. });
  801. uni.setStorageSync('userInfo', that.userInfo)
  802. that.getUserInfo()
  803. })
  804. },
  805. }
  806. })
  807. },
  808. clickTab(e) {
  809. this.tabIndex = e
  810. if (e === 0) {
  811. this.currServiceInfo()
  812. }
  813. },
  814. }
  815. }
  816. </script>
  817. <style lang="scss" scoped>
  818. @import './index.rpx.css';
  819. </style>