index.vue 18 KB

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