index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view>
  3. <view class="loginway">
  4. <div class="navigation"></div>
  5. <image class="loginimg" mode="widthFix" src="/static/login/logo_word.png"></image>
  6. <view class="input_wrap">
  7. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm">
  8. <u-form-item label="" prop="username" class="inputFormWrap">
  9. <u--input shape="circle" clearable prefixIcon="/static/login/icon-account.png"
  10. :prefixIconStyle="prefixIconStyle" v-model="form.username" placeholder="请输入账号"></u--input>
  11. </u-form-item>
  12. <u-form-item label="" prop="password" class="inputFormWrap">
  13. <u--input shape="circle" clearable password prefixIcon="/static/login/icon-password.png"
  14. :prefixIconStyle="prefixIconStyle" v-model="form.password" placeholder="请输入密码"></u--input>
  15. </u-form-item>
  16. <u-form-item label="" prop="" class="inputFormWrap">
  17. <u-checkbox-group v-model="checkboxs" placement="column" @change="changeRemember">
  18. <u-checkbox :label="'记住密码'" :name="'remember'"></u-checkbox>
  19. </u-checkbox-group>
  20. </u-form-item>
  21. <u-form-item>
  22. <u-button type="primary" text="登录" shape="circle" @click="handleLogin"></u-button>
  23. </u-form-item>
  24. <!-- <u-form-item>
  25. <view class="network_configuration_box">
  26. <view class="netWrokSet" @click="handleToConfiguration">
  27. <image src="/static/login/network.png" mode=""></image>
  28. <text class="text">呼叫中心配置</text>
  29. </view>
  30. </view>
  31. </u-form-item> -->
  32. </u--form>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. firstLoginState : "",
  42. // systemList,
  43. prefixIconStyle: {
  44. width: "16px",
  45. height: "16px",
  46. marginRight: "4px",
  47. marginLeft: "10px"
  48. },
  49. form: {
  50. // password: "Huilong@#$999",
  51. password: "",
  52. systemCode: "system_crm",
  53. username: "",
  54. clientFlag: "2",
  55. // username: "huihui",
  56. code: "996007qa.code",
  57. uuid: "123"
  58. },
  59. checkboxs: [],
  60. rules: {
  61. username: {
  62. type: 'string',
  63. required: true,
  64. message: '请输入账号',
  65. trigger: []
  66. },
  67. password: {
  68. type: 'string',
  69. required: true,
  70. message: '请输入密码',
  71. trigger: []
  72. }
  73. },
  74. // mac: getMacAddress(),
  75. };
  76. },
  77. computed: {
  78. systemList() {
  79. return this.$store.state.user.systemList;
  80. },
  81. remember: {
  82. get() {
  83. return this.checkboxs.length > 0
  84. },
  85. set(value) {
  86. this.checkboxs = value ? ['remember'] : [];
  87. }
  88. }
  89. },
  90. mounted() {
  91. // 触发水印隐藏
  92. this.systemChange(this.form.systemCode);
  93. this.getUserByCache();
  94. },
  95. onLoad(option){
  96. const { shiYuWxLogin } = option;
  97. this.firstLoginState = shiYuWxLogin;
  98. },
  99. methods: {
  100. changeRemember(value){
  101. if (value.length > 0) {
  102. uni.setStorageSync('username', this.form.username);
  103. uni.setStorageSync('password', this.form.password);
  104. } else {
  105. uni.removeStorageSync('username');
  106. uni.removeStorageSync('password');
  107. }
  108. },
  109. getUserByCache() {
  110. const savedUsername = uni.getStorageSync('username');
  111. const savedPassword = uni.getStorageSync('password');
  112. if (savedUsername && savedPassword) {
  113. this.form.username = savedUsername;
  114. this.form.password = savedPassword;
  115. this.remember = true;
  116. }
  117. },
  118. handleToConfiguration() {
  119. uni.navigateTo({
  120. url: "/pages/configuration/index"
  121. })
  122. },
  123. systemChange(e) {
  124. if (!e) return;
  125. uni.$u.api.getAppSystemList().then((res) => {
  126. const systemCodeList = res.data;
  127. this.$store.dispatch("user/setSystemlist", systemCodeList);
  128. const system = this.systemList.find(v => v.value === e);
  129. this.$store.commit("user/SET_SYSTEM", system);
  130. }).catch((e) => {
  131. uni.$u.toast("服务网络不通");
  132. })
  133. },
  134. handleLogin() {
  135. this.$refs.uForm.validate().then(() => {
  136. if (this.remember) {
  137. uni.setStorageSync('username', this.form.username);
  138. uni.setStorageSync('password', this.form.password);
  139. } else {
  140. uni.removeStorageSync('username');
  141. uni.removeStorageSync('password');
  142. }
  143. this.$store.dispatch("user/login", this.form).then(async (userId) => {
  144. // #ifdef H5
  145. uni.switchTab({
  146. url: `/pages/person/index`,
  147. success: () => {
  148. this.$store.dispatch("app/register");
  149. uni.$u.toast("登录成功");
  150. }
  151. })
  152. // if(this.firstLoginState){
  153. // // 有state要绑定一下用户
  154. // await uni.$u.api.firstLogin({ userId , firstLoginState : this.firstLoginState });
  155. // uni.reLaunch({
  156. // url:"/pages/bindSuccess/index",
  157. // success: () => {
  158. // uni.$u.toast("绑定成功");
  159. // }
  160. // });
  161. // }else{
  162. // uni.$u.toast("授权失败,无法绑定");
  163. // }
  164. // #endif
  165. // #ifdef APP-PLUS
  166. uni.switchTab({
  167. url: `/pages/person/index`,
  168. success: () => {
  169. this.$store.dispatch("app/register");
  170. uni.$u.toast("登录成功");
  171. }
  172. })
  173. // #endif
  174. }).catch((res) => {
  175. uni.$u.toast(res);
  176. })
  177. })
  178. },
  179. },
  180. }
  181. </script>
  182. <style lang="scss">
  183. .network_configuration_box {
  184. margin: auto;
  185. .netWrokSet {
  186. display: flex;
  187. align-items: center;
  188. image {
  189. width: 30rpx;
  190. height: 30rpx;
  191. }
  192. .text {
  193. margin-left: 10rpx;
  194. font-size: 26rpx;
  195. }
  196. }
  197. }
  198. .systemLabel_wrap {
  199. display: flex;
  200. align-items: center;
  201. .label {
  202. margin-left: 10rpx;
  203. }
  204. }
  205. .systemCode_wrap {
  206. position: relative;
  207. ::v-deep .uni-select {
  208. border-radius: 100px;
  209. border: 1px solid #dadbde;
  210. height: 40px;
  211. padding: 0px 10px 0px 46px;
  212. &:before {
  213. content: "";
  214. display: block;
  215. width: 16px;
  216. height: 16px;
  217. background-image: url("../../static/login/icon-system.png");
  218. background-size: 16px 16px;
  219. position: absolute;
  220. left: 20px;
  221. top: 50%;
  222. transform: translate(0%, -50%);
  223. }
  224. .uni-select__input-placeholder {
  225. font-size: 14px;
  226. color: rgb(192, 196, 204);
  227. }
  228. }
  229. .system_debt {
  230. ::v-deep .uni-select {
  231. &:before {
  232. background-image: url("../../static/outbound/icon-zycs.png");
  233. }
  234. }
  235. }
  236. .system_debt_ccb {
  237. ::v-deep .uni-select {
  238. &:before {
  239. background-image: url("../../static/outbound/icon-zycs.png");
  240. }
  241. }
  242. }
  243. .system_debt_spdb {
  244. ::v-deep .uni-select {
  245. &:before {
  246. background-image: url("../../static/outbound/icon-zycs.png");
  247. }
  248. }
  249. }
  250. .system_debt_public {
  251. ::v-deep .uni-select {
  252. &:before {
  253. background-image: url("../../static/outbound/icon-zycs.png");
  254. }
  255. }
  256. }
  257. .system_debt_dfkl {
  258. ::v-deep .uni-select {
  259. &:before {
  260. background-image: url("../../static/outbound/icon-zycs.png");
  261. }
  262. }
  263. }
  264. .system_debt_cib {
  265. ::v-deep .uni-select {
  266. &:before {
  267. background-image: url("../../static/outbound/icon-zycs.png");
  268. }
  269. }
  270. }
  271. .system_debt_icbc_h {
  272. ::v-deep .uni-select {
  273. &:before {
  274. background-image: url("../../static/outbound/icon-zycs.png");
  275. }
  276. }
  277. }
  278. .system_debt_tjxt {
  279. ::v-deep .uni-select {
  280. &:before {
  281. background-image: url("../../static/outbound/icon-zycs.png");
  282. }
  283. }
  284. }
  285. // .systemIcon{
  286. // width: 16px;
  287. // height: 16px;
  288. // position: absolute;
  289. // left: 20px;
  290. // top: 50%;
  291. // transform: translate(0%, -50%);
  292. // display: none;
  293. // }
  294. }
  295. .inputFormWrap {
  296. ::v-deep .u-border {
  297. border: 1px solid #dadbde !important;
  298. }
  299. }
  300. .max {
  301. width: 500rpx;
  302. height: 500rpx;
  303. }
  304. page {
  305. background: #fff;
  306. }
  307. .loginway {
  308. display: flex;
  309. flex-direction: column;
  310. height: 100vh;
  311. .navigation {
  312. background-color: #108cff;
  313. width: 100%;
  314. height: 120rpx;
  315. }
  316. .loginimg {
  317. display: block;
  318. width: 100%;
  319. height: 100%;
  320. }
  321. .input_wrap {
  322. padding: 20rpx 30rpx;
  323. }
  324. }
  325. </style>