index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. if(this.firstLoginState){
  146. // 有state要绑定一下用户
  147. await uni.$u.api.firstLogin({ userId , firstLoginState : this.firstLoginState });
  148. uni.reLaunch({
  149. url:"/pages/bindSuccess/index",
  150. success: () => {
  151. uni.$u.toast("绑定成功");
  152. }
  153. });
  154. }else{
  155. uni.$u.toast("授权失败,无法绑定");
  156. }
  157. // #endif
  158. // #ifdef APP-PLUS
  159. uni.switchTab({
  160. url: `/pages/person/index`,
  161. success: () => {
  162. this.$store.dispatch("app/register");
  163. uni.$u.toast("登录成功");
  164. }
  165. })
  166. // #endif
  167. }).catch((res) => {
  168. uni.$u.toast(res);
  169. })
  170. })
  171. },
  172. },
  173. }
  174. </script>
  175. <style lang="scss">
  176. .network_configuration_box {
  177. margin: auto;
  178. .netWrokSet {
  179. display: flex;
  180. align-items: center;
  181. image {
  182. width: 30rpx;
  183. height: 30rpx;
  184. }
  185. .text {
  186. margin-left: 10rpx;
  187. font-size: 26rpx;
  188. }
  189. }
  190. }
  191. .systemLabel_wrap {
  192. display: flex;
  193. align-items: center;
  194. .label {
  195. margin-left: 10rpx;
  196. }
  197. }
  198. .systemCode_wrap {
  199. position: relative;
  200. ::v-deep .uni-select {
  201. border-radius: 100px;
  202. border: 1px solid #dadbde;
  203. height: 40px;
  204. padding: 0px 10px 0px 46px;
  205. &:before {
  206. content: "";
  207. display: block;
  208. width: 16px;
  209. height: 16px;
  210. background-image: url("../../static/login/icon-system.png");
  211. background-size: 16px 16px;
  212. position: absolute;
  213. left: 20px;
  214. top: 50%;
  215. transform: translate(0%, -50%);
  216. }
  217. .uni-select__input-placeholder {
  218. font-size: 14px;
  219. color: rgb(192, 196, 204);
  220. }
  221. }
  222. .system_debt {
  223. ::v-deep .uni-select {
  224. &:before {
  225. background-image: url("../../static/outbound/icon-zycs.png");
  226. }
  227. }
  228. }
  229. .system_debt_ccb {
  230. ::v-deep .uni-select {
  231. &:before {
  232. background-image: url("../../static/outbound/icon-zycs.png");
  233. }
  234. }
  235. }
  236. .system_debt_spdb {
  237. ::v-deep .uni-select {
  238. &:before {
  239. background-image: url("../../static/outbound/icon-zycs.png");
  240. }
  241. }
  242. }
  243. .system_debt_public {
  244. ::v-deep .uni-select {
  245. &:before {
  246. background-image: url("../../static/outbound/icon-zycs.png");
  247. }
  248. }
  249. }
  250. .system_debt_dfkl {
  251. ::v-deep .uni-select {
  252. &:before {
  253. background-image: url("../../static/outbound/icon-zycs.png");
  254. }
  255. }
  256. }
  257. .system_debt_cib {
  258. ::v-deep .uni-select {
  259. &:before {
  260. background-image: url("../../static/outbound/icon-zycs.png");
  261. }
  262. }
  263. }
  264. .system_debt_icbc_h {
  265. ::v-deep .uni-select {
  266. &:before {
  267. background-image: url("../../static/outbound/icon-zycs.png");
  268. }
  269. }
  270. }
  271. .system_debt_tjxt {
  272. ::v-deep .uni-select {
  273. &:before {
  274. background-image: url("../../static/outbound/icon-zycs.png");
  275. }
  276. }
  277. }
  278. // .systemIcon{
  279. // width: 16px;
  280. // height: 16px;
  281. // position: absolute;
  282. // left: 20px;
  283. // top: 50%;
  284. // transform: translate(0%, -50%);
  285. // display: none;
  286. // }
  287. }
  288. .inputFormWrap {
  289. ::v-deep .u-border {
  290. border: 1px solid #dadbde !important;
  291. }
  292. }
  293. .max {
  294. width: 500rpx;
  295. height: 500rpx;
  296. }
  297. page {
  298. background: #fff;
  299. }
  300. .loginway {
  301. display: flex;
  302. flex-direction: column;
  303. height: 100vh;
  304. .navigation {
  305. background-color: #108cff;
  306. width: 100%;
  307. height: 120rpx;
  308. }
  309. .loginimg {
  310. display: block;
  311. width: 100%;
  312. height: 100%;
  313. }
  314. .input_wrap {
  315. padding: 20rpx 30rpx;
  316. }
  317. }
  318. </style>