xiaohaizhao 1 年間 前
コミット
7c9792b074
5 ファイル変更664 行追加33 行削除
  1. 222 27
      components/my_form.vue
  2. 4 0
      pages.json
  3. 273 0
      store/deliveryAddress/index.vue
  4. 146 0
      store/deliveryAddress/insert.vue
  5. 19 6
      utils/tool.js

+ 222 - 27
components/my_form.vue

@@ -4,20 +4,40 @@
             <!-- 文本输入 -->
             <view class="input-box" v-if="item.type == 'text'" :style="{ marginTop: tovw(item.marginTop || 0) }"
                 @click="focusLabel = item.label">
-                <view class="box">
+                <view class="box" :class="item.unBorBot ? '' : 'borBot'">
                     <view class="label">
                         <text class="must" v-if="item.isMust">*</text>
                         {{ item.label }}:
                     </view>
                     <view class="content-box">
-                        <textarea auto-height type="text" :focus="focusLabel == item.label"
-                            :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
-                            :style="{ width: item.value ? '220px' : '240px' }" @input="onInput($event, index)"
-                            :maxlength="item.maxlength || '499'" confirm-type="done" />
-                        <icon v-if="item.value" class="icon" type="clear" size="3.733vw" @click="onClearInput(index)" />
+                        <view class="content">
+                            <input v-if="item.inputmode == 'number'" type="number"
+                                placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;"
+                                :focus="focusLabel == item.label" :placeholder="item.placeholder || '请填写' + item.label"
+                                :value="item.value" :style="{ width: item.value ? '220px' : '240px' }"
+                                @input="onInput($event, index)" :maxlength="item.maxlength || '499'" confirm-type="done" />
+                            <textarea v-else
+                                placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;"
+                                auto-height type="text" :focus="focusLabel == item.label"
+                                :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
+                                :style="{ width: item.value ? '220px' : '240px' }" @input="onInput($event, index)"
+                                :maxlength="item.maxlength || '499'" confirm-type="done" />
+                            <icon v-if="item.value" class="icon" type="clear" size="3.733vw" @click="onClearInput(index)" />
+                        </view>
+                        <view v-if="item.errText" class="err-text">
+                            <icon class="icon" color="#E3041F" type="clear" size="2.733vw" />
+                            {{ item.errText }}
+                        </view>
                     </view>
                 </view>
             </view>
+            <!-- 文本域 -->
+            <view class="textarea-box" v-else-if="item.type == 'textarea'">
+                <textarea class="textarea" :class="item.unBorBot ? '' : 'borBot'"
+                    placeholder-style="color: #BBBBBB;font-family: Source Han Sans SC, Source Han Sans SC;" type="text"
+                    :placeholder="item.placeholder || '请填写' + item.label" :value="item.value"
+                    @input="onInput($event, index)" :maxlength="item.maxlength || '499'" confirm-type="done" />
+            </view>
             <!-- 自定义选项分类 -->
             <view class="custom-class-box" v-else-if="item.type == 'customClass'"
                 :style="{ marginTop: tovw(item.marginTop || 0) }">
@@ -39,6 +59,26 @@
                     </view>
                 </view>
             </view>
+            <!-- 选择所在地区 -->
+            <picker class="region" @change="selectRegion($event, index)" mode='region' :disabled="item.disabled"
+                :value="item.value" v-else-if="item.type == 'region'"
+                :style="{ marginTop: tovw(item.marginTop || 0), opacity: item.disabled ? 0.7 : 1 }">
+                <view class="box" :class="item.unBorBot ? '' : 'borBot'">
+                    <view class="label">
+                        <text class="must" v-if="item.isMust">*</text>
+                        {{ item.label }}:
+                    </view>
+                    <view class="content-box">
+                        <view class="value" v-if="item.value.length">
+                            {{ item.value.join(",") }}
+                        </view>
+                        <view v-else class="placeholder" hover-class="none">
+                            {{ item.placeholder || '请选择' + item.label }}
+                        </view>
+                        <view v-if="!item.disabled" class="iconfont icon-a-wodetiaozhuan" />
+                    </view>
+                </view>
+            </picker>
             <!-- 上传附件 -->
             <view class="custom-class-box" v-else-if="item.type == 'upload'"
                 :style="{ marginTop: tovw(item.marginTop || 0) }">
