editStore.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="creat">
  3. <!-- <cu-custom bgColor="bg-fff" :isBack="true" style="position: relative;
  4. z-index: 999999999999999999"> -->
  5. <view class="top"></view>
  6. <view class="head">
  7. <view class="handle">
  8. <view class="head_left">
  9. <span class="cuIcon-back" @click="back"></span>
  10. </view>
  11. <span class="center">编辑门店</span>
  12. <view class="head_right">
  13. </view>
  14. </view>
  15. </view>
  16. <block slot="content">编辑门店</block>
  17. </cu-custom>
  18. <view class="borderRadiu">
  19. <view class="cu-form-group">
  20. <view class="title">门店名称</view>
  21. <input placeholder="请输入门店名称" v-model="form.storeName" name="input"></input>
  22. </view>
  23. <view class="cu-form-group">
  24. <view class="title">所在地区</view>
  25. <view style="display: flex;width: 77%;justify-content: space-between;" @click="$refs.picker.show()">
  26. <!-- <u-input readonly placeholder="去设置" v-model="form.locality" @click="$refs.picker.show()" /> -->
  27. <view style="font-size: 30rpx;">
  28. <text v-if="form.locality"> {{ form.locality }}</text>
  29. <text v-else style="color: grey">请选择所在地区</text>
  30. </view>
  31. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  32. </view>
  33. <!-- <view>
  34. <input disabled="true" @mousedown="$refs.picker.show()" placeholder="请选择所在地区" ref="inputRef"
  35. name="input" v-model="form.locality"></input>
  36. <text class='cuIcon-right' style="color: #C7C6CA ;" @click="$refs.picker.show()"></text>
  37. <w-picker :visible.sync="visible" ref="picker" mode="region" :value="form.locality"
  38. @confirm="onConfirm($event, 'region')"></w-picker>
  39. </view> -->
  40. </view>
  41. <view class="cu-form-group">
  42. <view class="title">门店地址</view>
  43. <input placeholder="请输入门店详细地址" v-model="form.address" name="input"></input>
  44. </view>
  45. <view class="customize">
  46. <view class="title">地理位置</view>
  47. <view class=" booder-top" style="padding-bottom: 16upx;" :style="{ 'display': mapIsHidden }"
  48. @click="selectAddress">
  49. <!-- <map style="width: 100%; height: 218upx; position: relative;
  50. z-index: 1;" :latitude="savedLocation.lat" scale="14" :longitude="savedLocation.lng" :markers="markers"
  51. @tap="handleMarkerTap"></map> -->
  52. <tdmap style="" :initialPosition="savedLocation" :allowSelection="false" :showCoordinates="false" :key="mapKey"></tdmap>
  53. </view>
  54. <!-- <aMap class=" booder-top" style="padding-bottom: 7px;"></aMap> -->
  55. <view class="business-prompt">
  56. 若位置有误直接影响客户到店,请在地图中仔细核对,可拖拽地图确保位置正确
  57. </view>
  58. </view>
  59. <view class="cu-form-group">
  60. <view class="title">店铺面积</view>
  61. <input placeholder="请输入店铺面积" v-model="form.storeExtent" name="input"></input>
  62. </view>
  63. <view class="customize">
  64. <view class="title">门头照片</view>
  65. <view class="grid col-3 grid-square flex-sub booder-top">
  66. <view class="bg-img" v-for="(item, index) in headPhotoImg" :key="index" @tap="ViewImage"
  67. :data-url="headPhotoImg[index]">
  68. <image :src="headPhotoImg[index]" mode="aspectFill"></image>
  69. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  70. <text class='cuIcon-close'></text>
  71. </view>
  72. </view>
  73. <view class="solids" @tap="ChooseImage" v-if="headPhotoImg.length <= 4">
  74. <text class='cuIcon-cameraadd'></text>
  75. </view>
  76. </view>
  77. <view class="business-prompt">
  78. 门店照片需包含完整的门店入口和招牌名称,建议现场拍摄门头照;最多可上传5张,支持格式bmp、png、jpeg、jpg,单个图片不超过5MB,建议尺寸在2000*1500px以上
  79. </view>
  80. </view>
  81. </view>
  82. <view class="padding flex flex-direction sub-bottom">
  83. <button class="cu-btn bg-blue round " @click="submit">提交审核</button>
  84. </view>
  85. <w-picker :visible.sync="visible" ref="picker" mode="region" :value="form.locality"
  86. @confirm="onConfirm($event, 'region')"></w-picker>
  87. </view>
  88. </template>
  89. <script>
  90. import regionPicker from "../../components/w-picker/region-picker.vue"
  91. import {
  92. USER_INFO
  93. } from "@/common/util/constants"
  94. import configService from '../../common/service/config.service'
  95. import tdmap from "./tdtuMap.vue"
  96. export default {
  97. components: {
  98. regionPicker,
  99. tdmap
  100. // aMap
  101. },
  102. data() {
  103. return {
  104. imgList: [],
  105. form: {},
  106. visible: false,
  107. markers: [],
  108. headPhotoImg: [],
  109. imageList: [],
  110. mapIsHidden: false,
  111. savedLocation: {},
  112. isDataLoaded: false,
  113. mapKey:0
  114. }
  115. },
  116. watch: {
  117. visible(val) {
  118. if (!val) {
  119. this.mapIsHidden = 'block'
  120. }
  121. }
  122. },
  123. async onload() {
  124. console.log('-----------')
  125. },
  126. async onShow() {
  127. this.$http
  128. .get(
  129. "/merchant/localMerchantTime/list?merchantId=" +
  130. uni.getStorageSync(USER_INFO).merchantId
  131. )
  132. .then((res) => {
  133. if (res.data.success) {
  134. this.businessData = res.data.result;
  135. } else {
  136. this.$tip.error(res.data.message);
  137. }
  138. });
  139. let da = uni.getStorageSync("address");
  140. this.savedLocation.lnglat = {
  141. lng: da.lng || 0,
  142. lat: da.lat || 0,
  143. };
  144. this.savedLocation.address = da.address || '位置';
  145. this.latitude = da.lat;
  146. this.longitude = da.lng;
  147. this.mapKey += 1;
  148. this.merchantId = uni.getStorageSync(USER_INFO).merchantId;
  149. let res = await this.$http.get("/merchant/localMerchantInfo/queryAppInfoById?id=" + this.merchantId)
  150. if (res.data.success) {
  151. // this.savedLocation = res.data.result.longitude && res.data.result.latitude ? [{
  152. // lng: res.data.result.longitude,
  153. // lat: res.data.result.latitude,
  154. // }] :
  155. // uni.getStorageSync('address') ? [Object.assign(uni.getStorageSync('address'), {
  156. // })] : []
  157. if(res.data.result.longitude && res.data.result.latitude){
  158. this.savedLocation.lnglat = {
  159. lng:res.data.result.longitude || 0,
  160. lat: res.data.result.latitude || 0,
  161. };
  162. this.savedLocation.address = res.data.result.address || '位置';
  163. }
  164. res.data.result.headPhoto = res.data.result.headPhoto ? res.data.result.headPhoto.split(',').filter(id =>
  165. id !== '') : []
  166. this.headPhotoImg = res.data.result.headPhoto ? res.data.result.headPhoto : []
  167. res.data.result.locality = res.data.result.locality ? res.data.result.locality : ''
  168. this.form = res.data.result
  169. } else {
  170. this.$tip.toast(res.data.message);
  171. }
  172. // this.getCurrentLocation();
  173. },
  174. // async onLoad(option) {
  175. // this.merchantId = uni.getStorageSync(USER_INFO).merchantId;
  176. // let res = await this.$http.get("/merchant/localMerchantInfo/queryAppInfoById?id=" + this.merchantId)
  177. // if (res.data.success) {
  178. // // this.savedLocation = res.data.result.longitude && res.data.result.latitude ? [{
  179. // // lng: res.data.result.longitude,
  180. // // lat: res.data.result.latitude,
  181. // // address:res.data.result.address
  182. // // }] :
  183. // // uni.getStorageSync('address') ? [Object.assign(uni.getStorageSync('address'), {
  184. // // iconPath: '../../static/boiaoji.png'
  185. // // })] : []
  186. // if (option.lng) {
  187. // this.$nextTick(
  188. // this.savedLocation.lng = option.lng,
  189. // this.savedLocation.lat = option.lat,
  190. // this.savedLocation.address = option.address,
  191. // this.form.longitude = option.lng,
  192. // this.form.latitude = option.lat,
  193. // this.form.address = option.address,
  194. // console.log(this.form)
  195. // )
  196. // } else {
  197. // if (res.data.result.longitude && res.data.result.latitude) {
  198. // this.savedLocation.lng = res.data.result.longitude,
  199. // this.savedLocation.lat = res.data.result.latitude,
  200. // this.savedLocation.address = res.data.result.address
  201. // }
  202. // res.data.result.headPhoto = res.data.result.headPhoto ? res.data.result.headPhoto.split(',').filter(id =>
  203. // id !== '') : []
  204. // this.headPhotoImg = res.data.result.headPhoto ? res.data.result.headPhoto.slice() : []
  205. // res.data.result.locality = res.data.result.locality ? res.data.result.locality : ''
  206. // this.form = res.data.result
  207. // }
  208. // } else {
  209. // this.$tip.toast(res.data.message);
  210. // }
  211. // },
  212. methods: {
  213. selectAddress() {
  214. uni.navigateTo({
  215. url: '/pages/store/selectTdMap?url=' + '/pages/store/editStore'
  216. })
  217. },
  218. back() {
  219. uni.navigateTo({
  220. url: '/pages/index/shop'
  221. })
  222. },
  223. submit() {
  224. // this.$http.post('/merchant/localMerchantInfo/edit', { ...this.form, headPhoto: this.form.headPhoto.join(',') }).then(res => {
  225. this.$http.post('/merchant/localMerchantInfo/editMerchantInfo ', {
  226. ...this.form,
  227. headPhoto: this.form.headPhoto.join(',')
  228. }).then(res => {
  229. if (res.data.success) {
  230. // this.$tip.success(res.data.result || '成功')
  231. uni.showToast({
  232. title: '提交成功',
  233. icon: 'none'
  234. });
  235. uni.navigateTo({
  236. url: '/pages/index/shop'
  237. })
  238. } else {
  239. this.$tip.error(res.data.message);
  240. }
  241. })
  242. },
  243. uploadAll() {
  244. if (this.imageList.length === 0) {
  245. uni.showToast({
  246. title: '请先选择图片',
  247. icon: 'none'
  248. });
  249. return;
  250. }
  251. uni.showLoading({
  252. title: '上传中...',
  253. mask: true
  254. });
  255. const uploadPromises = this.imageList.map((path, index) => {
  256. return new Promise((resolve, reject) => {
  257. uni.uploadFile({
  258. url: configService.apiUrl + '/sys/common/upload', // 替换为实际接口
  259. filePath: path,
  260. formData: {
  261. 'biz': 'temp',
  262. },
  263. name: 'file',
  264. success: (files) => {
  265. resolve(configService.apiUrl + '/' + JSON.parse(files.data).message)
  266. },
  267. fail: reject
  268. });
  269. });
  270. });
  271. Promise.all(uploadPromises)
  272. .then(results => {
  273. uni.hideLoading();
  274. this.imageList = []; // 清空已上传列表
  275. this.headPhotoImg = this.headPhotoImg.concat(results)
  276. this.form.headPhoto = this.form.headPhoto.concat(results)
  277. })
  278. .catch(error => {
  279. uni.hideLoading();
  280. });
  281. },
  282. ChooseImage() {
  283. uni.chooseImage({
  284. count: 5 - Number(this.headPhotoImg.length),
  285. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  286. sourceType: ['album'], //从相册选择
  287. success: (res) => {
  288. if (res) {
  289. this.imageList = [...this.imageList, ...res.tempFilePaths];
  290. this.uploadAll()
  291. }
  292. }
  293. });
  294. },
  295. onConfirm(e) {
  296. console.log(e)
  297. this.mapIsHidden = false
  298. this.form.locality = e.result
  299. this.form.country = e.value[e.value.length - 1]
  300. this.form.thirdPartyAreaList = e.value
  301. },
  302. DelImg(e) {
  303. uni.showModal({
  304. title: '提示',
  305. content: '确定要删除?',
  306. cancelText: '取消',
  307. confirmText: '确定',
  308. success: res => {
  309. if (res.confirm) {
  310. this.headPhotoImg.splice(e.currentTarget.dataset.index, 1)
  311. this.form.headPhoto.splice(e.currentTarget.dataset.index, 1)
  312. }
  313. }
  314. })
  315. },
  316. ViewImage(e) {
  317. uni.previewImage({
  318. urls: this.headPhotoImg,
  319. current: e.currentTarget.dataset.url
  320. });
  321. },
  322. handleMarkerTap() {
  323. const queryString = this.form.longitude && this.form.latitude ? {
  324. longitude: this.form.longitude,
  325. latitude: this.form.latitude,
  326. } :
  327. uni.getStorageSync('address') ?
  328. encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : {}
  329. // const queryString = uni.getStorageSync('address') ? encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : ''
  330. uni.navigateTo({
  331. url: `/pages/login/map?position=${queryString}`
  332. })
  333. },
  334. }
  335. }
  336. </script>
  337. <style scoped lang="scss">
  338. .top {
  339. width: 100%;
  340. height: var(--status-bar-height);
  341. background: linear-gradient(87deg, #FFFFFF 0%, #A3CDFF 100%), linear-gradient(360deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
  342. }
  343. .head {
  344. width: 100%;
  345. background: #ffffff;
  346. .handle {
  347. height: 112rpx;
  348. display: flex;
  349. justify-content: space-between;
  350. align-items: center;
  351. padding: 0px 24rpx;
  352. position: relative;
  353. .head_left {
  354. font-size: 40rpx;
  355. }
  356. .center {
  357. position: absolute;
  358. left: 50%;
  359. top: 50%;
  360. transform: translate(-50%, -50%);
  361. font-size: 30rpx;
  362. font-weight: 600;
  363. }
  364. .head_right {
  365. display: flex;
  366. justify-content: space-between;
  367. align-items: center;
  368. span {
  369. width: 40rpx;
  370. height: 40rpx;
  371. display: flex;
  372. font-size: 28rpx;
  373. justify-content: center;
  374. align-items: center;
  375. }
  376. }
  377. }
  378. }
  379. .creat {
  380. background: #F7F8FC;
  381. // flex-direction: column;
  382. // position: fixed;
  383. }
  384. .borderRadiu {
  385. margin: 22upx 26upx;
  386. padding-bottom: 120upx;
  387. background-color: #ffffff;
  388. }
  389. .sub-bottom {
  390. position: fixed;
  391. width: 100%;
  392. bottom: 0;
  393. background: #FFFFFF;
  394. border-top: 1px solid #EEEEEE;
  395. }
  396. .customize {
  397. background-color: #fff;
  398. // border-top: 0.5px solid #eee;
  399. margin: 16upx 18upx;
  400. .title {
  401. font-size: 30upx;
  402. // padding: 10px;
  403. }
  404. .business-img {
  405. height: 218upx;
  406. width: 360upx;
  407. padding: 16upx;
  408. // padding-bottom: 16upx;
  409. background: url('/static/login/yingye2.png');
  410. margin: 16upx auto;
  411. background-size: cover;
  412. image {
  413. width: 100%;
  414. height: 100%;
  415. }
  416. }
  417. .business-prompt {
  418. padding-top: 16upx;
  419. font-size: 20upx;
  420. color: #999999;
  421. }
  422. }
  423. .booder-top {
  424. border-bottom: 1px solid rgb(238, 238, 238);
  425. padding-top: 7px;
  426. }
  427. .picker-style {
  428. .w-picker-cnt .visible {
  429. position: absolute;
  430. z-index: 100000;
  431. }
  432. }
  433. </style>