index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. //import * as WxJsApi from '@/utils/wxJsApi.js'
  2. import * as API from '@/apis/login.js'
  3. import ResumeAuth from '@/components/job/ResumeAuth.vue'
  4. import {
  5. checkPhone
  6. } from '@/utils'
  7. export default {
  8. data() {
  9. return {
  10. test:process.env.NODE_ENV === "development",
  11. phone:"",
  12. isReady:false,
  13. vcode:"",
  14. error:"",
  15. second:"",
  16. password:"",
  17. maxlength:6,
  18. value:"",
  19. show:"",
  20. isSendMsgIng: false,
  21. sendMsgSecond: 60*2,
  22. tel:'',
  23. tab:0,
  24. message:"",
  25. backUrl:"",
  26. form:"",
  27. readme:true,
  28. isReady:false,
  29. auth:false,
  30. authData:{
  31. }
  32. }
  33. },
  34. components: {
  35. ResumeAuth
  36. },
  37. onLoad(op){
  38. this.form=op.form;
  39. if(this.form=="hr"){
  40. this.tab=2
  41. }
  42. if(this.form=="job"){
  43. this.tab=1
  44. }
  45. this.message=op.message;
  46. this.backUrl=op.back;
  47. console.log(op)
  48. },
  49. computed: {
  50. inputStyle() {
  51. let style = {};
  52. if(this.tel) {
  53. style.color = "#fff";
  54. style.backgroundColor = this.$u.color['primary'];
  55. }
  56. return style;
  57. }
  58. },
  59. methods: {
  60. finish(e){
  61. if(!this.carhelp.getOpenId()){
  62. uni.showToast({
  63. title:"请使用“微信”访问本系统登录"
  64. })
  65. return
  66. }
  67. uni.showLoading({
  68. title:"加载中",mask:true,
  69. })
  70. API.validateCode({
  71. verifyCode: e,
  72. telephone:this.tel,
  73. openId:this.carhelp.getOpenId(),
  74. form:this.form
  75. }).then((response) => {
  76. this.loginOk(response);
  77. }).catch(error => {
  78. uni.showToast({
  79. title:error,
  80. icon:"none"
  81. })
  82. })
  83. },
  84. showphone(phone){
  85. if(!phone){
  86. return "";
  87. }
  88. if(phone.length!=11){
  89. return "";
  90. }
  91. return phone.substring(0,3)+'****'+phone.substring(8);
  92. },
  93. login2(){
  94. if (!this.readme) {
  95. uni.showToast({
  96. title: "请阅读并同意《用户协议》《隐私政策》",
  97. })
  98. }
  99. var time= this.carhelp.get("getvcodetime");
  100. if(time){
  101. var nowtime= new Date().getTime()
  102. var differ=(nowtime-time)/1000
  103. if(differ<2*60){
  104. this.sendMsgSecond=2*60 - parseInt(differ)
  105. this.tab=4;
  106. this.msgTimeInterval();
  107. }
  108. }
  109. if (!this.isSendMsgIng) {
  110. var checkPhoneResult = checkPhone(this.tel);
  111. if(checkPhoneResult!==true){
  112. uni.showToast({
  113. title: checkPhoneResult,
  114. })
  115. return;
  116. }else{
  117. uni.showLoading({
  118. title:"加载中",mask:true,
  119. })
  120. API.getVerifyCode(this.tel).then((response) => {
  121. this.tab=4;
  122. uni.hideLoading();
  123. this.carhelp.set("getvcodetime",new Date().getTime());
  124. this.tab=4;
  125. if(!""){ //response.message
  126. //倒计时
  127. this.msgTimeInterval();
  128. }else{
  129. uni.showToast({
  130. title:"您的验证码已经发送[5分钟有效],请勿重复点击"
  131. })
  132. }
  133. }).catch(error => {
  134. uni.showToast({
  135. title:error,
  136. icon:"none"
  137. })
  138. })
  139. }
  140. }
  141. },
  142. //倒计时
  143. msgTimeInterval() {
  144. this.isSendMsgIng = true;
  145. var time = this.sendMsgSecond;
  146. var _this = this;
  147. this.timer = setInterval(() => {
  148. if (time > 0) {
  149. _this.sendMsgSecond = time--;
  150. } else {
  151. _this.isSendMsgIng = false;
  152. _this.sendMsgSecond = 2*60;
  153. clearInterval(_this.timer)
  154. }
  155. }, 1000)
  156. },
  157. login3(){
  158. if(!this.carhelp.getOpenId()){
  159. uni.showToast({
  160. title:"请使用“微信”访问本系统登录"
  161. })
  162. return
  163. }
  164. //var checkPhoneResult = checkPhone(this.tel);
  165. // if(checkPhoneResult!== true){
  166. // uni.showToast({
  167. // title: checkPhoneResult,
  168. // })
  169. // return;
  170. // }
  171. if(!this.tel){
  172. uni.showToast({
  173. title: "请输入账号",
  174. })
  175. return;
  176. }
  177. if(!this.password){
  178. uni.showToast({
  179. title: "请输入密码",
  180. })
  181. return;
  182. }
  183. uni.showLoading({
  184. title:"加载中",mask:true,
  185. })
  186. API.passwordLogin({
  187. phone:this.tel,
  188. password:this.password,
  189. openId:this.carhelp.getOpenId(),
  190. form:this.form
  191. }).then((response) => {
  192. this.loginOk(response)
  193. }).catch(error => {
  194. uni.showToast({
  195. title:error,
  196. icon:"none"
  197. })
  198. })
  199. },
  200. loginOk(response){
  201. var token = response ? response.data.token : '';
  202. this.carhelp.setToken(token);
  203. if("job"==this.form){
  204. this.carhelp.setPersonInfo(response.data.jobUser );
  205. if(["1","2"].indexOf(response.data.jobUser.isAuthentication)>-1){
  206. this.loginBack();
  207. }else{
  208. uni.hideLoading();
  209. this.auth=true;
  210. }
  211. }
  212. if("hr"==this.form){
  213. this.carhelp.setPersonInfo(response.data.sysUser );
  214. this.loginBack();
  215. }
  216. },
  217. loginBack(){
  218. if(this.backUrl){
  219. window.location.href="#"+this.backUrl.split(",").find(function(item){
  220. return item.indexOf("pages/login/")==-1
  221. });
  222. }else{
  223. this.gotoUrl("pages/"+this.form+"/index/index")
  224. }
  225. },
  226. login(){
  227. if(!this.carhelp.getOpenId()){
  228. uni.showToast({
  229. title:"请使用“微信”访问本系统登录"
  230. })
  231. return
  232. }
  233. if(!this.readme){
  234. uni.showToast({
  235. title:"请阅读并同意《用户协议》《隐私政策》",
  236. icon:"none"
  237. })
  238. }else{
  239. uni.showLoading({
  240. title: '加载中'
  241. });
  242. API.wechatLogin({
  243. openId:this.carhelp.getOpenId(),
  244. form:this.form
  245. }).then((response) => {
  246. this.loginOk(response)
  247. }).catch(error => {
  248. uni.showToast({
  249. title:error,
  250. icon:"none"
  251. })
  252. })
  253. }
  254. }
  255. },onReady(){
  256. if(this.message){
  257. uni.showToast({
  258. title:this.message.split(",")[0],
  259. icon:"none"
  260. })
  261. }
  262. if(!this.carhelp.getOpenId()){
  263. uni.showToast({
  264. title:"请使用“微信”访问本系统登录"
  265. })
  266. }
  267. this.isReady=true;
  268. },onShow(){
  269. if(this.isReady){
  270. }
  271. },
  272. }