index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <view class="padding">
  3. <view class="text-white padding bg radius">
  4. <u-form :model="shop" label-position="top">
  5. <u-form-item label="店铺名称 ">
  6. <text class="text-sm" @click="gokefu()"
  7. style="color: red;position: absolute;top: 20rpx;left:135rpx;">*请联系客服修改</text>
  8. <u-input v-model="shop.shopName" placeholder="请输入店铺名称" :disabled="true" />
  9. </u-form-item>
  10. <u-form-item label="开店时间">
  11. <!-- #ifdef MP-WEIXIN -->
  12. <u-input v-model="shop.businessHours" placeholder="请填写" :disabled="true"
  13. @click="startShow = true" />
  14. <!-- #endif -->
  15. <!-- #ifndef MP-WEIXIN -->
  16. <view style="width: 100%;">
  17. <picker mode="time" :value="shop.businessHours" placeholder="请填写" start="00:00" end="23:59"
  18. @change="bindTimeChange">
  19. <view class="uni-input">{{shop.businessHours?shop.businessHours:'请填写'}}</view>
  20. </picker>
  21. </view>
  22. <!-- #endif -->
  23. </u-form-item>
  24. <u-form-item label="闭店时间">
  25. <!-- #ifdef MP-WEIXIN -->
  26. <u-input v-model="shop.lockHours" :disabled="true" placeholder="请填写" @click="endShow = true" />
  27. <!-- #endif -->
  28. <!-- #ifndef MP-WEIXIN -->
  29. <view style="width: 100%;">
  30. <picker mode="time" :value="shop.lockHours" placeholder="请填写" start="00:00" end="23:59"
  31. @change="bindTimeChanges">
  32. <view class="uni-input">{{shop.lockHours?shop.lockHours:'请填写'}}</view>
  33. </picker>
  34. </view>
  35. <!-- #endif -->
  36. </u-form-item>
  37. <u-form-item label="店铺地址">
  38. <text class="text-sm" @click="gokefu()"
  39. style="color: red;position: absolute;top: 20rpx;left:135rpx;">*请联系客服修改</text>
  40. <!-- @click="bindOpen()" -->
  41. <u-input v-model="shop.detailedAddress" :disabled="true" placeholder="请填写" />
  42. </u-form-item>
  43. <u-form-item label="店铺公告">
  44. <textarea v-model="shop.shopNotice" rows="3" placeholder="请填写" maxlength="50" />
  45. </u-form-item>
  46. <u-form-item label="配送费(元)">
  47. <text class="text-sm" @click="gokefu()"
  48. style="color: red;position: absolute;top: 20rpx;left:155rpx;">*请联系客服修改</text>
  49. <u-input v-model="shop.errandMoney" placeholder="请输入配送费" :disabled="true" />
  50. </u-form-item>
  51. <u-form-item label="最低起送金额(元)">
  52. <u-input v-model="shop.minimumDelivery" placeholder="请输入最低起送金额" />
  53. </u-form-item>
  54. <u-form-item label="减免配送费最小订单金额(元)">
  55. <u-input v-model="shop.exemptMinMoney" placeholder="请输入减免配送费最小订单金额" />
  56. </u-form-item>
  57. <u-form-item label="最大配送距离(千米)">
  58. <text class="text-sm" @click="gokefu()"
  59. style="color: red;position: absolute;top: 20rpx;left:285rpx;">*请联系客服修改</text>
  60. <u-input v-model="distributionDistance" placeholder="请输入最大配送距离(单位:km)" :disabled="true" />
  61. </u-form-item>
  62. <u-form-item label="是否上线">
  63. <u-radio-group v-model="shop.putawayFlag">
  64. <u-radio name=0>上班啦</u-radio>
  65. <u-radio name=1>打烊啦</u-radio>
  66. </u-radio-group>
  67. </u-form-item>
  68. <!-- <u-form-item label="是否开启平台配送">
  69. <u-radio-group v-model="shop.autoSendOrder">
  70. <u-radio name=0>开启</u-radio>
  71. <u-radio name=1>关闭</u-radio>
  72. </u-radio-group>
  73. </u-form-item> -->
  74. <u-form-item label="配送方式:">
  75. <text v-if="shop.autoSendOrder==0" style="font-weight: 500;font-size: 20px">平台配送</text>
  76. <text v-if="shop.autoSendOrder==1" style="fontSize:20px">商家自配</text>
  77. </u-form-item>
  78. <u-form-item label="是否开启自动接单">
  79. <u-radio-group v-model="shop.autoAcceptOrder">
  80. <u-radio name=0>开启</u-radio>
  81. <u-radio name=1>关闭</u-radio>
  82. </u-radio-group>
  83. </u-form-item>
  84. <u-form-item label="是否开启预约单功能">
  85. <u-radio-group v-model="shop.reservationOpenFlag">
  86. <u-radio name=1>开启</u-radio>
  87. <u-radio name=0>关闭</u-radio>
  88. </u-radio-group>
  89. </u-form-item>
  90. </u-form>
  91. </view>
  92. <view class="text-white padding bg radius margin-tb">
  93. <u-form :model="shop" label-position="top">
  94. <u-form-item label="打印机">
  95. <text class="text-sm"
  96. style="color: red;position: absolute;top: 25rpx;left: 105rpx;">*一个打印机只能绑定一个商家</text>
  97. <u-radio-group v-model="shop.facility">
  98. <!-- <u-radio name=0>上线</u-radio> -->
  99. <u-radio name=1>飞鹅</u-radio>
  100. </u-radio-group>
  101. </u-form-item>
  102. <u-form-item label="设备sn编码">
  103. <u-input v-model="shop.snCode" placeholder="请输入设备sn编码" />
  104. </u-form-item>
  105. <u-form-item label="设备key秘钥">
  106. <u-input v-model="shop.value" placeholder="请输入设备key秘钥" />
  107. </u-form-item>
  108. </u-form>
  109. </view>
  110. <view class="text-white padding bg radius margin-tb">
  111. <view>
  112. <view class="text-lg margin-top-sm text-black">店铺logo</view>
  113. <view class="flex" style="overflow: hidden;flex-wrap: wrap;">
  114. <view v-if="shop.shopCover.length">
  115. <view class="margin-top flex margin-right-sm flex-wrap">
  116. <view class="flex"
  117. style="width: 200rpx;height: 200rpx;margin-right: 2rpx;position: relative;">
  118. <image :src="shop.shopCover" style="width: 100%;height: 100%;"></image>
  119. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  120. @click="removeImgs()">
  121. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. <view class="margin-top" @click="addImage()" v-if="shop.shopCover.length<=0">
  127. <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
  128. class="flex justify-center align-center">
  129. <view>
  130. <view class="text-center">
  131. <image src="../static/addimg.png" style="width: 65rpx;height: 55rpx;">
  132. </image>
  133. </view>
  134. <view class="text-center text-black">添加图片</view>
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. <view>
  141. <view class="text-lg margin-top-sm text-black">店铺活动广告图(可多张)</view>
  142. <view class="flex" style="overflow: hidden;flex-wrap: wrap;">
  143. <view v-if="shopBanner.length">
  144. <view class="margin-top flex margin-right-sm flex-wrap">
  145. <view class="flex"
  146. style="width: 200rpx;height: 200rpx;margin-right: 2rpx;position: relative;"
  147. v-for="(image,index) in shopBanner" :key="index">
  148. <image :src="image" style="width: 100%;height: 100%;"></image>
  149. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  150. @click="removeImg(index)">
  151. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. <view class="margin-top" @click="addImages(2)" v-if="shopBanner.length<6">
  157. <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
  158. class="flex justify-center align-center">
  159. <view>
  160. <view class="text-center">
  161. <image src="../static/addimg.png" style="width: 65rpx;height: 55rpx;">
  162. </image>
  163. </view>
  164. <view class="text-center text-black">添加图片</view>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. </view>
  171. <!-- 时间筛选 -->
  172. <u-picker v-model="startShow" mode="time" :params="params" @confirm="getStarttime()"></u-picker>
  173. <u-picker v-model="endShow" mode="time" :params="paramss" @confirm="getEndtime()"></u-picker>
  174. <u-button @click="submit" class="margin-top" :custom-style="customStyle" shape="square" :hair-line="false">提交
  175. </u-button>
  176. </view>
  177. </template>
  178. <script>
  179. import configdata from '@/common/config.js';
  180. export default {
  181. data() {
  182. return {
  183. shop: {
  184. shopName: '',
  185. businessHours: '',
  186. lockHours: '',
  187. detailedAddress: '',
  188. shopNotice: '',
  189. putawayFlag: 1,
  190. latitude: '',
  191. longitude: '',
  192. shopCover: '',
  193. //详情图
  194. shopBanner: [],
  195. shopId: uni.getStorageSync('shopId'),
  196. errandMoney: '',
  197. minimumDelivery: '',
  198. exemptMinMoney: '',
  199. distributionDistance: '',
  200. autoSendOrder: 1,
  201. autoAcceptOrder: 1,
  202. reservationOpenFlag:0,
  203. facility: 1,
  204. snCode: '',
  205. value: ''
  206. },
  207. // facility:1,
  208. startShow: false,
  209. endShow: false,
  210. customStyle: {
  211. backgroundColor: '#FFCC00',
  212. color: '#000000',
  213. border: 0
  214. },
  215. status: 1,
  216. customStyle1: {
  217. color: '#000000',
  218. position: "fixed",
  219. bottom: "15rpx",
  220. left: "0rpx",
  221. right: "0rpx",
  222. margin: "0rpx 50rpx",
  223. backgroundColor: '#FFCC00',
  224. },
  225. selarr: [],
  226. show: false,
  227. //详情图
  228. shopBanner: [],
  229. params: {
  230. year: false,
  231. month: false,
  232. day: false,
  233. hour: true,
  234. minute: true,
  235. second: false
  236. },
  237. paramss: {
  238. year: false,
  239. month: false,
  240. day: false,
  241. hour: true,
  242. minute: true,
  243. second: false
  244. },
  245. shopId: '',
  246. page: 1,
  247. limit: 100,
  248. list: [{
  249. name: '上线',
  250. disabled: false
  251. },
  252. {
  253. name: '下线',
  254. disabled: false
  255. }
  256. ],
  257. distributionDistance: ''
  258. }
  259. },
  260. onLoad(option) {
  261. uni.showLoading({
  262. title: '加载中......',
  263. mask: true, // 是否显示透明蒙层,防止触摸穿透
  264. icon: 'loading'
  265. })
  266. // console.log(option, '店铺id')
  267. this.shopId = option.shopId
  268. this.getShopList()
  269. },
  270. onShow() {
  271. },
  272. methods: {
  273. gokefu() {
  274. uni.navigateTo({
  275. url: '/pages/my/chat'
  276. })
  277. },
  278. bindTimeChange: function(e) {
  279. console.log(e)
  280. this.shop.businessHours = e.target.value
  281. },
  282. bindTimeChanges: function(e) {
  283. console.log(e)
  284. this.shop.lockHours = e.target.value
  285. },
  286. //上线 下线
  287. radioChange(e) {
  288. // console.log(e)
  289. },
  290. // 店铺信息
  291. getShopList() {
  292. let data = {
  293. shopId: this.$queue.getData('shopId')
  294. }
  295. this.$Request.getA("/app/shop/selectShopMessage", data).then(res => {
  296. if (res.code == 0) {
  297. uni.hideLoading()
  298. this.shop.shopName = res.data.shopName
  299. this.shop.detailedAddress = res.data.detailedAddress
  300. this.shop.businessHours = res.data.businessHours
  301. this.shop.lockHours = res.data.lockHours
  302. this.shop.shopCover = res.data.shopCover
  303. this.shop.shopNotice = res.data.shopNotice
  304. this.shop.putawayFlag = res.data.putawayFlag ? res.data.putawayFlag : 0
  305. this.shop.errandMoney = res.data.errandMoney
  306. this.shop.minimumDelivery = res.data.minimumDelivery
  307. this.shop.exemptMinMoney = res.data.exemptMinMoney
  308. if (res.data.shopBanner) {
  309. this.shop.shopBanner = res.data.shopBanner.split(',')
  310. this.shopBanner = res.data.shopBanner.split(',')
  311. }
  312. this.shop.distributionDistance = res.data.distributionDistance
  313. this.distributionDistance = res.data.distributionDistance / 1000
  314. this.shop.autoSendOrder = res.data.autoSendOrder ? res.data.autoSendOrder : 0;
  315. this.shop.autoAcceptOrder = res.data.autoAcceptOrder ? res.data.autoAcceptOrder : 0;
  316. this.shop.reservationOpenFlag=res.data.reservationOpenFlag ? res.data.reservationOpenFlag : 0;
  317. this.shop.snCode = res.data.snCode //设备sn编码
  318. this.shop.value = res.data.value //设备key秘钥
  319. // this.shop.facility = res.data.facility // 设备类型
  320. }
  321. });
  322. },
  323. getStarttime(e) {
  324. console.log(e, '1111111111')
  325. this.shop.businessHours = e.hour + ':' + e.minute
  326. },
  327. getEndtime(e) {
  328. console.log(e)
  329. this.shop.lockHours = e.hour + ':' + e.minute
  330. },
  331. // 详情图删除
  332. removeImg(index) {
  333. this.shopBanner.splice(index, 1)
  334. },
  335. // 店铺logo删除
  336. removeImgs() {
  337. this.shop.shopCover = ''
  338. },
  339. bindOpen(e) {
  340. console.log(e)
  341. let that = this
  342. uni.chooseLocation({
  343. success: function(res) {
  344. console.log('位置名称:' + res.name);
  345. console.log('详细地址:' + res.address);
  346. console.log('纬度:' + res.latitude);
  347. console.log('经度:' + res.longitude);
  348. that.shop.detailedAddress = res.address
  349. that.shop.shopLat = res.latitude
  350. that.shop.shopLng = res.longitude
  351. }
  352. });
  353. },
  354. // 图片上传
  355. addImages(e) {
  356. let that = this
  357. uni.chooseImage({
  358. count: 6,
  359. sourceType: ['album', 'camera'],
  360. success: res => {
  361. for (let i = 0; i < res.tempFilePaths.length; i++) {
  362. that.$queue.showLoading("上传中...");
  363. uni.uploadFile({ // 上传接口
  364. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  365. filePath: res.tempFilePaths[i],
  366. name: 'file',
  367. success: (uploadFileRes) => {
  368. if (that.shopBanner.length < 6) {
  369. that.shopBanner.push(JSON.parse(uploadFileRes.data).data)
  370. }
  371. console.log(that.shopBanner)
  372. uni.hideLoading();
  373. }
  374. });
  375. }
  376. }
  377. })
  378. },
  379. // 图片上传
  380. addImage() {
  381. let that = this
  382. uni.chooseImage({
  383. count: 1,
  384. sourceType: ['album', 'camera'],
  385. success: res => {
  386. for (let i = 0; i < res.tempFilePaths.length; i++) {
  387. that.$queue.showLoading("上传中...");
  388. uni.uploadFile({ // 上传接口
  389. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  390. // url: 'https://jiazheng.xianmxkj.com/sqx_fast/alioss/upload',
  391. filePath: res.tempFilePaths[i],
  392. name: 'file',
  393. success: (uploadFileRes) => {
  394. that.shop.shopCover = JSON.parse(uploadFileRes.data).data
  395. uni.hideLoading();
  396. }
  397. });
  398. }
  399. }
  400. })
  401. },
  402. config: function(name) {
  403. var info = null;
  404. if (name) {
  405. var name2 = name.split("."); //字符分割
  406. if (name2.length > 1) {
  407. info = configdata[name2[0]][name2[1]] || null;
  408. } else {
  409. info = configdata[name] || null;
  410. }
  411. if (info == null) {
  412. let web_config = cache.get("web_config");
  413. if (web_config) {
  414. if (name2.length > 1) {
  415. info = web_config[name2[0]][name2[1]] || null;
  416. } else {
  417. info = web_config[name] || null;
  418. }
  419. }
  420. }
  421. }
  422. return info;
  423. },
  424. // 发布
  425. submit() {
  426. console.log(this.distributionDistance)
  427. this.shop.shopBanner = this.shopBanner
  428. this.shop.shopBanner = this.shop.shopBanner.toString();
  429. this.shop.distributionDistance = this.distributionDistance * 1000
  430. // this.shop.distributionDistance = this.shop.distributionDistance * 1000
  431. // if (!this.shop.shopName) {
  432. // uni.showToast({
  433. // title: '请填写店铺名称',
  434. // icon: 'none',
  435. // duration: 1000
  436. // })
  437. // return
  438. // }
  439. if (!this.shop.businessHours) {
  440. uni.showToast({
  441. title: '请填写开店时间',
  442. icon: 'none',
  443. duration: 1000
  444. })
  445. return
  446. }
  447. if (!this.shop.lockHours) {
  448. uni.showToast({
  449. title: '请填写闭店时间',
  450. icon: 'none',
  451. duration: 1000
  452. })
  453. return
  454. }
  455. if (this.shop.businessHours>=this.shop.lockHours) {
  456. uni.showToast({
  457. title: '开店时间不能大于闭店时间',
  458. icon: 'none',
  459. duration: 1000
  460. })
  461. return
  462. }
  463. // if (!this.shop.detailedAddress) {
  464. // uni.showToast({
  465. // title: '请填写店铺地址',
  466. // icon: 'none',
  467. // duration: 1000
  468. // })
  469. // return
  470. // }
  471. if (!this.shop.shopNotice) {
  472. uni.showToast({
  473. title: '请填写店铺公告',
  474. icon: 'none',
  475. duration: 1000
  476. })
  477. return
  478. }
  479. // if (!this.shop.snCode) {
  480. // uni.showToast({
  481. // title: '请填写设备sn编码',
  482. // icon: 'none',
  483. // duration: 1000
  484. // })
  485. // return
  486. // }
  487. // if (!this.shop.value) {
  488. // uni.showToast({
  489. // title: '请填写设备key秘钥',
  490. // icon: 'none',
  491. // duration: 1000
  492. // })
  493. // return
  494. // }
  495. if (!this.shop.shopCover) {
  496. uni.showToast({
  497. title: '请上传店铺logo',
  498. icon: 'none',
  499. duration: 1000
  500. })
  501. return
  502. }
  503. if (!this.shop.shopBanner) {
  504. uni.showToast({
  505. title: '请上传店铺轮播图',
  506. icon: 'none',
  507. duration: 1000
  508. })
  509. return
  510. }
  511. // console.log('this.shop.putawayFlag',this.shop.putawayFlag)
  512. // return
  513. if (this.shop.putawayFlag == 0) {
  514. // if (!this.shop.errandMoney) {
  515. // uni.showToast({
  516. // title: '请填写配送费',
  517. // icon: 'none',
  518. // duration: 1000
  519. // })
  520. // return
  521. // }
  522. if (!this.shop.minimumDelivery) {
  523. this.shop.minimumDelivery = 0;
  524. // uni.showToast({
  525. // title: '请填写最低起送金额',
  526. // icon: 'none',
  527. // duration: 1000
  528. // })
  529. // return
  530. }
  531. if (!this.shop.exemptMinMoney) {
  532. this.shop.exemptMinMoney = 0;
  533. // uni.showToast({
  534. // title: '请填写减免配送费最小订单金额',
  535. // icon: 'none',
  536. // duration: 1000
  537. // })
  538. // return
  539. }
  540. console.log(this.shop.distributionDistance)
  541. // if (!this.shop.distributionDistance) {
  542. // uni.showToast({
  543. // title: '请填写最大配送距离',
  544. // icon: 'none',
  545. // duration: 1000
  546. // })
  547. // return
  548. // }
  549. }
  550. console.log(this.shop)
  551. // uni.setStorageSync('shopId', this.shop.shopId)
  552. this.$Request.postJsonA("/app/shop/updateShopMessage", this.shop).then(res => {
  553. if (res.code == 0) {
  554. uni.showToast({
  555. title: '修改成功',
  556. icon: 'none'
  557. })
  558. setTimeout(function() {
  559. uni.navigateBack()
  560. // uni.navigateTo({
  561. // url: '/my/publish/index'
  562. // })
  563. }, 1000)
  564. } else {
  565. uni.showModal({
  566. title: '提示',
  567. content: res.msg,
  568. success: function (res) {
  569. if (res.confirm) {
  570. } else if (res.cancel) {
  571. }
  572. }
  573. });
  574. }
  575. });
  576. },
  577. }
  578. }
  579. </script>
  580. <style>
  581. page {
  582. background-color: #F5F5F5;
  583. }
  584. .bg {
  585. background-color: #FFFFFF;
  586. }
  587. .tabBox {
  588. border: 1rpx solid #999999;
  589. padding: 15rpx 20rpx;
  590. border-radius: 15rpx;
  591. font-size: 28rpx;
  592. }
  593. .btnnum {
  594. color: #005DFF;
  595. border: 1rpx solid #005DFF;
  596. }
  597. </style>