index.vue 9.1 KB

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