ningmei-login-box.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view>
  3. <!-- 宁煤信息平台登录框 -->
  4. <uni-popup ref="popup" type="center" @maskClick="maskClick">
  5. <view class="login_box">
  6. <view class="input_box">
  7. <view class="label">工号:</view>
  8. <view class="box">
  9. {{staff_num}}
  10. </view>
  11. </view>
  12. <view class="input_box">
  13. <view class="label">登录密码(宁煤信息平台):</view>
  14. <view class="box">
  15. <input type="password" v-model="password" />
  16. </view>
  17. </view>
  18. <view class="btn" @click="login()">确认</view>
  19. </view>
  20. </uni-popup>
  21. </view>
  22. </template>
  23. <script>
  24. import time from "@/common/time.js"
  25. export default {
  26. name:"ningmei_login_box",
  27. data() {
  28. return {
  29. staff_num: "",
  30. password: "",
  31. url: "",
  32. app_id: "",
  33. gps: "",
  34. deviceID: "",
  35. phoneType: ""
  36. };
  37. },
  38. mounted() {
  39. this.staff_num = uni.getStorageSync('user').staff_num
  40. },
  41. methods:{
  42. maskClick() {
  43. this.password = ""
  44. },
  45. login() {
  46. // #ifdef APP-PLUS
  47. if (this.password == '') {
  48. uni.showToast({
  49. icon: "none",
  50. title: "密码不能为空!"
  51. })
  52. return
  53. }
  54. this.$refs.popup.close()
  55. // 获取gps
  56. uni.getLocation({
  57. type: 'wgs84',
  58. success: (res) => {
  59. console.log('当前位置的经度:' + res.longitude);
  60. console.log('当前位置的纬度:' + res.latitude);
  61. this.gps = res.longitude + ',' + res.latitude
  62. // 获取设备信息
  63. plus.device.getInfo({
  64. success: (e) => {
  65. console.log(JSON.stringify(e.uuid));
  66. console.log(plus.device.model)
  67. this.deviceID = JSON.stringify(e.uuid)
  68. this.phoneType = plus.device.model
  69. uni.request({
  70. method: "POST",
  71. url: "http://mtyyxs.shnxmyjt.com:33300/api/OAuth/Login",
  72. header: {
  73. 'Content-Type': 'application/json;charset=UTF-8',
  74. 'caller': 'UnifiedPortal'
  75. },
  76. data: {
  77. phoneType: this.phoneType,
  78. password: this.password,
  79. gps: this.gps,
  80. userID: this.staff_num,
  81. resolvingPower: "851*393",
  82. deviceID: this.deviceID,
  83. ip: "112312313"
  84. },
  85. success: (res) => {
  86. console.log(this.password)
  87. console.log(res)
  88. if (res.data.code = '11002') {
  89. uni.showToast({
  90. icon: "none",
  91. title: res.data.msg
  92. })
  93. if (res.data.data.length > 20) {
  94. uni.setStorageSync('ningmei_token', res
  95. .data.data)
  96. uni.setStorageSync(
  97. 'ningmei_token_time',
  98. new Date().format("yyyy-MM-dd")
  99. )
  100. uni.navigateTo({
  101. url: "../../index/ningMeiXinXiPingTai/ningMeiXinXiPingTai",
  102. success: (res) => {
  103. // 通过eventChannel向被打开页面传送数据
  104. res.eventChannel
  105. .emit(
  106. 'acceptDataFromOpenerPage', {
  107. data: this
  108. .url
  109. })
  110. }
  111. })
  112. }
  113. }
  114. }
  115. })
  116. }
  117. });
  118. }
  119. })
  120. // #endif
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .login_box {
  127. width: 500rpx;
  128. padding: 30rpx 50rpx;
  129. border-radius: 20rpx;
  130. margin: 0 auto;
  131. background-color: #FFFFFF;
  132. .input_box {
  133. margin-bottom: 30rpx;
  134. .label {
  135. color: #6C6F74;
  136. margin-bottom: 20rpx;
  137. }
  138. .box {
  139. background: #FFFFFF;
  140. border-radius: 8rpx;
  141. border: 2rpx solid #E9EBF2;
  142. box-sizing: border-box;
  143. padding: 20rpx 25rpx;
  144. }
  145. }
  146. .btn {
  147. width: 500rpx;
  148. margin: 0 auto;
  149. border-radius: 8rpx;
  150. background-color: #009FE8;
  151. line-height: 90rpx;
  152. color: #FFFFFF;
  153. text-align: center;
  154. }
  155. }
  156. </style>