index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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. var openId= this.carhelp.getOpenId();
  89. if(openId){
  90. this.getInfo()
  91. }
  92. },
  93. methods: {
  94. getPhoneNumber(e){
  95. console.log(e)
  96. },
  97. getInfo(){
  98. uni.showLoading({
  99. title: "加载中",
  100. mask: true,
  101. })
  102. API.findByOpenId({
  103. openId: this.carhelp.getOpenId(),
  104. }).then((res) => {
  105. this.carhelp.setPersonInfo(res.data.regUser );
  106. this.carhelp.setToken(res.data.token);
  107. this.carhelp.setPersonInfoPlus(res.data);
  108. uni.redirectTo({
  109. url:"/pages/otherFunctions/homePage"
  110. })
  111. }).catch(error => {
  112. uni.hideLoading();
  113. //this.getPhone()
  114. })
  115. },
  116. codeChange(text) {
  117. this.codeTips = text;
  118. },
  119. //倒计时
  120. end() {
  121. this.sendMsgSecond = 2 * 60;
  122. this.isSendMsgIng = false;
  123. },
  124. finish() {
  125. if (!this.carhelp.getOpenId()) {
  126. // uni.showToast({
  127. // title: "请使用“微信”访问本系统登录"
  128. // })
  129. // return
  130. }
  131. if (!this.form.phone) {
  132. uni.showToast({
  133. title: "请输入手机号"
  134. })
  135. return
  136. }
  137. if (!this.form.code) {
  138. uni.showToast({
  139. title: "请输入验证码"
  140. })
  141. return
  142. }
  143. uni.showLoading({
  144. title: "加载中",
  145. mask: true,
  146. })
  147. var headImg = "";
  148. var userInfo = this.carhelp.get("xpgj_wx_user_info")
  149. if (userInfo) {
  150. headImg = userInfo.headimgurl;
  151. }
  152. API.validateCode({
  153. verifyCode: this.form.code,
  154. telephone: this.form.phone,
  155. openId: this.carhelp.getOpenId(),
  156. headImg: headImg
  157. }).then((response) => {
  158. this.loginset(response)
  159. }).catch(error => {
  160. uni.showToast({
  161. title: error,
  162. icon: "none"
  163. })
  164. })
  165. },
  166. loginset(response){
  167. var token = response ? response.data.token : '';
  168. this.carhelp.setToken(token);
  169. this.carhelp.setPersonInfo(response.data.regUser);
  170. this.carhelp.setPersonInfoPlus(response.data)
  171. //this.gotoUrl("pages/user/index")
  172. uni.redirectTo({
  173. url:"/pages/otherFunctions/homePage"
  174. })
  175. },
  176. start() {
  177. if (!this.isSendMsgIng) {
  178. uni.showLoading({
  179. title: "加载中",
  180. mask: true,
  181. })
  182. API.getVerifyCode(this.form.phone).then((response) => {
  183. uni.hideLoading();
  184. this.carhelp.set("getvcodetime", new Date().getTime());
  185. if (!"") {
  186. //倒计时
  187. uni.showToast({
  188. title: "发送成功"
  189. })
  190. } else {
  191. uni.showToast({
  192. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  193. })
  194. }
  195. }).catch(error => {
  196. uni.showToast({
  197. title: error,
  198. icon: "none"
  199. })
  200. })
  201. }
  202. },
  203. // 获取验证码
  204. getCode() {
  205. if (this.$refs.uCode.canGetCode) {
  206. } else {
  207. uni.showToast({
  208. title: '倒计时结束后再发送',
  209. icon: "none"
  210. })
  211. return
  212. }
  213. var checkPhoneResult = checkPhone(this.form.phone);
  214. if (checkPhoneResult !== true) {
  215. uni.showToast({
  216. title: checkPhoneResult,
  217. })
  218. return;
  219. }
  220. this.$refs.uCode.start();
  221. },
  222. changeoptionShow() {
  223. this.optionShow = !this.optionShow
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. page {
  230. background-color: #fff;
  231. }
  232. uni-image {
  233. width: 100%;
  234. height: 512px;
  235. position: absolute;
  236. top: 0;
  237. left: 0;
  238. right: 0;
  239. }
  240. .backgroundView{
  241. background-image: url('http://rccs.oss-cn-hangzhou.aliyuncs.com/Jp-jingli/login.jpg');
  242. background-size: contain;
  243. }
  244. .background {
  245. width: 100%;
  246. height: 512px;
  247. //background: linear-gradient(180deg, rgba(0, 45, 194, 1) 0%, rgba(0, 59, 254, 0.76) 49%, rgba(1, 122, 255, 0.5) 100%);
  248. position: relative;
  249. //z-index: 111;
  250. opacity: 0.5;
  251. padding-top: 300px;
  252. }
  253. .title {
  254. font-family: 'Alibaba-PuHuiTi-Regular';
  255. text-align: center;
  256. color: rgba(255, 255, 255, 1);
  257. font-size: 56rpx;
  258. position: absolute;
  259. top: 217px;
  260. left: 0;
  261. right: 0;
  262. z-index: 999;
  263. opacity: 1;
  264. }
  265. .logo {
  266. width: 144rpx;
  267. height: 144rpx;
  268. line-height: 144rpx;
  269. border-radius: 12px;
  270. background-color: rgba(255, 255, 255, 1);
  271. text-align: center;
  272. position: absolute;
  273. top: 133px;
  274. left: 0;
  275. right: 0;
  276. margin: auto;
  277. z-index: 999;
  278. img {
  279. width: 90%;
  280. height: 90%;
  281. vertical-align: middle;
  282. }
  283. }
  284. .login-box {
  285. position: absolute;
  286. border-radius: 24px 24px 0px 0px;
  287. background-color: rgba(255, 255, 255, 1);
  288. padding: 88rpx 96rpx;
  289. top: 410px;
  290. left: 0;
  291. right: 0;
  292. z-index: 999;
  293. .tel {
  294. /deep/.u-input {}
  295. }
  296. .pwd {
  297. /deep/.u-input {}
  298. }
  299. .tel,
  300. .pwd,
  301. .identity {
  302. width: 558rpx;
  303. background-color: rgba(244, 245, 249, 1);
  304. position: relative;
  305. display: flex;
  306. height: 80rpx;
  307. line-height: 80rpx;
  308. color: rgba(183, 172, 172, 1);
  309. margin: auto;
  310. margin-bottom: 36rpx;
  311. border: 1px solid rgba(193, 204, 223, 1);
  312. border-radius: 8px;
  313. /deep/.u-input__input {
  314. font-size: 32rpx;
  315. }
  316. .icon {
  317. width: 14%;
  318. text-align: center;
  319. color: #B0B8C8;
  320. img {
  321. width: 32rpx;
  322. height:32rpx;
  323. vertical-align: middle;
  324. }
  325. }
  326. .tips {
  327. text-indent: 16rpx;
  328. padding-right: 16rpx;
  329. display: flex;
  330. justify-content: space-between;
  331. /deep/uni-input {
  332. height: 80rpx !important;
  333. line-height: 80rpx !important;
  334. color: #A7ACB4;
  335. }
  336. .input {
  337. width: 60%;
  338. }
  339. }
  340. }
  341. // 验证码
  342. .verification-code {
  343. color: #1F4A99;
  344. line-height: 80rpx;
  345. font-family: 'Alibaba-PuHuiTi-Regular';
  346. color: rgba(0, 59, 254, 1);
  347. }
  348. .unfold {
  349. margin-left: auto;
  350. margin-right: 24rpx;
  351. }
  352. .options {
  353. background-color: #fff;
  354. z-index: 999;
  355. position: absolute;
  356. top: 80rpx;
  357. left: 40px;
  358. right: 4rpx;
  359. box-shadow: 0px 2px 4px #A7ACB4;
  360. color: #101010;
  361. .item {
  362. padding-left: 16rpx;
  363. line-height: 72rpx;
  364. }
  365. }
  366. .login-btn{
  367. margin-top: 80rpx;
  368. /deep/uni-button{
  369. border-radius: 8px;
  370. background-color: rgba(0, 59, 254, 1);
  371. color: #fff;
  372. height: 88rpx;
  373. line-height: 88rpx;
  374. }
  375. }
  376. }
  377. </style>