You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

609 lines
14 KiB

2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="logoStyle">
  3. <div class="status_bar"></div>
  4. <div class="top-info">
  5. <img src="../../assets/images/denglu-fanhui@2x.png" class="fanhui" @click="toBack"/>
  6. <!-- <div class="zctit">注册 </div> -->
  7. <div class="registered" >
  8. <div style="color: #999999" class="tozhuce">已有账号 </div>
  9. <div style="color: #188cfb" class="tozhuce" @click="tologin"> 去登录 </div>
  10. </div>
  11. </div>
  12. <div class="title">
  13. 绑定手机号
  14. </div>
  15. <!-- 读者证信息-->
  16. <div class="input-form organization-info">
  17. <div class="pohpas">
  18. <div class="uni-form-item uni-column" @click="clickSelectOrganization" >
  19. <div class="uni-input loginInput tushuguan" v-bind:class="{ 'gray': data.hasSid}" >
  20. {{data.selectName}}
  21. </div>
  22. <div class="arrow" v-show="!data.hasSid">
  23. <div class="icon iconfont" style="color:#999999;font-weight: 600;">&#xe65a;</div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <!-- 手机号信息-->
  29. <div class="input-form">
  30. <div class="pohpas">
  31. <div class="uni-form-item uni-column">
  32. <input v-model="data.certificateNo" class="loginInput yzm" placeholder-style="color:#999999;font-size:0.30rem" placeholder="手机号" />
  33. </div>
  34. <div class="verificationCode">
  35. <div class="loginInput yzm" >
  36. <input style="font-size: 0.3rem;height: 0.70rem;" v-model="data.verificationCode" placeholder-style="color:#999999;font-size:0.30rem" placeholder="验证码" />
  37. <div :class="['verificationBtn',{'color':data.agreeVal}]" @click="verificationPhone" >
  38. {{data.verification}}
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="protocol uni-column">
  44. <div @click="data.agreeVals=!data.agreeVals" style="display: flex;" >
  45. <div class="kon" v-if="!data.agreeVals"></div>
  46. <img src="../../assets/images/denglu-yiyuedu@2x.png" class="dui" v-if="data.agreeVals"/>
  47. <div>我已阅读并同意AI阅行用户服务协议</div>
  48. </div>
  49. </div>
  50. <div class="RegisteredBtn uni-column">
  51. <button type="primary" @click="nextStep" v-show="data.shoru">注册</button>
  52. <div v-show="!data.shoru" class="bu2">注册</div>
  53. </div>
  54. </div>
  55. <!-- 图片滑动校验码 -->
  56. <div class="imgVerificationCode" v-show="data.showVerificationDialog">
  57. <slide-verify ref="slideblock" @success="imgVerificationSuccess" @again="onAgain" @fulfilled="onFulfilled" @fail="imgVerificationfail" @refresh="onRefresh" :slider-text="text" :imgs="data.verificationImgs" :accuracy="data.verificationAccuracy"></slide-verify>
  58. </div>
  59. <!-- 遮罩层 -->
  60. <div class="dialog-mask" v-show="data.showVerificationDialog" @click="data.showVerificationDialog = false"></div>
  61. <!-- 选择读者证 -->
  62. <van-popup v-model:show="data.showSelectOrganization" position="bottom">
  63. <van-picker
  64. title=""
  65. show-toolbar
  66. :columns="data.array"
  67. @change="bindPickerChange"
  68. @confirm="onConfirmPicker"
  69. @cancel="onCancelPicker"
  70. />
  71. </van-popup>
  72. </div>
  73. </template>
  74. <script>
  75. import { Toast } from 'vant';
  76. import { reactive,computed,onMounted,getCurrentInstance,watch,toRefs } from 'vue';
  77. import slideVerify from "@/components/verify/slide-verify.vue";
  78. import { selectLbrary } from "@/common/selectLbrary.js";
  79. import img0 from '../../assets/images/img0.jpg';
  80. import img1 from '../../assets/images/img1.jpg';
  81. import img2 from '../../assets/images/img2.jpg';
  82. import img3 from '../../assets/images/img3.jpg';
  83. import img4 from '../../assets/images/img4.jpg';
  84. import img5 from '../../assets/images/img5.jpg';
  85. export default {
  86. components: {
  87. slideVerify
  88. },
  89. setup() {
  90. const { lbraryArrayData } = selectLbrary()
  91. const { proxy } = getCurrentInstance()
  92. const data = reactive({
  93. hasSid: false,
  94. array: [],
  95. showSelectOrganization: false,
  96. selectName:'请选择图书馆',
  97. selectId:0,
  98. verificationImgs: [
  99. img0,
  100. img1,
  101. img2,
  102. img3,
  103. img4,
  104. img5,
  105. ],
  106. verificationAccuracy: 1, // 精确度小,可允许的误差范围小;为1时,则表示滑块要与凹槽完全重叠,才能验证成功。默认值为5
  107. showVerificationDialog: false,
  108. agreeVals: false,
  109. certificateNo: "",
  110. verification: "获取验证码",
  111. verificationCode: "",
  112. agreeVal: false,
  113. num: 60,
  114. ClntId: "",
  115. sid: "",
  116. shoru:false,
  117. weChatUserInfo: {}
  118. })
  119. onMounted(() => {
  120. let option = proxy.$route.query;
  121. data.ClntId = option.ClntId;
  122. data.array = lbraryArrayData.lbraryArray
  123. /* 如果携带sid 则显示该机构, 未携带sid 则选择机构 */
  124. if (localStorage.getItem('aiyxSid')) {
  125. data.sid = localStorage.getItem('aiyxSid')
  126. data.hasSid = true;
  127. proxy.getClntBySid();
  128. } else {
  129. data.hasSid = false;
  130. }
  131. })
  132. /* 监听获取机构信息 */
  133. watch(() => lbraryArrayData.lbraryArray, (newValue,oldVlaue) => {
  134. data.array = newValue
  135. })
  136. watch(() => data.certificateNo, (newValue,oldVlaue) => {
  137. data.certificateNo = newValue;
  138. data.certificateNo && data.verificationCode ? data.shoru=true : data.shoru=false;
  139. })
  140. watch(() => data.verificationCode, (newValue,oldVlaue) => {
  141. data.verificationCode = newValue;
  142. data.certificateNo && data.verificationCode ? data.shoru=true : data.shoru=false;
  143. })
  144. /* 取消选择机构 */
  145. let onCancelPicker = () => {
  146. data.showSelectOrganization = false
  147. }
  148. /* 确定选择机构 */
  149. let onConfirmPicker = () => {
  150. data.showSelectOrganization = false
  151. }
  152. /*根据sid获得机构信息 */
  153. let getClntBySid = () => {
  154. let param = {
  155. tSid: data.sid
  156. }
  157. proxy.$http
  158. .get(proxy.$API.GETCLNTBYSID,
  159. {
  160. params: param
  161. }
  162. )
  163. .then(res => {
  164. if (res.type == 200) {
  165. if (res.data) {
  166. let resData = res.data;
  167. data.ClntId = resData.id;
  168. data.selectName = resData.name;
  169. }
  170. } else {
  171. data.hasSid = false;
  172. console.log(res.content)
  173. }
  174. })
  175. .catch(res => {
  176. data.hasSid = false;
  177. console.log(res)
  178. })
  179. }
  180. /* 点击弹出机构信息 */
  181. let clickSelectOrganization = () => {
  182. if (data.hasSid) {
  183. return;
  184. }
  185. data.showSelectOrganization = true
  186. }
  187. //图片滑动验证失败
  188. let imgVerificationfail = () => {
  189. Toast('验证失败, 请重试!')
  190. }
  191. //图片滑动验证成功
  192. let imgVerificationSuccess = () => {
  193. proxy.toRegistered();
  194. }
  195. /* 滑动选择机构 */
  196. let bindPickerChange = (value, index) => {
  197. data.ClntId = data.array[index].id;
  198. data.selectName = data.array[index].text
  199. }
  200. // 下一步
  201. let nextStep = () => {
  202. if (!data.ClntId) {
  203. Toast('请选择机构')
  204. return;
  205. }
  206. if (!data.agreeVals) {
  207. Toast('请阅读服务协议')
  208. return;
  209. }
  210. data.showVerificationDialog = true;
  211. }
  212. //验证手机号
  213. let verificationPhone = () => {
  214. const that = data;
  215. let PhoenTest = /^1[3,4,5,6,7,8,9]\d{9}$/;
  216. if (PhoenTest.test(that.certificateNo) == false) {
  217. Toast('手机号为空或手机格式不正确')
  218. } else {
  219. proxy.GetAuthCode();
  220. }
  221. }
  222. //获取验证码
  223. let GetAuthCode = () => {
  224. if (!data.agreeVal == true) {
  225. const that = proxy;
  226. let param = {
  227. phone: data.certificateNo
  228. }
  229. proxy.$http
  230. .post(proxy.$API.SENDMSGCODE,
  231. param
  232. )
  233. .then(res => {
  234. if (res.type == 200) {
  235. data.agreeVal = true;
  236. that.Num();
  237. } else {
  238. Toast(res.content)
  239. }
  240. })
  241. .catch(res => {
  242. console.log(res)
  243. })
  244. }
  245. }
  246. let Num = () => {
  247. const that = data;
  248. let clock = setInterval(function() {
  249. // console.log(typeof this.num);
  250. if (that.num == 0) {
  251. that.agreeVal = false;
  252. that.verification = "重新获取";
  253. that.num = 60;
  254. window.clearInterval(clock);
  255. // that.GetAuthCode();
  256. return;
  257. } else {
  258. that.num--;
  259. that.verification = that.num + "重新获取";
  260. }
  261. }, 1000);
  262. }
  263. let tologin = () => {
  264. proxy.$router.push("/Login");
  265. }
  266. let toBack = () => {
  267. proxy.$router.go(-1);
  268. }
  269. // 微信注册并登录
  270. let toRegistered = () => {
  271. const that = data;
  272. if (localStorage.getItem('weChatUserInfo')) {
  273. that.weChatUserInfo = JSON.parse(localStorage.getItem('weChatUserInfo'))
  274. }
  275. let param = {
  276. openid: that.weChatUserInfo.openid || '',
  277. nickname: that.weChatUserInfo.nickname || '',
  278. sex: that.weChatUserInfo.sex || '',
  279. province: that.weChatUserInfo.province || '',
  280. city: that.weChatUserInfo.city || '',
  281. country: that.weChatUserInfo.country || '',
  282. headimgurl: that.weChatUserInfo.headimgurl || '',
  283. privilege: that.weChatUserInfo.privilege || '',
  284. unionid: that.weChatUserInfo.unionid || '',
  285. ClntId: that.ClntId,
  286. Pwd: '',
  287. Phone: that.certificateNo,
  288. MsgCode: that.verificationCode,
  289. Source: 3
  290. }
  291. proxy.$http
  292. .post(proxy.$API.WECHATREGISTER,
  293. param,
  294. {
  295. headers: {
  296. 'Content-Type': 'application/x-www-form-urlencoded'
  297. }
  298. }
  299. )
  300. .then(res => {
  301. if (res.type == 200) {
  302. Toast('注册成功!')
  303. if (res.data) {
  304. localStorage.setItem("userData", JSON.stringify(res.data));
  305. localStorage.setItem("userphone", res.data.phone);
  306. localStorage.setItem("aiyxWeChatLoginStatus", "isLogin");
  307. }
  308. let url = "/";
  309. location.href = url;
  310. } else {
  311. Toast(res.content)
  312. proxy.$refs.slideblock.reset();
  313. that.showVerificationDialog = false
  314. }
  315. })
  316. .catch((res) => {
  317. console.log(res)
  318. })
  319. }
  320. return {
  321. data,
  322. onCancelPicker,
  323. onConfirmPicker,
  324. getClntBySid,
  325. toRegistered,
  326. clickSelectOrganization,
  327. bindPickerChange,
  328. imgVerificationSuccess,
  329. imgVerificationfail,
  330. verificationPhone,
  331. nextStep,
  332. GetAuthCode,
  333. Num,
  334. tologin,
  335. toBack
  336. }
  337. }
  338. };
  339. </script>
  340. <style lang="scss" scoped>
  341. .title{
  342. margin-top: 1.5rem;
  343. font-size: 0.42rem;
  344. color: #333;
  345. font-weight: bold;
  346. margin-left: 0.44rem;
  347. }
  348. .top-info {
  349. width: 90%;
  350. padding: 0 5% 0.20rem 5%;
  351. height: 0.72rem;
  352. display: flex;
  353. align-items: center;
  354. background-color: #fff;
  355. /* box-shadow: 0rem 0.15rem 0.20rem rgb(246,246,247); */
  356. }
  357. .status_bar {
  358. height: 0.30rem;
  359. width: 100%;
  360. background: #fff;
  361. }
  362. .fanhui{
  363. width: 0.34rem;
  364. height: 0.30rem;
  365. }
  366. .zctit{
  367. font-weight: 600;
  368. margin-left: 40%;
  369. font-size: 0.37rem;
  370. }
  371. .registered{
  372. font-size: .3rem;
  373. text-align: center;
  374. display: flex;
  375. justify-content: center;
  376. position: absolute;
  377. right: 0.4rem;
  378. }
  379. .yzm{
  380. display: flex;
  381. align-items: center;
  382. justify-content: space-between;
  383. border-bottom:0.01rem solid rgb(241,241,241)
  384. }
  385. .pohpas{
  386. width: 100%;
  387. box-shadow:0 0 0.20rem rgb(235,235,237);
  388. }
  389. .tozhuce{font-size: 0.24rem;}
  390. .tushuguan{
  391. display: flex;
  392. align-items: center;
  393. border-bottom:1px solid #f9f9f9 ;
  394. }
  395. .verification {
  396. font-size: 0.28rem;
  397. color: #222222;
  398. align-self: flex-start;
  399. }
  400. .logoStyle {
  401. width: 100%;
  402. height: 100%;
  403. background-size: cover;
  404. display: flex;
  405. flex-direction: column;
  406. }
  407. .input-form {
  408. width: 90%;
  409. margin: 0 auto;
  410. margin-top: 0.80rem;
  411. background-size: cover;
  412. display: flex;
  413. flex-direction: column;
  414. }
  415. .uni-form-item {
  416. width: 100%;
  417. display: flex;
  418. }
  419. .RegisteredBtn {
  420. width: 100%;
  421. margin: 0.35rem 0 0.40rem;
  422. overflow: hidden;
  423. }
  424. .loginInput {
  425. width: 86%;
  426. height: 0.98rem;
  427. margin: 0 auto;
  428. line-height: 0.92rem;
  429. font-size: 0.28rem;
  430. outline: none;
  431. }
  432. .verificationCode {
  433. width: 100%;
  434. display: flex;
  435. align-items: center;
  436. justify-content: space-between;
  437. }
  438. .verificationBtn {
  439. white-space: nowrap;
  440. width: 1.5rem;
  441. height: 0.48rem;
  442. border: 1px solid #188cfb;
  443. line-height: 0.48rem;
  444. text-align: center;
  445. color: #2794fb;
  446. font-size: 0.24rem;
  447. }
  448. .protocol {
  449. margin-top: 0.45rem;
  450. display: flex;
  451. align-items: center;
  452. justify-content: space-between;
  453. align-items: center;
  454. color: #999999;
  455. font-size: 0.22rem;
  456. }
  457. button {
  458. width: 100%;
  459. height: 0.88rem;
  460. line-height: 0.88rem;
  461. font-size: 0.28rem;
  462. color: #fff;
  463. background-color: #5194ff;
  464. }
  465. .color {
  466. color: #999999;
  467. }
  468. .dui{
  469. width: 0.26rem;
  470. height: 0.26rem;
  471. position: relative;
  472. top: 0.05rem;
  473. right: 0.07rem;
  474. }
  475. .kon{
  476. width: 0.26rem;
  477. height: 0.26rem;
  478. position: relative;
  479. top: 0.05rem;
  480. right: 0.07rem;
  481. border-radius: 50%;
  482. box-sizing: border-box;
  483. border: 1px solid #dadada;
  484. }
  485. .bu2{
  486. width: 100%;
  487. height: 0.90rem;
  488. line-height: 0.90rem;
  489. border-radius: 0.1rem;
  490. text-align: center;
  491. color: white;
  492. font-size: 0.30rem;
  493. background-color: rgb(138,197,253);
  494. }
  495. .input{
  496. position: relative;
  497. display: block;
  498. }
  499. /* 遮罩层 */
  500. .dialog-mask{
  501. background: #000;
  502. position: fixed;
  503. top: 0;
  504. left: 0;
  505. z-index: 2000;
  506. width: 100%;
  507. height: 100%;
  508. opacity: 0.4;
  509. }
  510. /* 图片校验码 */
  511. .imgVerificationCode{
  512. position: fixed;
  513. top: 50%;
  514. left: 50%;
  515. transform: translate3d(-50%,-50%,0);
  516. background: #fff;
  517. border-radius: 0.2rem;
  518. z-index: 2001;
  519. text-align: center;
  520. }
  521. .slider-section {
  522. margin: 20px 0;
  523. .img-box {
  524. position: relative;
  525. .bg-img {
  526. width: 100%;
  527. }
  528. .slider-img {
  529. position: absolute;
  530. left: 0;
  531. top: 0;
  532. }
  533. }
  534. .slider-box {
  535. margin-top: 20px;
  536. background: #f7f9fa;
  537. color: #666;
  538. border: 1px solid #e4e7eb;
  539. position: relative;
  540. height: 30px;
  541. width: 100%;
  542. &:hover {
  543. box-shadow: 0 0 3px #ccc;
  544. }
  545. .slider-text {
  546. font-size: 14px;
  547. position: absolute;
  548. top: 50%;
  549. left: 50%;
  550. transform: translate(-50%, -50%);
  551. }
  552. .slider-icon {
  553. width: 30px;
  554. height: 30px;
  555. background: #c8923a;
  556. text-align: center;
  557. font-size: 20px;
  558. color: #fff;
  559. box-shadow: 0 0 6px #ccc;
  560. }
  561. }
  562. }
  563. /* 机构信息 */
  564. .organization-info{
  565. margin-bottom: -0.2rem;
  566. .arrow{
  567. display: flex;
  568. align-items: center;
  569. position: relative;
  570. right: 0.2rem;
  571. .icon {
  572. color: #999999;
  573. font-weight: 600;
  574. font-size: 0.5rem;
  575. transform: rotate(90deg);
  576. }
  577. }
  578. }
  579. .gray {
  580. color: #999;
  581. }
  582. </style>