index.vue 19 KB

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