App.vue 12 KB

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