login.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. <template>
  2. <view class="">
  3. <view class="top">
  4. </view>
  5. <view class="content" style="height: 85vh;">
  6. <scroll-view style="border-radius: 20rpx;padding-left: 20rpx;" scroll-x class="bg-white nav"
  7. scroll-with-animation :scroll-left="scrollLeft">
  8. <view class="cu-item text-lg" :class="index==current?'text-checked text-bold cur':''"
  9. v-for="(item,index) in list" :key="index" @tap="tabSelect(index)">
  10. {{item.name}}
  11. </view>
  12. </scroll-view>
  13. <view class="item">
  14. <swiper :circular="true" style="height: 100%;" :current="current" @change="swiperChange"
  15. @animationfinish="animationfinish">
  16. <swiper-item style="height: 100%;">
  17. <view class="flex justify-center flex-direction align-center">
  18. <image style="width: 120rpx;height: 120rpx;" src="../../static/login/yuangong.png"></image>
  19. </view>
  20. <view class="input">
  21. <text class="cuIcon-discoverfill text-base"
  22. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  23. <input disabled v-model="agencyName" @click="agencyShow = true" placeholder="请选择您所在的园区"
  24. type="text" value="" />
  25. </view>
  26. <view class="input">
  27. <text class="cuIcon-mobilefill text-base text-bold"
  28. style="font-size: 38rpx;margin-right: 22rpx;"></text>
  29. <input v-model="phone" placeholder="请输入您的手机号码" type="text" value="" />
  30. </view>
  31. <view class="input" style="position: relative;">
  32. <text class="cuIcon-safe text-base text-bold"
  33. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  34. <input v-model="yzm" style="width: 60%;" placeholder="请输入验证码" type="text" value="" />
  35. <view :style="showText?'':'background-color: #A7A7A7;'" class="code" @click="getCode()">
  36. {{tips}}
  37. </view>
  38. </view>
  39. </swiper-item>
  40. <swiper-item>
  41. <view class="flex justify-center flex-direction align-center">
  42. <image style="width: 90rpx;height: 90rpx;" src="../../static/login/qiye.png"></image>
  43. </view>
  44. <view class="input">
  45. <text class="cuIcon-discoverfill text-base"
  46. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  47. <input disabled v-model="agencyName" @click="agencyShow = true" placeholder="请选择您所在的园区"
  48. type="text" value="" />
  49. </view>
  50. <view class="input">
  51. <text class="cuIcon-homefill text-base"
  52. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  53. <input disabled v-model="enterpriseName" @click="enterpriseShow = true"
  54. placeholder="请选择您所在的企业" type="text" value="" />
  55. </view>
  56. <view class="input">
  57. <image src="../../static/login/account.png"
  58. style="width: 32rpx;height: 34rpx;margin-right: 22rpx;"></image>
  59. <input v-model="enterpriseAccount" style="width: 60%;" placeholder="请输入您的登录账号" type="text"
  60. value="" />
  61. </view>
  62. <view class="input">
  63. <image src="../../static/login/password.png"
  64. style="width: 32rpx;height: 34rpx;margin-right: 22rpx;"></image>
  65. <input v-model="enterprisePassword" style="width: 60%;" placeholder="请输入您的登录密码"
  66. type="password" value="" />
  67. </view>
  68. </swiper-item>
  69. <swiper-item>
  70. <view class="flex justify-center ">
  71. <image style="width: 120rpx;height: 120rpx;" src="../../static/login/guanliyuan.png">
  72. </image>
  73. </view>
  74. <view class="input">
  75. <text class="cuIcon-discoverfill text-base"
  76. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  77. <input disabled v-model="agencyName" @click="agencyShow = true" placeholder="请选择您所在的园区"
  78. type="text" value="" />
  79. </view>
  80. <view class="input">
  81. <image src="../../static/login/account.png" mode=""
  82. style="width: 32rpx;height: 34rpx;margin-right: 22rpx;"></image>
  83. <input v-model="agencyAccount" style="width: 60%;" placeholder="请输入您的登录账号" type="text"
  84. value="" />
  85. </view>
  86. <view class="input">
  87. <image src="../../static/login/password.png"
  88. style="width: 32rpx;height: 34rpx;margin-right: 22rpx;"></image>
  89. <input type="password" v-model="agencyPassword" style="width: 60%;" placeholder="请输入您的登录密码"
  90. value="" />
  91. </view>
  92. </swiper-item>
  93. <swiper-item>
  94. <view class="flex justify-center flex-direction align-center">
  95. <image style="width: 100rpx;height: 100rpx;" src="../../static/login/fangke.png"></image>
  96. </view>
  97. <view class="input">
  98. <text class="cuIcon-timefill text-base"
  99. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  100. <input disabled v-model="interviewTime" @click="interviewTimeShow = true"
  101. placeholder="请选择您要访问的日期" type="text" value="" />
  102. </view>
  103. <view class="input">
  104. <text class="cuIcon-discoverfill text-base"
  105. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  106. <input disabled v-model="agencyName" @click="agencyShow = true" placeholder="请选择您要访问的园区"
  107. type="text" value="" />
  108. </view>
  109. <view class="input">
  110. <text class="cuIcon-homefill text-base"
  111. style="font-size: 34rpx;margin-right: 22rpx;"></text>
  112. <input disabled v-model="enterpriseName" @click="enterpriseShow = true"
  113. placeholder="请选择您要访问的企业 (选填)" type="text" value="" />
  114. </view>
  115. <view class="text-center base-color padding-top-50 text-lg">
  116. <text @click="jump('/pages/guest/records/records')"
  117. style="text-decoration: underline;">申请记录</text>
  118. </view>
  119. </swiper-item>
  120. </swiper>
  121. </view>
  122. <button v-if="current!=3" class="button" @click="login()">登 录</button>
  123. <button v-else class="button" @click="applyOpenDoor">申请开门</button>
  124. </view>
  125. <!-- 园区 -->
  126. <u-popup border-radius="8" height="60%" mode="bottom" v-model="agencyShow">
  127. <view class="fixed cu-bar search bg-white">
  128. <view class="search-form round">
  129. <text class="cuIcon-search"></text>
  130. <u-input style="width: 90%;" v-model="agencyKeyWord" type="text" :adjust-position="false"
  131. placeholder="请输入关键字搜索" confirm-type="search" />
  132. </view>
  133. </view>
  134. <scroll-view v-if="!$isEmpty(agencyList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true">
  135. <view @click="selectAgency(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom"
  136. v-for="(item,index) in agencyList" :key="index">
  137. <text>{{item.name}}</text>
  138. </view>
  139. <u-divider v-if="agencyList.length>=20" height="80">只显示20条数据</u-divider>
  140. </scroll-view>
  141. <u-empty v-else name="search"></u-empty>
  142. </u-popup>
  143. <!-- 企业列表 -->
  144. <u-popup border-radius="8" height="60%" mode="bottom" v-model="enterpriseShow">
  145. <view class="fixed cu-bar search bg-white">
  146. <view class="search-form round">
  147. <text class="cuIcon-search"></text>
  148. <u-input style="width: 90%;" v-model="enterpriseKeyword" type="text" :adjust-position="false"
  149. placeholder="请输入关键字搜索" confirm-type="search" />
  150. </view>
  151. </view>
  152. <scroll-view v-if="!$isEmpty(enterpriseList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true">
  153. <view @click="selectEnterprise(item)" hover-class="hoverClass"
  154. class="text-center padding-30 solid-bottom" v-for="(item,index) in enterpriseList" :key="index">
  155. <text>{{item.enterpriseName}}</text>
  156. </view>
  157. <u-divider v-if="enterpriseList.length>=20" height="80">只显示20条数据</u-divider>
  158. </scroll-view>
  159. <u-empty v-else name="search"></u-empty>
  160. </u-popup>
  161. <!-- 访问时间 -->
  162. <u-picker @confirm="interviewTimeConfirm" :params="params" v-model="interviewTimeShow" mode="time"></u-picker>
  163. <!-- 验证码 -->
  164. <u-verification-code seconds="60" @end="end" @start="start" ref="uCode" @change="codeChange">
  165. </u-verification-code>
  166. </view>
  167. </template>
  168. <script>
  169. var that;
  170. export default {
  171. name: 'card',
  172. data() {
  173. return {
  174. backpath: '',
  175. contentHeight: '',
  176. list: [{
  177. name: '员工'
  178. }, {
  179. name: '企业'
  180. }, {
  181. name: '管理员',
  182. }, {
  183. name: '访客',
  184. }],
  185. current: 0,
  186. //发送验证码
  187. tips: '',
  188. showText: true,
  189. //园区下拉框
  190. agencyName: '',
  191. agencyList: [],
  192. agencyKeyWord: '',
  193. agencyShow: false,
  194. //园区登录
  195. agencyId: '',
  196. agencyAccount: '',
  197. agencyPassword: '',
  198. //企业下拉框
  199. enterpriseName: '', //回显
  200. enterpriseShow: false,
  201. enterpriseList: [],
  202. enterpriseKeyword: '',
  203. //企业登录
  204. creditCode: '',
  205. enterpriseId: '',
  206. enterpriseAccount: '',
  207. enterprisePassword: '',
  208. openId: '',
  209. //员工登录
  210. phone: '',
  211. yzm: '',
  212. //访客
  213. interviewTimeShow: false,
  214. interviewTime: '',
  215. params: {
  216. year: true,
  217. month: true,
  218. day: true,
  219. hour: false,
  220. minute: false,
  221. second: false
  222. },
  223. };
  224. },
  225. onLoad(options) {
  226. this.contentHeight = this.$u.sys().windowHeight + 'px'
  227. that = this
  228. if (!this.$isEmpty(options.backpath)) {
  229. this.backpath = options.backpath
  230. }
  231. if (this.$isAuth()) {
  232. uni.reLaunch({
  233. url: '/pages/index/index'
  234. })
  235. //免登录
  236. return
  237. }
  238. if (this.$isEmpty(this.$cache.get('openId'))) {
  239. this.getOpenId()
  240. } else {
  241. this.openId = this.$cache.get('openId')
  242. }
  243. this.getAgencyList()
  244. },
  245. onShow() {
  246. this.handelNoToken()
  247. this.getAppletStatus()
  248. },
  249. watch: {
  250. agencyKeyWord() {
  251. let that = this
  252. //节流函数
  253. if (this.timer) {
  254. clearTimeout(this.timer)
  255. }
  256. this.timer = setTimeout(() => {
  257. that.agencyList = []
  258. that.getAgencyList()
  259. }, 500)
  260. },
  261. enterpriseKeyword() {
  262. let that = this
  263. //节流函数
  264. if (this.timer) {
  265. clearTimeout(this.timer)
  266. }
  267. this.timer = setTimeout(() => {
  268. that.enterpriseList = []
  269. that.getEnterpriseList()
  270. }, 500)
  271. },
  272. },
  273. methods: {
  274. //处理没token但是却选择了园区的情况
  275. //访客从申请列表返回登录页时,是没有token的,这样导致其他接口报错
  276. async handelNoToken() {
  277. let that = this
  278. if (!this.$cache.get('tokenObj') && !this.$isEmpty(this.agencyId)) {
  279. //如果没有token,且园区id不为空
  280. this.agencyList.forEach(item => {
  281. if (item.id == that.agencyId) {
  282. let params = {
  283. tenant_id: item.tenantId,
  284. username: item.account,
  285. password: item.password,
  286. grant_type: "password"
  287. }
  288. //放进缓存中,并获取token
  289. that.$cache.put('tokenObj', params)
  290. //获取token
  291. that.$api.getToken(that.$u.queryParams(params)).then(res => {
  292. let token = res.token_type + " " + res.access_token
  293. uni.setStorageSync('token', token)
  294. //获取企业列表
  295. that.getEnterpriseList()
  296. })
  297. }
  298. })
  299. }
  300. },
  301. //访问时间
  302. interviewTimeConfirm(e) {
  303. this.interviewTime = e.year + '-' + e.month + '-' + e.day
  304. },
  305. /**
  306. * 获取openid
  307. */
  308. getOpenId() {
  309. uni.login({
  310. success: (res) => {
  311. let data = {
  312. appId: this.$api.wxData.appId,
  313. jsCode: res.code,
  314. secret: this.$api.wxData.secret
  315. }
  316. this.$api.wxApi.getOpenId(data).then(res => {
  317. let resData = JSON.parse(res.data)
  318. this.openId = resData.openid
  319. this.$cache.put('openId', this.openId)
  320. })
  321. }
  322. })
  323. },
  324. //获取园区列表
  325. getAgencyList() {
  326. let params = {
  327. size: 20,
  328. name: this.agencyKeyWord
  329. }
  330. this.$api.agency.getAgencyTenantList(params).then(res => {
  331. this.agencyList = res.data
  332. })
  333. },
  334. //选择园区
  335. selectAgency(item) {
  336. console.log(item, "/**********");
  337. let params = {
  338. tenant_id: item.tenantId,
  339. username: item.account,
  340. password: item.password,
  341. grant_type: "password",
  342. scope: "all",
  343. type: "account"
  344. }
  345. this.agencyId = item.id
  346. this.agencyName = item.name
  347. this.agencyShow = false
  348. this.$cache.put('tokenObj', params)
  349. //获取token
  350. this.$api.getToken(this.$u.queryParams(params)).then(res => {
  351. let token = res.token_type + " " + res.access_token
  352. uni.setStorageSync('token', token)
  353. //获取企业列表
  354. this.getEnterpriseList()
  355. })
  356. },
  357. /**
  358. * 获取验证码
  359. */
  360. async getCode() {
  361. let that = this
  362. if (this.$isEmpty(this.phone)) {
  363. this.$u.toast("请输入手机号")
  364. return
  365. }
  366. if (!this.$u.test.mobile(this.phone)) {
  367. this.$u.toast("请输入正确的手机号")
  368. return
  369. }
  370. if (this.$refs.uCode.canGetCode) {
  371. // 模拟向后端请求验证码
  372. uni.showLoading({
  373. title: '正在获取验证码'
  374. })
  375. setTimeout(async () => {
  376. uni.hideLoading();
  377. let params = `?phone=${this.phone}`
  378. this.$api.SMSApi.sendSms(params).then(res => {
  379. if (res.data == '获取验证码成功') {
  380. that.$u.toast('验证码已发送');
  381. // 通知验证码组件内部开始倒计时
  382. that.$refs.uCode.start();
  383. } else {
  384. that.$refs.uTips.show({
  385. title: res.data,
  386. type: 'primary',
  387. duration: '3000'
  388. })
  389. }
  390. // 通知验证码组件内部开始倒计时
  391. that.$refs.uCode.start();
  392. }).catch(err => {
  393. that.$u.toast('获取验证码失败');
  394. })
  395. }, 800);
  396. } else {
  397. this.$u.toast('倒计时结束后再发送');
  398. }
  399. },
  400. codeChange(text) {
  401. this.tips = text;
  402. },
  403. end() {
  404. this.showText = true
  405. },
  406. start() {
  407. this.showText = false
  408. },
  409. //当前登录按钮操作
  410. async login() {
  411. if (this.current == 0) {
  412. //员工登录
  413. this.staffLogin()
  414. } else if (this.current == 1) {
  415. //企业登录
  416. this.enterpriseLogin()
  417. } else if (this.current == 2) {
  418. //管理员登陆
  419. this.ganderLogin()
  420. }
  421. },
  422. //员工登录
  423. async staffLogin() {
  424. //15622205184
  425. if (this.phone == '15622205184') {
  426. this.userLogin()
  427. return
  428. }
  429. if (this.$isEmpty(this.agencyId)) {
  430. this.$u.toast('请选择您所在的园区')
  431. return
  432. }
  433. if (!this.phone) {
  434. uni.showToast({
  435. title: '请输入手机号',
  436. icon: 'none'
  437. });
  438. return;
  439. }
  440. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) {
  441. uni.showToast({
  442. title: '请输入正确手机号',
  443. icon: 'none'
  444. });
  445. return;
  446. }
  447. if (!this.yzm) {
  448. uni.showToast({
  449. title: '请输入验证码',
  450. icon: 'none'
  451. });
  452. return;
  453. }
  454. if (this.yzm.length != 6) {
  455. this.$u.toast('请输入6位数的验证码')
  456. return
  457. }
  458. let params = {
  459. phone: this.phone,
  460. code: this.yzm
  461. }
  462. let smsRes = await this.$api.SMSApi.validCode(this.$u.queryParams(params))
  463. if (smsRes.data != 'success') {
  464. this.$u.toast(smsRes.data)
  465. return
  466. }
  467. this.userLogin()
  468. },
  469. //用户登陆
  470. async userLogin() {
  471. //通过手机号查找该员工信息
  472. let params = {
  473. openId: this.openId,
  474. loginType: 0,
  475. phone: this.phone
  476. }
  477. let staffRes = await this.$api.login(params)
  478. let userInfo = staffRes.data
  479. if (this.$isEmpty(userInfo)) {
  480. //如果没有员工信息。新用户。跳转到注册认证界面
  481. uni.navigateTo({
  482. url: '/pages/auth/auth?phone=' + this.phone
  483. })
  484. } else {
  485. if (userInfo.auditStatus == 0) {
  486. //有员工信息,但审核未通过,提示等待审核
  487. this.$showModel('您的认证信息尚未审核,请联系企业负责人审核', false)
  488. } else if (userInfo.auditStatus == 1) {
  489. //后台导入的员工信息没有openid,需要在小程序重新插入
  490. if (this.$isEmpty(userInfo.openId) && !this.$isEmpty(this.openId)) {
  491. userInfo.openId = this.openId
  492. this.$api.enterprisestaff.submit(userInfo)
  493. }
  494. this.$cache.put('agencyId', userInfo.agencyId)
  495. this.$cache.put('agencyTenantId', userInfo.tenantId)
  496. getApp().globalData.userInfo = userInfo
  497. //存储手机号,便于拉取用户信息
  498. this.$cache.put('phone', userInfo.phone)
  499. this.$cache.put('userId', userInfo.id)
  500. this.$cache.put('loginuser', userInfo)
  501. this.$cache.put('enterpriseId', userInfo.enterpriseId)
  502. this.handelSuccessLogin('staff')
  503. } else if (userInfo.auditStatus == 2) {
  504. //审核不通过
  505. this.$showModel('您的认证信息审核不通过,是否重新认证!').then(res => {
  506. uni.navigateTo({
  507. url: "/pages/auth/auth?operationType=1&phone=" + that.phone
  508. })
  509. })
  510. }
  511. }
  512. },
  513. //获取企业列表
  514. getEnterpriseList() {
  515. let params = {
  516. size: 20,
  517. enterpriseName: this.enterpriseKeyword
  518. }
  519. this.$api.enterprise.page(params).then(res => {
  520. this.enterpriseList = res.data.records
  521. })
  522. },
  523. //选择企业
  524. selectEnterprise(item) {
  525. this.creditCode = item.creditCode
  526. this.enterpriseShow = false
  527. this.enterpriseName = item.enterpriseName
  528. this.enterpriseId = item.id
  529. },
  530. /**
  531. * 企业登录
  532. */
  533. async enterpriseLogin() {
  534. if (this.$isEmpty(this.agencyId)) {
  535. this.$u.toast('请选择园区')
  536. return
  537. }
  538. if (this.$isEmpty(this.enterpriseId)) {
  539. this.$u.toast('请选择企业')
  540. return
  541. }
  542. if (this.$isEmpty(this.enterpriseAccount)) {
  543. this.$u.toast("请输入账号")
  544. return
  545. }
  546. if (this.$isEmpty(this.enterprisePassword)) {
  547. this.$u.toast("请输入密码")
  548. return
  549. }
  550. let params = {
  551. "loginType": 1,
  552. "enterpriseId": this.enterpriseId,
  553. "enterpriseAccount": this.enterpriseAccount,
  554. "enterprisePassword": this.enterprisePassword,
  555. "openId": this.openId
  556. }
  557. this.$api.login(params).then(res => {
  558. if (this.$isEmpty(res.data)) {
  559. this.$u.toast('账号或密码错误')
  560. return
  561. } else {
  562. //公司信息
  563. let userInfo = res.data
  564. this.$cache.put('agencyId', userInfo.agencyId)
  565. getApp().globalData.userInfo = userInfo
  566. this.$cache.put('loginuser', userInfo)
  567. this.$cache.put('loginAccount', this.enterpriseAccount)
  568. this.$cache.put('agencyTenantId', userInfo.tenantId)
  569. this.$cache.put('creditCode', this.creditCode)
  570. this.$cache.put('enterpriseId', userInfo.enterpriseId)
  571. this.handelSuccessLogin('enterprise')
  572. }
  573. })
  574. },
  575. /**
  576. * 管理员登陆
  577. */
  578. async ganderLogin() {
  579. if (this.$isEmpty(this.agencyId)) {
  580. this.$u.toast('请选择您所在的园区')
  581. return
  582. }
  583. if (this.$isEmpty(this.agencyAccount)) {
  584. this.$u.toast('请输入账号')
  585. return
  586. }
  587. if (this.$isEmpty(this.agencyPassword)) {
  588. this.$u.toast('请输入密码')
  589. return
  590. }
  591. let params = {
  592. "loginType": 2,
  593. "agencyId": this.agencyId,
  594. "agencyAccount": this.agencyAccount,
  595. "agencyPassword": this.agencyPassword,
  596. "openId": this.openId
  597. }
  598. let res = await this.$api.login(params)
  599. let ganderInfo = res.data
  600. if (this.$isEmpty(ganderInfo)) {
  601. this.$u.toast('账号或密码错误')
  602. return
  603. }
  604. //订阅消息通知 -- 登录不了,暂时去掉,
  605. // await this.$mpi.subscribe(this.$adminTmplIds)
  606. //输入密码成功
  607. //园区信息
  608. this.$cache.put('loginuser', ganderInfo)
  609. this.$cache.put('loginAccount', this.agencyAccount)
  610. this.$cache.put('agencyId', ganderInfo.agencyId)
  611. this.$cache.put('agency', ganderInfo.agencyName)
  612. this.$cache.put('agencyTenantId', ganderInfo.tenantId)
  613. getApp().globalData.userInfo = ganderInfo
  614. this.handelSuccessLogin('agency')
  615. },
  616. /**
  617. * 登录成功的处理方式
  618. * 如果是从其他地方跳转回的登录页,则登录后跳转回原页面
  619. * 否则跳转到首页
  620. */
  621. handelSuccessLogin(loginType) {
  622. that.$cache.put("loginType", loginType)
  623. if (!this.$isEmpty(this.backpath)) {
  624. uni.navigateTo({
  625. url: this.backpath
  626. })
  627. return
  628. }
  629. uni.switchTab({
  630. url: "/pages/index/index"
  631. })
  632. },
  633. async applyOpenDoor() {
  634. if (this.$isEmpty(this.interviewTime)) {
  635. this.$u.toast('请选择访问日期')
  636. return
  637. }
  638. if (this.$isEmpty(this.agencyId)) {
  639. this.$u.toast('请选择要访问的园区')
  640. return
  641. }
  642. let params = {
  643. interviewTime: this.interviewTime,
  644. agencyId: this.agencyId,
  645. openId: this.openId
  646. }
  647. let res = await this.$api.guest.page(params)
  648. let data = res.data.records[0]
  649. if (this.$isEmpty(data)) {
  650. that.reApply(params)
  651. return
  652. }
  653. uni.showModal({
  654. content: "检测到您有该园区的申请记录,是否立即去开门?",
  655. cancelText: "重新申请",
  656. confirmText: '去开门',
  657. success: (res) => {
  658. if (res.confirm) {
  659. console.log("去开门")
  660. } else {
  661. that.reApply(params)
  662. }
  663. }
  664. })
  665. },
  666. reApply(params) {
  667. params.enterpriseId = this.enterpriseId,
  668. params.agencyName = this.agencyName
  669. params.enterpriseName = this.enterpriseName
  670. uni.navigateTo({
  671. url: "/pages/guest/guest" + this.$u.queryParams(params)
  672. })
  673. },
  674. jump(url) {
  675. if (!this.$isEmpty(url)) {
  676. uni.navigateTo({
  677. url
  678. })
  679. }
  680. },
  681. isToday(str) {
  682. var d = new Date(str.replace(/-/g, "/"));
  683. var todaysDate = new Date();
  684. if (d.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) {
  685. return true;
  686. } else {
  687. return false;
  688. }
  689. },
  690. getAppletStatus() {
  691. this.$api.wxApi.getAppletStatus({
  692. id: 2
  693. }).then(res => {
  694. uni.setStorageSync("appletStatus", res.data.appletType)
  695. })
  696. },
  697. tabSelect(index) {
  698. this.current = index
  699. },
  700. swiperChange(e) {
  701. this.current = e.detail.current
  702. },
  703. animationfinish({
  704. detail: {
  705. current
  706. }
  707. }) {
  708. this.current = current;
  709. },
  710. }
  711. };
  712. </script>
  713. <style lang="scss">
  714. page {
  715. background-color: #FFFFFF;
  716. height: 100%;
  717. }
  718. .text-checked {
  719. font-size: 36rpx;
  720. // color: #333;
  721. color: $base-color;
  722. }
  723. .button {
  724. position: fixed;
  725. bottom: 5%;
  726. left: 0;
  727. right: 0;
  728. font-size: 28rpx;
  729. background: $base-color;
  730. color: #fff;
  731. height: 90rpx;
  732. margin: 0rpx 30rpx;
  733. line-height: 90rpx;
  734. border-radius: 50rpx;
  735. box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
  736. }
  737. .guest {
  738. font-size: 28rpx;
  739. color: #fff;
  740. background: $base-color;
  741. height: 90rpx;
  742. margin: 120rpx 30rpx;
  743. line-height: 90rpx;
  744. border-radius: 50rpx;
  745. box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
  746. }
  747. .top {
  748. height: 220rpx;
  749. background-color: #5064eb;
  750. }
  751. .content {
  752. border-radius: 20rpx;
  753. background-color: #FFFFFF;
  754. margin: -120rpx 20rpx 0;
  755. .item {
  756. height: 100%;
  757. padding-top: 15%;
  758. .input {
  759. margin: 40rpx 30rpx;
  760. border-radius: 50rpx;
  761. background-color: rgba(80, 100, 235, .1);
  762. display: flex;
  763. padding: 20rpx 30rpx;
  764. image {
  765. width: 32rpx;
  766. height: 34rpx;
  767. margin-right: 22rpx;
  768. margin-top: 4rpx;
  769. }
  770. .phone {
  771. width: 40rpx;
  772. height: 40rpx;
  773. margin-top: 4rpx;
  774. margin-right: 22rpx;
  775. }
  776. .qiye {
  777. width: 38rpx;
  778. height: 38rpx;
  779. margin-top: 4rpx;
  780. margin-right: 22rpx;
  781. }
  782. input {
  783. width: 100%;
  784. height: 100%;
  785. }
  786. .code {
  787. position: absolute;
  788. right: 22rpx;
  789. top: 18rpx;
  790. background: $base-color;
  791. color: #fff;
  792. font-size: 24rpx;
  793. border-radius: 50rpx;
  794. height: 50rpx;
  795. line-height: 50rpx;
  796. padding: 0 25rpx;
  797. z-index: 1000;
  798. }
  799. }
  800. }
  801. }
  802. </style>