index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="">
  3. <view class="backgroundView">
  4. <view class="background">
  5. </view>
  6. <view class="logo">
  7. <img src="../../assets/img/loginLogo@1x.png" alt="">
  8. </view>
  9. <view class="title">
  10. 设备工器具管理系统
  11. </view>
  12. <view class="login">
  13. <view class="login-box">
  14. <!-- 登录身份 -->
  15. <!-- <view class="identity">
  16. <view class="icon">
  17. <img src="../../assets/img/riFill-account-box-fill@1x.png" alt="">
  18. </view>
  19. <view class="tips">
  20. 请选择登录身份
  21. </view>
  22. <view class="unfold" @click="changeoptionShow()">
  23. <u-icon name="arrow-down"></u-icon>
  24. </view>
  25. <view class="options" v-if="optionShow">
  26. <view class="item">选项1</view>
  27. <view class="item">选项2</view>
  28. <view class="item">选项3</view>
  29. </view>
  30. </view> -->
  31. <!-- 手机号 -->
  32. <view class="tel">
  33. <view class="icon">
  34. <img src="../../assets/img/riFill-smartphone-fill@1x.png" alt="">
  35. </view>
  36. <view class="tips">
  37. <!-- <view class="input">
  38. </view> -->
  39. <u-input class="telInput" v-model="form.phone" :placeholderStyle="{}" height="80" input-align="left" type="number" placeholder="请填写手机号码" />
  40. <!-- <view class="verification-code" @click="getPhoneNumber2" >获取</view> -->
  41. <!-- <button type="default" class="verification-code" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
  42. -->
  43. </view>
  44. </view>
  45. <!-- 验证码 -->
  46. <view class="pwd">
  47. <view class="icon">
  48. <img src="../../assets/img/riFill-message-3-fill Copy@1x.png" alt="">
  49. </view>
  50. <view class="tips">
  51. <view class="input">
  52. <u-input type="number" v-model="form.code"
  53. :placeholderStyle="{}" height="80" input-align="left" placeholder="请填写验证码" />
  54. </view>
  55. <view class="verification-code" @click="getCode" >{{codeTips}}</view>
  56. <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start">
  57. </u-verification-code>
  58. </view>
  59. </view>
  60. <view class="login-btn">
  61. <u-button type="primary" @click="finish()" >登录</u-button>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import * as API from '@/apis/pagejs/index.js'
  70. import {
  71. checkPhone
  72. } from '@/apis/utils'
  73. export default {
  74. data() {
  75. return {
  76. form: {
  77. name: '',
  78. phone: '',
  79. code: '',
  80. },
  81. codeTips: '',
  82. isSendMsgIng: false,
  83. sendMsgSecond: 60 * 2,
  84. optionShow: false
  85. }
  86. },
  87. onLoad(){
  88. },
  89. onReady() {
  90. this.getOpenId()
  91. },
  92. methods: {
  93. getOpenId(){
  94. var openId= this.carhelp.getOpenId();
  95. if(openId){
  96. this.getInfo()
  97. }else{
  98. setTimeout(()=>{
  99. this.getOpenId()
  100. },1000)
  101. }
  102. },
  103. getPhoneNumber(e){
  104. console.log(e)
  105. },
  106. getInfo(){
  107. uni.showLoading({
  108. title: "加载中",
  109. mask: true,
  110. })
  111. API.findByOpenId({
  112. openId: this.carhelp.getOpenId(),
  113. noerror:true,
  114. }).then((res) => {
  115. this.carhelp.setPersonInfo(res.data.regUser );
  116. this.carhelp.setToken(res.data.token);
  117. this.carhelp.setPersonInfoPlus(res.data);
  118. uni.redirectTo({
  119. url:"/pages/otherFunctions/homePage"
  120. })
  121. }).catch(error => {
  122. uni.hideLoading();
  123. //this.getPhone()
  124. })
  125. },
  126. codeChange(text) {
  127. this.codeTips = text;
  128. },
  129. //倒计时
  130. end() {
  131. this.sendMsgSecond = 2 * 60;
  132. this.isSendMsgIng = false;
  133. },
  134. finish() {
  135. if (!this.carhelp.getOpenId()) {
  136. // uni.showToast({
  137. // title: "请使用“微信”访问本系统登录"
  138. // })
  139. // return
  140. }
  141. if (!this.form.phone) {
  142. uni.showToast({
  143. title: "请输入手机号"
  144. })
  145. return
  146. }
  147. if (!this.form.code) {
  148. uni.showToast({
  149. title: "请输入验证码"
  150. })
  151. return
  152. }
  153. uni.showLoading({
  154. title: "加载中",
  155. mask: true,
  156. })
  157. var headImg = "";
  158. var userInfo = this.carhelp.get("xpgj_wx_user_info")
  159. if (userInfo) {
  160. headImg = userInfo.headimgurl;
  161. }
  162. API.validateCode({
  163. verifyCode: this.form.code,
  164. telephone: this.form.phone,
  165. openId: this.carhelp.getOpenId(),
  166. headImg: headImg
  167. }).then((response) => {
  168. this.loginset(response)
  169. }).catch(error => {
  170. uni.showToast({
  171. title: error,
  172. icon: "none"
  173. })
  174. })
  175. },
  176. loginset(response){
  177. var token = response ? response.data.token : '';
  178. this.carhelp.setToken(token);
  179. this.carhelp.setPersonInfo(response.data.regUser);
  180. this.carhelp.setPersonInfoPlus(response.data)
  181. //this.gotoUrl("pages/user/index")
  182. uni.redirectTo({
  183. url:"/pages/otherFunctions/homePage"
  184. })
  185. },
  186. start() {
  187. if (!this.isSendMsgIng) {
  188. uni.showLoading({
  189. title: "加载中",
  190. mask: true,
  191. })
  192. API.getVerifyCode(this.form.phone).then((response) => {
  193. uni.hideLoading();
  194. this.carhelp.set("getvcodetime", new Date().getTime());
  195. if (!"") {
  196. //倒计时
  197. uni.showToast({
  198. title: "发送成功"
  199. })
  200. } else {
  201. uni.showToast({
  202. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  203. })
  204. }
  205. }).catch(error => {
  206. uni.showToast({
  207. title: error,
  208. icon: "none"
  209. })
  210. })
  211. }
  212. },
  213. // 获取验证码
  214. getCode() {
  215. if (this.$refs.uCode.canGetCode) {
  216. } else {
  217. uni.showToast({
  218. title: '倒计时结束后再发送',
  219. icon: "none"
  220. })
  221. return
  222. }
  223. var checkPhoneResult = checkPhone(this.form.phone);
  224. if (checkPhoneResult !== true) {
  225. uni.showToast({
  226. title: checkPhoneResult,
  227. })
  228. return;
  229. }
  230. this.$refs.uCode.start();
  231. },
  232. changeoptionShow() {
  233. this.optionShow = !this.optionShow
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. page {
  240. background-color: #fff;
  241. }
  242. uni-image {
  243. width: 100%;
  244. height: 512px;
  245. position: absolute;
  246. top: 0;
  247. left: 0;
  248. right: 0;
  249. }
  250. .backgroundView{
  251. background-image: url('http://rccs.oss-cn-hangzhou.aliyuncs.com/Jp-jingli/login.jpg');
  252. background-size: contain;
  253. }
  254. .background {
  255. width: 100%;
  256. height: 512px;
  257. //background: linear-gradient(180deg, rgba(0, 45, 194, 1) 0%, rgba(0, 59, 254, 0.76) 49%, rgba(1, 122, 255, 0.5) 100%);
  258. position: relative;
  259. //z-index: 111;
  260. opacity: 0.5;
  261. padding-top: 300px;
  262. }
  263. .title {
  264. font-family: 'Alibaba-PuHuiTi-Regular';
  265. text-align: center;
  266. color: rgba(255, 255, 255, 1);
  267. font-size: 56rpx;
  268. position: absolute;
  269. top: 217px;
  270. left: 0;
  271. right: 0;
  272. z-index: 999;
  273. opacity: 1;
  274. }
  275. .logo {
  276. width: 144rpx;
  277. height: 144rpx;
  278. line-height: 144rpx;
  279. border-radius: 12px;
  280. background-color: rgba(255, 255, 255, 1);
  281. text-align: center;
  282. position: absolute;
  283. top: 133px;
  284. left: 0;
  285. right: 0;
  286. margin: auto;
  287. z-index: 999;
  288. img {
  289. width: 90%;
  290. height: 90%;
  291. vertical-align: middle;
  292. }
  293. }
  294. .login-box {
  295. position: absolute;
  296. border-radius: 24px 24px 0px 0px;
  297. background-color: rgba(255, 255, 255, 1);
  298. padding: 88rpx 96rpx;
  299. top: 410px;
  300. left: 0;
  301. right: 0;
  302. z-index: 999;
  303. .tel {
  304. /deep/.u-input {}
  305. }
  306. .pwd {
  307. /deep/.u-input {}
  308. }
  309. .tel,
  310. .pwd,
  311. .identity {
  312. width: 558rpx;
  313. background-color: rgba(244, 245, 249, 1);
  314. position: relative;
  315. display: flex;
  316. height: 80rpx;
  317. line-height: 80rpx;
  318. color: rgba(183, 172, 172, 1);
  319. margin: auto;
  320. margin-bottom: 36rpx;
  321. border: 1px solid rgba(193, 204, 223, 1);
  322. border-radius: 8px;
  323. /deep/.u-input__input {
  324. font-size: 32rpx;
  325. }
  326. .icon {
  327. width: 14%;
  328. text-align: center;
  329. color: #B0B8C8;
  330. img {
  331. width: 32rpx;
  332. height:32rpx;
  333. vertical-align: middle;
  334. }
  335. }
  336. .tips {
  337. text-indent: 16rpx;
  338. padding-right: 16rpx;
  339. display: flex;
  340. justify-content: space-between;
  341. /deep/uni-input {
  342. height: 80rpx !important;
  343. line-height: 80rpx !important;
  344. color: #A7ACB4;
  345. }
  346. .input {
  347. width: 60%;
  348. }
  349. }
  350. }
  351. // 验证码
  352. .verification-code {
  353. color: #1F4A99;
  354. line-height: 80rpx;
  355. font-family: 'Alibaba-PuHuiTi-Regular';
  356. color: rgba(0, 59, 254, 1);
  357. font-size: 12px;
  358. }
  359. .unfold {
  360. margin-left: auto;
  361. margin-right: 24rpx;
  362. }
  363. .options {
  364. background-color: #fff;
  365. z-index: 999;
  366. position: absolute;
  367. top: 80rpx;
  368. left: 40px;
  369. right: 4rpx;
  370. box-shadow: 0px 2px 4px #A7ACB4;
  371. color: #101010;
  372. .item {
  373. padding-left: 16rpx;
  374. line-height: 72rpx;
  375. }
  376. }
  377. .login-btn{
  378. margin-top: 80rpx;
  379. /deep/uni-button{
  380. border-radius: 8px;
  381. background-color: rgba(0, 59, 254, 1);
  382. color: #fff;
  383. height: 88rpx;
  384. line-height: 88rpx;
  385. }
  386. }
  387. }
  388. </style>