1
0

index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  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 ">
  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>
  249. <view class="popupTitle marginTop24">
  250. <text>选择服务技师</text>
  251. </view>
  252. <view class="flex-row justify-center">
  253. <view class="serviceItems ">
  254. <view class="flex-col serviceTeach "
  255. :class="{marginLeft28: (index+4) % 4!==0,marginTop24:index>3}"
  256. v-for="(item,index) in servicePersonList" :key="index"
  257. @click="servicePersonListIndex = index">
  258. <image class="serviceTeachImg" :src="item.facePhotoUrl ||'/static/ud4.png'"
  259. :class="{vBackGround: servicePersonListIndex === index}"></image>
  260. <view class="serviceTeachName">
  261. <text>{{ item.personName }}</text>
  262. </view>
  263. <image v-if="servicePersonListIndex === index" class="vImage"
  264. src="/static/index/xuanzhong.png"></image>
  265. </view>
  266. </view>
  267. </view>
  268. </view>
  269. </scroll-view>
  270. <view class="flex-row justify-around">
  271. <view class="cancelButton " @click="closeAddServicePopup">
  272. <text>取消</text>
  273. </view>
  274. <view class="confirmButton" @click="addServiceProject">
  275. <text>确定</text>
  276. </view>
  277. </view>
  278. </view>
  279. </uni-popup>
  280. <uni-popup ref="selectServiceObjectPopup" @change="popupChange" type="bottom">
  281. <view class="addService">
  282. <view class="popupTitle">
  283. <text>切换服务对象</text>
  284. </view>
  285. <scroll-view class="scrollY" scroll-y>
  286. <view class="flex-row objectItem" :class="{'vBackGround': selectServiceObjectIndex === index}"
  287. v-for="(item,index) in selectServiceObjectList" :key="index"
  288. @click="selectServiceObjectIndex = index">
  289. <image class="objectImage" :src="item.facePhotoUrl || '/static/ud4.png'"></image>
  290. <view class="flex-col objectName ">
  291. <text>{{ item.nickName }}</text>
  292. </view>
  293. <image v-if="selectServiceObjectIndex === index" class="vImage"
  294. src="/static/index/xuanzhong.png"></image>
  295. </view>
  296. </scroll-view>
  297. <view class="flex-row justify-around">
  298. <view class="cancelButton" @click="closeSelectServiceObjectPopup">
  299. <text>取消</text>
  300. </view>
  301. <view class="confirmButton" @click="switchServiceObject">
  302. <text>确定</text>
  303. </view>
  304. </view>
  305. </view>
  306. </uni-popup>
  307. <uni-popup ref="promotionPopup" type="center">
  308. <view class="promotionView">
  309. <view class="flex-row justify-center">
  310. <text>娇骄儿造型</text>
  311. </view>
  312. <view class="flex-row justify-center qrcodeView">
  313. <uv-qrcode ref="qrcode" size="400rpx" :value="codeUrl" :options="options"></uv-qrcode>
  314. </view>
  315. <view class="flex-row justify-center">
  316. <text>{{ this.userInfo.name }}({{ this.userInfo.workStoreName }})</text>
  317. </view>
  318. <view class="flex-row justify-center">
  319. <text>{{ codeTime }}</text>
  320. </view>
  321. </view>
  322. </uni-popup>
  323. </view>
  324. </template>
  325. <script>
  326. import MescrollItem from "./module/mescrollUni-item.vue";
  327. import QQMapWX from '../../common/js/qqmap/myqqmap-sdk.js'
  328. import {date} from "../../uni_modules/uv-ui-tools/libs/function/test";
  329. export default {
  330. components: {
  331. MescrollItem
  332. },
  333. data() {
  334. return {
  335. buttonState: [0, 0, 0, 0], //0:不禁用按钮,1:禁用按钮。
  336. previousServiceOrderId: '',
  337. content: '',
  338. selectServiceObjectList: [],
  339. selectServiceObjectIndex: -1,
  340. servicePersonList: [],
  341. servicePersonListIndex: 0,
  342. serviceProjectList: [],
  343. serviceProjectListIndex: 0,
  344. tabIndex: 0,
  345. sysHeight: '',
  346. readerHeight: '',
  347. readerWidth: '',
  348. userInfo: {},
  349. storeId: '',
  350. storeName: '',
  351. currService: null,
  352. qqMap: new QQMapWX({
  353. key: 'ZIABZ-543WB-747UM-JL5Y7-NDS4E-HWB4M',
  354. vm: this
  355. }),
  356. codeUrl:'',
  357. qrcodeUrl: 'https://jje.admin.xinyuekj.com.cn/recharge/recharge?storeId={promotionStoreId}&techNo={techNo}',
  358. options: {
  359. // 指定二维码前景,一般可在中间放logo
  360. foregroundImagePadding: 2,
  361. foregroundImageBorderRadius: 5,
  362. foregroundImageSrc: '/static/logo.png'
  363. },
  364. codeTime: null,
  365. serviceTabs:[{
  366. label:0,
  367. value: "我的"
  368. },
  369. {
  370. label:1,
  371. value: "客户"
  372. }],
  373. serviceTabIndex: 0,
  374. currServiceList:[],
  375. // 分别存储两个列表的数据
  376. myServiceList: [],
  377. customerServiceList: [],
  378. // 两个列表的serviceFee总和
  379. myServiceFeeSum: 0,
  380. customerServiceFeeSum: 0
  381. }
  382. },
  383. onLoad() {
  384. let sysInfo = uni.getSystemInfoSync()
  385. this.sysHeight = sysInfo.windowHeight - (sysInfo.windowWidth / 750) * 400 + 'px'
  386. this.readerHeight = sysInfo.windowHeight + 'px'
  387. this.readerWidth = sysInfo.windowWidth + 'px'
  388. },
  389. onShow() {
  390. this.getUserInfo()
  391. // this.userInfo = uni.getStorageSync('userInfo')
  392. // if (this.userInfo.signIn){
  393. // this.currServiceInfo()
  394. // }
  395. },
  396. methods: {
  397. avatarOpen() {
  398. this.$refs.avatarPopup.open()
  399. },
  400. async promotion() {
  401. await this.getUserInfo()
  402. console.log('------', this.userInfo)
  403. if (!this.userInfo.workStoreId || !this.userInfo.techNo) {
  404. uni.showToast({
  405. icon: 'error',
  406. duration: 2000,
  407. title: '请刷新页面重试'
  408. });
  409. return
  410. }
  411. let date = new Date();
  412. this.codeTime = date.toLocaleString();
  413. let data = {
  414. promotionStoreId: this.userInfo.workStoreId,
  415. techNo: this.userInfo.techNo
  416. };
  417. console.log(data)
  418. this.codeUrl = this.qrcodeUrl
  419. for (let key in data) {
  420. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  421. this.codeUrl = this.codeUrl.replace(regexp, data[key]); // 执行替换操作
  422. }
  423. console.log('++++qrcodeUrl+++++', this.codeUrl)
  424. this.$refs.promotionPopup.open()
  425. },
  426. closeReminderPopup() {
  427. this.previousServiceOrderId = ''
  428. this.$refs.reminderPopup.close()
  429. },
  430. openSelectServiceObjectPopup() {
  431. this.$api.service.getServiceObjectList({
  432. orderServiceId: this.currService.orderServiceId,
  433. }).then(res => {
  434. this.selectServiceObjectList = res.data.data
  435. this.getServiceObjectUrl(this.selectServiceObjectList)
  436. uni.hideTabBar()
  437. this.$refs.selectServiceObjectPopup.open()
  438. })
  439. },
  440. // 获取图片
  441. getServiceObjectUrl(items) {
  442. for (let i = 0; i < items.length; i++) {
  443. let ptoto = items[i].facePhoto || items[i].personPhoto
  444. if (ptoto) {
  445. this.$api.service.getImgUrlByOssId({
  446. ossId: ptoto
  447. }).then(res => {
  448. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  449. this.$forceUpdate()
  450. })
  451. }
  452. }
  453. },
  454. closeSelectServiceObjectPopup() {
  455. this.serviceProjectListIndex = -1
  456. this.$refs.selectServiceObjectPopup.close()
  457. },
  458. switchServiceObject() {
  459. if (this.selectServiceObjectIndex === -1) {
  460. uni.showToast({
  461. icon: 'none',
  462. duration: 2000,
  463. title: '请选择服务对象'
  464. });
  465. return
  466. }
  467. this.$api.service.switchServiceObject({
  468. orderServiceId: this.currService.orderServiceId,
  469. serviceObjectId: this.selectServiceObjectList[this.selectServiceObjectIndex].id
  470. }).then(res => {
  471. this.currServiceInfo()
  472. this.closeSelectServiceObjectPopup()
  473. })
  474. },
  475. addService() {
  476. if (!this.currService) {
  477. uni.showToast({
  478. icon: 'error',
  479. duration: 2000,
  480. title: '没有服务对象'
  481. });
  482. return
  483. }
  484. this.serviceProjectListIndex = 0
  485. this.$api.service.serviceProjectList().then(res => {
  486. this.serviceProjectList = res.data.data
  487. this.serviceUserList(res.data.data[0])
  488. uni.hideTabBar()
  489. this.$refs.addServicePopup.open()
  490. })
  491. },
  492. selectProject(item, index) {
  493. this.serviceProjectListIndex = index
  494. this.serviceUserList(item)
  495. },
  496. serviceUserList(item) {
  497. this.$api.service.serviceUserList({
  498. serviceProjectId: item.id,
  499. storeId: this.storeId
  500. }).then(res => {
  501. this.servicePersonListIndex = 0
  502. this.servicePersonList = res.data.data
  503. this.getServiceObjectUrl(this.servicePersonList)
  504. })
  505. },
  506. closeAddServicePopup() {
  507. this.serviceProjectListIndex = 0
  508. this.$refs.addServicePopup.close()
  509. },
  510. addServiceProject() {
  511. this.previousServiceOrderId = this.currService.serviceObjectId
  512. this.$api.service.addServiceProject({
  513. orderServiceId: this.currService.orderServiceId,
  514. serviceProjectId: this.serviceProjectList[this.serviceProjectListIndex].id,
  515. serviceUserId: this.servicePersonList[this.servicePersonListIndex].personId
  516. }).then(res => {
  517. this.closeAddServicePopup()
  518. this.currServiceInfo()
  519. this.$refs.reminderPopup.open()
  520. })
  521. },
  522. popupChange(e) {
  523. if (!e.show) {
  524. uni.showTabBar()
  525. }
  526. },
  527. takePlace() {
  528. if (!this.currService) {
  529. uni.showToast({
  530. icon: 'error',
  531. duration: 2000,
  532. title: '没有服务对象'
  533. });
  534. return
  535. }
  536. this.$api.service.takePlace({
  537. orderServiceId: this.currService.orderServiceId
  538. }).then(res => {
  539. uni.showToast({
  540. icon: 'success',
  541. duration: 2000,
  542. title: '操作成功'
  543. });
  544. this.currServiceInfo()
  545. })
  546. },
  547. preference() {
  548. this.$refs.reminderPopup.close()
  549. this.$api.service.preference({
  550. serviceObjectId: this.previousServiceOrderId,
  551. preference: this.content
  552. }).then(res => {
  553. if (this.currService) {
  554. if (this.currService.serviceObjectId == this.previousServiceOrderId) {
  555. this.currService.preference = this.content
  556. }
  557. }
  558. this.previousServiceOrderId = ''
  559. this.content = ''
  560. uni.showToast({
  561. icon: 'success',
  562. duration: 2000,
  563. title: '保存成功'
  564. });
  565. })
  566. },
  567. settle() {
  568. let that = this
  569. if (!that.currService) {
  570. uni.showToast({
  571. icon: 'error',
  572. duration: 2000,
  573. title: '没有服务对象'
  574. });
  575. return
  576. }
  577. uni.showModal({
  578. title: '温馨提示',
  579. content: '是否确定结算',
  580. editable: false,
  581. success: (e) => {
  582. console.log(e)
  583. if (e.confirm) {
  584. that.previousServiceOrderId = that.currService.serviceObjectId
  585. uni.showLoading({
  586. title: '结算中...'
  587. });
  588. that.$api.service.settle({
  589. orderServiceId: that.currService.orderServiceId
  590. }).then(res => {
  591. uni.hideLoading();
  592. that.currServiceInfo()
  593. that.$refs.reminderPopup.open()
  594. }).catch(err => {
  595. uni.hideLoading();
  596. })
  597. }
  598. }
  599. })
  600. },
  601. start() {
  602. this.$api.service.start({
  603. orderServiceId: this.currService.orderServiceId
  604. }).then(res => {
  605. this.currServiceInfo()
  606. })
  607. },
  608. end() {
  609. this.$api.service.end({
  610. orderServiceId: this.currService.orderServiceId
  611. }).then(res => {
  612. this.currServiceInfo()
  613. })
  614. },
  615. call() {
  616. this.$api.service.call({
  617. orderServiceId: this.currService.orderServiceId
  618. }).then(res => {
  619. this.currServiceInfo()
  620. })
  621. },
  622. next() {
  623. if (!this.userInfo.signIn) {
  624. uni.showToast({
  625. icon: 'error',
  626. duration: 2000,
  627. title: '请先扫码签到'
  628. });
  629. return
  630. }
  631. uni.showModal({
  632. title: '温馨提示',
  633. content: '是否确定下一位',
  634. editable: false,
  635. success: (e) => {
  636. if (e.confirm) {
  637. console.log(e.confirm)
  638. uni.showLoading({
  639. title: '叫号中...'
  640. });
  641. this.$api.service.next({
  642. orderServiceId: this.currService ? this.currService.orderServiceId :
  643. null,
  644. storeId: this.storeId
  645. }).then(res => {
  646. this.currServiceInfo(true)
  647. }).catch(err => {
  648. uni.hideLoading();
  649. })
  650. }
  651. }
  652. })
  653. },
  654. currServiceInfo(e) {
  655. if (!this.userInfo.signIn) {
  656. uni.showToast({
  657. icon: 'error',
  658. duration: 2000,
  659. title: '请先扫码签到'
  660. });
  661. return
  662. }
  663. uni.showLoading({
  664. title: '叫号中...'
  665. });
  666. this.$api.service.currServiceInfo({
  667. storeId: this.userInfo.workStoreId
  668. }).then(res => {
  669. if (e) {
  670. if (res.data.data === null) {
  671. uni.showModal({
  672. title: '温馨提示',
  673. content: '暂无需要服务的客户',
  674. editable: false,
  675. showCancel: false,
  676. success: (e) => {
  677. if (e.confirm) {
  678. }
  679. }
  680. })
  681. }
  682. }
  683. uni.hideLoading();
  684. this.currService = res.data.data
  685. console.log('当前服务对象============》', this.currService)
  686. this.setButtomState(this.currService)
  687. if (!this.currService) {
  688. this.currServiceList = []
  689. return
  690. }
  691. // 同时请求两个列表的数据
  692. this.currServiceInfoList(0)
  693. this.currServiceInfoList(1)
  694. this.equityCard(this.currService)
  695. this.currService.avatar = this.currService.avatar.replace(/^http:/, "https:")
  696. }).catch(err => {
  697. uni.hideLoading();
  698. console.log("出错了+++++++++++出错了+++++++", err)
  699. })
  700. },
  701. currServiceInfoList(isAll){
  702. this.serviceTabIndex = isAll
  703. this.$api.service.currServiceInfoList({
  704. storeId: this.userInfo.workStoreId,
  705. orderNo: this.currService.orderNo,
  706. isAll:isAll
  707. }).then(res=>{
  708. this.currServiceList = res.data.data
  709. // 分别存储并计算两个列表的serviceFee总和
  710. if (isAll === 0) {
  711. this.myServiceList = res.data.data
  712. this.myServiceFeeSum = this.calculateServiceFeeSum(this.myServiceList)
  713. } else {
  714. this.customerServiceList = res.data.data
  715. this.customerServiceFeeSum = this.calculateServiceFeeSum(this.customerServiceList)
  716. }
  717. })
  718. },
  719. // 计算serviceFee总和
  720. calculateServiceFeeSum(list) {
  721. if (!list || list.length === 0) {
  722. return 0
  723. }
  724. return list.reduce((sum, item) => {
  725. return sum + (parseFloat(item.serviceFee) || 0)
  726. }, 0)
  727. },
  728. //查询是否是有权益卡的服务对象
  729. equityCard(data) {
  730. if (!data || !data.serviceObjectId) {
  731. return
  732. }
  733. this.$api.service.equityCard({
  734. serviceObjectId: data.serviceObjectId,
  735. memberId: data.userId,
  736. serviceStoreId: data.serviceStoreId
  737. }).then(res => {
  738. // data.cardList = res.data.data
  739. this.$set(data, 'cardList', res.data.data)
  740. })
  741. },
  742. setButtomState(currService) {
  743. if (currService) {
  744. if (currService.status == 12) {
  745. //叫号中
  746. this.buttonState = [0, 0, 1, 1]
  747. } else if (currService.status == 8 || currService.status == 1) {
  748. //服务中
  749. this.buttonState = [1, 1, 0, 0]
  750. }
  751. } else {
  752. this.buttonState = [0, 1, 1, 1]
  753. }
  754. },
  755. getUserInfo() {
  756. return this.$api.user.getUserInfo().then(res => {
  757. this.userInfo = res.data.data
  758. this.storeId = res.data.data.workStoreId
  759. uni.setStorageSync('userInfo', this.userInfo)
  760. if (this.userInfo.avatar) {
  761. this.getImgUrlByOssId(this.userInfo.avatar)
  762. }
  763. if (this.userInfo.signIn) {
  764. this.buttonState = [0, 1, 1, 1]
  765. this.currServiceInfo()
  766. }
  767. this.$forceUpdate()
  768. console.log('获取个人信息完毕')
  769. })
  770. },
  771. getImgUrlByOssId(ossId) {
  772. this.$api.service.getImgUrlByOssId({
  773. ossId: ossId
  774. }).then(res => {
  775. this.$set(this.userInfo, 'avatarUrl', res.data.data[0].url.replace(/^http:/, "https:"))
  776. uni.setStorageSync('userInfo', this.userInfo)
  777. })
  778. },
  779. userScanCode() {
  780. let that = this
  781. uni.navigateTo({
  782. url: '/pages/scanCode/scanCode',
  783. events: {
  784. getScancode: function (data) {
  785. let param = {
  786. storeId: JSON.parse(data).storeId,
  787. timestamp: JSON.parse(data).timestamp
  788. }
  789. that.$api.service.clockIn(param).then(res => {
  790. uni.showToast({
  791. icon: 'success',
  792. duration: 2000,
  793. title: '签到成功'
  794. });
  795. uni.setStorageSync('userInfo', that.userInfo)
  796. that.getUserInfo()
  797. })
  798. },
  799. }
  800. })
  801. },
  802. clickTab(e) {
  803. this.tabIndex = e
  804. if (e === 0) {
  805. this.currServiceInfo()
  806. }
  807. },
  808. }
  809. }
  810. </script>
  811. <style lang="scss" scoped>
  812. @import './index.rpx.css';
  813. </style>