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.
 
 
 
 

364 lines
7.8 KiB

  1. <template>
  2. <view class="content">
  3. <view class="head">
  4. <view class="text">
  5. <view class="text1">
  6. <view style="color: #666666;">输入短信验证码</view>
  7. <view style="color: #303030;margin-top: 20rpx;">短信已发送至{{phone}},请在下方输入框内输入4位数字验证码</view>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="sction">
  12. <view class="mama">
  13. <view class="mamaz">
  14. <input type="text" v-model="msg" maxlength="4" placeholder="请输入验证码" placeholder-class="input-class" class="input" />
  15. </view>
  16. <view class="mamay">
  17. <view class="sada" v-if="sendAuthCode" style="font-size: 35rpx;" @click="getAuthCode">获取验证码</view>
  18. <text class="sada" v-if="!sendAuthCode">
  19. 重新发送
  20. <text>({{ auth_time }})</text>
  21. </text>
  22. </view>
  23. </view>
  24. <view class="login-btn" :style="{ background: msg == '' ? '#F2F2F2' : '#2671E2' }" @click="denglu"><text
  25. class="">登录</text></view>
  26. <view class="code-login" @click="passwordlogin"><text>密码登录</text></view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. var util = require("../../utils/util.js");
  32. var config = require("../../config");
  33. var app = getApp();
  34. var WXB_SESSION_LOGIN_DATA = 'weapp_session_login_data';
  35. export default {
  36. data() {
  37. return {
  38. sendAuthCode: true,
  39. auth_time: 0,
  40. msg: '',
  41. phonecet: '',
  42. role:'',
  43. phone:''
  44. };
  45. },
  46. onLoad: function(options) {
  47. var phonese = options.username;
  48. var phonexxz = phonese.substring(0, 3) + '****' + phonese.substring(7);
  49. this.phone = phonexxz,
  50. this.phonecet = options.username,
  51. this.role = options.role
  52. this.sendAuthCode = false;
  53. this.auth_time = 60;
  54. var auth_timetimer = setInterval(() => {
  55. this.auth_time--;
  56. if (this.auth_time <= 0) {
  57. this.sendAuthCode = true;
  58. clearInterval(auth_timetimer);
  59. }
  60. }, 1000);
  61. },
  62. methods: {
  63. //跳转密码登录页面
  64. passwordlogin() {
  65. uni.reLaunch({
  66. url: '/pages/login/index',
  67. })
  68. },
  69. //获取验证码
  70. getAuthCode() {
  71. uni.request({
  72. url: config.service.sendCode + "/" + this.phonecet,
  73. method: "GET",
  74. header: {
  75. 'content-type': 'application/json',
  76. // 'Authorization': 'Bearer '+uni.getStorageSync('weapp_session_login_data').token
  77. },
  78. success: (data) => {
  79. console.log(data)
  80. // 成功地响应会话信息
  81. if (data.data.code == 0) {
  82. util.showSuccess('发送成功');
  83. this.sendAuthCode = false;
  84. this.auth_time = 60;
  85. var auth_timetimer = setInterval(() => {
  86. this.auth_time--;
  87. if (this.auth_time <= 0) {
  88. this.sendAuthCode = true;
  89. clearInterval(auth_timetimer);
  90. }
  91. }, 1000);
  92. } else {
  93. util.showNone(data.data.message);
  94. return false;
  95. }
  96. },
  97. })
  98. },
  99. //登录
  100. denglu() {
  101. var that = this;
  102. if (this.msg=='') {
  103. uni.showToast({
  104. title: '验证码不能为空',
  105. icon: 'none'
  106. });
  107. return
  108. }
  109. if (this.msg.length == 4) {
  110. // let porme = {
  111. // loginName: this.phonecet,
  112. // password: this.msg
  113. // }
  114. uni.request({
  115. url: config.service.plogin+'?mobile=SMS@'+this.phonecet+'&code='+this.msg+'&grant_type=mobile',
  116. method: "POST",
  117. header: {
  118. 'Authorization': 'Basic cGlnOnBpZw=='
  119. },
  120. data: {
  121. mobile:'SMS@'+this.phonecet,
  122. code:this.msg,
  123. grant_type:'mobile'
  124. },
  125. success: (result) => {
  126. var data = result.data; //console.log("登录信息", data);
  127. if (data) {
  128. var res = data;
  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. } else {
  148. uni.showToast({
  149. title: '验证码位数不正确',
  150. icon: 'none'
  151. });
  152. }
  153. },
  154. getMenu(){
  155. uni.request({
  156. url: config.service.getMenu,
  157. method: "POST",
  158. header: {
  159. 'content-type': 'application/json',
  160. 'Authorization': 'Bearer '+uni.getStorageSync('weapp_session_login_data').token
  161. },
  162. success: (data) => {
  163. let rescor=data.data;
  164. if (rescor.code == 0) {
  165. uni.setStorageSync("weapp_session_Menu_data", rescor.data)
  166. }else{
  167. uni.showToast({
  168. title: rescor.msg,
  169. duration: 2000,
  170. icon:"none"
  171. });
  172. return
  173. }
  174. }
  175. })
  176. },
  177. getUser(){
  178. util.getRequestPromise(config.service.getUser, {}, false, "GET").then(data => {
  179. if (data.user.total==0) {
  180. uni.showToast({
  181. title: '暂无绑定楼盘',
  182. duration: 2000,
  183. icon:"none"
  184. });
  185. return
  186. } else {
  187. let lopan = {
  188. id: data.houseList[0].id,
  189. name: data.houseList[0].propertyName
  190. }
  191. let users=data.user
  192. users.zkProperties=data.houseList
  193. uni.setStorageSync("fendianindex", 0); //写入缓存
  194. uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
  195. uni.setStorageSync("buildingID", lopan); //楼盘id写入缓存
  196. uni.switchTab({
  197. url: '/pages/index/index'
  198. });
  199. }
  200. });
  201. },
  202. }
  203. };
  204. </script>
  205. <style lang="scss">
  206. .head {
  207. width: 750rpx;
  208. height:400rpx;
  209. position: relative;
  210. .text{
  211. width: 100%;
  212. position: absolute;
  213. top: 180rpx;
  214. left: 0rpx;
  215. .text1{
  216. width: 80%;
  217. margin: 0 auto;
  218. }
  219. }
  220. }
  221. .mama {
  222. width: 620rpx;
  223. display: flex;
  224. border-bottom: 1px solid #E1E1E1;
  225. margin: 60rpx auto;
  226. }
  227. .sadsadasdasdsadasd {
  228. font-size: 34rpx;
  229. font-family: PingFangSC-Medium, PingFang SC;
  230. font-weight: 500;
  231. color: #008EF2;
  232. width: 100%;
  233. text-align: center;
  234. padding-top: 340rpx;
  235. }
  236. .mamaz {
  237. width: 50%;
  238. height: 90rpx;
  239. }
  240. .mamay {
  241. width: 50%;
  242. height: 90rpx;
  243. }
  244. .input {
  245. width: 350rpx;
  246. color: #78DFB0;
  247. height: 100%;
  248. line-height: 90rpx;
  249. font-size: 17px;
  250. color: #171717;
  251. }
  252. .sada {
  253. width: 70%;
  254. line-height: 90rpx;
  255. color: #2B6EFF;
  256. text-align: right;
  257. font-size: 35rpx;
  258. margin-left: 100rpx;
  259. display: block;
  260. }
  261. .content {
  262. margin: 0;
  263. padding: 0;
  264. border-top: 1rpx solid #E0E0E0;
  265. }
  266. .login-text {
  267. font-size: 60rpx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. color: rgba(23, 23, 23, 1);
  271. letter-spacing: 8rpx;
  272. margin-left: 75rpx;
  273. font-weight: bold;
  274. }
  275. .login-input {
  276. border-bottom: 1px solid #e1e1e1;
  277. color: #c9cac9;
  278. margin: 98rpx 64rpx 200rpx 75rpx;
  279. font-size: 17px;
  280. }
  281. .login-btn {
  282. margin: 0 auto;
  283. margin-top: 240rpx;
  284. width: 630rpx;
  285. height: 86rpx;
  286. border-radius: 49rpx;
  287. font-size: 17px;
  288. font-weight: bold;
  289. border: none;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. color: #ffffff;
  294. }
  295. .code-login {
  296. display: flex;
  297. justify-content: center;
  298. margin-top: 40rpx;
  299. color: #D6D7D6;
  300. margin-bottom: 200rpx;
  301. font-size: 30rpx;
  302. }
  303. .log-box {
  304. display: flex;
  305. flex-direction: row;
  306. justify-content: center;
  307. align-items: center;
  308. font-size: 28rpx;
  309. color: #bfc0bf;
  310. margin-bottom: 65rpx;
  311. }
  312. .hengx {
  313. margin: 0 20rpx 0 20rpx;
  314. height: 2rpx;
  315. width: 232rpx;
  316. background: #e1e1e1;
  317. }
  318. .wechat {
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. width: 93rpx;
  323. height: 93rpx;
  324. background: rgba(255, 255, 255, 1);
  325. box-shadow: 0px 10rpx 30rpx rgba(120, 223, 176, 0.22);
  326. border-radius: 50%;
  327. margin: 0 auto;
  328. }
  329. .btn-get {
  330. width: 250rpx;
  331. font-size: 17px;
  332. color: #c9cac9;
  333. position: relative;
  334. top: -290rpx;
  335. right: -450rpx;
  336. }
  337. .input-class {
  338. color: #D6D7D6;
  339. font-size: 17px;
  340. letter-spacing: 1rpx;
  341. }
  342. </style>