shopAdd.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  1. <!--
  2. * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
  3. * @Date: 2023-05-26 16:37:34
  4. * @LastEditors: wenjie 1454560336@qq.com
  5. * @LastEditTime: 2024-11-12 15:37:19
  6. * @FilePath: \admin-manage\src\views\operationManage\shopManage\shopAdd.vue
  7. * @Description:
  8. *
  9. * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
  10. -->
  11. <template>
  12. <div class="shopAdd app-container" v-loading="loading">
  13. <el-form
  14. :model="setQuery"
  15. ref="setQuery"
  16. :rules="rules"
  17. v-loading="pageLoading"
  18. :disabled="disabled"
  19. label-width="180px"
  20. >
  21. <el-tabs v-model="activeName">
  22. <el-tab-pane label="基本信息" name="1">
  23. <el-form-item label="商铺主体:" prop="shopMainId">
  24. <el-select v-model="setQuery.shopMainId" @change="changeMain" :disabled="mode != 'add'" size="small" filterable class="item-width-300" placeholder="请搜索选择店铺主体">
  25. <el-option
  26. v-for="item in shopMainOptions"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="店铺经营类型:" prop="shopMenuId">
  34. <!-- <el-select v-model="setQuery.shopMenuId" size="small" class="item-width-300" placeholder="请选择店铺经营类型">
  35. <el-option
  36. v-for="item in options"
  37. :key="item.value"
  38. :label="item.label"
  39. :value="item.value">
  40. </el-option>
  41. </el-select> -->
  42. <el-cascader
  43. size="small"
  44. class="item-width-300"
  45. placeholder="请选择店铺经营类型"
  46. v-model="setQuery.shopMenuId"
  47. :options="options"
  48. :props="{
  49. value:'id',
  50. label:'menuName',
  51. children:'child',
  52. }"
  53. ></el-cascader>
  54. </el-form-item>
  55. <el-form-item label="店铺名称:" prop="shopName">
  56. <el-input
  57. v-model="setQuery.shopName"
  58. size="small"
  59. class="item-width-300"
  60. ></el-input>
  61. </el-form-item>
  62. <!-- <el-form-item label="店铺标签:">
  63. <el-input
  64. v-model="setQuery.shopLabel"
  65. size="small"
  66. class="item-width-300"
  67. ></el-input>
  68. </el-form-item> -->
  69. <!-- <el-form-item label="店铺类型:" prop="shopType">
  70. <el-select v-model="setQuery.shopType" size="small" class="item-width-300" placeholder="请选择店铺经营类型">
  71. <el-option
  72. v-for="item in options1"
  73. :key="item.value"
  74. :label="item.label"
  75. :value="item.value">
  76. </el-option>
  77. </el-select>
  78. </el-form-item> -->
  79. <el-form-item label="店铺地址:" prop="address">
  80. <el-input
  81. disabled
  82. v-model="setQuery.address"
  83. class="item-width-500"
  84. size="small"
  85. placeholder="请点击右侧定位图标选择店铺地址"
  86. ></el-input>
  87. <i class="el-icon-location ml10 position red" @click="chooseAddress"></i>
  88. </el-form-item>
  89. <el-form-item label="区域:" prop="regionCode">
  90. <el-input
  91. placeholder="请输入区域"
  92. v-model="setQuery.regionCode"
  93. class="item-width-500"
  94. >
  95. </el-input>
  96. </el-form-item>
  97. <el-form-item label="店铺简介:">
  98. <el-input
  99. type="textarea"
  100. placeholder="请输入店铺简介"
  101. v-model="setQuery.detailContent"
  102. maxlength="400"
  103. class="item-width-500"
  104. show-word-limit
  105. >
  106. </el-input>
  107. </el-form-item>
  108. <el-form-item label="店铺电话:" prop="serviceTel">
  109. <el-input
  110. type="tel"
  111. placeholder="请输入店铺电话"
  112. v-model="setQuery.serviceTel"
  113. class="item-width-300"
  114. >
  115. </el-input>
  116. </el-form-item>
  117. <el-form-item label="店铺头像:" prop="logoPath">
  118. <Upload
  119. type="logoPath"
  120. id="logoPath"
  121. width="250px"
  122. height="150px"
  123. :disabled="mode == 'detail'"
  124. uploadType="SHOP_INFO"
  125. :imgUrl="setQuery.logoPath"
  126. @uploadEnd="uploadEnd"
  127. ></Upload>
  128. </el-form-item>
  129. <el-form-item label="店铺图片:" prop="detailImg">
  130. <Upload
  131. type="detailImg"
  132. id="detailImg"
  133. width="250px"
  134. height="150px"
  135. :disabled="mode == 'detail'"
  136. uploadType="SHOP_INFO"
  137. :imgUrl="setQuery.detailImg"
  138. @uploadEnd="uploadEnd"
  139. ></Upload>
  140. </el-form-item>
  141. <!-- <el-form-item label="店铺状态:">
  142. <el-radio-group v-model="setQuery.doorImg">
  143. <el-radio :label="1">关闭</el-radio>
  144. <el-radio :label="2">运营中</el-radio>
  145. </el-radio-group>
  146. </el-form-item> -->
  147. </el-tab-pane>
  148. <el-tab-pane label="其他信息" name="2">
  149. <el-form-item label="经营商品类型:" prop="serviceCode">
  150. <el-checkbox-group v-model="setQuery.serviceCode">
  151. <el-checkbox label="801">研学商品</el-checkbox>
  152. <el-checkbox label="802">虚拟商品充值</el-checkbox>
  153. <el-checkbox label="803">餐饮商品</el-checkbox>
  154. <el-checkbox label="809">贵大商品</el-checkbox>
  155. </el-checkbox-group>
  156. </el-form-item>
  157. <el-form-item label="经营商品分类:" prop="serviceCate">
  158. <el-cascader
  159. v-model="setQuery.serviceCate"
  160. :options="typeOptions"
  161. :props="{
  162. multiple: true,
  163. value:'id',
  164. label:'cateName',
  165. children:'child'
  166. }"
  167. @change=""></el-cascader>
  168. </el-form-item>
  169. <!-- <el-form-item label="银联分账帐户:">
  170. <el-select v-model="setQuery.authAccount" size="small" filterable class="item-width-300" placeholder="请搜索选择店铺主体">
  171. <el-option
  172. v-for="(item,index) in authOptions"
  173. :key="index"
  174. :label="item.label"
  175. :value="item.value">
  176. </el-option>
  177. </el-select>
  178. </el-form-item>
  179. <el-form-item label="分账规则:" prop="shareId">
  180. <el-select
  181. v-model="setQuery.shareId"
  182. class="item-width-300"
  183. placeholder="请选择分账规则"
  184. >
  185. <el-option
  186. v-for="item in ruleOptions"
  187. :key="item.value"
  188. :label="item.label"
  189. :value="item.value"
  190. >
  191. </el-option>
  192. </el-select>
  193. </el-form-item> -->
  194. <el-form-item label="店铺搜索:">
  195. <el-radio-group v-model="setQuery.searchEnable">
  196. <el-radio :label="1">可搜索</el-radio>
  197. <el-radio :label="2">不可搜索</el-radio>
  198. </el-radio-group>
  199. </el-form-item>
  200. <el-form-item label="店铺状态:" >
  201. <el-radio-group :disabled="isDisabled" v-model="setQuery.state">
  202. <el-radio :label="1">运营中</el-radio>
  203. <el-radio :label="2">关闭</el-radio>
  204. </el-radio-group>
  205. </el-form-item>
  206. <el-form-item label="绑定所属平台及分账规则" prop="platformType">
  207. <el-checkbox-group v-model="setQuery.platformType" prop="platformType">
  208. <div class="flex" v-for="(item,index) in shopOptions" :key="index" >
  209. <el-checkbox :label="item.value">{{item.label}}</el-checkbox>
  210. <el-form-item label="分账规则:" v-if="setQuery.platformType.includes(item.value)" :prop="'shopInfos.' + index + '.shareId'" :rules="{required: true, message: '请选择分账规则', trigger: 'change'}">
  211. <el-select
  212. v-model="setQuery.shopInfos[index].shareId"
  213. class="item-width-300"
  214. placeholder="请选择分账规则"
  215. >
  216. <el-option
  217. v-for="item in ruleOptions"
  218. :key="item.value"
  219. :label="item.label"
  220. :value="item.value"
  221. >
  222. </el-option>
  223. </el-select>
  224. </el-form-item>
  225. <el-form-item label="银联分账帐户:" v-if="setQuery.platformType.includes(item.value)" >
  226. <el-select v-model="setQuery.shopInfos[index].authAccount" filterable class="item-width-300" placeholder="请搜索选择店铺主体">
  227. <el-option
  228. v-for="(item,index) in authOptions"
  229. :key="index"
  230. :label="item.label"
  231. :value="item.value">
  232. </el-option>
  233. </el-select>
  234. </el-form-item>
  235. </div>
  236. </el-checkbox-group>
  237. </el-form-item>
  238. <!-- <el-form-item label="绑定主商户" prop="platformType">
  239. <el-checkbox-group v-model="setQuery.platformType">
  240. <el-checkbox label="1">慧研学惠生活</el-checkbox>
  241. <el-checkbox label="2" >印象贵大</el-checkbox>
  242. </el-checkbox-group>
  243. </el-form-item> -->
  244. </el-tab-pane>
  245. </el-tabs>
  246. </el-form>
  247. <el-dialog title="选择地址" close="chose-model" :close-on-press-escape="false" :close-on-click-modal="false" width="60vw" :visible.sync="showMap">
  248. <div id="container"></div>
  249. <el-form
  250. :model="setQuery"
  251. ref="address"
  252. :rules="rules1"
  253. >
  254. <el-form-item label="" prop="address">
  255. <div class="address-input-box">
  256. <el-select v-model="setQuery.address" :loading="addressLoading" filterable remote :remote-method="searchAddress" @change="selectAddress" class="address-input" placeholder="请选择输入地址或者点击地图">
  257. <el-option
  258. v-for="item in addressOptions"
  259. :key="item.label+item.value"
  260. :label="item.label+' '+item.value"
  261. :value="item.value">
  262. <span style="color: #222; font-size: 13px">{{ item.label }}</span>
  263. <span style="margin-left:10px; color: #8492a6; font-size: 13px">{{ item.value }}</span>
  264. </el-option>
  265. </el-select>
  266. <!-- <el-input
  267. v-model="setQuery.address"
  268. size="small"
  269. class="address-input"
  270. placeholder="请先点击地图定位,再修改详细地址"
  271. ></el-input> -->
  272. <el-button type="primary" size="small" class="address-btn" @click="saveAddress">提 交</el-button>
  273. </div>
  274. </el-form-item>
  275. </el-form>
  276. </el-dialog>
  277. <!-- 新增和编辑模式 -->
  278. <div class="btn-group" v-if="mode == 'add'|| mode == 'edit'">
  279. <el-button>取 消</el-button>
  280. <el-button type="primary" :loading="loading" @click="save"
  281. >提交</el-button >
  282. </div>
  283. <!-- 详情时的按钮 -->
  284. <div class="btn-group" v-else>
  285. <el-button>取 消</el-button>
  286. <el-button type="primary" :loading="loading" @click="edit"
  287. >编辑</el-button >
  288. </div>
  289. </div>
  290. </template>
  291. <script>
  292. import Upload from "@/components/Upload";
  293. import { add, detail, update,getMainName } from "@/api/shop";
  294. import {getMenuData} from '@/api/appConfig';
  295. import {getRuleList} from '@/api/rule'
  296. import {getData} from '@/api/goods'
  297. import {finishComplexList} from '@/api/payment'
  298. import {getSearchList,uidToAddress} from '@/api/common'
  299. import {accountDetail } from "@/api/user";
  300. import { debounce } from "@/utils/index";
  301. export default {
  302. components: {
  303. Upload,
  304. },
  305. data() {
  306. var validateTel = (rule, value, callback) => {
  307. if (value == '') {
  308. callback(new Error('请输入店铺电话'));
  309. } else {
  310. let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
  311. if (reg.test(value)) {
  312. callback();
  313. }else{
  314. callback(new Error('请输入正确的手机号'));
  315. }
  316. }
  317. };
  318. return {
  319. shopOptions:[],
  320. checkList:[],
  321. activeName:"1",
  322. map:null,
  323. mode:'detail',//编辑模式
  324. showMap:false,
  325. cityName:'',
  326. addressLoading:false,
  327. setQuery: {
  328. regionCode:'',
  329. address: "",
  330. businessImg: "",
  331. city: "",
  332. detailImg: "",
  333. district: "",
  334. doorImg: "",
  335. idCardNo: "",
  336. logoPath: "",
  337. mapLat: "",
  338. mapLon: "",
  339. province: "",
  340. serviceName: "",
  341. serviceTel: "",
  342. shopLabel: "",
  343. shopMainId: "",
  344. shopName: "",
  345. shopType: '',
  346. source:'2',
  347. shareId:'',
  348. shareChannelId:'',
  349. serviceCode:[],//经营类型
  350. serviceCate:[],//商品分类
  351. authAccount:"",
  352. searchEnable:1,
  353. state:2,
  354. platformType:[],
  355. shopInfos:[],//店铺主体分账规则绑定
  356. },
  357. authOptions:[],//银联账号
  358. typeOptions:[],//商品分类
  359. ruleOptions:[],
  360. options:[],
  361. addressOptions:[],
  362. options1:[
  363. {
  364. value: 1,
  365. label: "小微商户",
  366. },
  367. {
  368. value: 2,
  369. label: "个体工商户",
  370. },
  371. {
  372. value: 3,
  373. label: "企业",
  374. },
  375. {
  376. value: 4,
  377. label: "机关事业单位或社会团体",
  378. },
  379. ],
  380. shopMainOptions:[],//主体选择
  381. disabled: false,
  382. pageLoading: false, //页面loading
  383. loading: false,
  384. rules: {
  385. regionCode: [
  386. { required: true, message: "请输入区域", trigger: "blur" },
  387. ],
  388. shopMainId: [
  389. { required: true, message: "请选择商铺主体", trigger: "change" },
  390. ],
  391. shopMenuId: [
  392. { required: true, message: "请选择商铺经营类型", trigger: "change" },
  393. ],
  394. shopType: [
  395. { required: true, message: "请选择商铺类型", trigger: "change" },
  396. ],
  397. shopName: [
  398. { required: true, message: "请输入商铺名称", trigger: "blur" },
  399. ],
  400. address: [
  401. { required: true, message: "请输入商铺地址", trigger: "blur" },
  402. ],
  403. shareChannelId: [
  404. { required: true, message: "请选择商家佣金", trigger: "change" },
  405. ],
  406. logoPath: [
  407. { required: true, message: "请上传店铺头像", trigger: "change" },
  408. ],
  409. shareId: [
  410. { required: true, message: "请选择分账规则", trigger: "change" },
  411. ],
  412. detailImg: [
  413. { required: true, message: "请上传店铺详情图", trigger: "change" },
  414. ],
  415. businessImg: [
  416. { required: true, message: "请上传营业执照", trigger: "change" },
  417. ],
  418. serviceCate: [
  419. { required: true, message: "请选择经营商品分类", trigger: "change" },
  420. ],
  421. serviceCode: [
  422. { required: true, message: "请选择经营商品类型", trigger: "change" },
  423. ],
  424. platformType: [
  425. { type: 'array', required: true, message: '请绑定所属平台', trigger: 'change' }
  426. ],
  427. serviceTel: [
  428. { required: true, message: "请输入店铺电话", trigger: "blur" },
  429. // { validator: validateTel, trigger: 'change' }
  430. ],
  431. },
  432. rules1:{
  433. address: [
  434. { required: true, message: "请输入商铺地址或者点击地图", trigger: "blur" },
  435. ],
  436. }
  437. };
  438. },
  439. watch: {
  440. // 'setQuery.address':debounce(function(val){
  441. // if(this.map){
  442. // let that = this
  443. // //创建地址解析器实例
  444. // var myGeo = new BMapGL.Geocoder();
  445. // that.marker? that.map.removeOverlay(that.marker):''
  446. // // 将地址解析结果显示在地图上,并调整地图视野
  447. // myGeo.getPoint(val, function(point){
  448. // if(point ){
  449. // console.log(point);
  450. // that.setQuery.mapLat = point.lat
  451. // that.setQuery.mapLon = point.lng
  452. // that.marker = new BMapGL.Marker(point, {title: val})
  453. // if(that.map){
  454. // that.map.centerAndZoom(point, 16);
  455. // that.map.addOverlay(that.marker)
  456. // myGeo.getLocation(new BMapGL.Point(point.lng, point.lat), function(result){
  457. // if (result){
  458. // console.log(result);
  459. // // 选择营业地址时保存省市区
  460. // that.setQuery.province = result.addressComponents.province;
  461. // that.setQuery.city = result.addressComponents.city;
  462. // that.setQuery.district = result.addressComponents.district;
  463. // }
  464. // });
  465. // }
  466. // }
  467. // }, that.setQuery.city)
  468. // }
  469. // }),
  470. "setQuery.shopMainId":function(val){
  471. if(val){
  472. this.accountDetail(val)
  473. this.finishComplexList()
  474. }else{
  475. this.authOptions = []
  476. }
  477. },
  478. // 'setQuery.authAccount'(val){
  479. // if(!val){
  480. // this.setQuery.state = 2
  481. // }
  482. // }
  483. },
  484. computed: {
  485. isDisabled(val){
  486. let flag = true
  487. this.setQuery.platformType.forEach(item=>{
  488. this.setQuery.shopInfos.forEach(i=>{
  489. if(i.platformType == item&&i.authAccount){
  490. flag = false
  491. }
  492. })
  493. })
  494. if(flag){
  495. this.setQuery.state = 2
  496. }
  497. return flag
  498. },
  499. },
  500. methods: {
  501. changeMain(val){
  502. this.setQuery.shopInfos = []
  503. },
  504. // 选择地址
  505. selectAddress(val){
  506. let item = this.addressOptions.filter(item=>item.value==val)[0]
  507. console.log(val,item);
  508. this.setQuery.mapLat = item.location.lat
  509. this.setQuery.mapLon = item.location.lng
  510. this.map.removeOverlay(this.marker); //移除点标记
  511. this.marker = new BMapGL.Marker(item.location, {title: val})
  512. this.map.addOverlay(this.marker)
  513. this.setQuery.province = item.province;
  514. this.setQuery.city = item.city;
  515. this.setQuery.district = item.district;
  516. this.map.centerAndZoom(item.location, 19);
  517. },
  518. // 查询地址
  519. searchAddress(val){
  520. if(val){
  521. this.addressLoading = true
  522. getSearchList({query:val,region:this.cityName,output:'json',ak:'7aGqlyBw6mGwS6vNMLbmMlsHqE2OGV0E'}).then(res=>{
  523. this.addressLoading = false
  524. if(res.status == 0){
  525. this.addressOptions = []
  526. res.result.map(item=>{
  527. this.addressOptions.push({
  528. label:item.name,
  529. value:item.address,
  530. location:item.location,
  531. province:item.province,
  532. city:item.city,
  533. district:item.district,
  534. })
  535. })
  536. }
  537. })
  538. }else{
  539. this.addressOptions = []
  540. }
  541. // ?query=天安门&region=北京&city_limit=true&output=json&ak=7aGqlyBw6mGwS6vNMLbmMlsHqE2OGV0E
  542. // }
  543. },
  544. edit(){
  545. this.$router.push({
  546. path: "/operationManage/shopManage/shopAdd",
  547. query: {
  548. title: "店铺编辑",
  549. id:this.$route.query.id,
  550. },
  551. });
  552. },
  553. save() {
  554. this.$refs.setQuery.validate((v) => {
  555. if (v) {
  556. if(this.loading) return
  557. let obj = JSON.parse(JSON.stringify(this.setQuery))
  558. obj.serviceCode = obj.serviceCode.toString()
  559. let str = ''
  560. obj.serviceCate.map((item,index)=>{
  561. if(index != (obj.serviceCate.length -1 )){
  562. str += item.toString()+'/'
  563. }else{
  564. str += item.toString()
  565. }
  566. })
  567. obj.serviceCate = str
  568. obj.shopMenuId = obj.shopMenuId.toString()
  569. let shopInfos = JSON.parse(JSON.stringify(obj.shopInfos))
  570. obj.shopInfos = []
  571. shopInfos.map(item=>{
  572. if(item.shareId&&obj.platformType.includes(Number(item.platformType))){
  573. obj.shopInfos.push(item)
  574. }
  575. })
  576. console.log(obj.shopInfos);
  577. obj.platformType = obj.platformType.toString()
  578. if (this.setQuery.shopId) {
  579. this.update(obj);
  580. } else {
  581. this.add(obj);
  582. }
  583. }else{
  584. this.$message.error('请检查是否有必填项未填');
  585. }
  586. });
  587. },
  588. add(obj) {
  589. this.loading = true;
  590. add(obj).then((res) => {
  591. this.loading = false;
  592. if (res.state == "Success") {
  593. this.$notify({
  594. title: "成功",
  595. message: "操作成功",
  596. type: "success",
  597. });
  598. this.$router.push("/operationManage/shopManage/index");
  599. }
  600. });
  601. },
  602. update(obj) {
  603. this.loading = true;
  604. // let obj = JSON.parse(JSON.stringify(this.setQuery))
  605. // obj.serviceCode = obj.serviceCode.toString()
  606. // let str = ''
  607. // obj.serviceCate.map((item,index)=>{
  608. // if(index != (obj.serviceCate.length -1 )){
  609. // str += item.toString()+'/'
  610. // }else{
  611. // str += item.toString()
  612. // }
  613. // })
  614. // obj.serviceCate = str
  615. // obj.shopMenuId = obj.shopMenuId.toString()
  616. // obj.platformType = obj.platformType.toString()
  617. update(obj).then((res) => {
  618. this.loading = false;
  619. if (res.state == "Success") {
  620. this.$notify({
  621. title: "成功",
  622. message: "操作成功",
  623. type: "success",
  624. });
  625. this.$router.push("/operationManage/shopManage/index");
  626. }
  627. });
  628. },
  629. // 图片统一上传
  630. uploadEnd(val) {
  631. this.setQuery[val.type] = val.url;
  632. },
  633. detail() {
  634. this.pageLoading = true;
  635. detail({ shopId: this.$route.query.id }).then((res) => {
  636. this.pageLoading = false;
  637. if (res.state == "Success") {
  638. this.setQuery = res.content;
  639. this.setQuery.serviceCode = this.setQuery.serviceCode.split(',')
  640. this.setQuery.serviceCate = this.setQuery.serviceCate.split('/').map(item=>{return item = item.split(',').map(item=> Number(item))})
  641. this.setQuery.shopMenuId = this.setQuery.shopMenuId.split(',').map(item=> Number(item))
  642. this.setQuery.platformType = this.setQuery.platformType.split(',').map(item=> Number(item))
  643. // let shopInfos = JSON.parse(JSON.stringify(this.setQuery.shopInfos))
  644. // this.setQuery.shopInfos=[]
  645. // this.shopOptions.map(item=>{
  646. // this.setQuery.shopInfos.push({
  647. // shareId:'',
  648. // authAccount:'',
  649. // platformType:item.value
  650. // })
  651. // })
  652. // this.setQuery.shopInfos.map(item=>{
  653. // shopInfos.map(i=>{
  654. // if(item.platformType == i.platformType){
  655. // item.shareId = i.shareId
  656. // item.authAccount = i.authAccount
  657. // }
  658. // })
  659. // })
  660. }
  661. });
  662. },
  663. // 获取经营类型
  664. getMenuName(){
  665. getMenuData().then(res=>{
  666. if(res.state == 'Success'){
  667. this.options = res.content
  668. }
  669. })
  670. },
  671. // 获取主体类型
  672. getMainName(){
  673. getMainName().then(res=>{
  674. if(res.state == 'Success'){
  675. for (const key in res.content) {
  676. if (Object.hasOwnProperty.call(res.content, key)) {
  677. this.shopMainOptions.push({
  678. label:res.content[key],
  679. value:key
  680. })
  681. }
  682. }
  683. }
  684. })
  685. },
  686. // 选择经营地址
  687. chooseAddress() {
  688. if(this.mode == 'detail') return
  689. this.showMap = true;
  690. let that = this
  691. this.$nextTick(() => {
  692. this.map = new BMapGL.Map("container",{enableIconClick: true});
  693. // var point = new BMapGL.Point(this.setQuery.mapLon,this.setQuery.mapLat);
  694. // this.map.centerAndZoom(point, 15);
  695. var geoc = new BMapGL.Geocoder();
  696. this.map.enableScrollWheelZoom(true)
  697. var myCity = new BMapGL.LocalCity();
  698. myCity.get((result)=> {
  699. console.log(result);
  700. that.cityName = result.name
  701. var cityName = result.name;
  702. that.map.setCenter(cityName);
  703. var point = new BMapGL.Point(result.center.lat, result.center.lng);
  704. that.map.centerAndZoom(point, 15);
  705. let cache = this.setQuery.address
  706. this.setQuery.address = '切换地址触发标记点'
  707. setTimeout(() => {
  708. this.setQuery.address = cache
  709. }, 100);
  710. });
  711. that.map.addEventListener("click", function (e) {
  712. let itemId = that.map.getIconByClickPosition(e)
  713. console.log(1111111,itemId);
  714. if (itemId) {
  715. uidToAddress({uid:itemId.uid,scope:2,output:'json',ak:'7aGqlyBw6mGwS6vNMLbmMlsHqE2OGV0E'}).then(res=>{
  716. if(res.status == 0){
  717. console.log(res.result);
  718. that.setQuery.mapLat = res.result.location.lat
  719. that.setQuery.mapLon = res.result.location.lng
  720. that.map.removeOverlay(that.marker); //移除点标记
  721. that.marker = new BMapGL.Marker(res.result.location, {title: res.result.name})
  722. that.map.addOverlay(that.marker)
  723. that.setQuery.address = res.result.name+'-'+ res.result.address;
  724. that.setQuery.province = res.result.province;
  725. that.setQuery.city = res.result.city;
  726. that.setQuery.district = res.result.area;
  727. that.map.centerAndZoom(res.result.location, 19);
  728. }
  729. })
  730. // let url = "//api.map.baidu.com/?qt=inf&uid="+itemId.uid+'&operate=mapclick&clicktype=tile&ie=utf-8&oue=1&fromproduct=jsapi&res=api&&ak=7aGqlyBw6mGwS6vNMLbmMlsHqE2OGV0E&callback=sucess'
  731. }
  732. // var pt = e.latlng;
  733. // that.map.removeOverlay(that.marker); //移除点标记
  734. // geoc.getLocation(pt, function (rs) {
  735. // var addComp = rs.addressComponents;
  736. // let point1 = new BMapGL.Point(rs.point.lng, rs.point.lat);
  737. // that.marker = new BMapGL.Marker(point1); // 创建标注
  738. // that.map.addOverlay(that.marker); // 将标注添加到地图中
  739. // that.setQuery.address = rs.address +rs.content.poi_desc
  740. // // 选择营业地址时保存省市区
  741. // that.setQuery.province = addComp.province
  742. // that.setQuery.city = addComp.city
  743. // that.setQuery.district = addComp.district
  744. // that.setQuery.mapLat = rs.point.lat
  745. // that.setQuery.mapLon = rs.point.lng
  746. // console.log(rs);
  747. // });
  748. });
  749. });
  750. },
  751. // 保存地址
  752. saveAddress(){
  753. this.$refs.address.validate((v) => {
  754. if (v) {
  755. this.$confirm('请确认地址信息准确无误,并精确到门牌号?', '提示', {
  756. confirmButtonText: '确定',
  757. cancelButtonText: '取消',
  758. type: 'warning'
  759. }).then(() => {
  760. this.showMap = false
  761. })
  762. }
  763. })
  764. },
  765. // 规则
  766. getRuleList() {
  767. getRuleList({currentPage:1,pageSize:999}).then((res) => {
  768. if (res.state == "Success") {
  769. res.content.records.map(item=>{
  770. this.ruleOptions.push({
  771. label:item.shareRule,
  772. value:item.id
  773. })
  774. })
  775. }
  776. });
  777. },
  778. // 获取商品分类
  779. getData(){
  780. getData().then(res=>{
  781. if(res.state == 'Success'){
  782. // this.typeOptions = res.content
  783. this.typeOptions = res.content.map(e=>{
  784. try{
  785. e.child.map(
  786. r=>{
  787. delete r.child
  788. return r
  789. }
  790. )
  791. }catch(e){
  792. console.log(e);
  793. }
  794. return e
  795. });
  796. }
  797. })
  798. },
  799. // 获取当前主体下面的已签约银联账号
  800. finishComplexList(){
  801. finishComplexList({
  802. "accesseId": "",
  803. "epId": this.setQuery.shopMainId
  804. }).then(res=>{
  805. if(res.state == 'Success'){
  806. let list = []
  807. res.content.map(item=>{
  808. list.push({
  809. value:item.accesser_user_id,
  810. label:item.externalName
  811. })
  812. })
  813. this.authOptions = list
  814. }
  815. })
  816. },
  817. accountDetail(accountId) {
  818. return new Promise((resolve, reject) => {
  819. accountDetail({accountId}).then((res) => {
  820. if (res.state == "Success") {
  821. if(res.content.platformShares){
  822. this.shopOptions = []
  823. JSON.parse(res.content.platformShares).map((item) => {
  824. this.shopOptions.push({
  825. label: this.filterMasterName(item.platformType),
  826. value: Number(item.platformType)
  827. })
  828. })
  829. let shopInfos = JSON.parse(JSON.stringify(this.setQuery.shopInfos))
  830. this.setQuery.shopInfos=[]
  831. this.shopOptions.map(item=>{
  832. this.setQuery.shopInfos.push({
  833. shareId:'',
  834. authAccount:'',
  835. platformType:item.value
  836. })
  837. })
  838. this.setQuery.shopInfos.map(item=>{
  839. shopInfos.map(i=>{
  840. if(item.platformType == i.platformType){
  841. item.shareId = i.shareId
  842. item.authAccount = i.authAccount
  843. }
  844. })
  845. })
  846. }
  847. resolve()
  848. }
  849. });
  850. })
  851. },
  852. },
  853. created() {
  854. // this.setQuery.shopInfos=[]
  855. // this.masterShopOptions.map(item=>{
  856. // this.setQuery.shopInfos.push({
  857. // shareId:'',
  858. // authAccount:'',
  859. // platformType:item.value
  860. // })
  861. // })
  862. // this.finishComplexList()
  863. this.getData()
  864. this.getRuleList()
  865. this.getMenuName()
  866. this.getMainName()
  867. if (this.$route.query.title == "店铺编辑") {
  868. this.disabled = false;
  869. this.mode = 'edit'
  870. this.detail();
  871. } else if (this.$route.query.title == "店铺详情") {
  872. this.disabled = true;
  873. this.mode = 'detail'
  874. this.detail();
  875. } else {
  876. this.disabled = false;
  877. this.mode = 'add'
  878. }
  879. },
  880. };
  881. </script>
  882. <style lang="scss" scoped>
  883. .shopAdd {
  884. padding-bottom: 40px;
  885. .flex{
  886. display: flex;
  887. }
  888. .position{
  889. cursor: pointer;
  890. font-size: 20px;
  891. }
  892. .btn-group {
  893. display: flex;
  894. align-items: center;
  895. justify-content: center;
  896. }
  897. #container {
  898. width: 100%;
  899. height: 600px;
  900. }
  901. .address-input-box {
  902. display: flex;
  903. .address-input {
  904. flex: 1;
  905. }
  906. }
  907. }
  908. </style>