editStore.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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.code == 200) {
  230. uni.showToast({
  231. icon:'none',
  232. title:res.data.message || '成功'
  233. })
  234. setTimeout(()=>{
  235. uni.navigateBack({
  236. delta: 1 // 返回的页面数,默认为1
  237. })
  238. },1000)
  239. } else {
  240. uni.showToast({
  241. icon:'none',
  242. title:res.data.message
  243. })
  244. }
  245. })
  246. },
  247. uploadAll() {
  248. if (this.imageList.length === 0) {
  249. uni.showToast({
  250. title: '请先选择图片',
  251. icon: 'none'
  252. });
  253. return;
  254. }
  255. uni.showLoading({
  256. title: '上传中...',
  257. mask: true
  258. });
  259. const uploadPromises = this.imageList.map((path, index) => {
  260. return new Promise((resolve, reject) => {
  261. uni.uploadFile({
  262. url: configService.apiUrl + '/sys/common/upload', // 替换为实际接口
  263. filePath: path,
  264. formData: {
  265. 'biz': 'temp',
  266. },
  267. name: 'file',
  268. success: (files) => {
  269. resolve(configService.apiUrl + '/' + JSON.parse(files.data).message)
  270. },
  271. fail: reject
  272. });
  273. });
  274. });
  275. Promise.all(uploadPromises)
  276. .then(results => {
  277. uni.hideLoading();
  278. this.imageList = []; // 清空已上传列表
  279. this.headPhotoImg = this.headPhotoImg.concat(results)
  280. this.form.headPhoto = this.form.headPhoto.concat(results)
  281. })
  282. .catch(error => {
  283. uni.hideLoading();
  284. });
  285. },
  286. ChooseImage() {
  287. uni.chooseImage({
  288. count: 5 - Number(this.headPhotoImg.length),
  289. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  290. sourceType: ['album'], //从相册选择
  291. success: (res) => {
  292. if (res) {
  293. this.imageList = [...this.imageList, ...res.tempFilePaths];
  294. this.uploadAll()
  295. }
  296. }
  297. });
  298. },
  299. onConfirm(e) {
  300. console.log(e)
  301. this.mapIsHidden = false
  302. this.form.locality = e.result
  303. this.form.country = e.value[e.value.length - 1]
  304. this.form.thirdPartyAreaList = e.value
  305. },
  306. DelImg(e) {
  307. uni.showModal({
  308. title: '提示',
  309. content: '确定要删除?',
  310. cancelText: '取消',
  311. confirmText: '确定',
  312. success: res => {
  313. if (res.confirm) {
  314. this.headPhotoImg.splice(e.currentTarget.dataset.index, 1)
  315. this.form.headPhoto.splice(e.currentTarget.dataset.index, 1)
  316. }
  317. }
  318. })
  319. },
  320. ViewImage(e) {
  321. uni.previewImage({
  322. urls: this.headPhotoImg,
  323. current: e.currentTarget.dataset.url
  324. });
  325. },
  326. handleMarkerTap() {
  327. const queryString = this.form.longitude && this.form.latitude ? {
  328. longitude: this.form.longitude,
  329. latitude: this.form.latitude,
  330. } :
  331. uni.getStorageSync('address') ?
  332. encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : {}
  333. // const queryString = uni.getStorageSync('address') ? encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : ''
  334. uni.navigateTo({
  335. url: `/pages/login/map?position=${queryString}`
  336. })
  337. },
  338. }
  339. }
  340. </script>
  341. <style scoped lang="scss">
  342. .top {
  343. width: 100%;
  344. height: var(--status-bar-height);
  345. background: linear-gradient(87deg, #FFFFFF 0%, #A3CDFF 100%), linear-gradient(360deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
  346. }
  347. .head {
  348. width: 100%;
  349. background: #ffffff;
  350. .handle {
  351. height: 112rpx;
  352. display: flex;
  353. justify-content: space-between;
  354. align-items: center;
  355. padding: 0px 24rpx;
  356. position: relative;
  357. .head_left {
  358. font-size: 40rpx;
  359. }
  360. .center {
  361. position: absolute;
  362. left: 50%;
  363. top: 50%;
  364. transform: translate(-50%, -50%);
  365. font-size: 30rpx;
  366. font-weight: 600;
  367. }
  368. .head_right {
  369. display: flex;
  370. justify-content: space-between;
  371. align-items: center;
  372. span {
  373. width: 40rpx;
  374. height: 40rpx;
  375. display: flex;
  376. font-size: 28rpx;
  377. justify-content: center;
  378. align-items: center;
  379. }
  380. }
  381. }
  382. }
  383. .creat {
  384. background: #F7F8FC;
  385. // flex-direction: column;
  386. // position: fixed;
  387. }
  388. .borderRadiu {
  389. margin: 22upx 26upx;
  390. padding-bottom: 120upx;
  391. background-color: #ffffff;
  392. }
  393. .sub-bottom {
  394. position: fixed;
  395. width: 100%;
  396. bottom: 0;
  397. background: #FFFFFF;
  398. border-top: 1px solid #EEEEEE;
  399. }
  400. .customize {
  401. background-color: #fff;
  402. // border-top: 0.5px solid #eee;
  403. margin: 16upx 18upx;
  404. .title {
  405. font-size: 30upx;
  406. // padding: 10px;
  407. }
  408. .business-img {
  409. height: 218upx;
  410. width: 360upx;
  411. padding: 16upx;
  412. // padding-bottom: 16upx;
  413. background: url('/static/login/yingye2.png');
  414. margin: 16upx auto;
  415. background-size: cover;
  416. image {
  417. width: 100%;
  418. height: 100%;
  419. }
  420. }
  421. .business-prompt {
  422. padding-top: 16upx;
  423. font-size: 20upx;
  424. color: #999999;
  425. }
  426. }
  427. .booder-top {
  428. border-bottom: 1px solid rgb(238, 238, 238);
  429. padding-top: 7px;
  430. }
  431. .picker-style {
  432. .w-picker-cnt .visible {
  433. position: absolute;
  434. z-index: 100000;
  435. }
  436. }
  437. </style>