index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="login_warp">
  3. <view class="infowarp">
  4. <image :src="info.user_logo" class="logoimg" mode=""></image>
  5. <view class="cusname">{{info.user_name}}</view>
  6. </view>
  7. <view class="loginForm">
  8. <view class="loginli">
  9. <view class="logli" style="border-bottom:0;padding:0;">
  10. <view class="label">{{i18n['账号']}}</view>
  11. <input type="number" v-model="account" :placeholder="i18n['请输入手机号']" class="selfinput">
  12. </view>
  13. <image src="/static/img/close.png" @click="clearPhone" v-if="phone" class="closeimg" mode=""></image>
  14. </view>
  15. <view class="loginli">
  16. <view class="logli" style="border-bottom:0;padding:0;">
  17. <view class="label">密码</view>
  18. <input type="number" v-model="password" placeholder="请输入密码" class="selfinput">
  19. </view>
  20. <!-- <image src="/static/img/close.png" @click="clearPhone" v-if="phone" class="closeimg" mode=""></image>
  21. --> </view>
  22. <!-- <view class="loginli">
  23. <view class="logli">
  24. <view class="label">{{i18n['验证码']}}</view>
  25. <input type="number" v-model="code" :placeholder="i18n['请输入验证码']" class="passinput">
  26. </view>
  27. <view class="code" v-if="!showTime" @click="sendCode">{{i18n['发送验证码']}}</view>
  28. <view class="code" v-else>{{time}}s{{i18n['重试']}}</view>
  29. </view> -->
  30. </view>
  31. <view class="loginbtn" @click="toLogin">{{i18n['登录']}}</view>
  32. <!-- <view class="freelogin" @click="freeLogin">暂不登录,进行演示</view>
  33. --> </view>
  34. </template>
  35. <script>
  36. import { checkPhone } from '@/util/common.js'
  37. import { netLogin, netsendText, netInfo, login_text } from '@/api/api.js'
  38. let T;
  39. export default{
  40. data() {
  41. return{
  42. phone:'',
  43. remember:false,
  44. account:uni.getStorageSync('account'),
  45. password:'',
  46. isChinese:false,
  47. info:{},
  48. code:'', //验证码
  49. showTime:false,
  50. time:60
  51. }
  52. },
  53. computed:{
  54. i18n() {
  55. return this.$t("login")
  56. }
  57. },
  58. onLoad() {
  59. this.getInfo()
  60. },
  61. onShow() {
  62. console.log(uni.getStorageSync('locale') == 'zh')
  63. this.isChinese = !uni.getStorageSync('locale') || uni.getStorageSync('locale') == 'zh' ? true : false
  64. },
  65. methods:{
  66. getInfo() {
  67. netInfo().then(res=>{
  68. this.info = res.data
  69. })
  70. },
  71. changeLan(item) {
  72. this.isChinese = !this.isChinese
  73. this.$i18n.locale = item
  74. uni.setStorageSync('locale', item)
  75. },
  76. clearPhone() {
  77. this.phone = ''
  78. },
  79. changeRmem() {
  80. this.remember = !this.remember
  81. if(this.remember){
  82. uni.setStorageSync('account',this.account)
  83. }else{
  84. uni.removeStorageSync('account')
  85. }
  86. },
  87. sendCode() {
  88. if(!checkPhone(this.account)){
  89. uni.showToast({
  90. title:'请输入正确的手机号',
  91. icon:'none'
  92. })
  93. return
  94. }
  95. netsendText({mobile:this.account,_ajax:1}).then(res=>{
  96. this.time = 60
  97. this.showTime = true
  98. T = setInterval(()=>{
  99. this.time --
  100. if(this.time <= 0){
  101. this.showTime = false
  102. clearInterval(T)
  103. }
  104. },1000)
  105. })
  106. },
  107. toLogin() {
  108. if(!checkPhone(this.account)){
  109. uni.showToast({
  110. title:'请输入正确的手机号',
  111. icon:'none'
  112. })
  113. return
  114. }
  115. let params = {
  116. account:this.account,
  117. code:this.code,
  118. password:this.password
  119. }
  120. netLogin(params).then(res=>{
  121. this.jumpPage(res)
  122. })
  123. },
  124. //暂不登录 进行演示
  125. freeLogin() {
  126. login_text().then(res=>{
  127. this.jumpPage(res)
  128. })
  129. },
  130. jumpPage(res){
  131. uni.setStorageSync('token',res.data.token)
  132. uni.redirectTo({
  133. url:'/pages/index/index'
  134. })
  135. },
  136. toRegister() {
  137. uni.redirectTo({
  138. url:'/pages/login/register'
  139. })
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .freelogin{
  146. text-align: center;
  147. font-size:24rpx;
  148. color:red;
  149. margin-top:50rpx;
  150. }
  151. .login_warp{
  152. position: relative;
  153. background: linear-gradient(180deg, #DFF0FF 0%, #F4F4F4 100%);
  154. padding-top:80rpx;
  155. .langbox{
  156. position: absolute;
  157. right:30rpx;
  158. top:30rpx;
  159. .lanimg{
  160. width:44rpx;
  161. height:44rpx;
  162. }
  163. }
  164. }
  165. .infowarp{
  166. width:200rpx;
  167. margin:0 auto;
  168. text-align: center;
  169. .logoimg{
  170. width:145rpx;
  171. height:145rpx;
  172. border-radius: 50%;
  173. border:1rpx solid #f5f5f5;
  174. margin:0 auto 15rpx;
  175. }
  176. .cusname{
  177. font-size:30rpx;
  178. color:#333;
  179. font-weight: bold;
  180. text-align: center;
  181. }
  182. }
  183. .loginForm{
  184. width:700rpx;
  185. padding:0 30rpx;
  186. margin:100rpx auto 0;
  187. .loginli{
  188. display: flex;
  189. justify-content: space-between;
  190. align-items: center;
  191. padding:20rpx 10rpx;
  192. border-bottom:1rpx solid #CACACA;
  193. .selfinput{
  194. width:400rpx;
  195. height: 50px;
  196. font-size:26rpx;
  197. color:#333;
  198. }
  199. .closeimg{
  200. width:30rpx;
  201. height:30rpx;
  202. }
  203. .logli{
  204. display: flex;
  205. justify-content: flex-start;
  206. align-items: center;
  207. flex:1;
  208. border-bottom:1rpx solid #f5f5f5;
  209. padding:20rpx 0;
  210. .label{
  211. width:120rpx;
  212. font-size:26rpx;
  213. color:#333;
  214. margin-right:24rpx;
  215. flex-shrink: 0;
  216. }
  217. .passinput{
  218. width:300rpx;
  219. font-size:26rpx;
  220. height: 50px;
  221. color:#333;
  222. }
  223. }
  224. .code{
  225. flex-shrink: 0;
  226. width:150rpx;
  227. // height:55rpx;
  228. font-size:26rpx;
  229. color:#0287FF;
  230. // border:1rpx solid #0287FF;
  231. border-radius: 10rpx;
  232. text-align: center;
  233. line-height: 52rpx;
  234. }
  235. }
  236. }
  237. .loginbtn{
  238. width:620rpx;
  239. height:88rpx;
  240. background:#7FC2FF;
  241. border-radius: 44rpx;
  242. color:#fff;
  243. font-size:32rpx;
  244. text-align: center;
  245. line-height: 88rpx;
  246. margin:80rpx auto 0;
  247. }
  248. .textlog{
  249. font-size:26rpx;
  250. color:#000;
  251. text-align: center;
  252. margin-top:15rpx;
  253. }
  254. .botbox{
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. padding:0 30rpx;
  259. .remember{
  260. display: flex;
  261. justify-content: flex-start;
  262. align-items: center;
  263. margin-top:30rpx;
  264. font-size:24rpx;
  265. color:#666;
  266. radio{
  267. transform: scale(0.7);
  268. }
  269. .rem_label{
  270. font-size:24rpx;
  271. color:#666;
  272. }
  273. }
  274. }
  275. </style>