Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

342 строки
7.4 KiB

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