editStore.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. if (res.data.success) {
  129. this.$tip.success(res.data.result || '成功')
  130. uni.navigateBack({
  131. delta: 1 // 返回的页面数,默认为1
  132. })
  133. }
  134. else {
  135. this.$tip.error(res.data.message);
  136. }
  137. })
  138. },
  139. uploadAll() {
  140. if (this.imageList.length === 0) {
  141. uni.showToast({ title: '请先选择图片', icon: 'none' });
  142. return;
  143. }
  144. uni.showLoading({ title: '上传中...', mask: true });
  145. const uploadPromises = this.imageList.map((path, index) => {
  146. return new Promise((resolve, reject) => {
  147. uni.uploadFile({
  148. url: configService.apiUrl + '/sys/common/upload',// 替换为实际接口
  149. filePath: path,
  150. formData: {
  151. 'biz': 'temp',
  152. },
  153. name: 'file',
  154. success: (files) => {
  155. resolve(configService.apiUrl + '/' + JSON.parse(files.data).message)
  156. },
  157. fail: reject
  158. });
  159. });
  160. });
  161. Promise.all(uploadPromises)
  162. .then(results => {
  163. uni.hideLoading();
  164. this.imageList = []; // 清空已上传列表
  165. this.headPhotoImg = this.headPhotoImg.concat(results)
  166. this.form.headPhoto = this.form.headPhoto.concat(results)
  167. })
  168. .catch(error => {
  169. uni.hideLoading();
  170. });
  171. },
  172. ChooseImage() {
  173. uni.chooseImage({
  174. count: 5-Number(this.headPhotoImg.length) ,
  175. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  176. sourceType: ['album'], //从相册选择
  177. success: (res) => {
  178. if (res) {
  179. this.imageList = [...this.imageList, ...res.tempFilePaths];
  180. this.uploadAll()
  181. }
  182. }
  183. });
  184. },
  185. onConfirm(e) {
  186. this.mapIsHidden = false
  187. this.form.locality = e.result
  188. this.form.country = e.value[e.value.length - 1]
  189. },
  190. DelImg(e) {
  191. uni.showModal({
  192. title: '提示',
  193. content: '确定要删除?',
  194. cancelText: '取消',
  195. confirmText: '确定',
  196. success: res => {
  197. if (res.confirm) {
  198. this.headPhotoImg.splice(e.currentTarget.dataset.index, 1)
  199. this.form.headPhoto.splice(e.currentTarget.dataset.index, 1)
  200. }
  201. }
  202. })
  203. },
  204. ViewImage(e) {
  205. uni.previewImage({
  206. urls: this.headPhotoImg,
  207. current: e.currentTarget.dataset.url
  208. });
  209. },
  210. handleMarkerTap() {
  211. const queryString = this.form.longitude && this.form.latitude ?
  212. {
  213. longitude: this.form.longitude,
  214. latitude: this.form.latitude,
  215. }
  216. : uni.getStorageSync('address') ?
  217. encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : {}
  218. // const queryString = uni.getStorageSync('address') ? encodeURIComponent(JSON.stringify(uni.getStorageSync('address'))) : ''
  219. uni.navigateTo({
  220. url: `/pages/login/map?position=${queryString}`
  221. })
  222. },
  223. }
  224. }
  225. </script>
  226. <style scoped lang="scss">
  227. .creat {
  228. background: #F7F8FC;
  229. // flex-direction: column;
  230. // position: fixed;
  231. }
  232. .borderRadiu {
  233. margin: 22upx 26upx;
  234. padding-bottom: 120upx;
  235. background-color: #ffffff;
  236. }
  237. .sub-bottom {
  238. position: fixed;
  239. width: 100%;
  240. bottom: 0;
  241. background: #FFFFFF;
  242. border-top: 1px solid #EEEEEE;
  243. }
  244. .customize {
  245. background-color: #fff;
  246. // border-top: 0.5px solid #eee;
  247. margin: 16upx 18upx;
  248. .title {
  249. font-size: 30upx;
  250. // padding: 10px;
  251. }
  252. .business-img {
  253. height: 218upx;
  254. width: 360upx;
  255. padding: 16upx;
  256. // padding-bottom: 16upx;
  257. background: url('/static/login/yingye2.png');
  258. margin: 16upx auto;
  259. background-size: cover;
  260. image {
  261. width: 100%;
  262. height: 100%;
  263. }
  264. }
  265. .business-prompt {
  266. padding-top: 16upx;
  267. font-size: 20upx;
  268. color: #999999;
  269. }
  270. }
  271. .booder-top {
  272. border-bottom: 1px solid rgb(238, 238, 238);
  273. padding-top: 7px;
  274. }
  275. .picker-style {
  276. .w-picker-cnt .visible {
  277. position: absolute;
  278. z-index: 100000;
  279. }
  280. }
  281. </style>