t-i-ice.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="content">
  3. <view class="nav">
  4. <view class="item" v-for="(item,index) in iceList" :key="index" @click="go_link(item)">
  5. <view class="icon">
  6. <image :src="item.thumb" mode=""></image>
  7. </view>
  8. <view class="name">{{item.title}}</view>
  9. </view>
  10. </view>
  11. <!-- 宁煤信息平台登录框 -->
  12. <uni-popup ref="popup" type="center" @maskClick="maskClick">
  13. <view class="login_box">
  14. <view class="input_box">
  15. <view class="label">工号:</view>
  16. <view class="box">
  17. {{staff_num}}
  18. </view>
  19. </view>
  20. <view class="input_box">
  21. <view class="label">登录密码(宁煤信息平台):</view>
  22. <view class="box">
  23. <input type="password" v-model="password" />
  24. </view>
  25. </view>
  26. <view class="btn" @click="login()">确认</view>
  27. </view>
  28. </uni-popup>
  29. </view>
  30. </template>
  31. <script>
  32. import time from "@/common/time.js"
  33. import {diffTime} from "@/common/time.js"
  34. import {goToLink} from "@/common/common.js"
  35. export default {
  36. name: "t-i-ice",
  37. props: [
  38. "iceList",
  39. "mine_code"
  40. ],
  41. data() {
  42. return {
  43. staff_num: "",
  44. password: "",
  45. url: "",
  46. app_id: "",
  47. gps: "",
  48. deviceID: "",
  49. phoneType: ""
  50. };
  51. },
  52. mounted() {
  53. this.staff_num = uni.getStorageSync('user').staff_num
  54. },
  55. methods: {
  56. maskClick() {
  57. this.password = ""
  58. },
  59. // 宁煤信息平台
  60. go_link(item) {
  61. let link = item.link
  62. if (link.indexOf("nativeApp://") != -1) {
  63. let app_name = link.match(/nativeApp:\/\/(\S*)\?/)[1]
  64. let app_down_link = link.split('?')[1]
  65. // #ifdef APP
  66. if (plus.os.name == 'Android') {
  67. plus.runtime.launchApplication({
  68. pname: app_name
  69. }, (e) => {
  70. console.log('Open system default browser failed: ' + e.message)
  71. uni.showModal({
  72. title: app_name,
  73. content: '未安装此应用、是否下载?',
  74. success: (res)=> {
  75. if (res.confirm) {
  76. console.log('用户点击确定');
  77. uni.navigateTo({
  78. url:"../../index/h5/h5?url="+app_down_link
  79. })
  80. } else if (res.cancel) {
  81. console.log('用户点击取消');
  82. }
  83. }
  84. });
  85. })
  86. }
  87. // #endif
  88. } else if (link.indexOf("http://mtyyxs.shnxmyjt.com") != -1) {
  89. console.log("信息平台")
  90. this.url = item
  91. // 有登录记录
  92. let token = uni.getStorageSync('ningmei_token')
  93. let time = uni.getStorageSync('ningmei_token_time')
  94. // 30天刷新一次
  95. let diffTimeShow = diffTime(time,new Date().format("yyyy-MM-dd")).split(' ')[0];
  96. console.log(diffTimeShow)
  97. if (token.length > 20 && diffTimeShow < 30) {
  98. uni.navigateTo({
  99. url: "../../index/ningMeiXinXiPingTai/ningMeiXinXiPingTai",
  100. success: (res) => {
  101. // 通过eventChannel向被打开页面传送数据
  102. res.eventChannel.emit('acceptDataFromOpenerPage', {
  103. data: this.url
  104. })
  105. }
  106. })
  107. } else {
  108. this.$refs.popup.open()
  109. }
  110. }else{
  111. goToLink(item,this.mine_code)
  112. }
  113. },
  114. login() {
  115. // #ifdef APP-PLUS
  116. if (this.password == '') {
  117. uni.showToast({
  118. icon: "none",
  119. title: "密码不能为空!"
  120. })
  121. return
  122. }
  123. this.$refs.popup.close()
  124. // 获取gps
  125. uni.getLocation({
  126. type: 'wgs84',
  127. success: (res) => {
  128. console.log('当前位置的经度:' + res.longitude);
  129. console.log('当前位置的纬度:' + res.latitude);
  130. this.gps = res.longitude + ',' + res.latitude
  131. // 获取设备信息
  132. plus.device.getInfo({
  133. success: (e) => {
  134. console.log(JSON.stringify(e.uuid));
  135. console.log(plus.device.model)
  136. this.deviceID = JSON.stringify(e.uuid)
  137. this.phoneType = plus.device.model
  138. uni.request({
  139. method: "POST",
  140. url: "http://mtyyxs.shnxmyjt.com:33300/api/OAuth/Login",
  141. header: {
  142. 'Content-Type': 'application/json;charset=UTF-8',
  143. 'caller': 'UnifiedPortal'
  144. },
  145. data: {
  146. phoneType: this.phoneType,
  147. password: this.password,
  148. gps: this.gps,
  149. userID: this.staff_num,
  150. resolvingPower: "851*393",
  151. deviceID: this.deviceID,
  152. ip: "112312313"
  153. },
  154. success: (res) => {
  155. console.log(this.password)
  156. console.log(res)
  157. if (res.data.code = '11002') {
  158. uni.showToast({
  159. icon: "none",
  160. title: res.data.msg
  161. })
  162. if (res.data.data.length > 20) {
  163. uni.setStorageSync('ningmei_token', res.data.data)
  164. uni.setStorageSync('ningmei_token_time', new Date().format("yyyy-MM-dd"))
  165. uni.navigateTo({
  166. url: "../../index/ningMeiXinXiPingTai/ningMeiXinXiPingTai",
  167. success: (res) => {
  168. // 通过eventChannel向被打开页面传送数据
  169. res.eventChannel
  170. .emit(
  171. 'acceptDataFromOpenerPage', {
  172. data: this
  173. .url
  174. })
  175. }
  176. })
  177. }
  178. }
  179. }
  180. })
  181. }
  182. });
  183. }
  184. })
  185. // #endif
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss">
  191. .content {
  192. margin-bottom: 20rpx;
  193. background-color: #FFFFFF;
  194. box-sizing: border-box;
  195. padding: 50rpx 25rpx 15rpx;
  196. }
  197. .nav {
  198. overflow: hidden;
  199. .item {
  200. float: left;
  201. width: 120rpx;
  202. margin-right: 25rpx;
  203. margin-bottom: 30rpx;
  204. .icon {
  205. width: 120rpx;
  206. text-align: center;
  207. image {
  208. width: 100rpx;
  209. height: 100rpx;
  210. border-radius: 50%;
  211. }
  212. }
  213. .name {
  214. width: 120rpx;
  215. text-align: center;
  216. font-size: 30rpx;
  217. white-space: nowrap;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. }
  221. }
  222. .item:nth-child(5n) {
  223. margin-right: 0;
  224. }
  225. }
  226. .login_box {
  227. width: 500rpx;
  228. padding: 30rpx 50rpx;
  229. border-radius: 20rpx;
  230. margin: 0 auto;
  231. background-color: #FFFFFF;
  232. .input_box {
  233. margin-bottom: 30rpx;
  234. .label {
  235. color: #6C6F74;
  236. margin-bottom: 20rpx;
  237. }
  238. .box {
  239. background: #FFFFFF;
  240. border-radius: 8rpx;
  241. border: 2rpx solid #E9EBF2;
  242. box-sizing: border-box;
  243. padding: 20rpx 25rpx;
  244. }
  245. }
  246. .btn {
  247. width: 500rpx;
  248. margin: 0 auto;
  249. border-radius: 8rpx;
  250. background-color: #009FE8;
  251. line-height: 90rpx;
  252. color: #FFFFFF;
  253. text-align: center;
  254. }
  255. }
  256. </style>