@@ -71,6 +111,20 @@
                     </my-upload>
                 </view>
             </view>
+            <!-- 开关 -->
+            <view class="region" v-else-if="item.type == 'switch'">
+                <view class="box" :class="item.unBorBot ? '' : 'borBot'">
+                    <view class="label">
+                        <text class="must" v-if="item.isMust">*</text>
+                        {{ item.label }}:
+                    </view>
+                    <view class="content-box">
+                        <view />
+                        <u-switch activeColor="#70D95D" v-model="item.value" :disabled="item.disabled"
+                            @change="switchChange($event, index)" />
+                    </view>
+                </view>
+            </view>
         </block>
     </view>
 </template>
@@ -100,13 +154,16 @@ export default {
         }
     },
     watch: {
-        form: function (newVal) {
-            if (newVal) {
-                this.list = JSON.parse(JSON.stringify(newVal));
-                this.verify()
-            } else {
-
-            }
+        form: {
+            handler: function (newVal) {
+                if (newVal) {
+                    this.list = JSON.parse(JSON.stringify(newVal));
+                    setTimeout(() => {
+                        this.verify()
+                    }, 200);
+                }
+            },
+            immediate: true,
         }
     },
     async created() {
@@ -116,7 +173,9 @@ export default {
                 label: "标题",
                 isMust: true,//是否必填
                 value: "",
-                marginTop: 10
+                inputmode:"", //https://uniapp.dcloud.net.cn/component/input.html#type
+                marginTop: 10,
+                verify:[],
             }, {
                 key: "Class",
                 type: "customClass",
@@ -140,16 +199,48 @@ export default {
                 allowDelete: true,
                 value:[],
                 marginTop: 10
+            }, {
+                key: "region",
+                type: "region",
+                label: "所在地区",
+                isMust: true,//是否必填
+                value: [],
+            }, {
+                key: "address",
+                type: "textarea",
+                label: "详细地址",
+                isMust: true,//是否必填
+                value: '',
+            }, {
+                key: "isdefault",
+                type: "switch",
+                label: "设为默认地址",
+                isMust: false,//是否必填
+                value: false,
+                isNum: true,
+                unBorBot: true
             }] */
     },
     methods: {
         onInput(e, index) {
+            let item = this.list[index];
+            item.errText = "";
             this.$set(this.list[index], 'value', e.detail.value)
-            if (this.list[index].isMust) this.verify()
+            if (item.verify && item.verify.length && item.value != '') {
+                let err = item.verify.find(r => !new RegExp(r.reg).test(item.value));
+                if (err) this.$set(this.list[index], 'errText', err.errText)
+            }
+            this.verify()
         },
         onClearInput(index) {
+            let item = this.list[index];
+            item.errText = ''
             this.$set(this.list[index], 'value', '')
-            if (this.list[index].isMust) this.verify()
+            this.verify()
+        },
+        switchChange(e, index) {
+            this.$set(this.list[index], 'value', e)
+            this.verify()
         },
         changOptions(value, index) {
             let item = this.list[index];
@@ -168,7 +259,7 @@ export default {
             } else {
                 this.$set(this.list[index], 'value', value)
             }
-            if (this.list[index].isMust) this.verify()
+            this.verify()
         },
         verify() {
             let list = this.list.filter(v => v.isMust);
@@ -183,11 +274,15 @@ export default {
                     }
                 } else if (v.type == 'upload') {
                     res = v.value.length == 0;
+                } else if (v.type == 'text') {
+                    res = v.value == "";
+                    if (v.errText) res = true;
                 } else {
                     res = v.value == "";
                 }
                 return res
             })
