AI销管
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.
 
 
 
 

405 lines
8.5 KiB

  1. <template>
  2. <view>
  3. <view class="head">
  4. <image class="head-immg" src="https://autoiot.oss-cn-beijing.aliyuncs.com/static/login.png" mode=""></image>
  5. </view>
  6. <view class="input">
  7. <view class="">
  8. <view class="text-1">
  9. 您好,
  10. </view>
  11. <view class="text-2">
  12. 欢迎登录AI销管~
  13. </view>
  14. </view>
  15. <view class="cwjs-cells item-flex" style="margin-top: 80rpx;">
  16. <view class="cwjs-item center">
  17. <image src="https://qufang.oss-cn-beijing.aliyuncs.com/channelHelper/user.png" class="logo_input">
  18. </image>
  19. <input class="cwjs-item cwjs-input" v-model="username" placeholder="请输入账号名" type="number"
  20. maxlength="11" placeholder-style="color:#AAAAAA"></input>
  21. </view>
  22. </view>
  23. <view class="cwjs-cells item-flex" style="margin-top:13rpx;">
  24. <view class="cwjs-item center">
  25. <image src="https://qufang.oss-cn-beijing.aliyuncs.com/channelHelper/lock.png" class="logo_input">
  26. </image>
  27. <input class="cwjs-item cwjs-input" placeholder="请输入密码" placeholder-style="color:#AAAAAA"
  28. type="password" v-model="password" maxlength="16" v-if="passwordType"></input>
  29. <input class="cwjs-item cwjs-input" placeholder="请输入密码" placeholder-style="color:#AAAAAA"
  30. maxlength="16" v-model="password" v-else></input>
  31. </view>
  32. <view class="imagesBox" @tap="changeBindPassword">
  33. <image v-if="passwordType==false" src="../../static/images/zhengkai.png" class="images"
  34. mode="scaleToFill"></image>
  35. <image v-if="passwordType==true" src="../../static/images/bishang.png" class="images"
  36. mode="scaleToFill"></image>
  37. </view>
  38. </view>
  39. <view class="textbox">
  40. <view class="textbox-1" @tap="bindVerification">验证码登录</view>
  41. <view class="textbox-2"></view>
  42. <view class="textbox-11" @tap="bindpassword">忘记密码</view>
  43. </view>
  44. <view class="button" @tap="bindWxBLogin">立即登录</view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. var util = require("../../utils/util.js");
  50. var config = require("../../config");
  51. var app = getApp();
  52. var WXB_SESSION_LOGIN_DATA = 'weapp_session_login_data';
  53. export default {
  54. data() {
  55. return {
  56. username: '13388881113',//用户名
  57. password: '1234567',//密码
  58. passwordType: true,
  59. agreeChecked: true
  60. };
  61. },
  62. onLoad: function(options) {
  63. uni.hideToast();
  64. },
  65. methods: {
  66. //验证码登录
  67. bindVerification() {
  68. uni.navigateTo({
  69. url: '/pages/login/Verification?role=1',
  70. })
  71. },
  72. //忘记密码
  73. bindpassword() {
  74. // uni.navigateTo({
  75. // url: '/pages/login/Verification?role=2',
  76. // })
  77. uni.navigateTo({
  78. url: '/pages/login/Setthepassword',
  79. })
  80. },
  81. //密码选择
  82. changeBindPassword: function(e) {
  83. this.passwordType=!this.passwordType;
  84. },
  85. //登录
  86. bindWxBLogin: function(e) {
  87. util.showBusy('正在登录...');
  88. var that = this;
  89. if (this.username == '') {
  90. util.showNone("请输入账号名");
  91. return false;
  92. }
  93. if (this.password == '') {
  94. util.showNone("请输入密码");
  95. return false;
  96. }
  97. var loginParams = {
  98. username: this.username,
  99. password: this.password,
  100. scope: 'server',
  101. grant_type: 'password'
  102. };
  103. const user = util.encryption({
  104. data: loginParams,
  105. key: 'pigxpigxpigxpigx',
  106. param: ['password']
  107. })
  108. console.log(user)
  109. // return
  110. // 请求服务器登录地址,获得会话信息
  111. uni.request({
  112. url: config.service.login,
  113. header: {
  114. 'Authorization': 'Basic dGVzdDp0ZXN0',
  115. 'content-type': 'application/x-www-form-urlencoded'
  116. },
  117. method: "POST",
  118. data: {
  119. username:user.username,
  120. password:user.password,
  121. scope: 'server',
  122. grant_type: 'password'
  123. },
  124. success: function(result) {
  125. var data = result.data; //console.log("登录信息", data);
  126. if (data) {
  127. var res = data;
  128. console.log(res.code)
  129. if (res.code!=1) {
  130. var data = {
  131. 'token': res.access_token
  132. };
  133. uni.setStorageSync(WXB_SESSION_LOGIN_DATA, data); //写入缓存
  134. that.getMenu()
  135. that.getUser();
  136. util.showSuccess('登录成功');
  137. } else {
  138. util.showNone("账号名或密码错误,请重试");
  139. return false;
  140. }
  141. } else {
  142. util.showNone(data.message);
  143. return false;
  144. }
  145. },
  146. // 响应错误
  147. fail: function(loginResponseError) {
  148. util.showNone("网络异常,请重试");
  149. return false;
  150. }
  151. });
  152. },
  153. getUser(){
  154. util.getRequestPromise(config.service.getUser, {}, false, "GET").then(data => {
  155. if (data.user.total==0) {
  156. uni.showToast({
  157. title: '暂无绑定项目',
  158. duration: 2000,
  159. icon:"none"
  160. });
  161. return
  162. } else {
  163. let lopan = {
  164. id: data.houseList[0].id,
  165. name: data.houseList[0].propertyName
  166. }
  167. let users=data.user
  168. users.zkProperties=data.houseList
  169. uni.setStorageSync("fendianindex", 0); //写入缓存
  170. uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
  171. uni.setStorageSync("buildingID", lopan); //项目id写入缓存
  172. uni.switchTab({
  173. url: '/pages/index/index'
  174. });
  175. }
  176. });
  177. },
  178. //获取权限
  179. getMenu(){
  180. uni.request({
  181. url: config.service.getMenu,
  182. method: "POST",
  183. header: {
  184. 'content-type': 'application/json',
  185. 'Authorization': 'Bearer '+uni.getStorageSync('weapp_session_login_data').token
  186. },
  187. success: (data) => {
  188. let rescor=data.data;
  189. if (rescor.code == 0) {
  190. uni.setStorageSync("weapp_session_Menu_data", rescor.data)
  191. }else{
  192. uni.showToast({
  193. title: rescor.msg,
  194. duration: 2000,
  195. icon:"none"
  196. });
  197. return
  198. }
  199. }
  200. })
  201. },
  202. }
  203. };
  204. </script>
  205. <style lang="scss">
  206. .cwjs-logo {
  207. display: block;
  208. width: 219rpx;
  209. height: 158rpx;
  210. margin: 54rpx auto 66rpx;
  211. }
  212. .cwjs-tips {
  213. font-size: 24rpx;
  214. padding: 80rpx 0;
  215. color: #8a8a8a;
  216. }
  217. .cwjs-form {
  218. position: relative;
  219. margin: 0;
  220. background-color: #fff;
  221. border-radius: 10px;
  222. padding: 20rpx 40rpx 113rpx;
  223. }
  224. .cwjs-cells {
  225. width: 510rpx;
  226. display: flex;
  227. flex-direction: row;
  228. justify-content: space-between;
  229. align-items: center;
  230. margin: 0 auto;
  231. height: 88rpx;
  232. overflow: hidden;
  233. border: 1rpx solid #BFC7D3;
  234. position: relative;
  235. border-radius: 12rpx;
  236. }
  237. .center {
  238. flex: 1;
  239. }
  240. .cwjs-input {
  241. height: 48rpx;
  242. line-height: 48rpx;
  243. padding: 23rpx 23rpx 23rpx 78rpx;
  244. font-size: 28rpx;
  245. font-family: PingFangSC-Regular, PingFang SC;
  246. color: #000;
  247. }
  248. .images {
  249. display: block;
  250. width: 40rpx;
  251. height: 21rpx;
  252. margin-right: 30rpx;
  253. margin-top: 33.5rpx;
  254. }
  255. .mod-btn {
  256. position: absolute;
  257. bottom: -80rpx;
  258. left: 50%;
  259. margin-left: -80rpx;
  260. }
  261. /* 头部 */
  262. .head {
  263. width: 750rpx;
  264. height: 500rpx;
  265. position: relative;
  266. .head-immg {
  267. // width: 118rpx;
  268. // height: 61rpx;
  269. // position: absolute;
  270. // top: 300rpx;
  271. // left: 100rpx;
  272. width: 750rpx;
  273. height: 778rpx;
  274. position: absolute;
  275. }
  276. }
  277. .logo {
  278. width: 248upx;
  279. height: 248upx;
  280. display: block;
  281. position: absolute;
  282. top: 134rpx;
  283. left: 240.5rpx;
  284. }
  285. /* 输入框 */
  286. .input {
  287. width: 630rpx;
  288. height: 824rpx;
  289. padding: 60rpx 60rpx 80rpx 60rpx;
  290. box-sizing: border-box;
  291. background: #FFFFFF;
  292. box-shadow: 0px 14px 20px -6px rgba(6, 16, 88, 0.1);
  293. border-radius: 20px;
  294. position: absolute;
  295. top: 107rpx;
  296. left: 60rpx;
  297. }
  298. .text-1 {
  299. font-size: 44rpx;
  300. line-height: 62rpx;
  301. }
  302. .text-2 {
  303. margin-top: 16rpx;
  304. font-size: 36rpx;
  305. line-height: 50rpx;
  306. }
  307. .logo_input {
  308. width: 34rpx;
  309. height: 38rpx;
  310. position: absolute;
  311. top: 25rpx;
  312. left: 30rpx;
  313. }
  314. /* 登录 */
  315. .button {
  316. width: 510rpx;
  317. height: 86rpx;
  318. background: #2671E2;
  319. box-shadow: 0px 2px 20px 0px rgba(38, 113, 226, 0.5);
  320. border-radius: 12rpx;
  321. text-align: center;
  322. line-height: 89rpx;
  323. color: #fff;
  324. margin: 0 auto;
  325. margin-top: 120rpx;
  326. font-size: 34rpx;
  327. }
  328. .footer {
  329. width: 100%;
  330. height: 157rpx;
  331. position: absolute;
  332. bottom: 0;
  333. left: 0;
  334. }
  335. .imagesBox {
  336. width: 80rpx;
  337. height: 88rpx;
  338. }
  339. .login {
  340. text-decoration: underline;
  341. text-align: center;
  342. margin-top: 40px;
  343. color: #88909E;
  344. font-size: 28rpx;
  345. }
  346. .textbox {
  347. width: 569rpx;
  348. display: flex;
  349. margin-top: 40rpx;
  350. }
  351. .textbox-1 {
  352. width: 30%;
  353. font-size: 30rpx;
  354. color: #999999;
  355. }
  356. .textbox-11 {
  357. width: 30%;
  358. text-align: right;
  359. font-size: 30rpx;
  360. color: #999999;
  361. }
  362. .textbox-2 {
  363. width: 30%;
  364. }
  365. </style>