Browse Source

+ 与会企业行程

chen.cheng 11 months ago
parent
commit
7a8370f149

+ 14 - 0
common/api.js

@@ -1,3 +1,5 @@
+import { getToken } from '@/util';
+
 const { http } = uni.$u
 // 获取菜单
 export const fetchMenu = (params, config = {}) => http.post(
@@ -15,3 +17,15 @@ export const fetchViewCfgList = (params) => http.get('/cp/viewcfg/list',
 
 export const fetchFileList = (params) => http.get('/cp/fileInfo/list',
   { params });
+
+export const putUsrRegist = (params) => {
+  const token = getToken();
+  if (getToken()) {
+    return Promise.reject('未登录');
+  }
+  return http.put('/cp/user', params, {
+    headers: {
+      Authorization: `Bearer ${token}`,
+    },
+  });
+};

+ 10 - 0
components/SingleDropList/index.scss

@@ -0,0 +1,10 @@
+.single-drop-list {
+  width: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: flex-start;
+}
+
+page {
+  height: 100%;
+}

+ 77 - 0
components/SingleDropList/index.vue

@@ -0,0 +1,77 @@
+<template>
+  <view class="single-drop-list" @click="show = true">
+    <u--input
+        v-model="name"
+        disabled
+        disabledColor="#ffffff"
+        :placeholder="placeholder"
+        border="none"
+    ></u--input>
+    <u-icon
+        slot="right"
+        name="arrow-right"
+    ></u-icon>
+    <u-action-sheet
+        :show="show"
+        :actions="src"
+        :title="placeholder"
+        @close="show = false"
+        @select="onSelect"
+    >
+    </u-action-sheet>
+  </view>
+</template>
+
+<script>
+
+export default {
+  name: 'single-drop-list',
+  props: {
+    src: {
+      type: Array,
+      default: () => [],
+    },
+    defaultValue: {
+      type: String,
+      default: () => {},
+    },
+    placeholder: {
+      type: String,
+      default: '选择参会企业',
+    },
+    onChange: {
+      type: Function,
+      default: () => {},
+    },
+  },
+  data() {
+    return {
+      show: false,
+      name: '',
+      value: '',
+    };
+  },
+  watch: {
+    src: {
+      handler(val) {
+        if (val && val.length > 0 && this.defaultValue) {
+          const defItem = val.find((item) => item.value === this.defaultValue);
+          this.name = defItem.name;
+        }
+      },
+      immediate: true,
+    },
+  },
+  created() {
+  },
+  mounted() {
+  },
+  methods: {
+    onSelect(item) {
+      this.name = item.name;
+      this.onChange(item);
+    },
+  },
+};
+</script>
+<style lang="scss" src="./index.scss" />

+ 2 - 2
package.json

@@ -38,8 +38,8 @@
 				"title": "微信开发版",
 				"env": {
 					"UNI_PLATFORM": "mp-weixin",
-					"UNI_FILE_PREFIX": "http://127.0.0.1:8080/tfc",
-					"UNI_API_PREFIX": "http://127.0.0.1:8080/tfc"
+					"UNI_FILE_PREFIX": "http://172.192.13.74:8080/tfc",
+					"UNI_API_PREFIX": "http://172.192.13.74:8080/tfc"
 				},
 				"define": {
 					"MP-WEIXIN": true

+ 34 - 4
pasb/pages/regist/index.scss

@@ -1,16 +1,46 @@
-.register-container {
+.register-bg {
   width: 100%;
   height: 100%;
   display: flex;
   flex-direction: column;
   justify-content: flex-start;
   align-items: center;
-  padding: 20rpx;
-  box-sizing: border-box;
-  /deep/ .form-content{
+  background-color: #79797938;
 
+  .bg-container {
+    width: 100%;
+    height:300rpx;
+    background-color: #005598;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    color: #fefefe;
+    font-size: 40rpx;
+    font-weight: 600;
+  }
+
+  .register-container {
+    width: 90%;
+    margin-top: -100rpx;
+    z-index: 1;
+    border-radius: 20rpx;
+    padding: 20rpx;
+    box-sizing: border-box;
+    background-color: #fefefe;
+
+    /deep/ .u-form {
+      .u-form-item {
+        .u-form-item__body__left {
+          width: auto !important;
+        }
+        .u-form-item__body__right__message{
+          margin-left: 0 !important;
+        }
+      }
+    }
   }
 }
+
 page {
   height: 100%;
 }

+ 152 - 62
pasb/pages/regist/index.vue

@@ -1,84 +1,151 @@
 <template>
-  <auth-wrap class="register-container" ref="authWrap">
-    <view class="form-content" slot="content">
-      <u--form
-          labelPosition="left"
-          :model="model1"
-          :rules="rules"
-          ref="uForm"
-      >
-        <u-form-item
-            prop="userInfo.name"
-            borderBottom
-            ref="item1"
-        >
-          <u--input
-              prefixIcon="account"
-              v-model="model1.userInfo.name"
-              border="none"
-          ></u--input>
-        </u-form-item>
-        <u-form-item
-            prop="userInfo.tel"
-            borderBottom
-            ref="item1"
+  <view class="register-bg">
+    <view class="bg-container">
+      参会报名
+    </view>
+    <auth-wrap class="register-container" ref="authWrap">
+      <view class="form-content" slot="content">
+        <u--form
+            labelPosition="left"
+            :model="model1"
+            :rules="rules"
+            ref="uForm"
         >
-          <u--input
-              prefixIcon="phone"
-              placeholder="输入手机号"
-              border="none"
-              v-model="model1.userInfo.tel"
-          ></u--input>
-        </u-form-item>
+          <u-form-item
+              prop="userInfo.name"
+              borderBottom
+              ref="item1"
+          >
+            <u--input
+                prefixIcon="account"
+                v-model="model1.userInfo.name"
+                border="none"
+            ></u--input>
+          </u-form-item>
+          <u-form-item
+              prop="userInfo.tel"
+              borderBottom
+              ref="item1"
+          >
+            <u--input
+                prefixIcon="phone"
+                placeholder="输入手机号"
+                border="none"
+                v-model="model1.userInfo.tel"
+            ></u--input>
+          </u-form-item>
 
-        <u-form-item
-            label="性别"
-            prop="userInfo.sex"
-            borderBottom
+          <u-form-item
+              label="性别"
+              prop="userInfo.sex"
+              borderBottom
+          >
+            <u-radio-group
+                v-model="model1.userInfo.sex"
+                placement="row"
+            >
+              <u-radio
+                  :style="{
+                  marginRight: '20rpx'
+                }"
+                  v-for="(item, index) in sexList"
+                  :key="index"
+                  :label="item.name"
+                  :name="item.value"
+              >
+              </u-radio>
+            </u-radio-group>
+          </u-form-item>
+          <u-form-item
+              label="参会企业"
+              prop="userInfo.enterpriseId"
+              borderBottom
+              ref="item1"
+          >
+            <SingleDropList
+                :style="{
+                marginLeft: '20rpx'
+              }"
+                defaultValue="1"
+                :src="sexList"
+                placeholder="请选择参会企业"
+                :on-change="enterpriseSelect"
+            >
+            </SingleDropList>
+          </u-form-item>
+          <u-form-item
+              label="参会行程"
+              prop="userInfo.tripId"
+              borderBottom
+              ref="item1"
+          >
+            <SingleDropList
+                :style="{
+                marginLeft: '20rpx'
+              }"
+                defaultValue="1"
+                :src="sexList"
+                placeholder="请选择参会行程"
+                :on-change="enterpriseSelect"
+            >
+            </SingleDropList>
+          </u-form-item>
+        </u--form>
+        <u-button
+            :style="{
+             marginTop: '120rpx'
+            }"
+            type="primary"
+            text="提交"
+            :disabled="loading"
+            :loading="loading"
+            loadingText="正在提交..."
+            @click="onSubmit"
         >
-          <u--input
-              v-model="model1.userInfo.sex"
-              disabled
-              disabledColor="#ffffff"
-              placeholder="请选择性别"
-              border="none"
-          ></u--input>
-          <u-icon
-              slot="right"
-              name="arrow-right"
-          ></u-icon>
-        </u-form-item>
-      </u--form>
-    </view>
-  </auth-wrap>
+        </u-button>
+      </view>
+    </auth-wrap>
+  </view>
+
 </template>
 
 <script>
 
+import { putUsrRegist } from '@/common/api';
 import { ICON_CFG } from '@/common/EnumConst';
 import AuthWrap from '@/components/AuthComp/index.vue';
-import { getImageUrl, setStorageObj } from '@/util';
+import SingleDropList from '@/components/SingleDropList/index.vue';
+import { getImageUrl, getUserInfo } from '@/util';
 
 export default {
   name: 'login',
-  components: { AuthWrap },
+  components: {
+    AuthWrap,
+    SingleDropList
+  },
   props: {},
   data() {
     return {
       ICON_CFG,
+      showEnterprise: false,
+      loading: false,
       model1: {
         userInfo: {
-          name: 'uView UI',
+          name: '',
           sex: '',
         },
       },
-      actions: [{
-        name: '男',
-      },
+      sexList: [
+        {
+          value: '0',
+          name: '男',
+        },
         {
+          value: '1',
           name: '女',
         },
         {
+          value: '2',
           name: '保密',
         },
       ],
@@ -87,14 +154,14 @@ export default {
           type: 'string',
           required: true,
           message: '请填写姓名',
-          trigger: ['blur', 'change']
+          trigger: ['blur', 'change'],
         },
-        'userInfo.sex': {
+        'userInfo.tel': {
           type: 'string',
-          max: 1,
+          max: 11,
           required: true,
-          message: '请选择男或女',
-          trigger: ['blur', 'change']
+          message: '请填写11位手机号',
+          trigger: ['blur', 'change'],
         },
       },
     };
@@ -103,14 +170,37 @@ export default {
   },
   onLoad() {
     //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
-    this.$refs.uForm.setRules(this.rules)
+    this.$refs.uForm.setRules(this.rules);
+    this.$refs.authWrap.reloadPage();
+    const user = getUserInfo();
+    if (user) {
+      this.model1.userInfo.name = user.usrName;
+    }
   },
   onReady() {
     //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
-    this.$refs.uForm.setRules(this.rules)
+    this.$refs.uForm.setRules(this.rules);
   },
   methods: {
     getImageUrl,
+    enterpriseSelect(enterprise) {
+      this.model1.userInfo.enterpriseId = enterprise.value;
+      this.model1.userInfo.enterpriseName = enterprise.name;
+      this.$refs.uForm.validateField('userInfo.enterpriseId');
+    },
+    onSubmit() {
+      this.loading = true;
+      this.$refs.uForm.validate().then(res => {
+        putUsrRegist(this.model1.userInfo);
+        this.loading = false;
+      }).catch(errors => {
+        uni.$u.toast('校验失败');
+        this.loading = false;
+      });
+    },
+    hideKeyboard() {
+      uni.hideKeyboard();
+    },
   },
 };
 </script>