+            if (!Uncomplete) Uncomplete = this.list.filter(v => !v.isMust).some(v => v.errText);
             this.$emit("isUncomplete", Uncomplete)
         },
         previewImg(item) {
@@ -218,7 +313,7 @@ export default {
                 }
 
                 this.$set(this.list[index], 'value', item.value)
-                if (this.list[index].isMust) this.verify()
+                this.verify()
             })
         },
         deleteFiles() {
@@ -242,6 +337,10 @@ export default {
             this.$set(this.list[index], 'loading', e)
             this.$emit("onUploading", e)
         },
+        selectRegion({ detail }, index) {
+            this.$set(this.list[index], 'value', detail.value)
+            this.verify()
+        },
         deleteFile(flie, index) {
             let item = this.list[index];
             item.value = item.value.filter(v => v.attachmentid != flie.attachmentid)
@@ -266,7 +365,7 @@ export default {
                 }
             }
             this.$set(this.list[index], 'value', item.value)
-            if (this.list[index].isMust) this.verify()
+            this.verify()
         },
         submit() {
             return new Promise((resolve, reject) => {
@@ -287,8 +386,28 @@ export default {
                         } catch (error) {
 
                         }
+                    } else if (v.type == 'region') {
+                        if (v.value.length) {
+                            res.province = v.value[0];
+                            res.city = v.value[1];
+                            res.county = v.value[2];
+                        } else {
+                            res.province = ''
+                            res.city = ''
+                            res.county = ''
+                        }
+                    } else if (v.type == 'switch') {
+                        if (v.isNum) {
+                            res[v.key] = v.value ? 1 : 0;
+                        } else {
+                            res[v.key] = v.value;
+                        }
                     } else {
-                        res[v.key] = v.value;
+                        try {
+                            res[v.key] = v.value.trim();
+                        } catch (error) {
+                            res[v.key] = v.value;
+                        }
                     }
                 })
                 resolve(res)
@@ -298,7 +417,12 @@ export default {
 }
 </script>
 
+
 <style lang="scss">
+.borBot {
+    border-bottom: 1px #DDDDDD solid;
+}
+
 .custom-class-box {
     width: 100%;
     background: #fff;
@@ -389,6 +513,18 @@ export default {
     }
 }
 
