shish 4 rokov pred
rodič
commit
557686be12

+ 2 - 2
ghsApp/src/admin/staff/miniAutoLogin.vue

@@ -3,8 +3,8 @@
     <form>
       <view class="module-com input-line-wrap">
         <view class="btn-wrap">
-          <view style="padding:30upx 0 30upx 0;font-size:30upx;">帐号绑定微信,下次打开小程序自动登录后台</view>
-          <button class="admin-button-com blue middle" @click="autoLogin()">授权并绑定</button>
+          <view style="padding:30upx 0 30upx 0;font-size:30upx;">绑定微信,下次打开小程序自动登录后台</view>
+          <button class="admin-button-com blue big" @click="autoLogin()">授权并绑定</button>
         </view>
       </view>
     </form>

+ 52 - 64
hdApp/src/admin/staff/add.vue

@@ -1,10 +1,14 @@
 <template>
   <div class="app-content">
-    <div v-show="showStaffArea">
-      <!-- 员工信息 -->
+    <div>
       <form @submit="formSubmit" @reset="formReset">
         <div class="module-com input-line-wrap">
-          
+
+          <tui-list-cell class="line-cell" :hover="false">
+              <div class="tui-title required">昵称</div>
+              <input v-model="form.name" type="text" placeholder-class="phcolor" placeholder-style="color:#CCCCCC" class="tui-input" name="name" placeholder="员工昵称" />
+          </tui-list-cell>
+
           <tui-list-cell class="line-cell" :arrow="true">
             <div class="tui-title required">角色</div>
             <picker mode="selector" :value="form.roleId" :range="roleList" range-key="roleName" @change="changeRoleFn" class="tui-input" >
@@ -14,7 +18,7 @@
             </picker>
           </tui-list-cell>
 
-          <tui-list-cell class="line-cell" padding="14upx 30upx" :hover="false">
+          <tui-list-cell class="line-cell" :hover="false">
             <div class="tui-title">动态通知</div>
             <view><switch style="transform:scale(0.7,0.7)" :checked="form.remind == 0 ? false : true" @change="remindChangeFn" /></view>
           </tui-list-cell>
@@ -34,38 +38,27 @@
           <tui-list-cell class="line-cell remark-wrap" :hover="false">
             <div class="tui-title">备注信息</div>
             <div class="tui-input">
-              <textarea v-model="form.remark" class="tui-textarea remark" placeholder-class="phcolor" style="height:80upx;" placeholder="请输入内容" />
+              <textarea v-model="form.remark" class="tui-textarea remark" placeholder-class="phcolor" style="height:80upx;" placeholder="选填" />
             </div>
           </tui-list-cell>
+
         </div>
 
         <div class="confirm-btn">
           <button class="admin-button-com big blue" formType="submit">确认</button>
         </div>
+
       </form>
     </div>
-    <div v-show="showMiniCodeArea">
-      <view style="text-align:center;">
-          <image style="width:200upx;height:200upx;margin:0 auto;" :src="miniCodeSrc"></image>
-          <view style="text-align:center;margin-top:20upx;margin-bottom:20upx;">请让员工扫描上方太阳码完成绑定</view>
-          <button class="admin-button-com big blue" @click="complete" style="padding-left:23upx;padding-right:23upx;">完成</button>
-      </view>
-    </div>
   </div>
 </template>
-
 <script>
 import TuiListCell from "@/components/plugin/list-cell";
 import AppAvatarModule from "@/components/module/app-avatar";
 const form = require("@/utils/formValidation.js");
-// api
-import {
-  getRoleList,
-  getStaffDet as getDet,
-  updateStaff as update
-} from "@/api/staff";
+import { getRoleList, getStaffDet as getDet, updateStaff as update } from "@/api/staff";
 import { getDet as getMemberDet } from "@/api/member";
