merchantAdd.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div class="shopAdd">
  3. <el-dialog width="600px" :title="title" destroy-on-close center :visible.sync="showVisible">
  4. <el-form :model="form">
  5. <el-form-item label="商家名称" label-width="103px">
  6. <el-input v-model="form.merchantName" placeholder="请输入店铺名称" autocomplete="off" style="width: 100%"></el-input>
  7. </el-form-item>
  8. <el-form-item label="主营业务" label-width="103px">
  9. <div class="category_box">
  10. <div class="item" :class="form.categoryId == item.id ? 'active':''" v-for="(item,i) in products" :key="i" @click="$set(form,'categoryId',item.id)">
  11. {{item.name}}
  12. </div>
  13. </div>
  14. </el-form-item>
  15. <el-form-item label="商家地址" label-width="103px">
  16. <el-input v-model="form.address" placeholder="请点击地图选择具体地址" disabled autocomplete="off" style="width: 100%">
  17. <el-image @click="showMap" slot="append" class="map" src="../../../static/image/icon_map.png"></el-image>
  18. </el-input>
  19. </el-form-item>
  20. <el-form-item label="门牌号" label-width="103px">
  21. <el-input v-model="form.street" placeholder="请填写门牌号" autocomplete="off" style="width: 100%">
  22. </el-input>
  23. </el-form-item>
  24. <el-form-item label="联系人姓名" label-width="103px">
  25. <el-input v-model="form.contactName" placeholder="请填写姓名" autocomplete="off" style="width: 40%"></el-input>
  26. </el-form-item>
  27. <el-form-item label="联系人电话" label-width="103px">
  28. <el-input v-model="form.mobile" placeholder="请填写手机号" autocomplete="off" style="width: 40%"></el-input>
  29. </el-form-item>
  30. </el-form>
  31. <div slot="footer" class="dialog-footer">
  32. <el-button :loading="loading" class="btn" @click="save">保存</el-button>
  33. </div>
  34. </el-dialog>
  35. <!-- 通过地图选择地理位置 -->
  36. <order-map @getAddressDetail="getAddressDetail" ref="orderMap"></order-map>
  37. </div>
  38. </template>
  39. <script>
  40. import orderMap from "../components/orderComponents/orderAMap.vue";
  41. import { merchantAdd, merchantDetail, merchantModify } from "../api/user.js";
  42. import bus from "../common/bus.js";
  43. export default {
  44. props: {
  45. products: {
  46. type: Array,
  47. default: function () {
  48. return [];
  49. },
  50. },
  51. },
  52. data() {
  53. return {
  54. title: "成为商家",
  55. showVisible: false,
  56. form: {
  57. id: "",
  58. address: "",
  59. cityCode: "",
  60. cityName: "",
  61. contactName: "",
  62. districtName: "",
  63. lat: "",
  64. lng: "",
  65. mobile: "",
  66. merchantName: "",
  67. street: "",
  68. categoryId: "",
  69. },
  70. deliveries: [],
  71. revieweds: [],
  72. loading: false,
  73. };
  74. },
  75. components: {
  76. orderMap,
  77. },
  78. methods: {
  79. init(type) {
  80. if (type) {
  81. this.title = "修改资料";
  82. getShopDetail({ shopId: e.id }).then((res) => {
  83. console.log(res);
  84. if (res.code === 200) {
  85. this.form = res.data;
  86. this.deliveries = this.form.deliveries.filter((v) => {
  87. return v.bindStatus === 1 && v.type !== 3;
  88. });
  89. this.revieweds = this.form.deliveries.filter((v) => {
  90. return v.type === 3;
  91. });
  92. } else {
  93. this.$message({
  94. type: "error",
  95. message: res.msg,
  96. });
  97. }
  98. });
  99. } else {
  100. this.title = "成为商户";
  101. this.form = {
  102. address: "",
  103. contactName: "",
  104. mobile: "",
  105. name: "",
  106. street: "",
  107. categoryId: "",
  108. };
  109. }
  110. this.showVisible = true;
  111. },
  112. showMap() {
  113. this.$refs.orderMap.chooseLocation();
  114. },
  115. getAddressDetail(v, lng, lat) {
  116. this.form.address = v.address;
  117. this.form.provinceName = v.province;
  118. this.form.cityName = v.city;
  119. this.form.cityCode = v.citycode;
  120. this.form.districtName = v.district;
  121. this.form.lng = lng;
  122. this.form.lat = lat;
  123. },
  124. save() {
  125. if (!this.form.merchantName.trim()) {
  126. return this.$message({
  127. type: "error",
  128. message: "请输入商家名称!",
  129. });
  130. }
  131. if (!String(this.form.categoryId).trim()) {
  132. return this.$message({
  133. type: "error",
  134. message: "请选择主营业务!",
  135. });
  136. }
  137. if (!this.form.address.trim()) {
  138. return this.$message({
  139. type: "error",
  140. message: "请选择详细地址!",
  141. });
  142. }
  143. if (!this.form.street.trim()) {
  144. return this.$message({
  145. type: "error",
  146. message: "请输入门牌号!",
  147. });
  148. }
  149. if (!this.form.contactName.trim()) {
  150. return this.$message({
  151. type: "error",
  152. message: "请输入联系人姓名!",
  153. });
  154. }
  155. if (!this.form.mobile.trim()) {
  156. return this.$message({
  157. type: "error",
  158. message: "请输入联系人电话!",
  159. });
  160. }
  161. this.loading = true;
  162. if (this.form.id) {
  163. merchantModify(this.form).then((res) => {
  164. if (res.code === 200) {
  165. this.$message({
  166. type: "success",
  167. message: `已经修改成功,即将跳出重新登录!`,
  168. });
  169. setTimeout(() => {
  170. localStorage.clear();
  171. bus.$emit("closeGetSoundMsg");
  172. this.$router.push({
  173. path: "/login",
  174. });
  175. }, 2000);
  176. } else {
  177. this.$message({
  178. type: "error",
  179. message: res.msg,
  180. });
  181. }
  182. this.showVisible = false;
  183. this.loading = false;
  184. });
  185. } else {
  186. merchantAdd(this.form).then((res) => {
  187. if (res.code === 200) {
  188. this.$message({
  189. type: "success",
  190. message: `已经成为商家,即将跳出重新登录`,
  191. });
  192. setTimeout(() => {
  193. localStorage.clear();
  194. bus.$emit("closeGetSoundMsg");
  195. this.$router.push({
  196. path: "/login",
  197. });
  198. }, 2000);
  199. } else {
  200. this.$message({
  201. type: "error",
  202. message: res.msg,
  203. });
  204. }
  205. this.loading = false;
  206. });
  207. }
  208. },
  209. },
  210. };
  211. </script>
  212. <style lang="scss">
  213. .shopAdd {
  214. .map {
  215. height: 25px;
  216. width: 25px;
  217. cursor: pointer;
  218. }
  219. .el-dialog {
  220. border-radius: 16px;
  221. overflow: hidden;
  222. }
  223. .el-dialog__headerbtn .el-dialog__close:hover {
  224. color: #909399;
  225. }
  226. .el-dialog__header {
  227. /*height: 48px;*/
  228. background: #f7f7f7;
  229. padding: 16px 20px;
  230. }
  231. .el-dialog__title {
  232. font-size: 16px;
  233. font-weight: 500;
  234. color: #000000;
  235. }
  236. .el-form-item__label {
  237. text-align: left;
  238. color: #000000;
  239. }
  240. .el-input__inner:focus {
  241. border-color: #fc7b0f;
  242. }
  243. .el-input__inner {
  244. color: #222222;
  245. }
  246. .category_box {
  247. display: flex;
  248. flex-wrap: wrap;
  249. width: 100%;
  250. margin-top: -10px;
  251. .item {
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. width: 92px;
  256. height: 38px;
  257. margin: 10px 10px 0 0;
  258. background: #f4f4f4;
  259. border-radius: 2px;
  260. cursor: pointer;
  261. &.active {
  262. color: #ffffff;
  263. background: #fc7200;
  264. }
  265. }
  266. }
  267. .line {
  268. position: absolute;
  269. left: -103px;
  270. right: 0;
  271. bottom: -12px;
  272. border: 0.5px dashed #e0e0e0;
  273. }
  274. .logo_box {
  275. width: 100%;
  276. height: 40px;
  277. display: flex;
  278. align-items: center;
  279. line-height: 0;
  280. img {
  281. width: 20px;
  282. height: 20px;
  283. border-radius: 50%;
  284. margin-right: 10px;
  285. vertical-align: top;
  286. }
  287. }
  288. .btn {
  289. width: 220px;
  290. background: #fc7200;
  291. color: #ffffff;
  292. border-color: #fc7200;
  293. }
  294. }
  295. </style>