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.
 
 
 

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