login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="wrap">
  3. <view class="h1">
  4. 员工们好!
  5. </view>
  6. <view class="h2">
  7. 欢迎使用员工APP
  8. </view>
  9. <view class="">
  10. <form @submit="formSubmit" @reset="formReset">
  11. <view class="uni-form-item uni-column">
  12. <view class="userName">
  13. <u-input v-model="value" type="number" :border='false' placeholder="请输入手机号码" />
  14. </view>
  15. <view class="uni-btn-v">
  16. <!-- <button form-type="submit">通过手机号登录</button> -->
  17. <u-button type="success" shape="circle" form-type="submit">通过手机号登录</u-button>
  18. <!-- <button type="default" form-type="reset">重置</button> -->
  19. </view>
  20. </view>
  21. </form>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. value: ""
  30. }
  31. },
  32. onBackPress(event) { //监听页面返回
  33. console.log(event)
  34. return true
  35. },
  36. methods: {
  37. async formSubmit() {
  38. uni.showLoading({
  39. title: '登录中...'
  40. });
  41. const res = await this.$myRequest({
  42. url: '/api/api_gateway?method=back_source.production.operator_login',
  43. data: {
  44. mobile: this.value,
  45. }
  46. })
  47. console.log(res);
  48. uni.hideLoading();
  49. let session_key = res.session_key;
  50. uni.setStorageSync('session_key', session_key);
  51. uni.setStorageSync('is_login', 'true');
  52. uni.setStorageSync('user_name', this.value);
  53. //传给后端cid
  54. let pinf = plus.push.getClientInfo();
  55. let cid = pinf && pinf.clientid || ''; //客户端标识
  56. plus.push.getClientInfoAsync((info) => {
  57. cid = info.clientid;
  58. }, err => {});
  59. console.log(pinf)
  60. console.log(cid, 9999)
  61. console.log('cid', this.$store.state.cid);
  62. const res2 = await this.$myRequest({
  63. url: '/api/api_gateway?method=back_source.apppush.set_app_clientid',
  64. data: {
  65. client_id: cid,
  66. }
  67. })
  68. uni.redirectTo({
  69. url: '../index/index',
  70. fail: () => {
  71. console.log(111)
  72. },
  73. success: () => {
  74. console.log(222)
  75. }
  76. });
  77. },
  78. async postCid() {
  79. const res = await this.$myRequest({
  80. url: '/api/api_gateway?method=back_source.apppush.set_app_clientid',
  81. data: {
  82. client_id: this.$store.state.cid,
  83. }
  84. })
  85. console.log(res)
  86. },
  87. formReset() {},
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. .wrap {
  93. padding: 200rpx 40rpx;
  94. .h1 {
  95. font-size: 60rpx;
  96. font-weight: 800;
  97. line-height: 100rpx;
  98. }
  99. .h2 {
  100. font-size: 50rpx;
  101. font-weight: 600;
  102. line-height: 90rpx;
  103. }
  104. .userName {
  105. margin: 50rpx 0;
  106. border-bottom: 1px solid #ddd;
  107. }
  108. }
  109. </style>