123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- <template>
- <div class="shopAdd">
- <el-dialog width="600px" :title="title" destroy-on-close center :visible.sync="showVisible">
- <el-form :model="form">
- <el-form-item label="商家名称" label-width="103px">
- <el-input v-model="form.merchantName" placeholder="请输入店铺名称" autocomplete="off" style="width: 100%"></el-input>
- </el-form-item>
- <el-form-item label="主营业务" label-width="103px">
- <div class="category_box">
- <div class="item" :class="form.categoryId == item.id ? 'active':''" v-for="(item,i) in products" :key="i" @click="$set(form,'categoryId',item.id)">
- {{item.name}}
- </div>
- </div>
- </el-form-item>
- <el-form-item label="商家地址" label-width="103px">
- <el-input v-model="form.address" placeholder="请点击地图选择具体地址" disabled autocomplete="off" style="width: 100%">
- <el-image @click="showMap" slot="append" class="map" src="../../../static/image/icon_map.png"></el-image>
- </el-input>
- </el-form-item>
- <el-form-item label="门牌号" label-width="103px">
- <el-input v-model="form.street" placeholder="请填写门牌号" autocomplete="off" style="width: 100%">
- </el-input>
- </el-form-item>
- <el-form-item label="联系人姓名" label-width="103px">
- <el-input v-model="form.contactName" placeholder="请填写姓名" autocomplete="off" style="width: 40%"></el-input>
- </el-form-item>
- <el-form-item label="联系人电话" label-width="103px">
- <el-input v-model="form.mobile" placeholder="请填写手机号" autocomplete="off" style="width: 40%"></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button :loading="loading" class="btn" @click="save">保存</el-button>
- </div>
- </el-dialog>
- <!-- 通过地图选择地理位置 -->
- <order-map @getAddressDetail="getAddressDetail" ref="orderMap"></order-map>
- </div>
- </template>
- <script>
- import orderMap from "../components/orderComponents/orderAMap.vue";
- import { merchantAdd, merchantDetail, merchantModify } from "../api/user.js";
- import bus from "../common/bus.js";
- export default {
- props: {
- products: {
- type: Array,
- default: function () {
- return [];
- },
- },
- },
- data() {
- return {
- title: "成为商家",
- showVisible: false,
- form: {
- id: "",
- address: "",
- cityCode: "",
- cityName: "",
- contactName: "",
- districtName: "",
- lat: "",
- lng: "",
- mobile: "",
- merchantName: "",
- street: "",
- categoryId: "",
- },
- deliveries: [],
- revieweds: [],
- loading: false,
- };
- },
- components: {
- orderMap,
- },
- methods: {
- init(type) {
- if (type) {
- this.title = "修改资料";
- getShopDetail({ shopId: e.id }).then((res) => {
- console.log(res);
- if (res.code === 200) {
- this.form = res.data;
- this.deliveries = this.form.deliveries.filter((v) => {
- return v.bindStatus === 1 && v.type !== 3;
- });
- this.revieweds = this.form.deliveries.filter((v) => {
- return v.type === 3;
- });
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- } else {
- this.title = "成为商户";
- this.form = {
- address: "",
- contactName: "",
- mobile: "",
- name: "",
- street: "",
- categoryId: "",
- };
- }
- this.showVisible = true;
- },
- showMap() {
- this.$refs.orderMap.chooseLocation();
- },
- getAddressDetail(v, lng, lat) {
- this.form.address = v.address;
- this.form.provinceName = v.province;
- this.form.cityName = v.city;
- this.form.cityCode = v.citycode;
- this.form.districtName = v.district;
- this.form.lng = lng;
- this.form.lat = lat;
- },
- save() {
- if (!this.form.merchantName.trim()) {
- return this.$message({
- type: "error",
- message: "请输入商家名称!",
- });
- }
- if (!String(this.form.categoryId).trim()) {
- return this.$message({
- type: "error",
- message: "请选择主营业务!",
- });
- }
- if (!this.form.address.trim()) {
- return this.$message({
- type: "error",
- message: "请选择详细地址!",
- });
- }
- if (!this.form.street.trim()) {
- return this.$message({
- type: "error",
- message: "请输入门牌号!",
- });
- }
- if (!this.form.contactName.trim()) {
- return this.$message({
- type: "error",
- message: "请输入联系人姓名!",
- });
- }
- if (!this.form.mobile.trim()) {
- return this.$message({
- type: "error",
- message: "请输入联系人电话!",
- });
- }
- this.loading = true;
- if (this.form.id) {
- merchantModify(this.form).then((res) => {
- if (res.code === 200) {
- this.$message({
- type: "success",
- message: `已经修改成功,即将跳出重新登录!`,
- });
- setTimeout(() => {
- localStorage.clear();
- bus.$emit("closeGetSoundMsg");
- this.$router.push({
- path: "/login",
- });
- }, 2000);
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- this.showVisible = false;
- this.loading = false;
- });
- } else {
- merchantAdd(this.form).then((res) => {
- if (res.code === 200) {
- this.$message({
- type: "success",
- message: `已经成为商家,即将跳出重新登录`,
- });
- setTimeout(() => {
- localStorage.clear();
- bus.$emit("closeGetSoundMsg");
- this.$router.push({
- path: "/login",
- });
- }, 2000);
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- this.loading = false;
- });
- }
- },
- },
- };
- </script>
- <style lang="scss">
- .shopAdd {
- .map {
- height: 25px;
- width: 25px;
- cursor: pointer;
- }
- .el-dialog {
- border-radius: 16px;
- overflow: hidden;
- }
- .el-dialog__headerbtn .el-dialog__close:hover {
- color: #909399;
- }
- .el-dialog__header {
- /*height: 48px;*/
- background: #f7f7f7;
- padding: 16px 20px;
- }
- .el-dialog__title {
- font-size: 16px;
- font-weight: 500;
- color: #000000;
- }
- .el-form-item__label {
- text-align: left;
- color: #000000;
- }
- .el-input__inner:focus {
- border-color: #fc7b0f;
- }
- .el-input__inner {
- color: #222222;
- }
- .category_box {
- display: flex;
- flex-wrap: wrap;
- width: 100%;
- margin-top: -10px;
- .item {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 92px;
- height: 38px;
- margin: 10px 10px 0 0;
- background: #f4f4f4;
- border-radius: 2px;
- cursor: pointer;
- &.active {
- color: #ffffff;
- background: #fc7200;
- }
- }
- }
- .line {
- position: absolute;
- left: -103px;
- right: 0;
- bottom: -12px;
- border: 0.5px dashed #e0e0e0;
- }
- .logo_box {
- width: 100%;
- height: 40px;
- display: flex;
- align-items: center;
- line-height: 0;
- img {
- width: 20px;
- height: 20px;
- border-radius: 50%;
- margin-right: 10px;
- vertical-align: top;
- }
- }
- .btn {
- width: 220px;
- background: #fc7200;
- color: #ffffff;
- border-color: #fc7200;
- }
- }
- </style>
|