소스 검색

保姆明细

WFADLMOXAOK6T5N\Administrator 4 년 전
부모
커밋
34d88a06e3

+ 1 - 1
client/app.js

@@ -14,6 +14,6 @@ App({
     // options.query == {number:1}
   },
   globalData:{
-    
+    userInfo:{},
   }
 });

+ 2 - 1
client/app.json

@@ -6,7 +6,8 @@
     "pages/servant/servantCenter/servantCenter",
     "pages/customer/createServant/createServant",
     "pages/customer/dailytasks/dailytasks",
-    "pages/servant/servantdetail/servantdetail"
+    "pages/servant/servantdetail/servantdetail",
+    "pages/customer/customerCenter/customerCenter"
   ],
   "window": {
     "defaultTitle": "保姆管家"

+ 47 - 12
client/pages/common/index/index.js

@@ -1,13 +1,26 @@
 import request from '../../../util/http'
+import apiUrl from '../../../util/apiUrl'
 import util from '../../../util/util'
 import moment from 'moment'
-
+var app = getApp();
 Page({
   onLoad(query) {
     // 页面加载
     console.log('onLoad');
     console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
-    this.authInit();
+    let storageRes = my.getStorageSync({ key: 'userInfo' });
+    console.log(storageRes);
+    //  this.authInit();
+    if(storageRes.data==null){
+      // 没有用户信息获取授权
+       this.authInit();
+    }else{
+     let id= storageRes.data.id;
+      // 有用户信息更新用户信息
+      let params={'id':id};
+      this.getUserInfo(params);
+    }
+      
   },
   onReady() {
     // 页面加载完成
@@ -39,26 +52,48 @@ Page({
     };
   },
   // 授权登录
-  authInit(){
+   authInit(){
  my.authorize({
   scopes: 'scope.userInfo',
   success: (res) => {
     my.getAuthUserInfo({
-      success: (userInfo) => {
+      success:  (userInfo) => {
         console.log(userInfo);
-        my.alert({
-      content: userInfo.nickName
-    });
-        request.httpService();
+      //  let  data= await request.httpServicePost(apiUrl.registerUserPath);
+        request.httpServicePost(apiUrl.registerUserPath).then(data=>{
+        console.log(data);
+        let userInfo=data;
+        //  授权注册成功后将用户信息存到本地存储和globalData
+        my.setStorageSync({
+          key: 'userInfo',
+         data: userInfo
+           });
+        })
+        app.globalData.userInfo = userInfo;
+         
       }
     });
   },
 });
   },
-  requestPost(){
-   
-  
-  
+
+  // 获取用户信息
+       getUserInfo(params){
+      request.httpServiceGet(apiUrl.getUserInfoPath,params).then(data=>{
+        console.log(data);
+        //  授权用户信息后将用户信息存到本地存储和globalData
+        if(data!=undefined){
+           app.globalData.userInfo=data;
+       my.setStorageSync({
+         key:"userInfo",
+         data:data
+       });
+        }
+      
+        })
+
+      // let  res=await request.httpServiceGet(apiUrl.getUserInfoPath,params);
+      // console.log(res);
   }
 
 });

+ 121 - 0
client/pages/customer/customerCenter/customerCenter.acss

@@ -0,0 +1,121 @@
+page{
+  padding-top:24rpx;
+}
+.module-card{
+  height: 118rpx;
+  background: url('/image/icon-right.png') no-repeat  97% center;
+  background-size:12rpx;
+  background-color: #fff;
+  padding:0 24rpx;
+  margin:0 0 24rpx 0;
+}
+/* 任务提醒 */
+.task-module{
+  padding:24rpx;
+  margin:0 0 24rpx 0;
+}
+.task-top{
+  background: url('/image/icon-right.png') no-repeat  right 6rpx;
+  background-size:12rpx;
+  background-color: #fff;
+  margin:0 0 20rpx 0;
+}
+.no-add{
+  background: #FAFAFA;
+  height: 240rpx;
+  font-size: 36rpx;
+  color:#09AFFF;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border-radius:12rpx;
+}
+/* 今天无任务 */
+.no-task{
+  background: #FAFAFA;
+  height: 326rpx;
+  font-size: 36rpx;
+  color:#999;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border-radius:12rpx;
+}
+/* 任务列表 */
+.task-item{
+  background: #FAFAFA;
+  height: 100rpx;
+  line-height: 100rpx;
+  border-radius:12rpx;
+  padding-left:28rpx;
+  margin:0 0 16rpx 0;
+  color:#666;
+  font-weight: bold;
+}
+.task-item:last-child{
+  margin:0;
+}
+.task-schedule{
+  color:#FFAA00;
+  font-size: 20rpx;
+  border-radius:4rpx;
+  background: #FFF6E6;
+  padding:2rpx 8rpx;
+  margin-left:6rpx;
+  font-weight: normal;
+}
+.module-text{
+  height: 118rpx;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+}
+.module-title{
+  font-size: 28rpx;
+  font-weight: bold;
+  display: flex;
+  align-items: center;
+}
+.module-detail{
+  color: #999;
+  font-size: 20rpx;
+  margin-top:8rpx;
+}
+.no-service-standard{
+  color:#FF5030;
+  font-size: 20rpx;
+  border-radius:4rpx;
+  background: #FFEDEA;
+  padding:2rpx 8rpx;
+  margin-left:6rpx;
+  font-weight: normal;
+}
+.report-tips{
+  color:#09AFFF;
+  font-size: 20rpx;
+  border-radius:4rpx;
+  background: #E6F7FF;
+  padding:2rpx 8rpx;
+  margin-left:6rpx;
+  font-weight: normal;
+}
+/* 敬请期待 */
+.future-module{
+  padding:24rpx 24rpx 32rpx;
+}
+.forward-title{
+  font-size:32rpx;
+  font-weight:bold;
+  margin-bottom:20rpx;
+}
+.forward-unit-wrapper{
+  height: 128rpx;
+  display: flex;
+  justify-content: space-between
+}
+.forward-unit-wrapper image{
+  width:128rpx;
+  height:128rpx;
+  border-radius: 12rpx;
+  background: #ddd;
+}

+ 60 - 0
client/pages/customer/customerCenter/customerCenter.axml

@@ -0,0 +1,60 @@
+<view class="common-page-padding">
+ <!-- 信息面板 -->
+ <view class="common-card"></view>
+ <!-- 通知 -->
+ <view class="notice-bar"></view>
+ <!-- 任务提醒 -->
+  <view class="common-card task-module">
+     <view class="task-top">
+      <view class="module-title">任务提醒
+       <text class="task-schedule"  a:if="{{taskListShow}}">完成进度7/10</text>
+      </view>
+      <view class="module-detail">高效沟通 任务提醒更可靠</view>
+      </view>
+     <!-- 暂未添加 -->
+     <view class="no-add" a:if="{{noAddTaskShow}}">
+         +快速添加
+     </view>
+     <!-- 今天无任务 -->
+     <view class="no-task" a:if="{{noTaskShow}}">
+     今天保姆休息
+     </view>
+     <!-- 任务列表 -->
+     <view class="task-list" a:if="{{taskListShow}}">
+        <view class="task-item" a:for="{{taskList}}" key="{{index}}">
+        {{item}}
+        </view>
+     </view>
+     
+  </view>
+  <!-- 服务标准 -->
+   <view class="common-card module-card">
+      <view class="module-text">
+      <view class="module-title">
+      服务标准
+      <text class="no-service-standard">未设置</text>
+      </view>
+      <view class="module-detail">标准化服务 更贴心</view>
+      </view>
+   </view>
+   <!-- 月报 -->
+    <view class="common-card module-card">
+       <view class="module-text">
+      <view class="module-title">
+      保姆月报
+      <text class="report-tips">服务时间较短,暂未生成~</text>
+      </view>
+      <view class="module-detail">服务回顾 发现问题</view>
+      </view>
+    </view>
+    <!-- 敬请期待 -->
+     <view class="common-card future-module">
+        <view class="forward-title">敬请期待</view>
+        <view class="forward-unit-wrapper">
+          <image mode="scaleToFill" src=""/>
+          <image mode="scaleToFill" src=""/>
+          <image mode="scaleToFill" src=""/>
+          <image mode="scaleToFill" src=""/>
+        </view>
+     </view>
+</view>

+ 9 - 0
client/pages/customer/customerCenter/customerCenter.js

@@ -0,0 +1,9 @@
+Page({
+  data: {
+    noAddTaskShow:false,//未添加任务
+    noTaskShow:false,//今天无任务
+    taskListShow:true,//任务列表
+    taskList:['洗衣服','做晚饭','打扫卫生'],
+  },
+  onLoad() {},
+});

+ 3 - 0
client/pages/customer/customerCenter/customerCenter.json

@@ -0,0 +1,3 @@
+{
+   "defaultTitle": "保姆工作站"
+}

+ 15 - 0
client/util/apiUrl.js

@@ -0,0 +1,15 @@
+let baseService='/servantappletservice';
+// 授权后注册
+const registerUserPath=baseService+'/auth/registerUser';
+// 获取用户信息/user/getUserInfo
+const getUserInfoPath=baseService+'/user/getUserInfo';
+
+// POST /auth/chooseIdentity 身份选择
+const chooseIdentityPath=baseService+'/auth/chooseIdentity'
+
+
+export default{
+registerUserPath,
+getUserInfoPath,
+chooseIdentityPath
+}

+ 74 - 9
client/util/http.js

@@ -1,27 +1,92 @@
-const httpService= async ()=>{
+// get请求
+const httpServiceGet= async (path,params)=>{
+  const {cloud} = getApp();
+  try {
+    console.log('request begin'); 
+  const result = await  cloud.application.httpRequest({
+ //不需要完整域名,只需要接口访问路径即可
+  // 'path' : '/servantappletservice/auth/registerUser', 
+    'path' : path, 
+  'method':'GET',
+  'headers':{ },
+  'params':params,
+  'body':{  },
+ //对于一个小程序关联多个云应用的场景,调用非默认云应用,需要指定对应的云应用Id,超时时间单位ms
+  'exts':{  "cloudAppId":"21907" ,"timeout":60000}  });
+   console.log('response');
+  console.log(result);
+//      my.alert({
+//   content: JSON.stringify(result) 
+//  }); 
+
+if(result.errno=='0'){
+  return result.data;
+}
+
+//  return new Promise((resolve,reject) => {
+//    if(result.errno=='0'){
+//         resolve(result.data);
+//    }else{
+//       my.alert({
+//     content: result.errmsg 
+//  });  
+//     reject('error')
+//    }
+       
+      // })
+    
+  } catch(e) {
+    console.log(e);
+  my.alert({
+    
+  // content: 'error'+e.message 
+    content: e.msg 
+ });  
+ } 
+} 
+// post请求
+const httpServicePost= async (path,params)=>{
   const {cloud} = getApp();
   try {
     console.log('request begin');
   const result = await cloud.application.httpRequest({
  //不需要完整域名,只需要接口访问路径即可
-  'path' : '/servantappletservice/getKey', 
-  'method':'GET',
-  'headers':{  "mc-dd":"test",  },
-  'params':{"key":1},
-  'body':{  "xftest":"hhh",  "id":"1234",  },
+  // 'path' : '/servantappletservice/auth/registerUser', 
+    'path' : path, 
+  'method':'POST',
+  'headers':{ 'Content-type': 'application/json' },
+  'params':{},
+  'body':params,
  //对于一个小程序关联多个云应用的场景,调用非默认云应用,需要指定对应的云应用Id,超时时间单位ms
   'exts':{  "cloudAppId":"21907" ,"timeout":60000}  });
+   console.log(result);
    console.log('response');
-  console.log(JSON.stringify(result));
+  // console.log(JSON.stringify(result));
      my.alert({
   content: JSON.stringify(result) 
  }); 
+ console.log(result);
+if(result.errno=='0'){
+  return result.data;
+}
+//   return new Promise((resolve) => {
+//         if(result.errno=='0'){
+//         resolve(result.data);
+//    }else{
+//       my.alert({
+//     content: result.errmsg 
+//  });  
+//    }
+//       })
   } catch(e) {
+    console.log(e);
   my.alert({
-  content: 'error'+e.message 
+     content: 'false'+JSON.stringify(e) 
+  // content: 'error'+e.msg 
  });  
  } 
 } 
 export default{
-  httpService
+  httpServiceGet,
+  httpServicePost
 }