+.textarea-box {
+    width: 100%;
+
+    .textarea {
+        width: 355px;
+        height: 160px;
+        padding: 15px 10px;
+        box-sizing: border-box;
+        margin: 0 auto;
+    }
+}
+
 .input-box {
     width: 100vw;
     background: #fff;
@@ -401,7 +537,6 @@ export default {
         min-height: 54.4px;
         padding: 15px 0;
         box-sizing: border-box;
-        border-bottom: 1px #DDDDDD solid;
         align-items: center;
     }
 
@@ -421,14 +556,74 @@ export default {
     }
 
     .content-box {
-        flex: 1;
-        display: flex;
-        align-items: center;
         padding-right: 10px;
-        box-sizing: border-box;
 
-        .icon {
-            padding: 5px;
+        .content {
+            flex: 1;
+            display: flex;
+            align-items: center;
+            box-sizing: border-box;
+
+
+
+            .icon {
+                padding: 5px;
+            }
+        }
+
+        .err-text {
+            font-size: 12px;
+            color: #E3041F;
+            margin-bottom: -12px;
+
+            .icon {
+                margin-right: 2px;
+            }
+        }
+
+    }
+}
+
+.region {
+    width: 100vw;
+    background: #fff;
+    box-sizing: border-box;
+    padding: 15px 10px 0;
+
+    .box {
+        display: flex;
+        padding-bottom: 15px;
+
+        .label {
+            width: 100px;
+            margin-right: 10px;
+            line-height: 20px;
+            font-family: Source Han Sans SC, Source Han Sans SC;
+            font-size: 14px;
+            color: #666666;
+            flex-shrink: 0;
+
+            .must {
+                color: #E3041F;
+                margin-right: 5px;
+            }
+        }
+
+        .content-box {
+            flex: 1;
+            display: flex;
+            align-items: center;
+            justify-content: space-between;
+            height: 20px;
+            line-height: 20px;
+
+            .placeholder {
+                font-family: Source Han Sans SC, Source Han Sans SC;
+                font-size: 14px;
+                color: #BBBBBB;
+            }
+
+
         }
     }
 

+ 4 - 0
pages.json

@@ -63,6 +63,10 @@
 		"root": "store",
 		"pages": [{
 			"path": "product/detail"
+		}, {
+			"path": "deliveryAddress/index"
+		}, {
+			"path": "deliveryAddress/insert"
 		}]
 	}],
 	"preloadRule": {

+ 273 - 0
store/deliveryAddress/index.vue

@@ -0,0 +1,273 @@
+<template>
+    <view>
+        <view class="My_search-box">
+            <My_search :value="content.where.condition" @onSearch="onSearch" />
+        </view>
+        <My_listbox ref="List" @getlist="getList" bottomHeight="70">
+            <view class="item" v-for="(item, index) in list" :key="item.contactsid">
+                <view class="head" hover-class="navigator-hover">
+                    <view class="label u-line-1">
+                        <text class="iconfont icon-dizhi-hui" />
+                        <text style="margin-right: 10px;">
+                            {{ item.name }}
+                        </text>
+                        <text>
+                            {{ item.phonenumber }}
+                        </text>
+                    </view>
+                    <view class="address">
+                        {{ getCity(item) }}
+                    </view>
+                </view>
+                <view class="bottom">
+                    <view class="switch-box" @click="setDefault(index)">
+                        <u-switch :value="item.isdefault == 1" activeColor="#70D95D" size="18" :loading="item.loading" />
+                        <text class="text">
+                            设为默认
+                        </text>
+                    </view>
+
+                    <view class="funs">
+                        <view class="fun" @click="edit(item)">
+                            <text class="iconfont icon-bianji" />
+                            编辑
+                        </view>
+                        <view class="fun" @click="deleteItem(item.contactsid)">
+                            <text class="iconfont icon-shanchu" />
+                            删除
+                        </view>
+                    </view>
+                </view>
+            </view>
+        </My_listbox>
+
+        <view class="footer">
+            <navigator class="add" url="/store/deliveryAddress/insert" @click="toAdd" hover-class="navigator-hover">
+                添加地址
+            </navigator>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+            "content": {
+                "where": {
+                    "condition": ""
+                }
+            },
+            list: [],
+        }
+    },
+    onLoad() {
+        uni.setNavigationBarTitle({
+            title: '收货地址',
+        });
+        this.getList(true)
+    },
+    onShow() {
+        delete this.$Http.updateList
+    },
+    methods: {
+        getList(init = false) {
+            if (this.paging(this.content, init)) return;
+            this.$Http.basic({
+                "id": "20240506103702",
+                content: this.content
+            }).then(res => {
+                console.log("收货地址列表", res)
+                this.$refs.List.RefreshToComplete()
+                if (this.cutoff(res.msg)) return;
+                this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
+                this.content = this.$refs.List.paging(this.content, res)
+            })
+        },
+        updateList() {
+            let content = this.paging(this.content, true, true)
+            this.$Http.basic({
+                "id": "20240506103702",
+                content
+            }).then(res => {
+                console.log("更新收货地址列表", res)
+                if (this.cutoff(res.msg)) return;
+                this.list = res.data;
+            })
+        },
+        toAdd() {
+            this.$Http.updateList = this.updateList.bind(this);
+        },
+        onSearch(condition) {
+            if (condition == this.content.where.condition) return;
+            this.content.where.condition = condition;
+            this.getList(true);
+        },
+        setDefault(index) {
+            this.$set(this.list[index], 'loading', true);
+            let item = this.list[index],
+                isdefault = item.isdefault == 1 ? 0 : 1
+            this.$Http.basic({
+                "id": 20240506103602,
+                "content": {
+                    "contactsid": item.contactsid,
+                    isdefault
+                }
+            }).then(res => {
+                console.log("设置默认", res)
+                if (this.cutoff(res.msg)) return;
+                item.loading = false;
+                if (isdefault == 0) {
+                    item.isdefault = 0;
+                    this.$set(this.list, index, item);
+                } else {
+                    this.list = this.list.map(v => {
+                        v.isdefault = v.contactsid == item.contactsid ? 1 : 0
+                        return v
+                    })
+                }
+            })
+        },
+        deleteItem(id) {
+            let that = this;
+            uni.showModal({
+                title: '提示',
+                content: '是否确定删除该地址?',
+                confirmText: "删除",
+                success: function ({ confirm }) {
+                    if (confirm) that.$Http.basic({
+                        "id": 20240506103502,
+                        "content": {
+                            "contactsids": [
+                                id
+                            ]
+                        },
+                    }).then(res => {
+                        console.log("删除", res)
+                        if (that.cutoff(res.msg)) return;
+                        that.updateList()
+                    })
+                }
+            });
+
+        },
+        edit(item) {
+            this.toAdd()
+            uni.navigateTo({
+                url: '/store/deliveryAddress/insert?data=' + JSON.stringify(item),
+            });
+        }
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.My_search-box {
+    background: #fff;
+    width: 100vw;
+    padding: 10px;
+    box-sizing: border-box;
+}
+
+.item {
+    margin-top: 10px;
+    width: 100vw;
+    background: #fff;
+
+    .head {
+        padding: 10px;
+
+        .label {
+            line-height: 20px;
+            font-family: Source Han Sans SC, Source Han Sans SC;
+            font-weight: bold;
+            font-size: 14px;
+            color: #000000;
+
+            .iconfont {
+                font-size: 12px;
+                margin-right: 5px;
+            }
+
+        }
+
+        .address {
+            line-height: 17px;
+            font-family: Source Han Sans SC, Source Han Sans SC;
+            font-size: 12px;
+            color: #666666;
+            margin-top: 7px;
+        }
+    }
+
+    .bottom {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        border-top: 1px solid #ddd;
+        box-sizing: border-box;
+        width: 100vw;
+        height: 45px;
+        background: #fff;
+
+        .switch-box {
+            display: flex;
+            margin-left: 10px;
+            align-items: center;
+
+            .text {
+                margin-left: 5px;
+                font-family: Source Han Sans SC, Source Han Sans SC;
+                font-size: 12px;
+                color: #333333;
+            }
+        }
+
+        .funs {
+            display: flex;
+            align-items: center;
+            margin-right: 14px;
+
+            .fun {
+                font-family: Source Han Sans SC,
+                    Source Han Sans SC;
+                font-size: 12px;
+                color: #333333;
+                margin-left: 20px;
+
+                .iconfont {
+                    font-size: 12px;
+                    margin-right: 5px;
+                }
+            }
+        }
+
+    }
+
+}
+
+.footer {
+    position: fixed;
+    width: 100vw;
+    height: 65px;
+    background: #FFFFFF;
+    box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
+    box-sizing: border-box;
+    padding: 10px;
+    padding-top: 5px;
+    bottom: 0;
+
+    .add {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        width: 100%;
+        height: 45px;
+        background: #C30D23;
+        border-radius: 5px;
+        font-family: PingFang SC, PingFang SC;
+        font-size: 14px;
+        color: #FFFFFF;
+    }
+}
+</style>

+ 146 - 0
store/deliveryAddress/insert.vue

@@ -0,0 +1,146 @@
+<template>
+    <My_listbox :pullDown="false" boxBackground="#fff">
+        <my-form ref="form" :form="form" @isUncomplete="isUncomplete" />
+        <view class="footer">
+            <view class="add" :class="uncomplete ? 'forbidden' : ''" hover-class="navigator-hover"
+                @click="uncomplete || loading ? '' : submit()">
+                <u-loading-icon v-if="loading" />
+                <block v-else>
+                    {{ contactsid == 0 ? '确定添加' : '保存' }}
+                </block>
+            </view>
+        </view>
+    </My_listbox>
+</template>
+
+<script>
+import myForm from "../../components/my_form.vue";
+
+export default {
+    components: { myForm },
+    data() {
+        return {
+            form: [],
+            uncomplete: true,
+            contactsid: 0,
+            loading: false,
+        }
+    },
+    onLoad(options) {
+        console.log(options)
+        if (options.data) {
+            let data = JSON.parse(options.data)
+            this.contactsid = data.contactsid;
+            this.initForm(data)
+        } else {
+            this.initForm()
+        }
+        uni.setNavigationBarTitle({
+            title: this.contactsid ? '编辑地址' : '添加地址',
+        })
+    },
+    methods: {
+        async initForm(data = null) {
+            let form = [{
+                key: "name",
+                type: "text",
+                label: "收货人",
+                isMust: true,//是否必填
+                value: "",
+                placeholder: "请输入收货人姓名"
+            }, {
+                key: "phonenumber",
+                type: "text",
+                label: "手机号",
+                isMust: true,//是否必填
+                value: "",
+                placeholder: "请输入收货人手机号",
+                inputmode: 'number',
+                verify: [this.getReg("phonenumber")]
+            }, {
+                key: "region",
+                type: "region",
+                label: "所在地区",
+                isMust: true,//是否必填
+                value: [],
+            }, {
+                key: "address",
+                type: "textarea",
+                label: "详细地址",
+                isMust: true,//是否必填
+                value: '',
+            }, {
+                key: "isdefault",
+                type: "switch",
+                label: "设为默认地址",
+                isMust: false,//是否必填
+                value: false,
+                isNum: true,
+                unBorBot: true
+            }];
+
+            if (data) {
+                data.isdefault = data.isdefault == 1;
+                data.region = [data.province, data.city, data.county];
+                form = form.map(v => {
+                    v.value = data[v.key]
+                    return v
+                })
+            }
+            this.form = form;
+        },
+        isUncomplete(uncomplete) {
+            this.uncomplete = uncomplete;
+        },
+        submit() {
+            this.loading = true;
+            this.$refs.form.submit().then(data => {
+                console.log("提交", data)
+                this.$Http.basic({
+                    "id": 20240506103402,
+                    "content": {
+                        "contactsid": this.contactsid,
+                        ...data
+                    }
+                }).then(res => {
+                    this.loading = false;
+                    console.log("编辑地址", res)
+                    if (res.msg == '成功') this.$Http.updateList && this.$Http.updateList();
+                    if (this.cutoff(res.msg, this.contactsid == 0 ? '添加成功' : '保存成功', true, 800)) return;
+                })
+            })
+        },
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.footer {
+    position: fixed;
+    width: 100vw;
+    height: 65px;
+    background: #FFFFFF;
+    box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
+    box-sizing: border-box;
+    padding: 10px;
+    padding-top: 5px;
+    bottom: 0;
+
+    .add {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        width: 100%;
+        height: 45px;
+        background: #C30D23;
+        border-radius: 5px;
+        font-family: PingFang SC, PingFang SC;
+        font-size: 14px;
+        color: #FFFFFF;
+    }
+
+    .forbidden {
+        opacity: .6;
+    }
+}
+</style>

+ 19 - 6
utils/tool.js

@@ -47,7 +47,7 @@ function mount() {
                         } else {
                             uni.showModal({
                                 title: '提示',
-                                content: '您未开启地理位置授权',
+                                content: '需要获取您的地理位置,请确认授权,否则可能会定位门店不准确',
                                 cancelText: '下次再说',
                                 confirmText: '前去授权',
                                 success: ({
@@ -60,10 +60,10 @@ function mount() {
                                             }
                                         })
                                     } else {
-                                        uni.showToast({
-                                            title: "未获取到地理位置授权",
-                                            icon: "none",
-                                        })
+                                        /*  uni.showToast({
+                                             title: "您未授权地理位置,",
+                                             icon: "none",
+                                         }) */
                                         resolve();
                                     }
                                 }
@@ -99,7 +99,7 @@ function mount() {
         }
     }
     Vue.prototype.tovw = (num) => (num * 100 / 375).toFixed(3) + "vw";
-    Vue.prototype.getCity = (obj, isAll = true) => (obj.province || '') + (obj.city || '') + (obj.county || '') + isAll ? (obj.address || '') : '';
+    Vue.prototype.getCity = (obj, isAll = true) => obj.province + obj.city + obj.county + (isAll ? obj.address : '');
     Vue.prototype.getApps = (appRemark, route) => {
         const list = Object.values(uni.getStorageSync('authList')[appRemark])
         return route ? list.find(v => v.path == route || v.pathDetail == route) : list
@@ -186,6 +186,19 @@ function mount() {
             return v
         })
     }
+    Vue.prototype.getReg = name => {
+        let obj = {
+            phonenumber: {
+                reg: '^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\\d{8}$',
+                errText: "请输入正确的11位手机号码!"
+            },
+            email: {
+                reg: '^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})$',
+                errText: "请输入正确的邮箱格式!"
+            }
+        }
+        return obj[name] || ''
+    }
 }
 
 module.exports = {