login.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <view class="login">
  3. <view class="navLeft" @click="goBack">
  4. <image src="../static/img/nav_icon_back.png" mode="aspectFit" class="backImg" @click="goback"></image>
  5. </view>
  6. <image src="/static/img/logo.png" mode="" class="logoImg"></image>
  7. <view class="title">供应商登录</view>
  8. <view class="loginLine">
  9. <view class="lineTitle">账号</view>
  10. <view>
  11. <input v-model="form.phone" class="lineInput" placeholder="请输入账号" type="text">
  12. </view>
  13. </view>
  14. <view class="loginLine" style="margin-top: 30rpx;">
  15. <view class="lineTitle">密码</view>
  16. <view style="position: relative;">
  17. <input v-model="form.password" class="lineInput" placeholder="请输入密码" type="text" :password="!password.visible">
  18. <image src="/static/img/yanjing.png" v-if="password.visible" @click="switchPasswordVisible" mode="" class="yanjing"></image>
  19. <image src="/static/img/invisible.png" v-if="!password.visible" @click="switchPasswordVisible" mode="" class="yanjing2"></image>
  20. </view>
  21. </view>
  22. <view class="loginBtn" @click="login">登录</view>
  23. <view class="user-selector" style="display: none;">
  24. <!-- <view class="selected-area" @click="switchSelectorVisible">
  25. <view class="selected-content" v-if="userSelector.selectedUser">
  26. <image :src="userSelector.selectedUser.avatar"></image>
  27. <text>{{ userSelector.selectedUser.name }}</text>
  28. </view>
  29. <view class="selected-content" v-else>
  30. <text>请选择用户</text>
  31. </view>
  32. <image class="selected-icon rotate" src="/static/images/up.png"></image>
  33. </view> -->
  34. <view v-if="userSelector.visible" class="dialog-area">
  35. <view class="dialog-list">
  36. <view class="dialog-list-item" v-for="(user, index) in userSelector.users" :key="index" @click="selectUser(user)">
  37. <image class="dialog-list-item-avatar" :src="user.avatar"></image>
  38. <text>{{ user.name }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- <view class="password-box">
  44. <input v-model="form.phone" class="password-input" placeholder="请输入账号" type="text">
  45. </view>
  46. <view class="password-box">
  47. <input v-model="form.password" class="password-input" placeholder="请输入密码" :password="!password.visible" type="text">
  48. <image class="password-image" @click="switchPasswordVisible" src="/static/images/visible.png"></image>
  49. </view>
  50. <view v-show="errorVisible" class="alert-box">
  51. <image src="/static/images/login-alert-icon.png"></image>
  52. <span>请输入正确的用户名和密码</span>
  53. </view>
  54. <button class="login-btn" @click="login">登录</button>
  55. <view class="version">{{ versionName }}</view> -->
  56. </view>
  57. </template>
  58. <script>
  59. import restApi from '../lib/restapi';
  60. const {versionName} = require('../manifest.json');
  61. export default {
  62. name: 'Login',
  63. data() {
  64. return {
  65. versionName: versionName,
  66. userSelector: {
  67. users: [],
  68. visible: false,
  69. selectedUser: null
  70. },
  71. username: '',
  72. password: {
  73. visible: false,
  74. value: '123'
  75. },
  76. form:{
  77. password:'',
  78. phone:'',
  79. },
  80. errorVisible: false
  81. }
  82. },
  83. onLoad() {
  84. var token= uni.getStorageSync("accessToken")
  85. if(token){
  86. uni.switchTab({url: './conversations'});
  87. }
  88. //this.userSelector.users = restApi.findUsers();
  89. },
  90. methods: {
  91. goBack(){
  92. //app交互
  93. var standalone = window.navigator.standalone
  94. var userAgent = window.navigator.userAgent.toLowerCase()
  95. var safari = /safari/.test(userAgent)
  96. var ios = /iphone|ipod|ipad|mac/.test(userAgent)
  97. var android = /android/.test(userAgent)
  98. if (ios) {
  99. if ( true) {//!standalone&& !safari
  100. window.webkit.messageHandlers.goMyNav.postMessage(null)
  101. }
  102. } else if (android) {
  103. window.android.postMessage()
  104. }
  105. },
  106. switchSelectorVisible() {
  107. this.userSelector.visible = !this.userSelector.visible;
  108. },
  109. selectUser(user) {
  110. this.userSelector.visible = false;
  111. this.userSelector.selectedUser = user;
  112. this.username = user.name;
  113. },
  114. switchPasswordVisible() {
  115. this.password.visible = !this.password.visible;
  116. },
  117. login() {
  118. var that=this;
  119. var obj={
  120. name:'',
  121. id:'',
  122. email:'',
  123. avatar:'',
  124. password:'',
  125. phone:'',
  126. }
  127. this.$http('imSys/imLoginTmp', {
  128. userCode:this.form.phone,
  129. userPwd:this.form.password,
  130. },'POST').then(res => {
  131. console.log(res)
  132. uni.setStorageSync('loginInfo', res.data);
  133. obj.name=res.data.supplierName
  134. obj.id=res.data.userId
  135. obj.password=this.form.password
  136. obj.phone=this.form.phone
  137. uni.setStorageSync('currentUser', obj);
  138. uni.setStorageSync('token', res.data.imAccessToken.accessToken);
  139. uni.setStorageSync('accessToken', res.data.imAccessToken.accessToken);
  140. uni.switchTab({url: './conversations'});
  141. })
  142. /* if (this.username.trim() !== '' && this.password.value.trim() !== '') {
  143. let user = restApi.findUser(this.username, this.password.value);
  144. if (user) {
  145. uni.setStorageSync('currentUser', user);
  146. uni.switchTab({url: './conversations'});
  147. return
  148. }
  149. } */
  150. // this.errorVisible = true;
  151. }
  152. }
  153. }
  154. </script>
  155. <style scoped>
  156. .loginLine{
  157. padding: 10rpx 66rpx;
  158. }
  159. .lineInput{
  160. font-size: 34rpx;
  161. padding: 20rpx 0;
  162. border-bottom: 1px solid #DDDDDD;
  163. }
  164. .lineTitle{
  165. font-weight: 400;
  166. font-size: 24rpx;
  167. color: #333333;
  168. }
  169. .loginBtn{
  170. width: 620rpx;
  171. height: 87rpx;
  172. background: #3F90F7;
  173. border-radius: 10rpx;
  174. text-align: center;
  175. line-height: 87rpx;
  176. font-weight: 400;
  177. font-size: 32rpx;
  178. color: #FFFFFF;
  179. margin-top: 40rpx;
  180. margin-left: 64rpx;
  181. }
  182. .yanjing{
  183. position: absolute;
  184. right: 0;
  185. top: 30rpx;
  186. width: 34rpx;
  187. height: 18rpx;
  188. }
  189. .yanjing2{
  190. position: absolute;
  191. right: 0;
  192. top: 30rpx;
  193. width: 34rpx;
  194. height: 34rpx;
  195. }
  196. .login {
  197. width: 100%;
  198. height: 100%;
  199. /* display: flex;
  200. flex-direction: column;
  201. align-items: center; */
  202. background: linear-gradient( 180deg, #E4F0FF 0%, #FFFFFF 100%);
  203. }
  204. .title {
  205. padding-top: 190rpx;
  206. font-weight: 500;
  207. font-size: 48rpx;
  208. color: #101E29;
  209. padding-left: 60rpx;
  210. padding-bottom: 80rpx;
  211. }
  212. .alert-box {
  213. width: 640rpx;
  214. height: 60rpx;
  215. margin-bottom: 60rpx;
  216. padding: 0rpx 20rpx;
  217. font-size: 34rpx;
  218. line-height: 48rpx;
  219. display: flex;
  220. align-content: center;
  221. overflow: hidden;
  222. color: #EE593C;
  223. align-items: center;
  224. }
  225. .alert-box image {
  226. width: 30rpx;
  227. height: 30rpx;
  228. margin-right: 20rpx;
  229. }
  230. .login-btn {
  231. width: 680rpx;
  232. height: 100rpx;
  233. line-height: 100rpx;
  234. font-size: 36rpx;
  235. text-align: center;
  236. color: #ffffff;
  237. background: #d02129;
  238. outline: none;
  239. border: 0;
  240. }
  241. .password-box {
  242. position: relative;
  243. }
  244. .password-input {
  245. width: 620rpx;
  246. padding: 28rpx;
  247. border: 1px solid #cccccc;
  248. margin-bottom: 40rpx;
  249. font-size: 34rpx;
  250. }
  251. .password-image {
  252. width: 50rpx;
  253. height: 50rpx;
  254. position: absolute;
  255. top: 28rpx;
  256. right: 28rpx;
  257. }
  258. .user-selector {
  259. width: 700rpx;
  260. margin-bottom: 40rpx;
  261. }
  262. .selected-area {
  263. display: flex;
  264. flex-direction: row;
  265. align-items: center;
  266. width: 620rpx;
  267. height: 100rpx;
  268. border: 1px solid #cccccc;
  269. margin: 0 auto;
  270. padding: 0 28rpx;
  271. }
  272. .selected-content {
  273. display: flex;
  274. align-items: center;
  275. flex-grow: 1;
  276. }
  277. .selected-content image {
  278. width: 80rpx;
  279. height: 80rpx;
  280. margin-right: 30rpx;
  281. border-radius: 50%;
  282. }
  283. .selected-icon {
  284. width: 40rpx;
  285. height: 40rpx;
  286. margin-right: 10rpx;
  287. }
  288. .selected-icon.rotate {
  289. transform-origin: center;
  290. transform: rotate(180deg);
  291. }
  292. .dialog-area {
  293. position: absolute;
  294. width: 100%;
  295. background: #E5E5E5;
  296. }
  297. .dialog-list {
  298. position: absolute;
  299. left: 10rpx;
  300. top: 8rpx;
  301. width: 674rpx;
  302. border: 1px solid #cccccc;
  303. background: #ffffff;
  304. box-shadow: 8rpx 8rpx 10rpx #e1e1e1;
  305. padding: 30rpx 0;
  306. z-index: 99;
  307. }
  308. .dialog-list-item {
  309. width: 100%;
  310. margin: 25rpx 0;
  311. padding-left: 40rpx;
  312. display: flex;
  313. align-items: center;
  314. }
  315. .dialog-list-item-avatar {
  316. width: 80rpx;
  317. height: 80rpx;
  318. margin-right: 30rpx;
  319. border-radius: 50%;
  320. }
  321. .version {
  322. color: #ffffff;
  323. font-size: 40rpx;
  324. margin-top: 60rpx;
  325. }
  326. view {
  327. user-select: text;
  328. }
  329. .logoImg{
  330. width: 390rpx;
  331. position: fixed;
  332. top: 0;
  333. right: 0;
  334. }
  335. .backImg{
  336. width: 44rpx;
  337. height: 44rpx;
  338. }
  339. .navLeft{
  340. position: fixed;
  341. top: 40rpx;
  342. left: 40rpx;
  343. }
  344. </style>