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.
 
 
 
 

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