App.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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 = '4914243105615';
  47. // app.globalData.userinfo.userId = 4;
  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. }
  158. },
  159. fail: function (err) {
  160. uni.hideLoading();
  161. uni.showToast({
  162. title: '请求失败',
  163. icon: 'none',
  164. duration: 2000
  165. })
  166. }
  167. })
  168. },
  169. ajaxUnlogin: function(params){
  170. if (!params.type) {
  171. var type = 'POST';
  172. }else{
  173. var type = params.type;
  174. }
  175. if (!params.apiname) {
  176. var apiname = '1';
  177. } else {
  178. var apiname = params.apiname;
  179. }
  180. if (!params.data) {
  181. var data = [];
  182. }else{
  183. var data = params.data;
  184. }
  185. var app = getApp();
  186. var orgId = app.globalData.userinfo.orgId;
  187. if(orgId){
  188. data['orgId'] = orgId;
  189. }
  190. // uni.showLoading({
  191. // title: '加载中',
  192. // mask: true
  193. // });
  194. uni.request({
  195. url: params.url,
  196. data: data,
  197. method: type,
  198. header: {
  199. 'content-type': 'application/x-www-form-urlencoded'
  200. },
  201. success: function (res) {
  202. uni.hideLoading();
  203. uni.stopPullDownRefresh();
  204. var ret = app.checkCode(res.data.code); //检查token是否失效
  205. if(ret == false){
  206. return false;
  207. }
  208. if (res.data.code == 0) {
  209. if (app.ajaxReadyCallback) { //在onShow中调用数据的,添加在onShow方法内,防止不同页面覆盖
  210. res.data['apiname'] = apiname;
  211. app.ajaxReadyCallback(res)
  212. }
  213. } else {
  214. uni.showToast({
  215. title: res.data.message,
  216. icon: 'none',
  217. duration: 2000
  218. })
  219. }
  220. },
  221. fail: function (err) {
  222. uni.hideLoading();
  223. uni.showToast({
  224. title: '请求失败',
  225. icon: 'none',
  226. duration: 2000
  227. })
  228. }
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style>
  235. /*每个页面公共css */
  236. page{
  237. background-color: #F3F3F3;
  238. --themeColor:#023894;
  239. }
  240. .no-data{
  241. width: 100%;
  242. height: auto;
  243. margin: 0 auto;
  244. margin-top: 20%;
  245. text-align: center;
  246. }
  247. .no-data image{
  248. width: 430rpx;
  249. height: 316rpx;
  250. }
  251. .no-data .no-data-text{
  252. color: #C5C8D9;
  253. font-size: 25rpx;
  254. }
  255. .pull-right{
  256. float: right!important;
  257. }
  258. .text-red{
  259. color: var(--themeColor);
  260. }
  261. .container{
  262. padding: 20rpx;
  263. }
  264. .worker-box{
  265. position: relative;
  266. width: 670rpx;
  267. height: auto;
  268. margin-bottom: 20rpx;
  269. /* overflow: hidden; */
  270. padding: 0 20rpx;
  271. background-color: #ffffff;
  272. border-radius: 10rpx;
  273. }
  274. .worker-box.cur{
  275. border: 4rpx solid var(--themeColor);
  276. }
  277. .worker-box .worker-box-select{
  278. display: none;
  279. }
  280. .worker-box.cur .worker-box-select{
  281. display: inline-block;
  282. width: 66rpx;
  283. height: 68rpx;
  284. position: absolute;
  285. z-index: 5;
  286. top: -2rpx;
  287. right: -2rpx;
  288. }
  289. .worker-box .worker-box-header{
  290. height: 90rpx;
  291. line-height: 90rpx;
  292. font-size: 32rpx;
  293. font-weight: bold;
  294. color: #333333;
  295. margin-bottom: 20rpx;
  296. }
  297. .worker-box .worker-box-info{
  298. padding: 30rpx 0;
  299. width: 100%;
  300. height: 130rpx;
  301. overflow: hidden;
  302. }
  303. .worker-box .worker-box-info .worker-box-avator{
  304. position: relative;
  305. width: 130rpx;
  306. height: 130rpx;
  307. float: left;
  308. }
  309. .worker-box .worker-box-info .worker-box-avator image{
  310. width: 100%;
  311. height: 100%;
  312. border-radius: 50%;
  313. }
  314. .worker-box .worker-box-info .worker-box-avator .worker-box-status{
  315. position: absolute;
  316. z-index: 10;
  317. bottom: 0;
  318. left: 0;
  319. width: 100%;
  320. height: 36rpx;
  321. border-radius: 18rpx;
  322. color: #ffffff;
  323. background-color: var(--themeColor);
  324. text-align: center;
  325. font-size: 26rpx;
  326. }
  327. .worker-box .worker-box-info .worker-box-avator .worker-box-status.color2{
  328. background-color: #23C1CF;
  329. }
  330. .worker-box .worker-box-info .worker-box-body{
  331. width: 520rpx;
  332. height: 130rpx;
  333. float: right;
  334. }
  335. .worker-box .worker-box-info .worker-box-body .worker-box-title{
  336. color: #333333;
  337. font-size: 30rpx;
  338. font-weight: bold;
  339. line-height: 50rpx;
  340. }
  341. .worker-box .worker-box-info .worker-box-body .worker-box-star{
  342. display: inline-block;
  343. width: auto;
  344. float: right;
  345. }
  346. .worker-box .worker-box-info .worker-box-body .worker-box-desc{
  347. color: #999999;
  348. font-size: 26rpx;
  349. line-height: 40rpx;
  350. height: 40rpx;
  351. overflow: hidden;
  352. text-overflow: ellipsis;
  353. white-space:nowrap;
  354. }
  355. .worker-box .worker-box-footer{
  356. line-height: 99rpx;
  357. height: 99rpx;
  358. border-top: 1rpx solid #D9D9D9;
  359. }
  360. .worker-box .worker-box-footer image{
  361. width: 36rpx;
  362. height: 36rpx;
  363. vertical-align: middle;
  364. }
  365. .worker-box .worker-box-footer .worker-box-footer-money{
  366. vertical-align: middle;
  367. padding: 0 10rpx;
  368. font-size: 34rpx;
  369. color: #FF3F40;
  370. }
  371. .worker-box .worker-box-footer .worker-box-footer-btn{
  372. display: inline-block;
  373. width: 130rpx;
  374. height: 60rpx;
  375. line-height: 60rpx;
  376. color: #ffffff;
  377. background-color: var(--themeColor);
  378. border-radius: 30rpx;
  379. text-align: center;
  380. font-size: 30rpx;
  381. float: right;
  382. margin-top: 20rpx;
  383. margin-left: 10rpx;
  384. }
  385. .worker-box .worker-box-footer .worker-box-footer-btn-cancel{
  386. display: inline-block;
  387. width: 158rpx;
  388. height: 60rpx;
  389. line-height: 60rpx;
  390. color: #999999;
  391. border: 1rpx solid #B3B3B3;
  392. border-radius: 30rpx;
  393. text-align: center;
  394. font-size: 30rpx;
  395. float: right;
  396. margin-top: 20rpx;
  397. margin-left: 10rpx;
  398. }
  399. .form-box{
  400. width: 670rpx;
  401. height: 90rpx;
  402. line-height: 90rpx;
  403. background-color: #ffffff;
  404. border-radius: 10rpx;
  405. padding: 0 20rpx;
  406. margin-bottom: 20rpx;
  407. overflow: hidden;
  408. }
  409. .form-box2{
  410. min-height:200rpx;
  411. height: auto;
  412. }
  413. .form-box .form-box-label{
  414. display: inline-block;
  415. width: 250rpx;
  416. float: left;
  417. font-size: 34rpx;
  418. font-weight: bold;
  419. color: #333333;
  420. }
  421. .form-box .form-box-content{
  422. display: inline-block;
  423. width: 400rpx;
  424. float: right;
  425. text-align: right;
  426. }
  427. .form-box .form-box-content input{
  428. height: 70rpx;
  429. line-height: 70rpx;
  430. vertical-align: middle;
  431. margin-top: 10rpx;
  432. }
  433. .form-box .form-box-content image{
  434. width: 24rpx;
  435. height: 24rpx;
  436. vertical-align: middle;
  437. }
  438. .form-box .form-box-content .form-box-content-text{
  439. float: left;
  440. display: inline-block;
  441. width: 360rpx;
  442. overflow: hidden;
  443. font-size: 30rpx;
  444. height: 90rpx;
  445. text-overflow: ellipsis;
  446. white-space:nowrap;
  447. }
  448. .form-box .form-box-textarea{
  449. width: 100%;
  450. float: left;
  451. padding-bottom: 20rpx;
  452. overflow: hidden;
  453. }
  454. .form-box .form-box-textarea textarea{
  455. width: 100%;
  456. padding: 20rpx;
  457. line-height: 40rpx;
  458. background-color: #F7F7F7;
  459. }
  460. .form-box .form-box-sub{
  461. width: 670rpx;
  462. height: 90rpx;
  463. line-height: 90rpx;
  464. background-color: #ffffff;
  465. border-radius: 10rpx;
  466. padding: 0;
  467. overflow: hidden;
  468. }
  469. .form-box3{
  470. width: 100%;
  471. height: 90rpx;
  472. line-height: 90rpx;
  473. background-color: #ffffff;
  474. border-radius: 10rpx;
  475. padding: 0 20rpx;
  476. margin-bottom: 20rpx;
  477. overflow: hidden;
  478. }
  479. .form-box3 .form-box-label{
  480. display: inline-block;
  481. width: 40%;
  482. float: left;
  483. font-size: 34rpx;
  484. font-weight: bold;
  485. color: #333333;
  486. }
  487. .form-box3 .form-box-content{
  488. display: inline-block;
  489. width: 50%;
  490. float: left;
  491. text-align: right;
  492. }
  493. .form-box3 .form-box-content input{
  494. height: 70rpx;
  495. line-height: 70rpx;
  496. vertical-align: middle;
  497. margin-top: 10rpx;
  498. }
  499. .form-box3 .form-box-content image{
  500. width: 24rpx;
  501. height: 24rpx;
  502. vertical-align: middle;
  503. }
  504. .form-box3 .form-box-content .form-box-content-text{
  505. // float: left;
  506. display: inline-block;
  507. width: 85%;
  508. overflow: hidden;
  509. font-size: 30rpx;
  510. height: 90rpx;
  511. text-overflow: ellipsis;
  512. white-space:nowrap;
  513. }
  514. .form-box3 .form-box-textarea{
  515. width: 100%;
  516. float: left;
  517. padding-bottom: 20rpx;
  518. overflow: hidden;
  519. }
  520. .form-box3 .form-box-textarea textarea{
  521. width: 100%;
  522. padding: 20rpx;
  523. line-height: 40rpx;
  524. background-color: #F7F7F7;
  525. }
  526. </style>