businessInfor.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view>
  3. <view class="top"></view>
  4. <view class="head">
  5. <view class="handle">
  6. <view class="head_left">
  7. <span class="cuIcon-back" @click="back"></span>
  8. </view>
  9. <span class="center">经营信息</span>
  10. <view class="head_right"></view>
  11. </view>
  12. </view>
  13. <!-- <status v-if="form && form.videoStatus !== null" :status="form.videoStatus" :updateTime="form.videoUpdateTime"
  14. :remark="form.videoRemark" style="z-index: 0;"></status> -->
  15. <view class="tab-top" :style="form && form.videoStatus == null ? 'margin-top: 14upx;' : ''">
  16. <view class="borderRadiu">
  17. <view class=" cu-form-group margin-top1 justify-between">
  18. <view class="content ">
  19. <text class="text-bold">营业时间</text>
  20. <i class="text-bg "></i>
  21. </view>
  22. </view>
  23. <view class="customize">
  24. <view class="business-hours" v-for="(val,index) in businessData" :key="val.id" @click="hoursChange(index)">
  25. <view class="flex justify-between">
  26. <text>{{ val.period }}</text>
  27. <view @click.stop="delClick(val)" class="del-style">删除</view>
  28. </view>
  29. <view class="business-date" v-if="val.timeType==1">
  30. <text>24小时营业</text>
  31. </view>
  32. <view class="business-date" v-else>
  33. <text>{{ val.middleTime }}</text>
  34. <text>{{ val.beginTime }}</text>
  35. <text>{{ val.endTime }}</text>
  36. </view>
  37. </view>
  38. <image v-if="businessData.length!==2" style="width: 100%;height:137upx" src="/static/store/yingyeshijian.png"
  39. mode="" @click="hoursChange()"> </image>
  40. </view>
  41. </view>
  42. <view class="borderRadiu">
  43. <view class=" cu-form-group margin-top1 justify-between">
  44. <view class="content ">
  45. <text class="text-bold">经营信息</text>
  46. <i class="text-bg "></i>
  47. </view>
  48. </view>
  49. <!-- <view class="data-item">
  50. <span>店铺面积</span>
  51. <input v-model="form.storeExtent" type="Number"
  52. style="width: 100px;height: 49rpx;background-color: #f7f8fc;margin: 0px 8rpx 0px 20rpx;"></input>㎡
  53. </view> -->
  54. <view class="data-item">
  55. <span>开业时间</span>
  56. <view class="" style="flex: 1;display: flex;justify-content: space-between;padding-left: 20rpx;"
  57. @click="show = true">
  58. <span v-if="date">{{date}}</span>
  59. <span v-else style="color: #999999;">去设置</span>
  60. <u-icon name="arrow-right"></u-icon>
  61. </view>
  62. </view>
  63. <!-- <view class="customize">
  64. <view class="title">地理位置</view>
  65. <view class=" booder-top" style="padding-bottom: 16upx" :style="{ display: mapIsHidden }"
  66. @click="selectAddress">
  67. <tdmap
  68. :allowSelection="false"
  69. :showCoordinates="false"
  70. :key="mapKey"
  71. ></tdmap>
  72. </view>
  73. <view class="business-prompt">
  74. 若位置有误直接影响客户到店,请在地图中仔细核对,可拖拽地图确保位置正确
  75. </view>
  76. </view> -->
  77. </view>
  78. </view>
  79. <view class="padding flex sub-bottom">
  80. <button class="cu-btn round line-gray shadow" @click="$Router.push({ name: 'settings' })">取消</button>
  81. <button style="margin-left: 12upx;width:77%" class="cu-btn bg-blue round " @click.native="sumbit">提交</button>
  82. </view>
  83. <u-picker v-model="show" mode="time" @confirm="selectTime" style="z-index: 999 !important;"></u-picker>
  84. </view>
  85. </template>
  86. <script>
  87. import configService from "../../common/service/config.service";
  88. import { USER_INFO } from "@/common/util/constants";
  89. import status from "./components/status.vue";
  90. import tdmap from "./tdtuMap.vue"
  91. export default {
  92. components: { status, tdmap },
  93. data() {
  94. return {
  95. video: "",
  96. photoList: [],
  97. form: {},
  98. src: "",
  99. businessData: [],
  100. show: false,
  101. date: "",
  102. latitude: 37.860372,
  103. longitude: 112.588154,
  104. marker: [{
  105. latitude: "",
  106. longitude: "",
  107. iconPath: "/static/boiaoji.png",
  108. width: 30,
  109. height: 30,
  110. label: {
  111. content: "",
  112. color: "#000000",
  113. fontSize: 14,
  114. bgColor: "#FFFFFF",
  115. borderColor: "#CCCCCC",
  116. },
  117. }],
  118. mapIsHidden: 'block', // 修复:初始为block,确保地图容器显示
  119. mapKey: 1,
  120. // 修复:初始化savedLocation为合法对象,避免undefined
  121. savedLocation: { lng: 112.55, lat: 37.87 }
  122. };
  123. },
  124. onLoad(data) {
  125. if (data.params) {
  126. let obj = JSON.parse(decodeURIComponent(data.params));
  127. this.video = obj.video ? obj.video : '';
  128. obj.photo = obj.photo ? obj.photo.split(',').filter(id => id !== '') : [];
  129. this.form = obj;
  130. this.date = this.form.openingTime;
  131. // 修复:从obj中赋值坐标,确保数字类型
  132. if (obj.longitude && obj.latitude) {
  133. this.savedLocation = {
  134. lng: Number(obj.longitude) || 112.55,
  135. lat: Number(obj.latitude) || 37.87,
  136. address: obj.address || '位置'
  137. };
  138. uni.setStorage('mapMarkData',this.savedLocation)
  139. this.latitude = obj.latitude;
  140. this.longitude = obj.longitude;
  141. }
  142. }
  143. },
  144. onShow() {
  145. this.$http
  146. .get("/merchant/localMerchantTime/list?merchantId=" + uni.getStorageSync(USER_INFO).merchantId)
  147. .then((res) => {
  148. if (res.data.success) {
  149. this.businessData = res.data.result;
  150. } else {
  151. uni.showToast({ icon:'none', title:res.data.message });
  152. }
  153. });
  154. // 修复:安全获取存储的地址,避免da为undefined
  155. let da = uni.getStorageSync("address") || {};
  156. // console.log(da)
  157. // 核心:确保lng/lat是合法数字,兜底默认值
  158. const lng = Number(da.lng) || 112.55;
  159. const lat = Number(da.lat) || 37.87;
  160. // 更新savedLocation(触发子组件props更新)
  161. this.savedLocation = {
  162. lng: lng,
  163. lat: lat,
  164. address: da.address || '位置'
  165. };
  166. uni.setStorageSync('mapMarkData',this.savedLocation)
  167. this.latitude = lat;
  168. this.longitude = lng;
  169. // 优化:仅当坐标变化时更新mapKey,避免频繁刷新
  170. if (lng !== 112.55 || lat !== 37.87) {
  171. this.mapKey += 1;
  172. }
  173. },
  174. methods: {
  175. back() {
  176. uni.navigateBack();
  177. },
  178. selectAddress() {
  179. uni.navigateTo({ url: '/pages/store/selectTdMap?url=' + '/pages/store/businessInfor' });
  180. },
  181. handleMarkerTap() {
  182. const queryString = uni.getStorageSync("address") ?
  183. encodeURIComponent(JSON.stringify(uni.getStorageSync("address"))) : "";
  184. uni.navigateTo({ url: `/pages/login/map?position=${queryString}` });
  185. },
  186. selectTime(e) {
  187. this.date = e.year + "-" + e.month + "-" + e.day;
  188. },
  189. hoursChange(index) {
  190. const queryString = encodeURIComponent(JSON.stringify({ index, arr: this.businessData }));
  191. uni.navigateTo({ url: `/pages/store/addHours?params=${queryString}` });
  192. },
  193. delectVideo() {
  194. uni.showModal({
  195. title: "提示",
  196. content: "是否要删除此视频",
  197. success: (res) => {
  198. if (res.confirm) this.video = "";
  199. },
  200. });
  201. },
  202. DelImg(e) {
  203. uni.showModal({
  204. title: "提示",
  205. content: "确定要删除?",
  206. cancelText: "取消",
  207. confirmText: "确定",
  208. success: (res) => {
  209. if (res.confirm) this.form.photo.splice(e.currentTarget.dataset.index, 1);
  210. },
  211. });
  212. },
  213. ChooseImage() {
  214. uni.chooseImage({
  215. sizeType: ["original", "compressed"],
  216. sourceType: ["album"],
  217. success: (res) => {
  218. uni.uploadFile({
  219. url: configService.apiUrl + "/sys/common/upload",
  220. filePath: res.tempFilePaths[0],
  221. name: "file",
  222. formData: { biz: "temp" },
  223. success: (files) => {
  224. let data = JSON.parse(files.data);
  225. if (data.success) {
  226. const imgUrl = configService.apiUrl + "/" + data.message;
  227. this.form.photo = this.form.photo.length ? [...this.form.photo, imgUrl] : [imgUrl];
  228. }
  229. },
  230. });
  231. },
  232. });
  233. },
  234. ViewImage(e) {
  235. uni.previewImage({ urls: this.form.photo, current: e.currentTarget.dataset.url });
  236. },
  237. chooseVideo() {
  238. uni.chooseVideo({
  239. sourceType: ["camera", "album"],
  240. success: (res) => { this.video = res.tempFilePath; },
  241. });
  242. },
  243. sumbit() {
  244. if (!this.savedLocation.lng || !this.savedLocation.lat) {
  245. uni.showToast({ title: "请先获取位置信息", icon: "none" });
  246. return;
  247. }
  248. let data = {
  249. id: uni.getStorageSync(USER_INFO).merchantId,
  250. storeExtent: this.form.storeExtent,
  251. longitude: this.savedLocation.lng,
  252. latitude: this.savedLocation.lat,
  253. openingTime: this.date,
  254. };
  255. this.$http
  256. .post("/merchant/localMerchantInfo/shopEdit", { ...data })
  257. .then((res) => {
  258. if (res.data.success) {
  259. uni.showToast({ title: '提交成功', icon: 'none' });
  260. uni.navigateTo({ url: '/pages/store/settings' });
  261. } else {
  262. uni.showToast({ title: res.data.message, icon: 'none' });
  263. }
  264. });
  265. },
  266. delClick(val) {
  267. this.$http
  268. .delete("/merchant/localMerchantTime/delete?id=" + val.id)
  269. .then((res) => {
  270. if (res.data.success) {
  271. uni.showToast({ title: '提交成功', icon: 'none' });
  272. this.$http
  273. .get("/merchant/localMerchantTime/list?merchantId=" + uni.getStorageSync(USER_INFO).merchantId)
  274. .then((res) => {
  275. if (res.data.success) this.businessData = res.data.result;
  276. else uni.showToast({ icon:'none', title:res.data.message });
  277. });
  278. } else {
  279. uni.showToast({ icon:'none', title:res.data.message });
  280. }
  281. });
  282. },
  283. },
  284. };
  285. </script>
  286. <style scoped lang="scss">
  287. page { background: #f8f8fa; }
  288. .top {
  289. width: 100%;
  290. height: var(--status-bar-height);
  291. background: linear-gradient(87deg, #FFFFFF 0%, #A3CDFF 100%), linear-gradient(360deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
  292. }
  293. .head {
  294. width: 100%;
  295. background: #ffffff;
  296. .handle {
  297. height: 112rpx;
  298. display: flex;
  299. justify-content: space-between;
  300. align-items: center;
  301. padding: 0px 24rpx;
  302. position: relative;
  303. .head_left { font-size: 40rpx; }
  304. .center {
  305. position: absolute;
  306. left: 50%;
  307. top: 50%;
  308. transform: translate(-50%, -50%);
  309. font-size: 30rpx;
  310. font-weight: 600;
  311. }
  312. .head_right {
  313. display: flex;
  314. justify-content: space-between;
  315. align-items: center;
  316. span {
  317. width: 40rpx;
  318. height: 40rpx;
  319. display: flex;
  320. font-size: 28rpx;
  321. justify-content: center;
  322. align-items: center;
  323. }
  324. }
  325. }
  326. }
  327. .tab-top { padding: 0 26upx; padding-bottom: 130upx; }
  328. .progress-status {
  329. position: fixed;
  330. width: 100%;
  331. z-index: 9999;
  332. background: #ffffff;
  333. .status {
  334. font-size: 38upx;
  335. color: #f6863e;
  336. font-weight: 500;
  337. margin-bottom: 10upx;
  338. text { margin-left: 5upx; }
  339. image { vertical-align: text-top; width: 42upx; height: 42upx; }
  340. }
  341. }
  342. .borderRadiu {
  343. border-radius: 8px;
  344. background-color: #ffffff;
  345. .customize {
  346. padding: 0 18upx 18upx;
  347. .title { padding: 18upx 0; font-size: 28upx; }
  348. }
  349. .business-img {
  350. height: 210upx;
  351. width: 310upx;
  352. background-size: cover;
  353. image { width: 100%; height: 100%; }
  354. }
  355. .business-prompt {
  356. padding-top: 16upx;
  357. font-size: 20upx;
  358. color: #999999;
  359. }
  360. }
  361. .booder-top {
  362. border-bottom: 1px solid rgb(238, 238, 238);
  363. padding-bottom: 7px;
  364. .uploader_video { width: 310upx; height: 210upx; }
  365. .video-container { max-width: 100%; max-height: 100%; }
  366. }
  367. .sub-bottom {
  368. position: fixed;
  369. width: 100%;
  370. bottom: 0;
  371. background: #ffffff;
  372. border-top: 1px solid #eeeeee;
  373. }
  374. .uni-uploader__img { width: 200upx; height: 200upx; }
  375. .uni-uploader__file, .uploader_video {
  376. position: relative;
  377. z-index: 1;
  378. width: 200upx;
  379. height: 200upx;
  380. }
  381. .icon-cuo {
  382. position: absolute;
  383. right: 0;
  384. top: 5upx;
  385. color: #ffffff;
  386. z-index: 999;
  387. border-top-right-radius: 20upx;
  388. border-bottom-left-radius: 20upx;
  389. }
  390. .business-hours {
  391. padding: 27upx 22upx;
  392. background: #f7f8fc;
  393. font-size: 28upx;
  394. border-radius: 8px 8px 8px 8px;
  395. margin-bottom: 18upx;
  396. }
  397. .del-style {
  398. width: 116upx;
  399. background: #ffffff;
  400. border-radius: 4px 4px 4px 4px;
  401. border: 1px solid #eeeeee;
  402. color: #333333;
  403. font-size: 26upx;
  404. line-height: 50upx;
  405. text-align: center;
  406. }
  407. .business-date { text { margin-right: 22upx; } }
  408. .data-item {
  409. display: flex;
  410. align-items: center;
  411. border-bottom: 1px solid #eeeeee;
  412. padding-left: 16rpx;
  413. height: 80rpx;
  414. align-items: center;
  415. .custom-input { width: 160rpx; }
  416. }
  417. </style>