homePage.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. <template>
  2. <view class="HomeItem">
  3. <view v-if="!online && online !== undefined && workSchemeType == 1">
  4. <view class="goWork" @click="GoWork()">
  5. <view class="goWork_btn_E">
  6. <view class="goWork_btn_W"> 上班 </view>
  7. </view>
  8. </view>
  9. <view class="goWork_text">
  10. <view class="goWork_text-p">上班提醒</view>
  11. <view>请点击" 上班 "开始抢单!</view>
  12. </view>
  13. </view>
  14. <view v-if="!online && online !== undefined && workSchemeType == 2" class="goWorkAll">
  15. <view class="goWorkSelect combination">
  16. <view class="goWorkSelect-head">上班选择工作组合</view>
  17. <scroll-view class="goWorkSelect-list scroll" scroll-y :refresher-enabled="scroll_refresher_enabled"
  18. :refresher-triggered="triggered" @refresherrefresh="refresherrefresh" @refresherrestore="refresherrestore"
  19. @scrolltolower="scrolltolower" :scroll-top="scroll_top" @refresherabort="refresherabort" @scroll="scroll">
  20. <radio-group @change="radioChange1">
  21. <label class="goWorkSelect-item" v-for="item in zxzData" :key="item.str">
  22. <radio :value="item.str" :checked="item.checked" />
  23. <view>{{ item.configName }}</view>
  24. </label>
  25. </radio-group>
  26. </scroll-view>
  27. </view>
  28. <view class="goWorkSelect history">
  29. <view class="goWorkSelect-head"> 历史上班记录 </view>
  30. <view class="goWorkSelect-list">
  31. <radio-group @change="radioChange2">
  32. <label class="goWorkSelect-item" v-for="(item, index) in historys" :key="index">
  33. <radio :value="item.str" :checked="item.checked" />
  34. <view>{{ item.useTime }}上班记录快捷上班</view>
  35. <button @click="lock(item)">
  36. {{ item.locking == 1 ? "解锁" : "锁定" }}
  37. </button>
  38. </label>
  39. </radio-group>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- APP或H5账号密码登录页面 start -->
  44. <view class="login" v-if="!workSchemeType && (isApp||isH5AndPwd)">
  45. <view class="title"> 转运系统登录 </view>
  46. <input class="login_input" v-model="username" placeholder="请输入用户名" />
  47. <input class="login_input" password v-model="password" placeholder="请输入密码" />
  48. <input class="login_input" v-show="!isH5AndPwd" v-model="ip" placeholder="请输入域名或IP地址,如:http(s)://192.168.3.108" />
  49. <view class="page_item_btn" @click="login()"> 登录 </view>
  50. <view class="tips" v-show="isH5AndPwd">
  51. (此系统为药房使用,其他科室人员请勿进行操作)
  52. </view>
  53. </view>
  54. <!-- APP或H5账号密码登录页面 end -->
  55. <view class="botImg" v-if="online || (!online && online !== undefined && workSchemeType == 1)">
  56. <view class="img"></view>
  57. </view>
  58. <!-- 弹窗 -->
  59. <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
  60. @ok="ok" @cancel="cancel" :operate="models.operate" :phone="models.phone" @know="know"></showModel>
  61. <!-- 锁定-弹窗 -->
  62. <showModel :title="modelsLock.title" :icon="modelsLock.icon" :disjunctor="modelsLock.disjunctor"
  63. :content="modelsLock.content" @ok="okLock" @cancel="cancelLock" :operate="modelsLock.operate" @know="knowLock">
  64. </showModel>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. get,
  70. post,
  71. changeIP,
  72. webHandle
  73. } from "../../http/http.js";
  74. import showModel from "../../components/showModel/showModel.vue";
  75. export default {
  76. data() {
  77. return {
  78. //#ifdef H5
  79. type: "",
  80. //#endif
  81. // 是否上班了
  82. online: undefined,
  83. // 是否是app
  84. isApp: false,
  85. // 是否是H5,账号密码登录
  86. isH5AndPwd: false,
  87. // 用户名
  88. username: "",
  89. // 密码
  90. password: "",
  91. //ip地址或域名
  92. ip: "hsms.dashitech.com",
  93. scroll_refresher_enabled: true, //是否开启自定义下拉刷新
  94. triggered: false, //下拉刷新状态
  95. freshing: false, //上拉加载开关
  96. scroll_top: 0, //距离顶部的距离
  97. //分页页码
  98. idx: 0,
  99. // 列表项总数
  100. totalNum: -1,
  101. // 上班选择工作组合列表
  102. zxzData: [],
  103. workSchemeId: "", //启动中工作分配方案id
  104. workSchemeType: "", //启动中工作分配方案类型
  105. ruleType: "", //工作分配方案规则、、例如自由抢单等
  106. // 上班历史记录列表
  107. historys: [],
  108. // 弹窗model
  109. models: {
  110. disjunctor: false,
  111. },
  112. //锁定的选项
  113. itemLock: {},
  114. // 弹窗model--锁定
  115. modelsLock: {
  116. disjunctor: false,
  117. },
  118. };
  119. },
  120. methods: {
  121. // 锁定
  122. lock(data) {
  123. console.log(data);
  124. this.itemLock = data;
  125. this.modelsLock = {
  126. disjunctor: true,
  127. title: "提示",
  128. content: `是否${
  129. this.itemLock.locking == 1 ? "解锁" : "锁定"
  130. }该上班记录`,
  131. icon: "warn",
  132. operate: {
  133. ok: "确定",
  134. cancel: "取消",
  135. },
  136. };
  137. },
  138. //知道了
  139. knowLock() {
  140. this.modelsLock.disjunctor = false;
  141. let userId = uni.getStorageSync("userData").user.id;
  142. this.getHistorys(userId); //获取上班历史记录
  143. },
  144. //确定
  145. okLock() {
  146. this.modelsLock.disjunctor = false;
  147. let postData = {
  148. workConfigHistory: {
  149. id: this.itemLock.id,
  150. locking: this.itemLock.locking == 1 ? 0 : 1,
  151. },
  152. };
  153. uni.showLoading({
  154. title: "加载中",
  155. mask: true,
  156. });
  157. post("/configuration/updData/workConfigHistory", postData).then(
  158. (result) => {
  159. uni.hideLoading();
  160. if (result.status == 200) {
  161. this.modelsLock = {
  162. disjunctor: true,
  163. title: "提示",
  164. content: `${this.itemLock.locking == 0 ? "锁定" : "解锁"}成功`,
  165. icon: "success",
  166. operate: {
  167. know: "知道了",
  168. },
  169. };
  170. } else {
  171. uni.showToast({
  172. icon: "none",
  173. title: "请求失败",
  174. });
  175. }
  176. }
  177. );
  178. },
  179. //取消
  180. cancelLock() {
  181. this.modelsLock.disjunctor = false;
  182. },
  183. // 选择历史上班记录
  184. radioChange2(value) {
  185. this.objHistory = JSON.parse(value.target.value);
  186. let depts = this.objHistory.deptList.map((item) => item.dept).join();
  187. this.models = {
  188. disjunctor: true,
  189. title: "提示",
  190. content: `组合名称是【${this.objHistory.workAllocationQuick.configName}】;选择的科室是【${depts}】`,
  191. icon: "warn",
  192. operate: {
  193. ok: "快捷上班",
  194. cancel: "取消",
  195. },
  196. };
  197. },
  198. //知道了
  199. know() {
  200. this.models.disjunctor = false;
  201. },
  202. //确定
  203. ok() {
  204. this.models.disjunctor = false;
  205. this.ruleType = 3;
  206. uni.setStorageSync("setDepts", this.objHistory.deptList); //存科室列表
  207. uni.setStorageSync("setDeptConfg", {
  208. //存设置科室的配置信息
  209. configName: this.objHistory.workAllocationQuick.configName, //组合名称
  210. workSchemeType: 2, //方案类型
  211. ruleType: 3, //方案规则,科室绑定人员
  212. id: this.objHistory.workAllocationQuick.id, //组合id
  213. classesId: this.objHistory.classId,
  214. });
  215. this.GoWork();
  216. },
  217. //取消
  218. cancel() {
  219. this.models.disjunctor = false;
  220. let userId = uni.getStorageSync("userData").user.id;
  221. this.historys = [];
  222. this.getHistorys(userId); //获取上班历史记录
  223. },
  224. // 获取上班历史记录
  225. getHistorys(id) {
  226. let postData = {
  227. idx: 0,
  228. sum: 3,
  229. workConfigHistory: {
  230. hosId: uni.getStorageSync("userData").user.currentHospital.id,
  231. user: {
  232. id: id,
  233. },
  234. },
  235. };
  236. post("/configuration/fetchDataList/workConfigHistory", postData).then(
  237. (res) => {
  238. if (res.status == 200) {
  239. this.historys = res.list;
  240. this.historys.forEach((item) => {
  241. let d = new Date(item.useTime);
  242. let month = (d.getMonth() + 1 + "").padStart(2, "0");
  243. let day = (d.getDate() + "").padStart(2, "0");
  244. item.useTime = `${month}月${day}日`;
  245. let o = JSON.parse(JSON.stringify(item));
  246. item.str = JSON.stringify(o);
  247. item.checked = false;
  248. });
  249. } else {
  250. uni.showToast({
  251. icon: "none",
  252. title: "请求失败",
  253. });
  254. }
  255. }
  256. );
  257. },
  258. // 选择上班快捷组合
  259. radioChange1(value) {
  260. let obj = JSON.parse(value.target.value);
  261. console.log(obj);
  262. this.ruleType = obj.ruleType;
  263. if (obj.ruleType == 1) {
  264. //自由抢单,直接上班
  265. if (uni.getStorageSync("setDeptConfg")) {
  266. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  267. }
  268. this.GoWork();
  269. } else if (obj.ruleType == 3) {
  270. //科室绑定人员,进入设置科室界面
  271. uni.setStorageSync("setDeptConfg", {
  272. //存设置科室的配置信息
  273. configName: obj.configName,
  274. workSchemeType: this.workSchemeType,
  275. ruleType: obj.ruleType,
  276. id: obj.id,
  277. classesId: obj.classes.id,
  278. });
  279. uni.navigateTo({
  280. url: `../setDept/setDept?configName=${obj.configName}&id=${obj.id}`,
  281. });
  282. }
  283. },
  284. // 连接上下班的websocket baba type如果是wx则是微信,app则是app;有app必有ip
  285. offWork(type, ip) {
  286. let ipp, wws;
  287. if (type == "wx") {
  288. wws = document.location.protocol === "http:" ? "ws" : "wss"; //ws协议
  289. ipp = document.domain;
  290. } else if (type == "app") {
  291. wws = ip.split(":")[0] === "http" ? "ws" : "wss"; //ws协议
  292. ipp = ip.split(":")[1];
  293. }
  294. console.log(ipp, wws);
  295. uni.connectSocket({
  296. url: `${wws}://${ipp}:8080/webSocket/message/onlineStatus`,
  297. // url: `${wws}://192.168.3.74:8080/webSocket/message/onlineStatus`,
  298. });
  299. uni.onSocketOpen(function(res) {
  300. console.log("WebSocket连接已打开!");
  301. let userid = uni.getStorageSync("userData").user.id;
  302. uni.sendSocketMessage({
  303. data: JSON.stringify({
  304. userid,
  305. }),
  306. success: function(res) {
  307. console.log(res, "传参");
  308. },
  309. fail: function(err) {
  310. console.log(err, "传参错误");
  311. },
  312. });
  313. });
  314. uni.onSocketError(function(res) {
  315. console.log("WebSocket连接打开失败,请检查!");
  316. });
  317. uni.onSocketMessage((res) => {
  318. console.log("收到服务器内容:" + res.data);
  319. if (res.data == "ok") {
  320. this.goOffWork();
  321. }
  322. });
  323. },
  324. // 下班
  325. goOffWork() {
  326. let setDeptConfg = uni.getStorageSync("setDeptConfg");
  327. if (setDeptConfg.workSchemeType == 2 && setDeptConfg.ruleType == 3) {
  328. post("/auth/onOrOffLine", {
  329. type: "off",
  330. customWorking: "off",
  331. classId: uni.getStorageSync("setDeptConfg").classesId
  332. }).then((res) => {
  333. if (res.status == 200) {
  334. if (uni.getStorageSync("setDeptConfg")) {
  335. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  336. }
  337. uni.showToast({
  338. icon: "none",
  339. title: "您已被强制下班!",
  340. mask: true,
  341. duration: 5000,
  342. });
  343. setTimeout(() => {
  344. uni.redirectTo({
  345. url: "../mypage/mypage",
  346. });
  347. }, 5000);
  348. } else {
  349. uni.showToast({
  350. icon: "none",
  351. title: "请求失败",
  352. });
  353. }
  354. });
  355. } else {
  356. post("/auth/onOrOffLine", {
  357. type: "off",
  358. classId: uni.getStorageSync("setDeptConfg").classesId
  359. }).then((res) => {
  360. if (res.status == 200) {
  361. if (uni.getStorageSync("setDeptConfg")) {
  362. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  363. }
  364. uni.showToast({
  365. icon: "none",
  366. title: "您已被强制下班!",
  367. mask: true,
  368. duration: 5000,
  369. });
  370. setTimeout(() => {
  371. uni.redirectTo({
  372. url: "../mypage/mypage",
  373. });
  374. }, 5000);
  375. } else {
  376. uni.showToast({
  377. icon: "none",
  378. title: "请求失败",
  379. });
  380. }
  381. });
  382. }
  383. },
  384. // 上班
  385. GoWork() {
  386. uni.showLoading({
  387. title: "加载中",
  388. mask: true,
  389. });
  390. if (this.workSchemeType == 2 && this.ruleType == 3) {
  391. let obj = uni.getStorageSync("setDeptConfg");
  392. let depts = this.objHistory.deptList.map((item) => item.id).join();
  393. let userId = uni.getStorageSync("userData").user.id;
  394. post("/auth/onOrOffLine", {
  395. type: "on",
  396. customWorking: "on",
  397. quickId: obj.id,
  398. deptIds: depts,
  399. userId: userId,
  400. classId: uni.getStorageSync("setDeptConfg").classesId
  401. }).then((result) => {
  402. uni.hideLoading();
  403. if (result.status == 200) {
  404. let obj = uni.getStorageSync("userData");
  405. obj.user.online = true;
  406. uni.setStorageSync("userData", obj);
  407. uni.redirectTo({
  408. url: "../receiptpage/receiptpage",
  409. });
  410. } else if (result.status == 504) {
  411. let dept = result.department.dept;
  412. let user = result.user.name;
  413. let phone = result.user.phone;
  414. this.models = {
  415. disjunctor: true,
  416. title: "提示",
  417. content: `您选择的科室已经被使用,请换个科室,或者联系:科室[${dept}]人员[${user}]号码[${phone}] 切换科室解决`,
  418. icon: "warn",
  419. phone,
  420. operate: {
  421. know: "知道了",
  422. },
  423. };
  424. } else {
  425. uni.showToast({
  426. icon: "none",
  427. title: "请求失败",
  428. });
  429. }
  430. });
  431. } else {
  432. post("/auth/onOrOffLine", {
  433. type: "on",
  434. classId: uni.getStorageSync("setDeptConfg").classesId
  435. }).then((res) => {
  436. uni.hideLoading();
  437. if (res.status == 200) {
  438. let obj = uni.getStorageSync("userData");
  439. obj.user.online = true;
  440. uni.setStorageSync("userData", obj);
  441. uni.redirectTo({
  442. url: "../receiptpage/receiptpage",
  443. });
  444. } else {
  445. uni.showToast({
  446. icon: "none",
  447. title: "请求失败",
  448. });
  449. }
  450. });
  451. }
  452. },
  453. // 登录
  454. login() {
  455. // 用户名,密码,域名(ip)不能为空
  456. if (
  457. this.username.trim() === "" ||
  458. this.password.trim() === "" ||
  459. this.ip.trim() === ""
  460. ) {
  461. uni.showToast({
  462. icon: "none",
  463. title: "请输入用户名,密码,域名或IP",
  464. });
  465. return;
  466. }
  467. // 域名ip正则验证
  468. let regUrl =
  469. /^https?:\/\/([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)| (io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))(\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))?$/;
  470. let regIp =
  471. /^https?:\/\/((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)(\.((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)){3}(\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))?$/;
  472. if (!regUrl.test(this.ip.trim()) && !regIp.test(this.ip.trim())) {
  473. uni.showToast({
  474. icon: "none",
  475. title: "请输入正确的域名或IP",
  476. });
  477. return;
  478. }
  479. uni.setStorageSync("ip", this.ip);
  480. changeIP(this.ip);
  481. uni.showLoading({
  482. title: "登录中",
  483. mask: true,
  484. });
  485. let data = {
  486. username: this.username.trim(),
  487. password: this.password.trim(),
  488. type: 'APP'
  489. };
  490. post("/auth/login", data).then((res) => {
  491. uni.hideLoading();
  492. if (res.status == 200) {
  493. //获取角色信息
  494. let role = res.user.user.role;
  495. // 配药师和支助人员才能登录
  496. let workerFlag = role.some((item) => item.rolecode === "worker");
  497. let pharmacistFlag = role.some((item) => item.rolecode === "pharmacist");
  498. if (!workerFlag && !pharmacistFlag) {
  499. uni.showToast({
  500. icon: "none",
  501. title: "暂无权限登录!",
  502. });
  503. return;
  504. }
  505. uni.setStorageSync("userData", res.user);
  506. uni.setStorageSync("username", this.username); //存储用户名
  507. uni.setStorageSync("password", this.password); //存储密码
  508. this.getWorkScheme(false, res.user.user.currentHospital.id); //获取当前启动中的工作分配方案
  509. this.getHistorys(res.user.user.id); //获取上班历史记录
  510. this.offWork("app", this.ip);
  511. if (workerFlag) { //有配药师角色
  512. if (!res.user.user.online) {
  513. this.online = false;
  514. } else {
  515. this.online = true;
  516. // 建立websocket连接
  517. webHandle("receiptpage", "app", this.ip);
  518. }
  519. } else {
  520. webHandle("pharmacy", "app", this.ip);
  521. }
  522. } else if (!res.status && !res.remarks) {
  523. //如果乱填写域名或ip
  524. uni.showToast({
  525. icon: "none",
  526. title: "服务器连接失败!请检查输入的域名(IP)及端口号",
  527. });
  528. } else {
  529. uni.showToast({
  530. icon: "none",
  531. title: res.remarks ? res.remarks : "请求失败",
  532. });
  533. }
  534. });
  535. },
  536. // 微信登录公用方法
  537. // user:当前登录用户对象
  538. // type:有值的话则是从菜单访问的
  539. // workerFlag:是否有支助人员角色
  540. // pharmacistFlag:是否有配药师角色
  541. submCommon(user, type, workerFlag, pharmacistFlag) {
  542. //从药房菜单过来的
  543. if (type === "pharmacy") {
  544. //药房来
  545. // 药房才能登录
  546. if (!pharmacistFlag) {
  547. uni.showToast({
  548. icon: "none",
  549. title: "暂无权限登录!",
  550. });
  551. return;
  552. }
  553. } else if (type === "mypage") { //从我的菜单过来的
  554. if (!workerFlag) {
  555. uni.showToast({
  556. icon: "none",
  557. title: "暂无权限登录!",
  558. });
  559. return;
  560. }
  561. } else {
  562. //正常进入
  563. if (!workerFlag && !pharmacistFlag) {
  564. uni.showToast({
  565. icon: "none",
  566. title: "暂无权限登录!",
  567. });
  568. return;
  569. }
  570. }
  571. uni.setStorageSync("userData", user);
  572. this.getWorkScheme(false, user.user.currentHospital.id); //获取当前启动中的工作分配方案
  573. this.getHistorys(user.user.id); //获取上班历史记录
  574. this.offWork("wx");
  575. // uni.setStorageSync('type', '')
  576. if (type === "pharmacy") {
  577. // 建立websocket连接
  578. webHandle("pharmacy", "wx");
  579. } else if (type === "mypage") {
  580. // 建立websocket连接
  581. webHandle("mypage", "wx");
  582. } else {
  583. if (workerFlag) { //有支助人员的角色
  584. if (!user.user.online) {
  585. this.online = false;
  586. } else {
  587. this.online = true;
  588. // 建立websocket连接
  589. webHandle("receiptpage", "wx");
  590. }
  591. } else { //只有药房橘色
  592. webHandle("pharmacy", "wx");
  593. }
  594. }
  595. },
  596. //微信
  597. subm() {
  598. uni.showLoading({
  599. title: "登录中",
  600. mask: true,
  601. });
  602. var href = location.href; //获取链接地址
  603. console.log(href, "href");
  604. var href_wenhao = href.indexOf("?code="); //判断有没有问号,没有是-1
  605. var wenhaohoumian = location.href.split("?code="); //截取问号地址数组
  606. this.arr_last = wenhaohoumian[1]; //地址数组赋值
  607. if (href_wenhao == -1) {
  608. post("/auth/wxlogin").then((res) => {
  609. this.url = res.url;
  610. this.state = res.status;
  611. uni.setStorageSync("type", this.type); //存储来源type
  612. uni.hideLoading();
  613. if (this.state == "200") {
  614. //获取角色信息
  615. let role = res.user.user.role;
  616. let workerFlag = role.some((item) => item.rolecode === "worker");
  617. let pharmacistFlag = role.some((item) => item.rolecode === "pharmacist");
  618. this.submCommon(res.user, this.type, workerFlag, pharmacistFlag);
  619. } else if (this.state == "501") {
  620. uni.showModal({
  621. title: '提示',
  622. content: res.remarks,
  623. showCancel: false,
  624. confirmColor: '#49b856',
  625. success: function(res) {
  626. if (res.confirm) {
  627. console.log('用户点击确定');
  628. } else if (res.cancel) {
  629. console.log('用户点击取消');
  630. }
  631. }
  632. });
  633. } else if (this.state == "555") {
  634. // 如果需要绑定账号 并且 没有微信号
  635. if(this.type){
  636. uni.redirectTo({
  637. url: `../bindUser/bindUser?type=${this.type}`
  638. })
  639. }else{
  640. uni.redirectTo({
  641. url: `../bindUser/bindUser`
  642. })
  643. }
  644. } else {
  645. console.log(this.url, "url");
  646. // https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww2506abad3086cfab&redirect_uri=http://weixintest2.ngser.dashitech.com/app&response_type=code&scope=snsapi_base&agentid=1000013&state=STATE&connect_redirect=1#wechat_redirect
  647. location.assign(this.url);
  648. }
  649. });
  650. } else if (href_wenhao != -1) {
  651. this.arr_last = this.arr_last.split("&");
  652. this.arr_last = this.arr_last[0];
  653. post("/auth/wxlogina", {
  654. code: this.arr_last,
  655. }).then((res) => {
  656. this.state = res.status;
  657. uni.hideLoading();
  658. if (this.state == "200") {
  659. this.type = uni.getStorageSync("type"); //刷新页面后获取type
  660. console.log(this.type);
  661. //获取角色信息
  662. let role = res.user.user.role;
  663. let workerFlag = role.some((item) => item.rolecode === "worker");
  664. let pharmacistFlag = role.some((item) => item.rolecode === "pharmacist");
  665. this.submCommon(res.user, this.type, workerFlag, pharmacistFlag);
  666. } else if (this.state == "501") {
  667. uni.showModal({
  668. title: '提示',
  669. content: res.remarks,
  670. showCancel: false,
  671. confirmColor: '#49b856',
  672. success: function(res) {
  673. if (res.confirm) {
  674. console.log('用户点击确定');
  675. } else if (res.cancel) {
  676. console.log('用户点击取消');
  677. }
  678. }
  679. });
  680. } else if (this.state == "555") {
  681. this.type = uni.getStorageSync("type"); //刷新页面后获取type
  682. // 如果需要绑定账号 并且 没有微信号
  683. if(this.type){
  684. uni.redirectTo({
  685. url: `../bindUser/bindUser?type=${this.type}`
  686. })
  687. }else{
  688. uni.redirectTo({
  689. url: `../bindUser/bindUser`
  690. })
  691. }
  692. } else {
  693. uni.showToast({
  694. icon: "none",
  695. title: "请求失败",
  696. });
  697. }
  698. });
  699. }
  700. },
  701. // 获取工作组合列表
  702. getCombinationById(idx, type) {
  703. console.log(this.type);
  704. if (this.zxzData.length == this.totalNum && !type) {
  705. uni.showToast({
  706. icon: "none",
  707. title: "没有更多数据了!",
  708. });
  709. this.freshing = true;
  710. return;
  711. }
  712. let data = {
  713. workAllocationQuickConfig: {
  714. workSchemeId: this.workSchemeId,
  715. },
  716. idx: idx,
  717. sum: 20,
  718. };
  719. uni.showLoading({
  720. title: "加载中",
  721. mask: true,
  722. });
  723. // 请求列表数据
  724. post("/configuration/fetchDataList/workAllocationQuickConfig", data).then(
  725. (res) => {
  726. uni.hideLoading();
  727. if (res.status == 200) {
  728. this.triggered = false;
  729. this.freshing = true;
  730. this.totalNum = res.totalNum;
  731. if (idx === 0) {
  732. res.list.forEach((item) => {
  733. let o = JSON.parse(JSON.stringify(item));
  734. item.str = JSON.stringify(o);
  735. item.checked = false;
  736. });
  737. this.zxzData = res.list;
  738. } else {
  739. res.list.forEach((item) => {
  740. let o = JSON.parse(JSON.stringify(item));
  741. item.str = JSON.stringify(o);
  742. item.checked = false;
  743. });
  744. this.zxzData.push(...res.list);
  745. }
  746. } else {
  747. uni.showToast({
  748. icon: "none",
  749. title: "请求失败!",
  750. });
  751. }
  752. }
  753. );
  754. },
  755. //刷新
  756. refresherrefresh() {
  757. if (this.triggered) {
  758. return;
  759. }
  760. console.log("下拉刷新");
  761. this.triggered = true;
  762. this.idx = 0;
  763. this.totalNum = -1;
  764. this.getCombinationById(0);
  765. },
  766. // 下拉刷新复位
  767. refresherrestore() {
  768. this.triggered = false;
  769. console.log("下拉刷新复位");
  770. },
  771. //下拉刷新中止
  772. refresherabort() {
  773. this.triggered = false;
  774. console.log("下拉刷新中止");
  775. },
  776. //分页,上拉加载
  777. scrolltolower() {
  778. if (this.freshing) {
  779. console.log("上拉加载");
  780. this.freshing = false;
  781. this.getCombinationById(++this.idx);
  782. }
  783. },
  784. // 滚动
  785. scroll(e) {
  786. if (e.detail.scrollTop < 20) {
  787. this.scroll_refresher_enabled = true;
  788. } else {
  789. this.scroll_refresher_enabled = false;
  790. }
  791. },
  792. // 获取启动中的工作分配方案
  793. getWorkScheme(type, hosId) {
  794. let postData = {
  795. idx: 0,
  796. workScheme: {
  797. status: 1,
  798. hosId
  799. },
  800. sum: 1,
  801. };
  802. post("/simple/data/fetchDataList/workScheme", postData).then((res) => {
  803. if (res.status == 200) {
  804. this.workSchemeId = res.list[0].id;
  805. this.workSchemeType = res.list[0].workType;
  806. if (type) {
  807. if (this.workSchemeType == 2) {
  808. this.getCombinationById(0, "no");
  809. } else if (this.workSchemeType == 1) {
  810. if (uni.getStorageSync("setDeptConfg")) {
  811. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  812. }
  813. }
  814. } else {
  815. this.getCombinationById(0);
  816. }
  817. } else {
  818. uni.showToast({
  819. icon: "none",
  820. title: "请求失败!",
  821. });
  822. }
  823. });
  824. },
  825. // 阻止浏览器滑动
  826. stop(e) {
  827. e.preventDefault();
  828. },
  829. //获取查询参数
  830. GetQueryString(name) {
  831. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  832. var r = location.search.substr(1).match(reg);
  833. if (r != null) {
  834. return unescape(r[2]);
  835. }
  836. return null;
  837. }
  838. },
  839. onHide() {
  840. this.zxzData = [];
  841. this.historys = [];
  842. // #ifdef H5
  843. document.body.removeEventListener("touchmove", this.stop, {
  844. passive: false,
  845. });
  846. // #endif
  847. },
  848. onShow() {
  849. console.log('onShow');
  850. // let flag = true;
  851. if (uni.getStorageSync("userData")) {
  852. this.online = uni.getStorageSync("userData").user.online;
  853. }
  854. if (!this.workSchemeType) {
  855. return;
  856. }
  857. // if (this.workSchemeType == 2 && !this.online) {
  858. // let userId = uni.getStorageSync('userData').user.id;
  859. // this.getCombinationById(this.idx, 'no');
  860. // this.getHistorys(userId); //获取上班历史记录
  861. // }
  862. let userId = uni.getStorageSync("userData").user.id;
  863. this.getWorkScheme(true, uni.getStorageSync("userData").user.currentHospital.id);
  864. this.getHistorys(userId); //获取上班历史记录
  865. // #ifdef APP-PLUS
  866. uni.closeSocket();
  867. // #endif
  868. // #ifdef H5
  869. document.body.addEventListener("touchmove", this.stop, {
  870. passive: false,
  871. });
  872. // #endif
  873. },
  874. onLoad(options) {
  875. if (uni.getStorageSync("setDepts")) {
  876. uni.removeStorageSync("setDepts"); //清空选择的科室,初始化
  877. }
  878. console.log(options);
  879. this.ip = uni.getStorageSync("ip") || this.ip;
  880. this.username = uni.getStorageSync("username") || this.username;
  881. this.password = uni.getStorageSync("password") || this.password;
  882. //#ifdef H5
  883. this.isApp = false;
  884. this.type = options.type || "";
  885. console.log(this.type);
  886. if (this.GetQueryString('login') === '1') {
  887. //H5页面账号密码登录
  888. this.isH5AndPwd = true;
  889. this.ip = location.origin;
  890. } else {
  891. this.isH5AndPwd = false;
  892. this.subm();
  893. }
  894. //#endif
  895. // #ifdef APP-PLUS
  896. this.isApp = true;
  897. // 通知权限 start
  898. // var main = plus.android.runtimeMainActivity();
  899. // var pkName = main.getPackageName();
  900. // var NotificationManagerCompat = plus.android.importClass(
  901. // "android.support.v4.app.NotificationManagerCompat"
  902. // );
  903. // var packageNames = NotificationManagerCompat.from(main);
  904. // console.log(JSON.stringify(packageNames));
  905. // if (packageNames.areNotificationsEnabled()) {
  906. // console.log("已开启通知权限");
  907. // } else {
  908. // uni.showModal({
  909. // title: "提示",
  910. // content: "请先打开APP通知权限",
  911. // showCancel: true,
  912. // success: function(res) {
  913. // if (res.confirm) {
  914. // var Intent = plus.android.importClass("android.content.Intent");
  915. // var intent = new Intent(
  916. // "android.settings.APP_NOTIFICATION_SETTINGS"
  917. // ); //可设置表中所有Action字段
  918. // intent.putExtra("android.provider.extra.APP_PACKAGE", pkName);
  919. // main.startActivity(intent);
  920. // }
  921. // },
  922. // });
  923. // }
  924. // 通知权限 end
  925. // #endif
  926. },
  927. };
  928. </script>
  929. <style lang="less" scoped>
  930. .HomeItem {
  931. height: 100vh;
  932. .login {
  933. height: 420rpx;
  934. padding: 0 32rpx;
  935. padding-top: 164rpx;
  936. position: relative;
  937. z-index: 999;
  938. .login_input {
  939. margin-top: 32rpx;
  940. background-color: #ffffff;
  941. height: 72rpx;
  942. box-sizing: border-box;
  943. padding: 16rpx;
  944. }
  945. .title {
  946. font-size: 36rpx;
  947. color: #42b983;
  948. text-align: center;
  949. }
  950. .tips {
  951. font-size: 28rpx;
  952. color: #68686b;
  953. margin-top: 16rpx;
  954. }
  955. .page_item_btn {
  956. height: 88rpx;
  957. background-image: linear-gradient(to right, #72c172, #3bb197);
  958. border-radius: 8rpx;
  959. line-height: 88rpx;
  960. color: #fff;
  961. font-size: 36rpx;
  962. font-weight: 700;
  963. margin-top: 64rpx;
  964. text-align: center;
  965. }
  966. }
  967. //上班页面
  968. .goWorkAll {
  969. height: 100%;
  970. display: flex;
  971. flex-direction: column;
  972. justify-content: space-between;
  973. /deep/ .uni-radio-input-checked {
  974. background-color: #42b983 !important;
  975. border-color: #42b983 !important;
  976. }
  977. .goWorkSelect {
  978. &.history {
  979. height: 356rpx;
  980. padding-bottom: 16rpx;
  981. }
  982. &.combination {
  983. .goWorkSelect-head {
  984. position: fixed;
  985. top: 0;
  986. left: 0;
  987. width: 100%;
  988. }
  989. .goWorkSelect-list {
  990. margin-top: 82rpx;
  991. }
  992. }
  993. .goWorkSelect-head {
  994. font-size: 36rpx;
  995. padding: 16rpx 0;
  996. color: #42b983;
  997. border-bottom: 2rpx solid #42b983;
  998. text-align: center;
  999. }
  1000. .goWorkSelect-list {
  1001. &.scroll {
  1002. height: calc(100vh - 356rpx - 82rpx);
  1003. }
  1004. .goWorkSelect-item {
  1005. height: 52rpx;
  1006. display: flex;
  1007. align-items: center;
  1008. border-bottom: 2rpx solid #e5e9ed;
  1009. padding: 16rpx;
  1010. button {
  1011. font-size: 32rpx;
  1012. height: 52rpx;
  1013. line-height: 52rpx;
  1014. margin: 0;
  1015. margin-left: 16rpx;
  1016. color: rgb(7, 134, 60);
  1017. font-weight: 700;
  1018. }
  1019. }
  1020. }
  1021. }
  1022. }
  1023. .goWork {
  1024. margin: 0 auto 48rpx;
  1025. width: 240rpx;
  1026. height: 240rpx;
  1027. .goWork_btn_E {
  1028. width: 100%;
  1029. height: 100%;
  1030. background: #bee1a7;
  1031. border-radius: 30%;
  1032. .goWork_btn_W {
  1033. width: 75%;
  1034. height: 75%;
  1035. background-image: linear-gradient(to right, #72c172, #3bb197);
  1036. border-radius: 30%;
  1037. margin: 0 auto;
  1038. position: relative;
  1039. top: 12.5%;
  1040. line-height: 180rpx;
  1041. color: #fff;
  1042. font-size: 36rpx;
  1043. text-align: center;
  1044. }
  1045. }
  1046. }
  1047. .goWork_text {
  1048. width: 100%;
  1049. view {
  1050. text-align: center;
  1051. }
  1052. .goWork_text-p {
  1053. font-size: 36rpx;
  1054. margin-bottom: 48rpx;
  1055. }
  1056. }
  1057. .botImg {
  1058. height: 600rpx;
  1059. width: 100%;
  1060. position: fixed;
  1061. bottom: 0;
  1062. .img {
  1063. height: 100%;
  1064. background: url("../../static/img/BG.png") no-repeat center center;
  1065. background-size: 100% 100%;
  1066. }
  1067. }
  1068. }
  1069. </style>