storeInformation.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <view class="container">
  3. <view class="top-box">
  4. 为了方便我们与您尽快联系达成合作,请如实填写以下资料,谢谢您的支持与配合
  5. </view>
  6. <u-form :model="storeInfo" ref="uForm" labelPosition="left" :rules="rules" labelWidth="80">
  7. <view class="content-box">
  8. <view class="content-item">
  9. <u-form-item prop="legalRepresentativeName" required label="姓名" right>
  10. <view class="item-r">
  11. <u--input placeholder="请输入负责人名称" border="surround"
  12. v-model="storeInfo.legalRepresentativeName"></u--input>
  13. </view>
  14. </u-form-item>
  15. </view>
  16. <view class="content-item">
  17. <u-form-item prop="mobileNumber" required label="手机号码" right>
  18. <view class="item-r">
  19. <u--input placeholder="请输入手机号码" border="surround"
  20. v-model="storeInfo.mobileNumber"></u--input>
  21. </view>
  22. </u-form-item>
  23. </view>
  24. <view class="content-item">
  25. <u-form-item prop="email" required label="电子邮箱" right>
  26. <view class="item-r">
  27. <u--input placeholder="请输入您的邮箱" border="surround" v-model="storeInfo.email"></u--input>
  28. </view>
  29. </u-form-item>
  30. </view>
  31. </view>
  32. <view class="content-box">
  33. <view class="content-item">
  34. <u-form-item prop="storeName" required label="店铺名称" right>
  35. <view class="item-r">
  36. <u--input placeholder="请输入店铺名称" border="surround" v-model="storeInfo.storeName"></u--input>
  37. </view>
  38. </u-form-item>
  39. </view>
  40. <view class="content-item">
  41. <u-form-item prop="storeAddress" required label="所在地区" right>
  42. <view class="item-r">
  43. <u--input placeholder="请选择所在地区" border="surround" v-model="storeAddress"
  44. @focus="handlerChange"></u--input>
  45. </view>
  46. <view class="icon-right-box">
  47. <u-icon name="arrow-right" color="#c5c5c5" size="20"></u-icon>
  48. </view>
  49. </u-form-item>
  50. </view>
  51. <view class="content-item">
  52. <u-form-item prop="storeAddressDetail" required label="详细地址" right>
  53. <!-- <view class="item-r">
  54. <u--input placeholder="请输入门店详细地址" border="surround" v-model="storeInfo.storeAddressDetail"></u--input>
  55. </view> -->
  56. <view class="item-r" @click.stop="manualGetLocation">
  57. <u--input placeholder="请选择详细地址" border="surround"
  58. v-model="storeInfo.storeAddressDetail"></u--input>
  59. </view>
  60. <view class="icon-right-box">
  61. <u-icon name="arrow-down-fill" color="#333333" size="20"></u-icon>
  62. </view>
  63. </u-form-item>
  64. </view>
  65. </view>
  66. <!-- 商家信息 -->
  67. <view class="content-box">
  68. <view class="content-item">
  69. <u-form-item prop="mainBusiness" required label="主营业务" right>
  70. <view class="item-r">
  71. <u--input placeholder="请选择主营业务" border="surround" v-model="mainBusinessName"
  72. @focus="handlerChangeMainBusiness"></u--input>
  73. </view>
  74. <view class="icon-right-box">
  75. <u-icon name="arrow-right" color="#c5c5c5" size="20"></u-icon>
  76. </view>
  77. </u-form-item>
  78. </view>
  79. <view class="content-item">
  80. <u-form-item prop="ancillaryBusiness" required label="辅营业务" right>
  81. <view class="item-r">
  82. <!-- #ifndef APP-NVUE -->
  83. <u-input placeholder="请选择辅营业务" v-model="ancillaryBusinessName.join(',')" clearable
  84. @clear="ancillaryBusinessClear">
  85. <!-- #endif -->
  86. <!-- #ifdef APP-NVUE -->
  87. <u--input placeholder="sadasd">
  88. <!-- #endif -->
  89. <template slot="suffix">
  90. <u-icon @click="handlerChangeAncillaryBusiness" name="arrow-right"
  91. color="#c5c5c5" size="20"></u-icon>
  92. </template>
  93. <!-- #ifndef APP-NVUE -->
  94. </u-input>
  95. <!-- #endif -->
  96. </view>
  97. </u-form-item>
  98. </view>
  99. <view class="content-item">
  100. <u-form-item prop="opening" required label="营业时间" right>
  101. <view class="item-r">
  102. <u--input placeholder="请输入营业时间" border="surround" v-model="storeInfo.opening"></u--input>
  103. </view>
  104. </u-form-item>
  105. </view>
  106. </view>
  107. <view class="content-box">
  108. <u-form-item prop="storeImage">
  109. <imgs-upload @update="fileList" :value="1" :imageList="storeInfo.storeImage"></imgs-upload>
  110. <p class="upload-text">店铺门面图(需要包含完整牌匾)</p>
  111. </u-form-item>
  112. </view>
  113. <view class="content-box">
  114. <u-form-item prop="storeInnerImage">
  115. <imgs-upload @update="fileList" :value="2"
  116. :imageList="storeInfo.storeInnerImage.join(',')"></imgs-upload>
  117. <p class="upload-text">店内真实环境图</p>
  118. </u-form-item>
  119. </view>
  120. </u-form>
  121. <button class="btn" @click="handlerSkipNext">下一步</button>
  122. <!-- 选择器 -->
  123. <u-picker :show="show" ref="uPicker" :columns="list" keyName="name" @confirm="confirm" @change="changeHandler"
  124. @cancel="show = false"></u-picker>
  125. </view>
  126. </template>
  127. <script>
  128. import ImgsUpload from './components/ImgsUpload.vue';
  129. // 导入城市js文件
  130. import cityData from '@/utils/city';
  131. import {
  132. getParentCategoriesData,
  133. getRootCategoriesData
  134. } from '@/api/merchant/merchantAuth';
  135. export default {
  136. components: {
  137. ImgsUpload,
  138. },
  139. data() {
  140. return {
  141. storeAddress: "",
  142. mainBusinessName: "", // 主营业务,
  143. ancillaryBusinessName: [], // 辅营业务
  144. mainBusinessList: [], // 主营业务下拉数组
  145. ancillaryBusinessList: [], // 辅营业务数组
  146. storeInfo: {
  147. region: '',
  148. storeAddressDetail: '',
  149. legalRepresentativeName: '',
  150. mobileNumber: '',
  151. storeName: '',
  152. storeImage: '',
  153. storeInnerImage: [],
  154. email: "",
  155. longitude: '',
  156. latitude: '',
  157. opening: '',
  158. city: "",
  159. province: "",
  160. district: "",
  161. mainBusiness: "", // 主营业务,
  162. ancillaryBusiness: [], // 辅营业务
  163. },
  164. rules: {
  165. opening: {
  166. type: 'string',
  167. required: true,
  168. message: '请输入营业时间',
  169. trigger: ['blur', 'change'],
  170. },
  171. legalRepresentativeName: {
  172. type: 'string',
  173. required: true,
  174. message: '请输入负责人名称',
  175. trigger: ['blur', 'change'],
  176. },
  177. storeName: {
  178. type: 'string',
  179. required: true,
  180. message: '请输入店铺名',
  181. trigger: ['blur', 'change'],
  182. },
  183. storeAddressDetail: {
  184. type: 'string',
  185. required: true,
  186. message: '请输入详细地址',
  187. trigger: ['blur', 'change'],
  188. },
  189. mobileNumber: [{
  190. required: true,
  191. message: '请输入手机号码',
  192. trigger: ['blur', 'change'],
  193. },
  194. {
  195. validator: (rule, value, callback) => {
  196. return uni.$u.test.mobile(value);
  197. },
  198. message: '手机号码不正确',
  199. trigger: ['change', 'blur'],
  200. },
  201. ],
  202. email: [{
  203. required: true,
  204. message: '请输入您的邮箱',
  205. trigger: ['blur', 'change'],
  206. },
  207. {
  208. validator: (rule, value, callback) => {
  209. return uni.$u.test.email(value);
  210. },
  211. message: '您输入的邮箱不正确',
  212. trigger: ['change', 'blur'],
  213. },
  214. ],
  215. region: [{
  216. required: true,
  217. message: '请选择所在地区',
  218. trigger: ['change'],
  219. }, ],
  220. mainBusiness: [{
  221. required: true,
  222. message: '请选择主营业务',
  223. trigger: ['change'],
  224. }, ],
  225. // ancillaryBusiness: [{
  226. // type: 'string',
  227. // required: true,
  228. // message: '请输入详细地址',
  229. // trigger: ['blur', 'change'],
  230. // }, ],
  231. },
  232. show: false, //显示选择器
  233. // 打开选择器显示默认城市
  234. cityList: [], // 选择地区数组
  235. cityLevel1: [],
  236. cityLevel2: [],
  237. cityLevel3: [],
  238. list: [], // 数组控制器
  239. };
  240. },
  241. onReady() {
  242. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  243. this.$refs.uForm.setRules(this.rules);
  244. },
  245. created() {
  246. this.request()
  247. },
  248. onLoad() {
  249. if (this.$store.state.data.merchantInfo) {
  250. console.log(this.$store.state.data.merchantInfo, "this.$store.state.data.merchantInfo")
  251. this.storeInfo = {
  252. region: this.$store.state.data.merchantInfo.merchant.region,
  253. storeAddressDetail: this.$store.state.data.merchantInfo.storeAddressDetail,
  254. legalRepresentativeName: this.$store.state.data.merchantInfo.legalRepresentativeName,
  255. mobileNumber: this.$store.state.data.merchantInfo.mobileNumber,
  256. storeName: this.$store.state.data.merchantInfo.storeName,
  257. storeImage: this.$store.state.data.merchantInfo.storeImage,
  258. storeInnerImage: this.$store.state.data.merchantInfo.storeInnerImage,
  259. email: this.$store.state.data.merchantInfo.email,
  260. longitude: this.$store.state.data.merchantInfo.merchant.longitude,
  261. latitude: this.$store.state.data.merchantInfo.merchant.latitude,
  262. opening: this.$store.state.data.merchantInfo.merchant.opening,
  263. city: this.$store.state.data.merchantInfo.merchant.region.toString().slice(0, -2) + "00",
  264. province: this.$store.state.data.merchantInfo.merchant.region.toString().slice(0, -4) + "0000",
  265. district: this.$store.state.data.merchantInfo.merchant.region,
  266. mainBusiness: this.$store.state.data.merchantInfo.merchant.mainBusiness, // 主营业务,
  267. ancillaryBusiness: this.$store.state.data.merchantInfo.merchant.ancillaryBusiness, // 辅营业务
  268. }
  269. this.storeAddress = this.findAreaByCode(this.$store.state.data.merchantInfo.merchant.region)
  270. }
  271. },
  272. onShow() {
  273. this.initCityData();
  274. },
  275. methods: {
  276. async request() {
  277. const res = await getParentCategoriesData({
  278. type: "0"
  279. })
  280. this.mainBusinessList = res.data.map((item) => {
  281. return {
  282. name: item.name,
  283. id: item.id
  284. }
  285. })
  286. const res1 = await getRootCategoriesData({
  287. type: "0"
  288. })
  289. this.ancillaryBusinessList = res1.data.map((item) => {
  290. return {
  291. name: item.name,
  292. id: item.id,
  293. status: 1
  294. }
  295. })
  296. if (this.$store.state.data.merchantInfo) {
  297. this.mainBusinessName = this.nameFunction([this.$store.state.data.merchantInfo.merchant
  298. .mainBusiness
  299. ],
  300. this
  301. .mainBusinessList)
  302. this.ancillaryBusinessName = this.nameFunction(this.$store.state.data.merchantInfo.merchant
  303. .ancillaryBusiness, this.ancillaryBusinessList)
  304. }
  305. console.log(this.ancillaryBusinessList, "这是请i去的")
  306. },
  307. // 手动选择城市
  308. manualGetLocation() {
  309. uni.chooseLocation({
  310. success: res => {
  311. console.log(res, "点击获取的")
  312. let {
  313. longitude,
  314. latitude
  315. } = res;
  316. console.log(this.stereInfo, "this")
  317. this.storeInfo.longitude = parseFloat(longitude.toFixed(5))
  318. this.storeInfo.latitude = parseFloat(latitude.toFixed(5));
  319. this.storeInfo.storeAddressDetail = res.address
  320. },
  321. fail: err => {},
  322. });
  323. },
  324. initCityData() {
  325. // 遍历城市js
  326. cityData.forEach((item1, index1) => {
  327. let temp2 = [];
  328. this.cityLevel1.push({
  329. name: item1.provinceName,
  330. id: item1.provinceCode
  331. });
  332. let temp4 = [];
  333. let temp3 = [];
  334. // 遍历市
  335. item1.cities.forEach((item2, index2) => {
  336. temp2.push({
  337. name: item2.cityName,
  338. id: item2.cityCode
  339. });
  340. // 遍历区
  341. item2.counties.forEach((item3, index3) => {
  342. temp3.push({
  343. name: item3.countyName,
  344. id: item3.countyCode
  345. });
  346. });
  347. temp4[index2] = temp3;
  348. temp3 = [];
  349. });
  350. this.cityLevel3[index1] = temp4;
  351. this.cityLevel2[index1] = temp2;
  352. });
  353. // 选择器默认城市
  354. this.cityList.push(this.cityLevel1, this.cityLevel2[0], this.cityLevel3[0][0]);
  355. console.log(this.cityList, "this.cityList")
  356. },
  357. // 选中时执行
  358. changeHandler(e) {
  359. if (this.list.length > 1) {
  360. const {
  361. columnIndex,
  362. index,
  363. indexs,
  364. value,
  365. values,
  366. // 微信小程序无法将picker实例传出来,只能通过ref操作
  367. picker = this.$refs.uPicker,
  368. } = e;
  369. if (columnIndex === 0) {
  370. // 选择第一列数据时 设置第二列关联数据
  371. picker.setColumnValues(1, this.cityLevel2[index]);
  372. // 设置第三列关联数据
  373. picker.setColumnValues(2, this.cityLevel3[index][columnIndex]);
  374. } else if (columnIndex === 1) {
  375. // 选择第二列数据时 设置第三列关联数据
  376. picker.setColumnValues(2, this.cityLevel3[indexs[0]][index]);
  377. }
  378. }
  379. },
  380. // 单击确认按钮时执行
  381. confirm(e) {
  382. if (e.value.length > 1) {
  383. this.storeInfo.province = parseInt(e.value[0].id, 10)
  384. this.storeInfo.city = parseInt(e.value[1].id, 10)
  385. this.storeInfo.district = parseInt(e.value[2].id, 10)
  386. this.storeInfo.region = parseInt(e.value[2].id, 10)
  387. this.storeAddress = e.value.map(item => item.name).join('')
  388. // 隐藏城市选择器
  389. } else {
  390. if (e.value[0].status && e.value[0].status == 1) {
  391. this.ancillaryBusinessName.push(e.value[0].name)
  392. this.storeInfo.ancillaryBusiness.push(e.value[0].id)
  393. } else {
  394. this.mainBusinessName = e.value[0].name
  395. this.storeInfo.mainBusiness = e.value[0].id
  396. }
  397. }
  398. this.show = false;
  399. },
  400. // 点击选择地区
  401. handlerChange() {
  402. this.list = this.cityList
  403. this.show = true;
  404. },
  405. //点击选择主营业务
  406. handlerChangeMainBusiness() {
  407. this.list = [this.mainBusinessList]
  408. this.show = true;
  409. },
  410. //点击选择辅营业务
  411. handlerChangeAncillaryBusiness() {
  412. console.log("asdsd")
  413. this.list = [this.ancillaryBusinessList]
  414. console.log(this.list)
  415. this.show = true;
  416. },
  417. //点击清空按钮
  418. ancillaryBusinessClear() {
  419. this.ancillaryBusinessName = []
  420. this.storeInfo.ancillaryBusiness = []
  421. },
  422. handlerSkipNext() {
  423. this.$refs.uForm.validate().then(res => {
  424. this.$store.commit('SET_STOREINFO', this.storeInfo);
  425. setTimeout(() => {
  426. uni.navigateTo({
  427. url: '/pageMerchant/mineModule/certification/corporateInformation',
  428. });
  429. }, 1500);
  430. });
  431. },
  432. // 图片
  433. fileList(val, data) {
  434. console.log(data, "data")
  435. if (data == 1) {
  436. this.storeInfo.storeImage = val[0];
  437. } else if (data == 2) {
  438. this.storeInfo.storeInnerImage = val.map((item) => {
  439. return {
  440. url: item,
  441. media: "IMAGE"
  442. }
  443. })
  444. }
  445. },
  446. //回显时展示的
  447. nameFunction(idArray, services) {
  448. let nameString = ''
  449. if (idArray.length > 1) {
  450. nameString = idArray
  451. .map(id => services.find(service => service.id == id))
  452. .filter(service => service)
  453. .map(service => service.name);
  454. } else {
  455. nameString = idArray
  456. .map(id => services.find(service => service.id == id))
  457. .filter(service => service)
  458. .map(service => service.name)
  459. .join(',');
  460. }
  461. return nameString;
  462. },
  463. findAreaByCode(areaCode) {
  464. for (const province of cityData) {
  465. if (province.provinceCode == areaCode) {
  466. return `${province.provinceName}`;
  467. }
  468. for (const city of province.cities) {
  469. if (city.cityCode == areaCode) {
  470. return `${province.provinceName} - ${city.cityName}`;
  471. }
  472. const county = city.counties.find(item => item.countyCode == areaCode);
  473. if (county) {
  474. return `${province.provinceName} ${city.cityName} ${county.countyName}`;
  475. }
  476. }
  477. }
  478. return '未找到对应地区';
  479. }
  480. },
  481. };
  482. </script>
  483. <style lang="scss" scoped>
  484. .container {
  485. background-color: #f7f7f7 !important;
  486. padding-bottom: 40rpx;
  487. .top-box {
  488. color: #666666;
  489. font-size: 26rpx;
  490. text-align: center;
  491. padding: 20rpx 40rpx;
  492. background-color: #fff;
  493. }
  494. .content-box {
  495. padding: 20rpx 40rpx;
  496. background-color: #fff;
  497. margin: 10rpx 0;
  498. .content-item {
  499. position: relative;
  500. .item-r {
  501. background-color: #f7f7f7;
  502. border-radius: 20rpx;
  503. display: flex;
  504. .data_select {
  505. width: 90%;
  506. }
  507. ::v-deep .u-form-item {
  508. width: 100%;
  509. }
  510. ::v-deep .u-form-item__body {
  511. padding: 0;
  512. }
  513. }
  514. .icon-right-box {
  515. position: absolute;
  516. right: 15rpx;
  517. top: 40rpx;
  518. }
  519. }
  520. .upload-text {
  521. text-align: center;
  522. color: #666666;
  523. font-size: 28rpx;
  524. margin-top: 20rpx;
  525. }
  526. }
  527. .btn {
  528. background-color: #5992bb !important;
  529. color: #fff;
  530. font-size: 32rpx;
  531. border-radius: 40rpx;
  532. margin-top: 100rpx;
  533. margin-bottom: 100rpx;
  534. width: 95%;
  535. }
  536. }
  537. ::v-deep .uni-select {
  538. border: none !important;
  539. }
  540. ::v-deep .uni-select__input-placeholder {
  541. font-size: 28rpx !important;
  542. color: #cbced4 !important;
  543. }
  544. </style>