123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544 |
- <script>
- export default {
- globalData: {
- host: 'http://wy2.jiliyilian.com/wap',
- serverUrl: 'http://wy2.jiliyilian.com/api/h5/',
- uploadServerUrl: 'http://wy2.jiliyilian.com/api/h5/',
- // host: 'http://jili2.demo.com/wap',
- // serverUrl: 'http://jili2.demo.com/api/h5/',
- // uploadServerUrl: 'http://jili2.demo.com/api/h5/',
- appId: 'wx439b9d9527727911',
- redirectUri: 'http://wy2.jiliyilian.com/wap/ph/#/pages/index/wechat',
- storagePre: 'ph_',
- userinfo:{}
- },
- onLaunch: function() {
- var app = getApp();
- var orgId = this.getUrlCode('orgId');
- // var orgId = 3;
- //alert('当前url:'+window.location.href+'参数:'+orgId);
- if(orgId){
- uni.setStorageSync(app.globalData.storagePre+'orgId',orgId);
- app.globalData.userinfo.orgId = orgId;
- }else{
- orgId = uni.getStorageSync(app.globalData.storagePre+'orgId');
- if(orgId){
- app.globalData.userinfo.orgId = orgId;
- }else{
- uni.showToast({
- title: '参数错误',
- icon: 'none',
- duration: 2000
- })
- }
- }
-
- let token = uni.getStorageSync(app.globalData.storagePre+'token');
- if(token){
- app.globalData.userinfo.token = token;
- app.globalData.userinfo.userId = uni.getStorageSync(app.globalData.storagePre+'userId');
- }
- if(orgId){
- app.globalData.userinfo.orgId = orgId;
- }else{
- app.globalData.userinfo.orgId = 0;
- }
- // app.globalData.userinfo.orgId = 3;
- // app.globalData.userinfo.token = '4914243105615';
- // app.globalData.userinfo.userId = 4;
- this.checkLogin();
- },
- onShow: function() {
- console.log('App Show')
- },
- onHide: function() {
- console.log('App Hide')
- },
- methods: {
- getUrlCode (name) {
- return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
- },
- checkLogin: function(){ // 陪护调度端
- var app = getApp();
- var token = app.globalData.userinfo.token;
- if(!token){
- uni.reLaunch({ //关闭所有页面,跳转到闪屏页
- url: '/pages/index/wechat'
- })
- }
- },
- checkCode:function(code){
- if(code == -100){
- uni.showToast({
- title: '登录超时,请重新登录',
- icon: 'none',
- duration: 2000
- })
- var app = getApp();
- uni.removeStorageSync(app.globalData.storagePre+'token');
- uni.removeStorageSync(app.globalData.storagePre+'userId');
- setTimeout(function(){
- uni.reLaunch({ //关闭所有页面,打开到应用内的某个页面
- url: '/pages/index/wechat'
- })
- },2000);
- return false;
- }
- return true;
- },
- ajax: function(params){
- if (!params.type) {
- var type = 'POST';
- }else{
- var type = params.type;
- }
- if (!params.apiname) {
- var apiname = '1';
- } else {
- var apiname = params.apiname;
- }
- if (!params.data) {
- var data = [];
- }else{
- var data = params.data;
- }
- var app = getApp();
- var token = app.globalData.userinfo.token;
- var userId = app.globalData.userinfo.userId;
- if (!token || token == undefined) { //未登录
- uni.showToast({
- title: '未登录',
- icon: 'none',
- duration: 2000
- });
- uni.removeStorageSync(app.globalData.storagePre+'token');
- uni.removeStorageSync(app.globalData.storagePre+'userId');
- setTimeout(function () {
- uni.reLaunch({ //关闭所有页面,跳转到闪屏页
- url: '/pages/index/wechat'
- })
- }, 2000);
- return false;
- }
- data['token'] = token;
- data['userId'] = userId;
-
- var orgId = app.globalData.userinfo.orgId;
- if(orgId){
- data['orgId'] = orgId;
- }
-
- // uni.showLoading({
- // title: '加载中',
- // mask: true
- // });
-
- uni.request({
- url: params.url,
- data: data,
- method: type,
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- success: function (res) {
- uni.hideLoading();
- uni.stopPullDownRefresh();
- var ret = app.checkCode(res.data.code); //检查token是否失效
- if(ret == false){
- return false;
- }
-
- if (res.data.code == 0) {
- if (app.ajaxReadyCallback) { //在onShow中调用数据的,添加在onShow方法内,防止不同页面覆盖
- res.data['apiname'] = apiname;
- app.ajaxReadyCallback(res)
- }
- } else {
- uni.showToast({
- title: res.data.message,
- icon: 'none',
- duration: 2000
- })
- }
- },
- fail: function (err) {
- uni.hideLoading();
- uni.showToast({
- title: '请求失败',
- icon: 'none',
- duration: 2000
- })
- }
- })
- },
- ajaxUnlogin: function(params){
- if (!params.type) {
- var type = 'POST';
- }else{
- var type = params.type;
- }
- if (!params.apiname) {
- var apiname = '1';
- } else {
- var apiname = params.apiname;
- }
- if (!params.data) {
- var data = [];
- }else{
- var data = params.data;
- }
- var app = getApp();
- var orgId = app.globalData.userinfo.orgId;
- if(orgId){
- data['orgId'] = orgId;
- }
-
- // uni.showLoading({
- // title: '加载中',
- // mask: true
- // });
-
- uni.request({
- url: params.url,
- data: data,
- method: type,
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- success: function (res) {
- uni.hideLoading();
- uni.stopPullDownRefresh();
- var ret = app.checkCode(res.data.code); //检查token是否失效
- if(ret == false){
- return false;
- }
-
- if (res.data.code == 0) {
- if (app.ajaxReadyCallback) { //在onShow中调用数据的,添加在onShow方法内,防止不同页面覆盖
- res.data['apiname'] = apiname;
- app.ajaxReadyCallback(res)
- }
- } else {
- uni.showToast({
- title: res.data.message,
- icon: 'none',
- duration: 2000
- })
- }
- },
- fail: function (err) {
- uni.hideLoading();
- uni.showToast({
- title: '请求失败',
- icon: 'none',
- duration: 2000
- })
- }
- })
- }
- }
-
-
- }
- </script>
- <style>
- /*每个页面公共css */
- page{
- background-color: #F3F3F3;
- --themeColor:#023894;
- }
- .no-data{
- width: 100%;
- height: auto;
- margin: 0 auto;
- margin-top: 20%;
- text-align: center;
- }
- .no-data image{
- width: 430rpx;
- height: 316rpx;
- }
- .no-data .no-data-text{
- color: #C5C8D9;
- font-size: 25rpx;
- }
-
- .pull-right{
- float: right!important;
- }
- .text-red{
- color: var(--themeColor);
- }
-
- .container{
- padding: 20rpx;
- }
- .worker-box{
- position: relative;
- width: 670rpx;
- height: auto;
- margin-bottom: 20rpx;
- /* overflow: hidden; */
- padding: 0 20rpx;
- background-color: #ffffff;
- border-radius: 10rpx;
- }
- .worker-box.cur{
- border: 4rpx solid var(--themeColor);
- }
- .worker-box .worker-box-select{
- display: none;
- }
- .worker-box.cur .worker-box-select{
- display: inline-block;
- width: 66rpx;
- height: 68rpx;
- position: absolute;
- z-index: 5;
- top: -2rpx;
- right: -2rpx;
- }
- .worker-box .worker-box-header{
- height: 90rpx;
- line-height: 90rpx;
- font-size: 32rpx;
- font-weight: bold;
- color: #333333;
- margin-bottom: 20rpx;
- }
- .worker-box .worker-box-info{
- padding: 30rpx 0;
- width: 100%;
- height: 130rpx;
- overflow: hidden;
-
- }
- .worker-box .worker-box-info .worker-box-avator{
- position: relative;
- width: 130rpx;
- height: 130rpx;
- float: left;
- }
- .worker-box .worker-box-info .worker-box-avator image{
- width: 100%;
- height: 100%;
- border-radius: 50%;
- }
- .worker-box .worker-box-info .worker-box-avator .worker-box-status{
- position: absolute;
- z-index: 10;
- bottom: 0;
- left: 0;
- width: 100%;
- height: 36rpx;
- border-radius: 18rpx;
- color: #ffffff;
- background-color: var(--themeColor);
- text-align: center;
- font-size: 26rpx;
- }
- .worker-box .worker-box-info .worker-box-avator .worker-box-status.color2{
- background-color: #23C1CF;
- }
- .worker-box .worker-box-info .worker-box-body{
- width: 520rpx;
- height: 130rpx;
- float: right;
- }
- .worker-box .worker-box-info .worker-box-body .worker-box-title{
- color: #333333;
- font-size: 30rpx;
- font-weight: bold;
- line-height: 50rpx;
- }
- .worker-box .worker-box-info .worker-box-body .worker-box-star{
- display: inline-block;
- width: auto;
- float: right;
- }
- .worker-box .worker-box-info .worker-box-body .worker-box-desc{
- color: #999999;
- font-size: 26rpx;
- line-height: 40rpx;
- height: 40rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space:nowrap;
- }
- .worker-box .worker-box-footer{
- line-height: 99rpx;
- height: 99rpx;
- border-top: 1rpx solid #D9D9D9;
- }
- .worker-box .worker-box-footer image{
- width: 36rpx;
- height: 36rpx;
- vertical-align: middle;
- }
- .worker-box .worker-box-footer .worker-box-footer-money{
- vertical-align: middle;
- padding: 0 10rpx;
- font-size: 34rpx;
- color: #FF3F40;
- }
- .worker-box .worker-box-footer .worker-box-footer-btn{
- display: inline-block;
- width: 130rpx;
- height: 60rpx;
- line-height: 60rpx;
- color: #ffffff;
- background-color: var(--themeColor);
- border-radius: 30rpx;
- text-align: center;
- font-size: 30rpx;
- float: right;
- margin-top: 20rpx;
- margin-left: 10rpx;
- }
- .worker-box .worker-box-footer .worker-box-footer-btn-cancel{
- display: inline-block;
- width: 158rpx;
- height: 60rpx;
- line-height: 60rpx;
- color: #999999;
- border: 1rpx solid #B3B3B3;
- border-radius: 30rpx;
- text-align: center;
- font-size: 30rpx;
- float: right;
- margin-top: 20rpx;
- margin-left: 10rpx;
- }
-
-
- .form-box{
- width: 670rpx;
- height: 90rpx;
- line-height: 90rpx;
- background-color: #ffffff;
- border-radius: 10rpx;
- padding: 0 20rpx;
- margin-bottom: 20rpx;
- overflow: hidden;
- }
- .form-box2{
- min-height:200rpx;
- height: auto;
- }
- .form-box .form-box-label{
- display: inline-block;
- width: 250rpx;
- float: left;
- font-size: 34rpx;
- font-weight: bold;
- color: #333333;
- }
- .form-box .form-box-content{
- display: inline-block;
- width: 400rpx;
- float: right;
- text-align: right;
- }
- .form-box .form-box-content input{
- height: 70rpx;
- line-height: 70rpx;
- vertical-align: middle;
- margin-top: 10rpx;
- }
- .form-box .form-box-content image{
- width: 24rpx;
- height: 24rpx;
- vertical-align: middle;
- }
- .form-box .form-box-content .form-box-content-text{
- float: left;
- display: inline-block;
- width: 360rpx;
- overflow: hidden;
- font-size: 30rpx;
- height: 90rpx;
- text-overflow: ellipsis;
- white-space:nowrap;
- }
- .form-box .form-box-textarea{
- width: 100%;
- float: left;
- padding-bottom: 20rpx;
- overflow: hidden;
- }
- .form-box .form-box-textarea textarea{
- width: 100%;
- padding: 20rpx;
- line-height: 40rpx;
- background-color: #F7F7F7;
- }
-
- .form-box .form-box-sub{
- width: 670rpx;
- height: 90rpx;
- line-height: 90rpx;
- background-color: #ffffff;
- border-radius: 10rpx;
- padding: 0;
- overflow: hidden;
- }
- .form-box3{
- width: 100%;
- height: 90rpx;
- line-height: 90rpx;
- background-color: #ffffff;
- border-radius: 10rpx;
- padding: 0 20rpx;
- margin-bottom: 20rpx;
- overflow: hidden;
- }
- .form-box3 .form-box-label{
- display: inline-block;
- width: 40%;
- float: left;
- font-size: 34rpx;
- font-weight: bold;
- color: #333333;
- }
- .form-box3 .form-box-content{
- display: inline-block;
- width: 50%;
- float: left;
- text-align: right;
- }
- .form-box3 .form-box-content input{
- height: 70rpx;
- line-height: 70rpx;
- vertical-align: middle;
- margin-top: 10rpx;
- }
- .form-box3 .form-box-content image{
- width: 24rpx;
- height: 24rpx;
- vertical-align: middle;
- }
- .form-box3 .form-box-content .form-box-content-text{
- // float: left;
- display: inline-block;
- width: 85%;
- overflow: hidden;
- font-size: 30rpx;
- height: 90rpx;
- text-overflow: ellipsis;
- white-space:nowrap;
- }
- .form-box3 .form-box-textarea{
- width: 100%;
- float: left;
- padding-bottom: 20rpx;
- overflow: hidden;
- }
- .form-box3 .form-box-textarea textarea{
- width: 100%;
- padding: 20rpx;
- line-height: 40rpx;
- background-color: #F7F7F7;
- }
- </style>
|