editStore.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="creat">
  3. <cu-custom bgColor="bg-fff" :isBack="true" style="position: relative;
  4. z-index: 999999999999999999">
  5. <block slot="content">编辑门店</block>
  6. </cu-custom>
  7. <view class="borderRadiu">
  8. <view class="cu-form-group">
  9. <view class="title">门店名称</view>
  10. <input placeholder="请输入门店名称" v-model="form.storeName" name="input"></input>
  11. </view>
  12. <view class="cu-form-group">
  13. <view class="title">所在地区</view>
  14. <view style="display: flex;width: 77%;justify-content: space-between;" @click="$refs.picker.show()">
  15. <!-- <u-input readonly placeholder="去设置" v-model="form.locality" @click="$refs.picker.show()" /> -->
  16. <view style="font-size: 30rpx;">
  17. <text v-if="form.locality"> {{ form.locality }}</text>
  18. <text v-else style="color: grey">请选择所在地区</text>
  19. </view>
  20. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  21. </view>
  22. <!-- <view>
  23. <input disabled="true" @mousedown="$refs.picker.show()" placeholder="请选择所在地区" ref="inputRef"
  24. name="input" v-model="form.locality"></input>
  25. <text class='cuIcon-right' style="color: #C7C6CA ;" @click="$refs.picker.show()"></text>
  26. <w-picker :visible.sync="visible" ref="picker" mode="region" :value="form.locality"
  27. @confirm="onConfirm($event, 'region')"></w-picker>
  28. </view> -->
  29. </view>
  30. <view class="cu-form-group">
  31. <view class="title">门店地址</view>
  32. <input placeholder="请输入门店详细地址" v-model="form.address" name="input"></input>
  33. </view>
  34. <view class="customize">
  35. <view class="title">地理位置</view>
  36. <view class=" booder-top" style="padding-bottom: 16upx;" :style="{ 'display': mapIsHidden }">
  37. <map style="width: 100%; height: 218upx; position: relative;
  38. z-index: 1;" :latitude="form.latitude" scale="14"
  39. :longitude="form.longitude" :markers="markers" @tap="handleMarkerTap"></map>
  40. </view>
  41. <!-- <aMap class=" booder-top" style="padding-bottom: 7px;"></aMap> -->
  42. <view class="business-prompt">
  43. 若位置有误直接影响客户到店,请在地图中仔细核对,可拖拽地图确保位置正确
  44. </view>
  45. </view>
  46. <view class="cu-form-group">
  47. <view class="title">店铺面积</view>
  48. <input placeholder="请输入店铺面积" v-model="form.storeExtent" name="input"></input>
  49. </view>
  50. <view class="customize">
  51. <view class="title">门头照片</view>
  52. <view class="grid col-3 grid-square flex-sub booder-top">
  53. <view class="bg-img" v-for="(item, index) in headPhotoImg" :key="index" @tap="ViewImage"
  54. :data-url="headPhotoImg[index]">
  55. <image :src="headPhotoImg[index]" mode="aspectFill"></image>
  56. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  57. <text class='cuIcon-close'></text>
  58. </view>
  59. </view>
  60. <view class="solids" @tap="ChooseImage" v-if="headPhotoImg.length <= 4">
  61. <text class='cuIcon-cameraadd'></text>
  62. </view>
  63. </view>
  64. <view class="business-prompt">
  65. 门店照片需包含完整的门店入口和招牌名称,建议现场拍摄门头照;最多可上传5张,支持格式bmp、png、jpeg、jpg,单个图片不超过5MB,建议尺寸在2000*1500px以上
  66. </view>
  67. </view>
  68. </view>
  69. <view class="padding flex flex-direction sub-bottom">
  70. <button class="cu-btn bg-blue round " @click="submit">提交审核</button>
  71. </view>
  72. <w-picker :visible.sync="visible" ref="picker" mode="region" :value="form.locality"
  73. @confirm="onConfirm($event, 'region')"></w-picker>
  74. </view>
  75. </template>
  76. <script>
  77. import regionPicker from "../../components/w-picker/region-picker.vue"
  78. import { USER_INFO } from "@/common/util/constants"
  79. import configService from '../../common/service/config.service'
  80. export default {
  81. components: {
  82. regionPicker,
  83. // aMap
  84. },
  85. data() {
  86. return {
  87. imgList: [],
  88. form: {},
  89. visible: false,
  90. markers: [],
  91. headPhotoImg: [],
  92. imageList: [],
  93. mapIsHidden: false,
  94. }
  95. },
  96. watch: {
  97. visible(val) {
  98. if (!val) {
  99. this.mapIsHidden = 'block'
  100. }
  101. }
  102. },
  103. async onShow() {
  104. this.merchantId = uni.getStorageSync(USER_INFO).merchantId;
  105. let res = await this.$http.get("/merchant/localMerchantInfo/queryAppInfoById?id=" + this.merchantId)
  106. if (res.data.success) {
  107. this.markers = res.data.result.longitude && res.data.result.latitude ?
  108. [
  109. {
  110. longitude: res.data.result.longitude,
  111. latitude: res.data.result.latitude,
  112. iconPath: '../../static/boiaoji.png'
  113. }
  114. ]
  115. : uni.getStorageSync('address') ?
  116. [Object.assign(uni.getStorageSync('address'), { iconPath: '../../static/boiaoji.png' })] : []
  117. res.data.result.headPhoto = res.data.result.headPhoto ? res.data.result.headPhoto.split(',').filter(id => id !== '') : []
  118. this.headPhotoImg = res.data.result.headPhoto ? res.data.result.headPhoto : []
  119. res.data.result.locality=res.data.result.locality?res.data.result.locality:''
  120. this.form = res.data.result
  121. } else {
  122. this.$tip.toast(res.data.message);
  123. }
  124. },
  125. methods: {
  126. submit() {
  127. this.$http.post('/merchant/localMerchantInfo/edit', { ...this.form, headPhoto: this.form.headPhoto.join(',') }).then(res => {
  128. // this.$http.post('/merchant/localMerchantInfo/edit/new', { ...this.form, headPhoto: this.form.headPhoto.join(',') }).then(res => {
  129. if (res.data.success) {
  130. this.$tip.success(res.data.result || '成功')
  131. uni.navigateBack({
  132. delta: 1 // 返回的页面数,默认为1
  133. })
  134. }
  135. else {
  136. this.$tip.error(res.data.message);
  137. }
  138. })
  139. },
  140. uploadAll() {
  141. if (this.imageList.length === 0) {
  142. uni.showToast({ title: '请先选择图片', icon: 'none' });
  143. return;
  144. }
  145. uni.showLoading({ title: '上传中...', mask: true });
  146. const uploadPromises = this.imageList.map((path, index) => {
  147. return new Promise((resolve, reject) => {
  148. uni.uploadFile({
  149. url: configService.apiUrl + '/sys/common/upload',// 替换为实际接口
  150. filePath: path,
  151. formData: {
  152. 'biz': 'temp',
  153. },
  154. name: 'file',
  155. success: (files) => {
  156. resolve(configService.apiUrl + '/' + JSON.parse(files.data).message)
  157. },
  158. fail: reject
  159. });
  160. });
  161. });
  162. Promise.all(uploadPromises)
  163. .then(results => {
  164. uni.hideLoading();
  165. this.imageList = []; // 清空已上传列表
  166. this.headPhotoImg = this.headPhotoImg.concat(results)
  167. this.form.headPhoto = this.form.headPhoto.concat(results)
  168. })
  169. .catch(error => {
  170. uni.hideLoading();
  171. });
  172. },
  173. ChooseImage() {
  174. uni.chooseImage({
  175. count: 5-Number(this.headPhotoImg.length) ,
  176. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  177. sourceType: ['album'], //从相册选择
  178. success: (res) => {
  179. if (res) {
  180. this.imageList = [...this.imageList, ...res.tempFilePaths];
  181. this.uploadAll()
  182. }
  183. }
  184. });
  185. },
  186. onConfirm(e) {
  187. this.mapIsHidden = false
  188. this.form.locality = e.result
  189. this.form.country = e.value[e.value.length - 1]
  190. },
  191. DelImg(e) {
  192. uni.showModal({
  193. title: '提示',
  194. content: '确定要删除?',
  195. cancelText: '取消',
  196. confirmText: '确定',
  197. success: res => {
  198. if (res.confirm) {
  199. this.headPhotoImg.splice(e.currentTarget.dataset.index, 1)
  200. this.form.headPhoto.splice(e.currentTarget.dataset.index, 1)
  201. }
  202. }
  203. })
  204. },
  205. ViewImage(e) {
  206. uni.previewImage({
  207. urls: this.headPhotoImg,
  208. current: e.currentTarget.dataset.url
  209. });
  210. },
  211. handleMarkerTap() {
  212. const queryString = this.form.longitude && this.form.latitude ?
  213. {
  214. longitude: this.form.longitude,
  215. latitude: this.form.latitude,
  216. }
  217. : uni.getStorageSync('address') ?
  218. encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : {}
  219. // const queryString = uni.getStorageSync('address') ? encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : ''
  220. uni.navigateTo({
  221. url: `/pages/login/map?position=${queryString}`
  222. })
  223. },
  224. }
  225. }
  226. </script>
  227. <style scoped lang="scss">
  228. .creat {
  229. background: #F7F8FC;
  230. // flex-direction: column;
  231. // position: fixed;
  232. }
  233. .borderRadiu {
  234. margin: 22upx 26upx;
  235. padding-bottom: 120upx;
  236. background-color: #ffffff;
  237. }
  238. .sub-bottom {
  239. position: fixed;
  240. width: 100%;
  241. bottom: 0;
  242. background: #FFFFFF;
  243. border-top: 1px solid #EEEEEE;
  244. }
  245. .customize {
  246. background-color: #fff;
  247. // border-top: 0.5px solid #eee;
  248. margin: 16upx 18upx;
  249. .title {
  250. font-size: 30upx;
  251. // padding: 10px;
  252. }
  253. .business-img {
  254. height: 218upx;
  255. width: 360upx;
  256. padding: 16upx;
  257. // padding-bottom: 16upx;
  258. background: url('/static/login/yingye2.png');
  259. margin: 16upx auto;
  260. background-size: cover;
  261. image {
  262. width: 100%;
  263. height: 100%;
  264. }
  265. }
  266. .business-prompt {
  267. padding-top: 16upx;
  268. font-size: 20upx;
  269. color: #999999;
  270. }
  271. }
  272. .booder-top {
  273. border-bottom: 1px solid rgb(238, 238, 238);
  274. padding-top: 7px;
  275. }
  276. .picker-style {
  277. .w-picker-cnt .visible {
  278. position: absolute;
  279. z-index: 100000;
  280. }
  281. }
  282. </style>