index.js 5.7 KB

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