Selaa lähdekoodia

新增下单前完善信息

谢杰标 2 vuotta sitten
vanhempi
commit
2e799ac387
5 muutettua tiedostoa jossa 324 lisäystä ja 12 poistoa
  1. 2 2
      common/config.js
  2. 11 0
      pages.json
  3. 29 5
      pages2/order/confirm_pay.vue
  4. 277 0
      pages2/verify/info_fill.vue
  5. 5 5
      store/index.js

+ 2 - 2
common/config.js

@@ -6,13 +6,13 @@ const test = {
   tenantId: "867735392558919680", //详粤云学堂
   appid: "wxd3c8ae80cf43a305",
 };
-// const index = 0; // 测试环境
+const index = 0; // 测试环境
 // const index = 1; // 祥粤云学堂
 // const index = 2 // 祥粤学堂
 // const index = 3 // 勘设云学堂
 // const index = 4 // 中正云学堂
 // const index = 5 // 山西云学堂
-const index = 6 // 预发布
+// const index = 6 // 预发布
 const set = [
   test,
   // 祥粤云学堂

+ 11 - 0
pages.json

@@ -546,6 +546,17 @@
             }
           }
         },
+        {
+          "path": "verify/info_fill",
+          "style": {
+            "navigationBarTitleText": "填写资料",
+            "navigationStyle": "custom", // 隐藏系统导航栏
+            "app-plus": {
+              "titleNView": false, //禁用原生导航栏
+              "bounce": "none"
+            }
+          }
+        },
         {
           "path": "appointment/index",
           "style": {

+ 29 - 5
pages2/order/confirm_pay.vue

@@ -84,11 +84,9 @@
       </view>
 
       <view style="display: flex; color: #ffffff; align-items: center">
-        <!-- <view class="btn2" @click="pay()">确认支付</view> -->
         <button class="btn2" @click="pay()" :disabled="btnNo">确认支付</button>
       </view>
     </view>
-    <!-- <button class="bottomBtn" @click="pay()" :disabled="btnNo">确认支付</button> -->
 
     <u-modal
       v-model="showModal"
@@ -107,7 +105,7 @@
 </template>
 
 <script>
-import { mapGetters } from "vuex";
+import { mapGetters, mapActions } from "vuex";
 import { getQueryString } from "../../common/navTo";
 import ClassTimeTip from "../../components/common/ClassTimeTip.vue";
 export default {
@@ -155,6 +153,7 @@ export default {
     // #endif
   },
   methods: {
+    ...mapActions(["getUserInfo"]),
     authorize() {
       if (location.search.includes("code")) {
         const code = getQueryString("code");
@@ -199,10 +198,17 @@ export default {
           }
         });
     },
-    postOrder() {
+    async postOrder() {
       let list = this.shoppingCartList;
+      let keys = [];
       for (let i = 0; i < list.length; i++) {
         let item = list[i];
+        if (item.erJianErZao) {
+          keys.push("realname", "idCard");
+        }
+        if (item.jjShiGongYuan) {
+          keys.push("sex", "companyName", "eduLevel");
+        }
         if (item.goodsType == 1) {
           if (item.templateType == "class") {
             delete item.gradObj.goodsList;
@@ -227,6 +233,25 @@ export default {
           item.distributionCode = this.options.distributionCode;
         }
       }
+      // 二建 && 七大员 需要先完善信息
+      if (keys.length) {
+        if (!this.userInfo) await this.getUserInfo();
+        if (keys.some((key) => !this.userInfo[key])) {
+          this.btnNo = false;
+          uni.showModal({
+            title: "提示",
+            content: "请先完善个人信息!",
+            success: (res) => {
+              if (res.confirm) {
+                this.$navTo.togo("/pages2/verify/info_fill", {
+                  keys: keys.toString(),
+                });
+              }
+            },
+          });
+          return;
+        }
+      }
       let data = { goodsList: list };
       // 邀请码
       if (this.sac) {
@@ -427,7 +452,6 @@ export default {
       uni.login({
         provider: "weixin",
         success: function (loginRes) {
-          console.log(loginRes, 69);
           self.getOpenid(loginRes.code);
         },
       });

+ 277 - 0
pages2/verify/info_fill.vue

@@ -0,0 +1,277 @@
+<template>
+  <view>
+    <nav-bar title="填写资料"></nav-bar>
+    <view style="margin-top: 30rpx; padding: 0 40rpx">
+      <u-form :model="form" ref="uForm" :error-type="errorType">
+        <template v-for="(item, index) in listData">
+          <u-form-item
+            :key="index"
+            v-if="item.type === 'input'"
+            :label="item.label"
+            :required="item.required"
+            :label-width="auto"
+            :prop="item.required ? item.prop : ''"
+          >
+            <u-input
+              v-model="form[item.key]"
+              :disabled="item.disable"
+              :placeholder="`请输入${item.label}`"
+            />
+          </u-form-item>
+          <u-form-item
+            :key="index"
+            v-else-if="item.type === 'radio'"
+            :label="item.label"
+            :required="item.required"
+            :label-width="auto"
+            :prop="item.required ? item.prop : ''"
+          >
+            <u-radio-group v-model="form[item.key]">
+              <u-radio
+                v-for="(item, i) in backDictArr(item)"
+                :key="i"
+                :name="item.value"
+                :disabled="item.disabled"
+              >
+                {{ item.label }}
+              </u-radio>
+            </u-radio-group>
+          </u-form-item>
+          <u-form-item
+            :key="index"
+            v-else-if="item.type === 'select'"
+            :label="item.label"
+            :required="item.required"
+            :label-width="auto"
+            :prop="item.required ? item.prop : ''"
+          >
+            <u-input
+              @click="open(item)"
+              v-model="form[item.key]"
+              :disabled="item.disable"
+              :placeholder="`请输入${item.label}`"
+            />
+            <u-select
+              v-model="item.show"
+              :list="backDictArr(item)"
+              :default-value="defaultValue"
+              @confirm="
+                (e) => {
+                  confirm(e, item.key);
+                }
+              "
+            ></u-select>
+          </u-form-item>
+        </template>
+      </u-form>
+    </view>
+    <view @click="submitForm" class="submit_btn">提交资料</view>
+  </view>
+</template>
+
+<script>
+import { mapGetters, mapActions } from "vuex";
+const list = [
+  {
+    key: "realname",
+    type: "input",
+    label: "姓名",
+    required: true,
+    prop: "realname",
+  },
+  {
+    key: "idCard",
+    type: "input",
+    label: "身份证号",
+    required: true,
+    prop: "idCard",
+  },
+  {
+    key: "companyName",
+    type: "input",
+    label: "工作单位",
+    required: true,
+    prop: "companyName",
+  },
+  {
+    key: "sex",
+    type: "radio",
+    label: "性别",
+    required: true,
+    list: [
+      { label: "男", value: 1 },
+      { label: "女", value: 2 },
+    ],
+    prop: "sex",
+  },
+  {
+    key: "eduLevel",
+    type: "select",
+    label: "学历",
+    dictKey: "edu_level",
+    show: false,
+    required: true,
+    prop: "eduLevel",
+  },
+];
+export default {
+  name: "SaasMiniprogramInfoFill",
+
+  data() {
+    return {
+      listData: [],
+      form: {},
+      options: {},
+      errorType: ["message"],
+      auto: "180rpx",
+      defaultValue: [0],
+      isUploading: false,
+      rules: {
+        realname: [
+          {
+            required: true,
+            message: "请输入姓名",
+            trigger: ["change", "blur"],
+          },
+        ],
+        sex: [
+          {
+            validator: (rule, value, callback) => {
+              return !!value;
+            },
+            message: "请选择性别",
+            trigger: "change",
+          },
+        ],
+        idCard: [
+          {
+            required: true,
+            message: "请输入身份证号",
+            trigger: ["change", "blur"],
+          },
+        ],
+        eduLevel: [
+          {
+            required: true,
+            message: "请选择学历",
+            trigger: ["change", "blur"],
+          },
+        ],
+        companyName: [
+          {
+            required: true,
+            message: "请输入工作单位",
+            trigger: ["change", "blur"],
+          },
+        ],
+      },
+    };
+  },
+
+  async onLoad(options) {
+    this.options = options;
+    !this.userInfo && (await this.getUserInfo());
+    this.init();
+  },
+
+  methods: {
+    ...mapActions(["getUserInfo"]),
+    init() {
+      let { keys } = this.options;
+      if (!keys) {
+        return;
+      }
+      keys.split(",").forEach((key) => {
+        let item = list.find((item) => item.key == key);
+        if (item) {
+          const value = this.userInfo[key];
+          this.$set(this.form, key, value);
+          this.listData.push({ ...item, disable: !!value });
+        }
+      });
+    },
+    backDictArr(item) {
+      let { dictKey, list } = item;
+      if (dictKey) {
+        if (!this.dictObj) {
+          return [];
+        }
+        list = this.dictObj[dictKey].map((e, i) => {
+          return { label: e, value: i };
+        });
+        item.list = list;
+      }
+      return list;
+    },
+    open(item) {
+      let { key, list } = item;
+      const option = list.find((e) => e.label === this.form[key]);
+      this.defaultValue = [option ? option.value : 0];
+      item.show = true;
+    },
+    confirm(e, key) {
+      this.form[key] = e[0].label;
+    },
+    submitForm() {
+      if (this.isUploading) {
+        return;
+      }
+      this.isUploading = true;
+      this.$nextTick(() => {
+        this.$refs.uForm.validate((valid) => {
+          if (valid) {
+            this.$api
+              .appuserInfo(this.form)
+              .then((res) => {
+                if (res.data.code === 200) {
+                  uni.showToast({
+                    title: "提交成功",
+                    icon: "none",
+                  });
+                  this.getUserInfo();
+                  setTimeout(() => {
+                    uni.navigateBack();
+                  }, 1500);
+                } else {
+                  uni.showToast({
+                    title: res.data.msg,
+                    icon: "none",
+                  });
+                }
+              })
+              .finally(() => {
+                this.isUploading = false;
+              });
+          } else {
+            this.isUploading = false;
+            console.log(this.form);
+            console.log("验证失败");
+          }
+        });
+      });
+    },
+  },
+  computed: {
+    ...mapGetters(["userInfo", "dictObj"]),
+  },
+  onReady(res) {
+    this.$refs.uForm.setRules(this.rules);
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.submit_btn {
+  width: 526rpx;
+  height: 80rpx;
+  background: #007aff;
+  border-radius: 40rpx;
+  text-align: center;
+  line-height: 80rpx;
+  color: #ffffff;
+  position: absolute;
+  left: 50%;
+  margin-left: -263rpx;
+  bottom: 140rpx;
+}
+</style>

+ 5 - 5
store/index.js

@@ -36,11 +36,11 @@ const store = new Vuex.Store({
       return state.sysTime;
     },
     userInfo: (state) => {
-      // if (state.userInfo == null) {
-      // 	if (uni.getStorageSync('user_account')) {
-      // 		getUserInfo(state)
-      // 	}
-      // }
+      if (state.userInfo == null) {
+      	if (uni.getStorageSync('user_account')) {
+      		getUserInfo(state)
+      	}
+      }
       return state.userInfo;
     },
     dictObj: (state) => {