App.vue 12 KB

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