sign.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <image :src="login_top" mode="widthFix" class="width100" style="margin-top: -40upx;"></image>
  5. </view>
  6. <!-- <view class="logo-content align-center justify-center flex">
  7. <image :src="login_top" mode="widthFix" class="width100" style="margin-top: -80upx;"></image> -->
  8. <!-- <image :src="description" mode="widthFix" class="img_top"
  9. style="position: absolute;right: 0;top: 120upx; z-index: 999;width: 346upx;height: 330upx;"></image> -->
  10. <!-- </view> -->
  11. <!-- 账号密码框 -->
  12. <view class="login-form-content">
  13. <text style="color: #98AEAF;">角色</text>
  14. <view style="display: flex;margin: 15px auto;" class="u-demo-block__content">
  15. <u-checkbox-group placement="row" v-model="checkboxValue1" @change="checkboxChange"
  16. activeColor="#4CB2B6">
  17. <u-checkbox :customStyle="{margin:'0 0 8px 15px'}" v-for="(item, index) in checkboxList1"
  18. :key="index" :label="item.name" :name="item.name">
  19. </u-checkbox>
  20. </u-checkbox-group>
  21. </view>
  22. <text style="color: #98AEAF;">单位</text>
  23. <view class="u-demo-block__content" style="margin: 15px auto;">
  24. <view class="u-page__tag-item">
  25. <u-search @search="searchUnit" @custom="searchUnit" showAction placeholder="请搜索单位名称进行选择"
  26. v-model="loginForm.unit">
  27. </u-search>
  28. </view>
  29. </view>
  30. <text style="color: #98AEAF;">真实姓名</text>
  31. <view class="input-item flex align-center">
  32. <view class="iconfont icon-user icon"></view>
  33. <input v-model="loginForm.nickname" class="input" type="text" placeholder="请输入姓名" maxlength="30" />
  34. </view>
  35. <text style="color: #98AEAF;">账号</text>
  36. <view class="input-item flex align-center">
  37. <view class="iconfont icon-user icon"></view>
  38. <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
  39. </view>
  40. <text style="color: #98AEAF;">手机号</text>
  41. <view class="input-item flex align-center">
  42. <view class="iconfont icon-user icon"></view>
  43. <input v-model="loginForm.mobile" class="input" type="text" placeholder="请输入手机号" maxlength="30" />
  44. </view>
  45. <text style="color: #98AEAF;">密码</text>
  46. <view class="input-item flex align-center">
  47. <view class="iconfont icon-password icon"></view>
  48. <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
  49. </view>
  50. <text style="color: #98AEAF;">再次确认密码</text>
  51. <view class="input-item flex align-center">
  52. <view class="iconfont icon-password icon"></view>
  53. <input v-model="loginForm.passwords" type="password" class="input" placeholder="请确认密码" maxlength="20" />
  54. </view>
  55. <Verify @success="pwdLogin" :mode="'pop'" :captchaType="'blockPuzzle'"
  56. :imgSize="{ width: '330px', height: '155px' }" ref="verify"></Verify>
  57. <!-- 注册按钮 -->
  58. <view class="login-form-content2">
  59. <button @click="handleLogin" class="login-btn cu-btn block lg">确认注册</button>
  60. </view>
  61. </view>
  62. <u-picker :show="shows" :columns="columns1" @cancel="cancel" @confirm="confirm"></u-picker>
  63. <!-- <view class="xieyi text-center">
  64. <text class="text-grey1">登录即代表同意</text>
  65. <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
  66. <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
  67. </view> -->
  68. </view>
  69. </template>
  70. <script>
  71. import {
  72. addUser
  73. } from '@/api/staff_info'; //添加用户
  74. import {
  75. wxbind
  76. } from '@/api/login.js'; //微信绑定
  77. // #ifdef H5
  78. import Verify from '@/pagesA/components/verifition/Verify';
  79. // #endif
  80. import {
  81. getDepartUnit
  82. } from '@/api/login.js'
  83. import config from '@/config'
  84. const baseUrlImg=config.baseUrlImg
  85. export default {
  86. name: 'Login',
  87. components: {
  88. // #ifdef H5
  89. Verify
  90. // #endif
  91. },
  92. data() {
  93. return {
  94. shows: false, //单位搜索后的下拉框
  95. columns1: [
  96. ['未搜索到所属单位']
  97. ],
  98. searchData: [],
  99. checkboxValue1: [],
  100. // 基本案列数据
  101. checkboxList1: [{
  102. name: '管理者',
  103. disabled: false,
  104. },
  105. {
  106. name: '执行者',
  107. disabled: false
  108. }
  109. ],
  110. description: `${baseUrlImg}/login/description.png`, //登录页面顶部装饰图
  111. login_top:`${baseUrlImg}/login/login_top.png`, //登录页面顶部
  112. wx_login:`${baseUrlImg}/login/wx_login.png`, //登录按钮
  113. captchaEnabled: true, // 验证码开关 TODO 芋艿:需要抽到配置里
  114. canIUseGetUserProfile: false, // 用来判断用哪个登录
  115. globalConfig: getApp().globalData.config,
  116. userInfo: '',
  117. loginForm: {
  118. username: '',
  119. password: '',
  120. captchaVerification: '',
  121. socialCode: '',
  122. socialType: 34,
  123. socialState: '9b2ffbc1-7425-4155-9894-9d5c08541d62',
  124. orgId: '',
  125. unit: '',
  126. mobile: '',
  127. nickname: '', //真实姓名
  128. appRoleId: [],
  129. userId: '',
  130. realName: ''
  131. }
  132. };
  133. },
  134. onLoad(option) {
  135. this.loginForm.socialCode = option.socialCode
  136. //如果手机支持最新版登录就用新方法
  137. if (uni.getUserProfile) {
  138. this.canIUseGetUserProfile = true;
  139. }
  140. },
  141. methods: {
  142. checkboxChange(n) { //角色选择
  143. console.log(n, 'nnnnn');
  144. n.map(i => {
  145. if (i == '管理者') {
  146. this.loginForm.appRoleId.push('1')
  147. } else if (i == '执行者') {
  148. this.loginForm.appRoleId.push('2')
  149. } else {
  150. const arr = ["1", "2"]
  151. this.loginForm.appRoleId = arr
  152. }
  153. })
  154. },
  155. confirm(e) { //搜索单位确定
  156. console.log(e, 'eeeeeeeeee');
  157. this.loginForm.unit = e.value[0]
  158. this.searchData.map(i => {
  159. if (i.orgName == e.value[0] && i.orgName !== '未搜索到所属单位') {
  160. console.log(i.id, 'i.id');
  161. this.loginForm.orgId = i.id
  162. }
  163. })
  164. this.shows = false
  165. },
  166. cancel() {
  167. this.shows = false
  168. },
  169. //搜索单位
  170. searchUnit() {
  171. const org = this.loginForm.unit;
  172. getDepartUnit({
  173. orgName: org
  174. }).then(response => {
  175. console.log(response);
  176. // if (response.code == 0 && response.data.length == 0) {
  177. // this.$model.alert('暂无单位')
  178. // } else
  179. if (response.code == 0) {
  180. this.searchData = response.data
  181. this.shows = true
  182. response.data.map(i => {
  183. this.columns1[0].push(i.orgName)
  184. })
  185. console.log(this.columns1);
  186. }
  187. });
  188. },
  189. // 微信登录模块
  190. //老版登录接口(不再弹出登录弹框)
  191. bindGetUserInfo(e) {
  192. if (e.detail.userInfo) {
  193. //业务逻辑
  194. }
  195. },
  196. // 弹出登录弹框(新版)
  197. getUserProfiles() {},
  198. // 登录方法
  199. handleLogin(params) {
  200. if (this.loginForm.username === '') {
  201. this.$modal.msgError('请输入您的账号');
  202. } else if (this.loginForm.password === '') {
  203. this.$modal.msgError('请输入您的密码');
  204. } else if (this.loginForm.passwords === '') {
  205. this.$modal.msgError('请再次确认密码');
  206. } else if (this.loginForm.realname === '') {
  207. this.$modal.msgError('请输入您的真实姓名');
  208. } else if (this.loginForm.password != this.loginForm.passwords) {
  209. this.$modal.msgError('密码输入不一致,请重新输入');
  210. } else {
  211. this.pwdLogin({});
  212. }
  213. },
  214. // 密码登录
  215. async pwdLogin(captchaParams) {
  216. this.loginForm.appRoleId = [...new Set(this.loginForm.appRoleId)]
  217. console.log(this.loginForm, 'formData');
  218. addUser(JSON.stringify(this.loginForm)).then(reponse => {
  219. if (reponse.code == 0) {
  220. this.loginForm.userId = reponse.data
  221. this.loginForm.realName = this.loginForm.nickname
  222. console.log(this.loginForm.userId, '123456123456');
  223. wxbind(this.loginForm).then(res => {
  224. console.log(res, this.loginForm, '222222222222');
  225. // 注册成功后 不用路由
  226. // this.$modal.loading('登录中,请耐心等待...');
  227. // 执行登录
  228. // console.log(this.loginForm, 'this.loginForm');
  229. this.loginForm.captchaVerification = captchaParams.captchaVerification;
  230. this.$store.dispatch('Login', this.loginForm).then(() => {
  231. this.$modal.closeLoading(); //关闭遮罩层
  232. this.loginSuccess();
  233. });
  234. })
  235. }
  236. })
  237. },
  238. // 登录成功后,处理函数
  239. loginSuccess(result) {
  240. this.$store.dispatch('loadDictDatas');
  241. // 设置用户信息
  242. this.$store.dispatch('GetInfo').then(res => {
  243. this.$tab.reLaunch('/pages/index');
  244. // this.$tab.reLaunch('/pages/work/index');
  245. });
  246. }
  247. }
  248. };
  249. </script>
  250. <style lang="scss">
  251. page {
  252. background-color: #ffffff;
  253. }
  254. .normal-login-container {
  255. width: 100%;
  256. .logo-content {
  257. width: 100%;
  258. font-size: 21px;
  259. text-align: center;
  260. image {
  261. border-radius: 4px;
  262. }
  263. .title {
  264. margin-left: 10px;
  265. }
  266. }
  267. .login-form-content {
  268. text-align: left;
  269. margin: 0 0 0 40rpx;
  270. margin-top: 0;
  271. width: 90%;
  272. .input-item {
  273. margin: 15px auto;
  274. background-color: #f5f9f7;
  275. height: 35px;
  276. border-radius: 20px;
  277. .icon {
  278. font-size: 38rpx;
  279. margin-left: 10px;
  280. color: #999;
  281. }
  282. .input {
  283. width: 100%;
  284. font-size: 14px;
  285. line-height: 18px;
  286. text-align: left;
  287. padding-left: 15px;
  288. }
  289. }
  290. /deep/ .u-search__content,
  291. /deep/.u-search__content__input {
  292. background-color: rgb(245, 249, 247) !important;
  293. }
  294. .login-btn {
  295. margin-top: 30px;
  296. height: 80upx;
  297. border-radius: 356upx;
  298. background-color: #4cb2b6;
  299. color: #ffffff;
  300. box-shadow: 0px 2upx 6upx 0px rgba(123, 123, 123, 0.3);
  301. }
  302. .xieyi {
  303. color: #333;
  304. margin-top: 20px;
  305. }
  306. }
  307. .easyinput {
  308. width: 100%;
  309. }
  310. }
  311. // 登录按钮
  312. .login-form-content2 {
  313. text-align: center;
  314. margin: 10px auto;
  315. margin-top: 0%;
  316. margin-bottom: 30rpx;
  317. width: 75%;
  318. .wx_login {
  319. height: 100upx;
  320. width: 450upx;
  321. // font-size: 16px;
  322. // padding-top: 2px;
  323. // background-color: #f5f7f9;
  324. // color: #728f90;
  325. // border-radius: 356upx;
  326. // box-shadow: 0px 2upx 6upx 0px rgba(123, 123, 123, 0.3);
  327. }
  328. .or {
  329. font-size: 20upx;
  330. margin: 20upx;
  331. color: #98aeaf;
  332. }
  333. }
  334. .login-code-img {
  335. height: 45px;
  336. }
  337. .wx_icon {
  338. position: relative;
  339. margin-top: 27%;
  340. margin-left: 42%;
  341. }
  342. </style>