index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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. icon: 'loading'
  264. })
  265. // console.log(option, '店铺id')
  266. this.shopId = option.shopId
  267. this.getShopList()
  268. },
  269. onShow() {
  270. },
  271. methods: {
  272. gokefu() {
  273. uni.navigateTo({
  274. url: '/pages/my/chat'
  275. })
  276. },
  277. bindTimeChange: function(e) {
  278. console.log(e)
  279. this.shop.businessHours = e.target.value
  280. },
  281. bindTimeChanges: function(e) {
  282. console.log(e)
  283. this.shop.lockHours = e.target.value
  284. },
  285. //上线 下线
  286. radioChange(e) {
  287. // console.log(e)
  288. },
  289. // 店铺信息
  290. getShopList() {
  291. let data = {
  292. shopId: this.$queue.getData('shopId')
  293. }
  294. this.$Request.getA("/app/shop/selectShopMessage", data).then(res => {
  295. if (res.code == 0) {
  296. uni.hideLoading()
  297. this.shop.shopName = res.data.shopName
  298. this.shop.detailedAddress = res.data.detailedAddress
  299. this.shop.businessHours = res.data.businessHours
  300. this.shop.lockHours = res.data.lockHours
  301. this.shop.shopCover = res.data.shopCover
  302. this.shop.shopNotice = res.data.shopNotice
  303. this.shop.putawayFlag = res.data.putawayFlag ? res.data.putawayFlag : 0
  304. this.shop.errandMoney = res.data.errandMoney
  305. this.shop.minimumDelivery = res.data.minimumDelivery
  306. this.shop.exemptMinMoney = res.data.exemptMinMoney
  307. if (res.data.shopBanner) {
  308. this.shop.shopBanner = res.data.shopBanner.split(',')
  309. this.shopBanner = res.data.shopBanner.split(',')
  310. }
  311. this.shop.distributionDistance = res.data.distributionDistance
  312. this.distributionDistance = res.data.distributionDistance / 1000
  313. this.shop.autoSendOrder = res.data.autoSendOrder ? res.data.autoSendOrder : 0;
  314. this.shop.autoAcceptOrder = res.data.autoAcceptOrder ? res.data.autoAcceptOrder : 0;
  315. this.shop.reservationOpenFlag=res.data.reservationOpenFlag ? res.data.reservationOpenFlag : 0;
  316. this.shop.snCode = res.data.snCode //设备sn编码
  317. this.shop.value = res.data.value //设备key秘钥
  318. // this.shop.facility = res.data.facility // 设备类型
  319. }
  320. });
  321. },
  322. getStarttime(e) {
  323. console.log(e, '1111111111')
  324. this.shop.businessHours = e.hour + ':' + e.minute
  325. },
  326. getEndtime(e) {
  327. console.log(e)
  328. this.shop.lockHours = e.hour + ':' + e.minute
  329. },
  330. // 详情图删除
  331. removeImg(index) {
  332. this.shopBanner.splice(index, 1)
  333. },
  334. // 店铺logo删除
  335. removeImgs() {
  336. this.shop.shopCover = ''
  337. },
  338. bindOpen(e) {
  339. console.log(e)
  340. let that = this
  341. uni.chooseLocation({
  342. success: function(res) {
  343. console.log('位置名称:' + res.name);
  344. console.log('详细地址:' + res.address);
  345. console.log('纬度:' + res.latitude);
  346. console.log('经度:' + res.longitude);
  347. that.shop.detailedAddress = res.address
  348. that.shop.shopLat = res.latitude
  349. that.shop.shopLng = res.longitude
  350. }
  351. });
  352. },
  353. // 图片上传
  354. addImages(e) {
  355. let that = this
  356. uni.chooseImage({
  357. count: 6,
  358. sourceType: ['album', 'camera'],
  359. success: res => {
  360. for (let i = 0; i < res.tempFilePaths.length; i++) {
  361. that.$queue.showLoading("上传中...");
  362. uni.uploadFile({ // 上传接口
  363. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  364. filePath: res.tempFilePaths[i],
  365. name: 'file',
  366. success: (uploadFileRes) => {
  367. if (that.shopBanner.length < 6) {
  368. that.shopBanner.push(JSON.parse(uploadFileRes.data).data)
  369. }
  370. console.log(that.shopBanner)
  371. uni.hideLoading();
  372. }
  373. });
  374. }
  375. }
  376. })
  377. },
  378. // 图片上传
  379. addImage() {
  380. let that = this
  381. uni.chooseImage({
  382. count: 1,
  383. sourceType: ['album', 'camera'],
  384. success: res => {
  385. for (let i = 0; i < res.tempFilePaths.length; i++) {
  386. that.$queue.showLoading("上传中...");
  387. uni.uploadFile({ // 上传接口
  388. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  389. // url: 'https://jiazheng.xianmxkj.com/sqx_fast/alioss/upload',
  390. filePath: res.tempFilePaths[i],
  391. name: 'file',
  392. success: (uploadFileRes) => {
  393. that.shop.shopCover = JSON.parse(uploadFileRes.data).data
  394. uni.hideLoading();
  395. }
  396. });
  397. }
  398. }
  399. })
  400. },
  401. config: function(name) {
  402. var info = null;
  403. if (name) {
  404. var name2 = name.split("."); //字符分割
  405. if (name2.length > 1) {
  406. info = configdata[name2[0]][name2[1]] || null;
  407. } else {
  408. info = configdata[name] || null;
  409. }
  410. if (info == null) {
  411. let web_config = cache.get("web_config");
  412. if (web_config) {
  413. if (name2.length > 1) {
  414. info = web_config[name2[0]][name2[1]] || null;
  415. } else {
  416. info = web_config[name] || null;
  417. }
  418. }
  419. }
  420. }
  421. return info;
  422. },
  423. // 发布
  424. submit() {
  425. console.log(this.distributionDistance)
  426. this.shop.shopBanner = this.shopBanner
  427. this.shop.shopBanner = this.shop.shopBanner.toString();
  428. this.shop.distributionDistance = this.distributionDistance * 1000
  429. // this.shop.distributionDistance = this.shop.distributionDistance * 1000
  430. // if (!this.shop.shopName) {
  431. // uni.showToast({
  432. // title: '请填写店铺名称',
  433. // icon: 'none',
  434. // duration: 1000
  435. // })
  436. // return
  437. // }
  438. if (!this.shop.businessHours) {
  439. uni.showToast({
  440. title: '请填写开店时间',
  441. icon: 'none',
  442. duration: 1000
  443. })
  444. return
  445. }
  446. if (!this.shop.lockHours) {
  447. uni.showToast({
  448. title: '请填写闭店时间',
  449. icon: 'none',
  450. duration: 1000
  451. })
  452. return
  453. }
  454. if (this.shop.businessHours>=this.shop.lockHours) {
  455. uni.showToast({
  456. title: '开店时间不能大于闭店时间',
  457. icon: 'none',
  458. duration: 1000
  459. })
  460. return
  461. }
  462. // if (!this.shop.detailedAddress) {
  463. // uni.showToast({
  464. // title: '请填写店铺地址',
  465. // icon: 'none',
  466. // duration: 1000
  467. // })
  468. // return
  469. // }
  470. if (!this.shop.shopNotice) {
  471. uni.showToast({
  472. title: '请填写店铺公告',
  473. icon: 'none',
  474. duration: 1000
  475. })
  476. return
  477. }
  478. // if (!this.shop.snCode) {
  479. // uni.showToast({
  480. // title: '请填写设备sn编码',
  481. // icon: 'none',
  482. // duration: 1000
  483. // })
  484. // return
  485. // }
  486. // if (!this.shop.value) {
  487. // uni.showToast({
  488. // title: '请填写设备key秘钥',
  489. // icon: 'none',
  490. // duration: 1000
  491. // })
  492. // return
  493. // }
  494. if (!this.shop.shopCover) {
  495. uni.showToast({
  496. title: '请上传店铺logo',
  497. icon: 'none',
  498. duration: 1000
  499. })
  500. return
  501. }
  502. if (!this.shop.shopBanner) {
  503. uni.showToast({
  504. title: '请上传店铺轮播图',
  505. icon: 'none',
  506. duration: 1000
  507. })
  508. return
  509. }
  510. // console.log('this.shop.putawayFlag',this.shop.putawayFlag)
  511. // return
  512. if (this.shop.putawayFlag == 0) {
  513. // if (!this.shop.errandMoney) {
  514. // uni.showToast({
  515. // title: '请填写配送费',
  516. // icon: 'none',
  517. // duration: 1000
  518. // })
  519. // return
  520. // }
  521. if (!this.shop.minimumDelivery) {
  522. this.shop.minimumDelivery = 0;
  523. // uni.showToast({
  524. // title: '请填写最低起送金额',
  525. // icon: 'none',
  526. // duration: 1000
  527. // })
  528. // return
  529. }
  530. if (!this.shop.exemptMinMoney) {
  531. this.shop.exemptMinMoney = 0;
  532. // uni.showToast({
  533. // title: '请填写减免配送费最小订单金额',
  534. // icon: 'none',
  535. // duration: 1000
  536. // })
  537. // return
  538. }
  539. console.log(this.shop.distributionDistance)
  540. // if (!this.shop.distributionDistance) {
  541. // uni.showToast({
  542. // title: '请填写最大配送距离',
  543. // icon: 'none',
  544. // duration: 1000
  545. // })
  546. // return
  547. // }
  548. }
  549. console.log(this.shop)
  550. // uni.setStorageSync('shopId', this.shop.shopId)
  551. this.$Request.postJsonA("/app/shop/updateShopMessage", this.shop).then(res => {
  552. if (res.code == 0) {
  553. uni.showToast({
  554. title: '修改成功',
  555. icon: 'none'
  556. })
  557. setTimeout(function() {
  558. uni.navigateBack()
  559. // uni.navigateTo({
  560. // url: '/my/publish/index'
  561. // })
  562. }, 1000)
  563. } else {
  564. uni.showModal({
  565. title: '提示',
  566. content: res.msg,
  567. success: function (res) {
  568. if (res.confirm) {
  569. } else if (res.cancel) {
  570. }
  571. }
  572. });
  573. }
  574. });
  575. },
  576. }
  577. }
  578. </script>
  579. <style>
  580. page {
  581. background-color: #F5F5F5;
  582. }
  583. .bg {
  584. background-color: #FFFFFF;
  585. }
  586. .tabBox {
  587. border: 1rpx solid #999999;
  588. padding: 15rpx 20rpx;
  589. border-radius: 15rpx;
  590. font-size: 28rpx;
  591. }
  592. .btnnum {
  593. color: #005DFF;
  594. border: 1rpx solid #005DFF;
  595. }
  596. </style>