-import { prepareBind } from "@/api/shop-admin";
+import { getStaffAuthCode,createStaff } from "@/api/staff";
 export default {
   name: "staff-add",
   components: {
@@ -88,22 +81,39 @@ export default {
       showStaffArea: true,
       showMiniCodeArea: false,
       miniCodeSrc:'',
-      memberData: {}
+      memberData: {},
+      hasGet:false,
+      INT:null,
+      count:0
     };
   },
   onLoad() {},
   onShow() {
-    if (this.option.id) {
-      uni.setNavigationBarTitle({
-        title: `修改员工`
-      });
-    } else {
-      uni.setNavigationBarTitle({
-        title: `添加员工`
-      });
-    }
   },
   methods: {
+    requestAuthCode(){
+      let that = this
+      let mobile = this.form.mobile
+      if(this.$util.checkMobile(mobile) == false){
+        this.$msg('请输入正确手机号')
+        return
+      }
+      getStaffAuthCode({mobile}).then(res=>{
+        if(res.code == 1){
+          that.hasGet = true
+          that.count = 120
+          that.INT = setInterval(function(){
+            if(that.count <= 0){
+              clearInterval(that.INT)
+              that.hasGet = false
+              that.count = 120
+              return
+            }
+            that.count--
+          },1000)
+        }
+      })
+    },
     init() {
       let data = uni.getStorageSync("addStaffData");
       if (data) {
@@ -127,7 +137,6 @@ export default {
         }
       });
     },
-    // api
     async _getRoleList() {
       await getRoleList().then(res => {
         if (this.$util.isEmpty(res.data)) return false;
@@ -183,47 +192,27 @@ export default {
       this.form.status = e.detail.value ? 1 : 0;
     },
     confirmFn() {
-      let hostFn = this.option.id ? update : prepareBind;
-      if (this.option.id) {
-        this.form.id = this.option.id;
-      }
-      hostFn(this.form).then(res => {
-        console.log('23rh23r23')
-        console.log(res)
-        console.log(this.option.id)
-        if(typeof(this.option.id) == 'undefined'){
-          this.showMiniCodeArea = true;
-          this.miniCodeSrc = res.data.miniCode;
-          this.showStaffArea = false;
-          console.log(this.miniCodeSrc)
-          console.log('--oo0oooo---')
-        }else{
-          let promptText = this.option.id ? "修改成功!" : "添加成功!";
-          this.$msg(promptText);
-          setTimeout(() => {
-            this.$util.pageTo(1);
-          }, 1000);
-        }
-        
+      uni.showLoading({mask:true})
+      let that = this
+      createStaff(this.form).then(res => {
+          uni.hideLoading()
+          if(res.code == 1){
+            that.$msg('添加成功')
+            setTimeout(() => {
+              uni.navigateBack()
+            }, 1000)
+          }
       });
     },
     complete(){
       this.$util.pageTo(1)
     },
-    // 表单验证
     formSubmit(e) {
-      // 表单规则
       let rules = [
-        {
-          name: "roleId",
-          rule: ["required"],
-          msg: ["请选择角色"]
-        }
+        { name: "roleId", rule: ["required"], msg: ["请选择角色"] }
       ];
-      // 进行表单检查
       let formData = e.detail.value;
       let checkRes = form.validation(formData, rules);
-      // 验证通过!
       if (!checkRes) {
         this.confirmFn();
       } else {
@@ -233,7 +222,6 @@ export default {
   }
 };
 </script>
-
 <style lang="scss" scoped>
 .app-content {
   min-height: calc(100vh - 20upx);
@@ -268,4 +256,4 @@ export default {
     width: 100%;
   }
 }
-</style>
+</style>

+ 11 - 56
hdApp/src/admin/staff/detail.vue

@@ -1,74 +1,39 @@
 <template>
   <div class="app-content">
-    <div v-show="showStaffArea">
-      <!-- 员工信息 -->
+    <div>
       <form @submit="formSubmit" @reset="formReset">
         <div class="module-com input-line-wrap">
-          <picker
-              mode="selector"
-              :value="form.roleId"
-              :range="roleList"
-              range-key="roleName"
-              @change="changeRoleFn"
-              class="tui-input"
-            >
+          
           <tui-list-cell class="line-cell" :arrow="true">
             <div class="tui-title required">角色</div>
+            <picker mode="selector" :value="form.roleId" :range="roleList" range-key="roleName" @change="changeRoleFn" class="tui-input" >
               <input v-model="form.roleId" name="roleId" type="text" hidden />
               <div v-if="form.roleId">{{ roleSelData.roleName }}</div>
               <div class="tui-placeholder" v-else>请选择</div>
+            </picker>
           </tui-list-cell>
-          </picker>
 
-        </div>
-        <!-- 收款通知 -->
-        <div class="module-com input-line-wrap">
-          <tui-list-cell class="line-cell between" padding="14upx 30upx" :hover="false">
+          <tui-list-cell class="line-cell" :hover="false">
             <div class="tui-title">收款通知</div>
             <div>
-              <switch :checked="form.remind == 0 ? false : true" @change="remindChangeFn" />
+              <switch style="transform:scale(0.7,0.7)" :checked="form.remind == 0 ? false : true" @change="remindChangeFn" />
             </div>
           </tui-list-cell>
-        </div>
-        <!-- 登录信息 -->
-        <div class="module-com input-line-wrap">
-          <tui-list-cell class="line-cell" :hover="false">
-            <div class="tui-title">登录密码</div>
-            <input
-              v-model="form.password"
-              placeholder-class="phcolor"
-              class="tui-input"
-              name="password"
-              placeholder="请输入"
-              maxlength="50"
-              type="password"
-            />
-          </tui-list-cell>
+
           <tui-list-cell class="line-cell remark-wrap" :hover="false">
             <div class="tui-title">备注信息</div>
             <div class="tui-input">
-              <textarea
-                v-model="form.remark"
-                class="tui-textarea remark"
-                placeholder-class="phcolor"
-                placeholder="请输入内容"
-              />
+              <textarea v-model="form.remark" class="tui-textarea remark" placeholder-class="phcolor" style="height:80upx;" placeholder="选填" />
             </div>
           </tui-list-cell>
         </div>
-        <!-- 提交 -->
+        
         <div class="confirm-btn">
           <button class="admin-button-com big blue" formType="submit">确认</button>
         </div>
+
       </form>
     </div>
-    <div v-show="showMiniCodeArea">
-      <view style="text-align:center;">
-          <image style="width:200upx;height:200upx;margin:0 auto;" :src="miniCodeSrc"></image>
-          <view style="text-align:center;margin-top:20upx;margin-bottom:20upx;">请让员工扫描上方太阳码完成绑定</view>
-          <button class="admin-button-com big blue" @click="complete" style="padding-left:23upx;padding-right:23upx;">完成</button>
-      </view>
-    </div>
   </div>
 </template>
 
@@ -109,15 +74,7 @@ export default {
   },
   onLoad() {},
   onShow() {
-    if (this.option.id) {
-      uni.setNavigationBarTitle({
-        title: `修改员工`
-      });
-    } else {
-      uni.setNavigationBarTitle({
-        title: `添加员工`
-      });
-    }
+
   },
   methods: {
     init() {
@@ -154,9 +111,7 @@ export default {
       getDet({ id: this.option.id }).then(res => {
         if (this.$util.isEmpty(res.data)) return;
         Object.keys(this.form).forEach((i, index) => {
-          // if (i != 'password') {
           this.form[i] = res.data[i];
-          // }
         });
         this.roleSelData = this.roleList.filter(
           e => this.form.roleId == e.id

+ 2 - 2
hdApp/src/admin/staff/miniAutoLogin.vue

@@ -3,8 +3,8 @@
     <form>
       <view class="module-com input-line-wrap">
         <view class="btn-wrap">
-          <view style="padding:30upx 0 30upx 0;font-size:30upx;">帐号绑定微信,下次打开小程序自动登录后台</view>
-          <button class="admin-button-com blue middle" @click="autoLogin()">授权并绑定</button>
+          <view style="padding:30upx 0 30upx 0;font-size:30upx;">绑定微信,下次打开小程序自动登录后台</view>
+          <button class="admin-button-com blue big" @click="autoLogin()">授权并绑定</button>
         </view>
       </view>
     </form>

+ 12 - 6
hdApp/src/api/staff/index.js

@@ -56,16 +56,22 @@ export const updateRole = data => {
 	return https.post('/admin-role/update', data)
 }
 
-/** *
- * 员工角色--删除 b
- */
+//员工角色
 export const delRole = data => {
 	return https.get('/admin-role/delete', data)
 }
 
-/** *
- * 操作记录 b
- */
+//操作记录
 export const getLogList = data => {
 	return https.get('/admin-log/list', data)
 }
+
+//获取员工的验证码
+export const getStaffAuthCode = data => {
+	return https.get('/shop-admin/get-staff-auth-code', data)
+}
+
+//添加员工
+export const createStaff = data => {
+	return https.post('/shop-admin/add-staff', data)
+}

+ 20 - 1
hdApp/src/mixins/globalMixins.js

@@ -2,7 +2,7 @@ import { mapGetters,mapActions } from 'vuex'
 import { pageTo, getCheckLogin, isLogin } from '@/utils/util.js'
 import { getUser, wxLoginFn } from '@/utils/auth'
 import { postWxCode, getDictionaries } from '@/api/mini'
-import { getStaffApi } from '@/api/common'
+import { getStaffApi,hasTokenAutoLogin } from '@/api/common'
 import constant from '@/constant'
 export default {
 	data() {
@@ -56,7 +56,26 @@ export default {
 					})
 				}
 			}else{
+				let that = this
+				hasTokenAutoLogin().then(subRes=>{
+				  //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
+				  if(subRes.code == 1){
+					uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
+					getDictionaries({ token: subRes.data.token }).then(res => {
+						if (that.$util.isEmpty(res)) {
+							return false
+						}
+						that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
+						that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
+					})
+					that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
+					getUser(true).then(res => { 
+						uni.setNavigationBarTitle({ title: res.name })
+					})
+					that.setUserShopAll()
+				  }
 
+				})
 			}
 			// #endif
 		}