App.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <script>
  2. export default {
  3. globalData: {
  4. host: 'http://wy2.jiliyilian.com/wap',
  5. serverUrl: 'http://wy2.jiliyilian.com/api/h5/',
  6. uploadServerUrl: 'http://wy2.jiliyilian.com/api/h5/',
  7. appId: 'wx439b9d9527727911',
  8. redirectUri: 'http://wy2.jiliyilian.com/wap/ph/#/pages/index/wechat',
  9. storagePre: 'ph_',
  10. userinfo:{}
  11. },
  12. onLaunch: function() {
  13. var app = getApp();
  14. var orgId = this.getUrlCode('orgId');
  15. // var orgId = 3;
  16. //alert('当前url:'+window.location.href+'参数:'+orgId);
  17. if(orgId){
  18. uni.setStorageSync(app.globalData.storagePre+'orgId',orgId);
  19. app.globalData.userinfo.orgId = orgId;
  20. }else{
  21. orgId = uni.getStorageSync(app.globalData.storagePre+'orgId');
  22. if(orgId){
  23. app.globalData.userinfo.orgId = orgId;
  24. }else{
  25. uni.showToast({
  26. title: '参数错误',
  27. icon: 'none',
  28. duration: 2000
  29. })
  30. }
  31. }
  32. let token = uni.getStorageSync(app.globalData.storagePre+'token');
  33. if(token){
  34. app.globalData.userinfo.token = token;
  35. app.globalData.userinfo.userId = uni.getStorageSync(app.globalData.storagePre+'userId');
  36. }
  37. if(orgId){
  38. app.globalData.userinfo.orgId = orgId;
  39. }else{
  40. app.globalData.userinfo.orgId = 0;
  41. }
  42. // app.globalData.userinfo.orgId = 3;
  43. // app.globalData.userinfo.token = '4914243105615';
  44. // app.globalData.userinfo.userId = 4;
  45. this.checkLogin();
  46. },
  47. onShow: function() {
  48. console.log('App Show')
  49. },
  50. onHide: function() {
  51. console.log('App Hide')
  52. },
  53. methods: {
  54. getUrlCode (name) {
  55. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
  56. },
  57. checkLogin: function(){ // 陪护调度端
  58. var app = getApp();
  59. var token = app.globalData.userinfo.token;
  60. if(!token){
  61. uni.reLaunch({ //关闭所有页面,跳转到闪屏页
  62. url: '/pages/index/wechat'
  63. })
  64. }
  65. },
  66. checkCode:function(code){
  67. if(code == -100){
  68. uni.showToast({
  69. title: '登录超时,请重新登录',
  70. icon: 'none',
  71. duration: 2000
  72. })
  73. var app = getApp();
  74. uni.removeStorageSync(app.globalData.storagePre+'token');
  75. uni.removeStorageSync(app.globalData.storagePre+'userId');
  76. setTimeout(function(){
  77. uni.reLaunch({ //关闭所有页面,打开到应用内的某个页面
  78. url: '/pages/index/wechat'
  79. })
  80. },2000);
  81. return false;
  82. }
  83. return true;
  84. },
  85. ajax: function(params){
  86. if (!params.type) {
  87. var type = 'POST';
  88. }else{
  89. var type = params.type;
  90. }
  91. if (!params.apiname) {
  92. var apiname = '1';
  93. } else {
  94. var apiname = params.apiname;
  95. }
  96. if (!params.data) {
  97. var data = [];
  98. }else{
  99. var data = params.data;
  100. }
  101. var app = getApp();
  102. var token = app.globalData.userinfo.token;
  103. var userId = app.globalData.userinfo.userId;
  104. if (!token || token == undefined) { //未登录
  105. uni.showToast({
  106. title: '未登录',
  107. icon: 'none',
  108. duration: 2000
  109. });
  110. uni.removeStorageSync(app.globalData.storagePre+'token');
  111. uni.removeStorageSync(app.globalData.storagePre+'userId');
  112. setTimeout(function () {
  113. uni.reLaunch({ //关闭所有页面,跳转到闪屏页
  114. url: '/pages/index/wechat'
  115. })
  116. }, 2000);
  117. return false;
  118. }
  119. data['token'] = token;
  120. data['userId'] = userId;
  121. var orgId = app.globalData.userinfo.orgId;
  122. if(orgId){
  123. data['orgId'] = orgId;
  124. }
  125. // uni.showLoading({
  126. // title: '加载中',
  127. // mask: true
  128. // });
  129. uni.request({
  130. url: params.url,
  131. data: data,
  132. method: type,
  133. header: {
  134. 'content-type': 'application/x-www-form-urlencoded'
  135. },
  136. success: function (res) {
  137. uni.hideLoading();
  138. uni.stopPullDownRefresh();
  139. var ret = app.checkCode(res.data.code); //检查token是否失效
  140. if(ret == false){
  141. return false;
  142. }
  143. if (res.data.code == 0) {
  144. if (app.ajaxReadyCallback) { //在onShow中调用数据的,添加在onShow方法内,防止不同页面覆盖
  145. res.data['apiname'] = apiname;
  146. app.ajaxReadyCallback(res)
  147. }
  148. } else {
  149. uni.showToast({
  150. title: res.data.message,
  151. icon: 'none',
  152. duration: 2000
  153. })
  154. }
  155. },
  156. fail: function (err) {
  157. uni.hideLoading();
  158. uni.showToast({
  159. title: '请求失败',
  160. icon: 'none',
  161. duration: 2000
  162. })
  163. }
  164. })
  165. },
  166. ajaxUnlogin: function(params){
  167. if (!params.type) {
  168. var type = 'POST';
  169. }else{
  170. var type = params.type;
  171. }
  172. if (!params.apiname) {
  173. var apiname = '1';
  174. } else {
  175. var apiname = params.apiname;
  176. }
  177. if (!params.data) {
  178. var data = [];
  179. }else{
  180. var data = params.data;
  181. }
  182. var app = getApp();
  183. var orgId = app.globalData.userinfo.orgId;
  184. if(orgId){
  185. data['orgId'] = orgId;
  186. }
  187. // uni.showLoading({
  188. // title: '加载中',
  189. // mask: true
  190. // });
  191. uni.request({
  192. url: params.url,
  193. data: data,
  194. method: type,
  195. header: {
  196. 'content-type': 'application/x-www-form-urlencoded'
  197. },
  198. success: function (res) {
  199. uni.hideLoading();
  200. uni.stopPullDownRefresh();
  201. var ret = app.checkCode(res.data.code); //检查token是否失效
  202. if(ret == false){
  203. return false;
  204. }
  205. if (res.data.code == 0) {
  206. if (app.ajaxReadyCallback) { //在onShow中调用数据的,添加在onShow方法内,防止不同页面覆盖
  207. res.data['apiname'] = apiname;
  208. app.ajaxReadyCallback(res)
  209. }
  210. } else {
  211. uni.showToast({
  212. title: res.data.message,
  213. icon: 'none',
  214. duration: 2000
  215. })
  216. }
  217. },
  218. fail: function (err) {
  219. uni.hideLoading();
  220. uni.showToast({
  221. title: '请求失败',
  222. icon: 'none',
  223. duration: 2000
  224. })
  225. }
  226. })
  227. }
  228. }
  229. }
  230. </script>
  231. <style>
  232. /*每个页面公共css */
  233. page{
  234. background-color: #F3F3F3;
  235. --themeColor:#023894;
  236. }
  237. .no-data{
  238. width: 100%;
  239. height: auto;
  240. margin: 0 auto;
  241. margin-top: 20%;
  242. text-align: center;
  243. }
  244. .no-data image{
  245. width: 430rpx;
  246. height: 316rpx;
  247. }
  248. .no-data .no-data-text{
  249. color: #C5C8D9;
  250. font-size: 25rpx;
  251. }
  252. .pull-right{
  253. float: right!important;
  254. }
  255. .text-red{
  256. color: var(--themeColor);
  257. }
  258. .container{
  259. padding: 20rpx;
  260. }
  261. .worker-box{
  262. position: relative;
  263. width: 670rpx;
  264. height: auto;
  265. margin-bottom: 20rpx;
  266. /* overflow: hidden; */
  267. padding: 0 20rpx;
  268. background-color: #ffffff;
  269. border-radius: 10rpx;
  270. }
  271. .worker-box.cur{
  272. border: 4rpx solid var(--themeColor);
  273. }
  274. .worker-box .worker-box-select{
  275. display: none;
  276. }
  277. .worker-box.cur .worker-box-select{
  278. display: inline-block;
  279. width: 66rpx;
  280. height: 68rpx;
  281. position: absolute;
  282. z-index: 5;
  283. top: -2rpx;
  284. right: -2rpx;
  285. }
  286. .worker-box .worker-box-header{
  287. height: 90rpx;
  288. line-height: 90rpx;
  289. font-size: 32rpx;
  290. font-weight: bold;
  291. color: #333333;
  292. margin-bottom: 20rpx;
  293. }
  294. .worker-box .worker-box-info{
  295. padding: 30rpx 0;
  296. width: 100%;
  297. height: 130rpx;
  298. overflow: hidden;
  299. }
  300. .worker-box .worker-box-info .worker-box-avator{
  301. position: relative;
  302. width: 130rpx;
  303. height: 130rpx;
  304. float: left;
  305. }
  306. .worker-box .worker-box-info .worker-box-avator image{
  307. width: 100%;
  308. height: 100%;
  309. border-radius: 50%;
  310. }
  311. .worker-box .worker-box-info .worker-box-avator .worker-box-status{
  312. position: absolute;
  313. z-index: 10;
  314. bottom: 0;
  315. left: 0;
  316. width: 100%;
  317. height: 36rpx;
  318. border-radius: 18rpx;
  319. color: #ffffff;
  320. background-color: var(--themeColor);
  321. text-align: center;
  322. font-size: 26rpx;
  323. }
  324. .worker-box .worker-box-info .worker-box-avator .worker-box-status.color2{
  325. background-color: #23C1CF;
  326. }
  327. .worker-box .worker-box-info .worker-box-body{
  328. width: 520rpx;
  329. height: 130rpx;
  330. float: right;
  331. }
  332. .worker-box .worker-box-info .worker-box-body .worker-box-title{
  333. color: #333333;
  334. font-size: 30rpx;
  335. font-weight: bold;
  336. line-height: 50rpx;
  337. }
  338. .worker-box .worker-box-info .worker-box-body .worker-box-star{
  339. display: inline-block;
  340. width: auto;
  341. float: right;
  342. }
  343. .worker-box .worker-box-info .worker-box-body .worker-box-desc{
  344. color: #999999;
  345. font-size: 26rpx;
  346. line-height: 40rpx;
  347. height: 40rpx;
  348. overflow: hidden;
  349. text-overflow: ellipsis;
  350. white-space:nowrap;
  351. }
  352. .worker-box .worker-box-footer{
  353. line-height: 99rpx;
  354. height: 99rpx;
  355. border-top: 1rpx solid #D9D9D9;
  356. }
  357. .worker-box .worker-box-footer image{
  358. width: 36rpx;
  359. height: 36rpx;
  360. vertical-align: middle;
  361. }
  362. .worker-box .worker-box-footer .worker-box-footer-money{
  363. vertical-align: middle;
  364. padding: 0 10rpx;
  365. font-size: 34rpx;
  366. color: #FF3F40;
  367. }
  368. .worker-box .worker-box-footer .worker-box-footer-btn{
  369. display: inline-block;
  370. width: 130rpx;
  371. height: 60rpx;
  372. line-height: 60rpx;
  373. color: #ffffff;
  374. background-color: var(--themeColor);
  375. border-radius: 30rpx;
  376. text-align: center;
  377. font-size: 30rpx;
  378. float: right;
  379. margin-top: 20rpx;
  380. margin-left: 10rpx;
  381. }
  382. .worker-box .worker-box-footer .worker-box-footer-btn-cancel{
  383. display: inline-block;
  384. width: 158rpx;
  385. height: 60rpx;
  386. line-height: 60rpx;
  387. color: #999999;
  388. border: 1rpx solid #B3B3B3;
  389. border-radius: 30rpx;
  390. text-align: center;
  391. font-size: 30rpx;
  392. float: right;
  393. margin-top: 20rpx;
  394. margin-left: 10rpx;
  395. }
  396. .form-box{
  397. width: 670rpx;
  398. height: 90rpx;
  399. line-height: 90rpx;
  400. background-color: #ffffff;
  401. border-radius: 10rpx;
  402. padding: 0 20rpx;
  403. margin-bottom: 20rpx;
  404. overflow: hidden;
  405. }
  406. .form-box2{
  407. min-height:200rpx;
  408. height: auto;
  409. }
  410. .form-box .form-box-label{
  411. display: inline-block;
  412. width: 250rpx;
  413. float: left;
  414. font-size: 34rpx;
  415. font-weight: bold;
  416. color: #333333;
  417. }
  418. .form-box .form-box-content{
  419. display: inline-block;
  420. width: 400rpx;
  421. float: right;
  422. text-align: right;
  423. }
  424. .form-box .form-box-content input{
  425. height: 70rpx;
  426. line-height: 70rpx;
  427. vertical-align: middle;
  428. margin-top: 10rpx;
  429. }
  430. .form-box .form-box-content image{
  431. width: 24rpx;
  432. height: 24rpx;
  433. vertical-align: middle;
  434. }
  435. .form-box .form-box-content .form-box-content-text{
  436. float: left;
  437. display: inline-block;
  438. width: 360rpx;
  439. overflow: hidden;
  440. font-size: 30rpx;
  441. height: 90rpx;
  442. text-overflow: ellipsis;
  443. white-space:nowrap;
  444. }
  445. .form-box .form-box-textarea{
  446. width: 100%;
  447. float: left;
  448. padding-bottom: 20rpx;
  449. overflow: hidden;
  450. }
  451. .form-box .form-box-textarea textarea{
  452. width: 100%;
  453. padding: 20rpx;
  454. line-height: 40rpx;
  455. background-color: #F7F7F7;
  456. }
  457. .form-box .form-box-sub{
  458. width: 670rpx;
  459. height: 90rpx;
  460. line-height: 90rpx;
  461. background-color: #ffffff;
  462. border-radius: 10rpx;
  463. padding: 0;
  464. overflow: hidden;
  465. }
  466. .form-box3{
  467. width: 100%;
  468. height: 90rpx;
  469. line-height: 90rpx;
  470. background-color: #ffffff;
  471. border-radius: 10rpx;
  472. padding: 0 20rpx;
  473. margin-bottom: 20rpx;
  474. overflow: hidden;
  475. }
  476. .form-box3 .form-box-label{
  477. display: inline-block;
  478. width: 40%;
  479. float: left;
  480. font-size: 34rpx;
  481. font-weight: bold;
  482. color: #333333;
  483. }
  484. .form-box3 .form-box-content{
  485. display: inline-block;
  486. width: 50%;
  487. float: left;
  488. text-align: right;
  489. }
  490. .form-box3 .form-box-content input{
  491. height: 70rpx;
  492. line-height: 70rpx;
  493. vertical-align: middle;
  494. margin-top: 10rpx;
  495. }
  496. .form-box3 .form-box-content image{
  497. width: 24rpx;
  498. height: 24rpx;
  499. vertical-align: middle;
  500. }
  501. .form-box3 .form-box-content .form-box-content-text{
  502. // float: left;
  503. display: inline-block;
  504. width: 85%;
  505. overflow: hidden;
  506. font-size: 30rpx;
  507. height: 90rpx;
  508. text-overflow: ellipsis;
  509. white-space:nowrap;
  510. }
  511. .form-box3 .form-box-textarea{
  512. width: 100%;
  513. float: left;
  514. padding-bottom: 20rpx;
  515. overflow: hidden;
  516. }
  517. .form-box3 .form-box-textarea textarea{
  518. width: 100%;
  519. padding: 20rpx;
  520. line-height: 40rpx;
  521. background-color: #F7F7F7;
  522. }
  523. </style>