headPhoto.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-fff" :isBack="true">
  4. <block slot="content" style="font-size: 36rpx;"> 商户形象</block>
  5. </cu-custom>
  6. <status v-if="form && form.headPhotoStatus !== null" :status="form.headPhotoStatus" :updateTime="form.headPhotoUpdateTime"
  7. :remark="form.headPhotoRemark"></status>
  8. <view class="tab-top" :style="form && form.headPhotoStatus == null ? 'margin-top: 14upx;' : 'margin-top: 144upx;'">
  9. <view class="borderRadiu">
  10. <view class="customize">
  11. <view class=" cu-form-group justify-between">
  12. <view class="content ">
  13. <text class="text-bold">门头照片</text>
  14. <i class="text-bg "></i>
  15. </view>
  16. </view>
  17. <view class="grid col-4 grid-square flex-sub booder-top">
  18. <view class="bg-img" v-for="(item, index) in form.photo" :key="index" @tap="ViewImage"
  19. :data-url="item">
  20. <image :src="item" mode="aspectFill"></image>
  21. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  22. <text class='cuIcon-close'></text>
  23. </view>
  24. </view>
  25. <view class="solids" @tap="ChooseImage" >
  26. <text class='cuIcon-cameraadd'></text>
  27. </view>
  28. </view>
  29. <view class="business-prompt">
  30. 门店照片需包含完整的门店入口和招牌名称,建议现场拍摄门头照;最多可上传10张,支持格式bmp、png、jpeg、jpg,单个图片不超过5MB,建议宽高比7:5
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="padding flex sub-bottom" style="justify-content: space-around;">
  36. <button class="cu-btn round line-gray shadow" @click="back()"
  37. style="width: 205rpx;">取消</button>
  38. <button style="width:443rpx;background: linear-gradient( 90deg, #77B6FF 0%, #449AFF 100%);border-radius:53rpx ;"
  39. class="cu-btn bg-blue round " @click="sumbit">提交审核</button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import configService from '../../common/service/config.service'
  45. import {
  46. USER_INFO
  47. } from "@/common/util/constants"
  48. import status from "./components/status.vue"
  49. export default {
  50. components: {
  51. status
  52. },
  53. data() {
  54. return {
  55. photoList: [],
  56. form: {},
  57. src: '',
  58. cameraList: [{
  59. value: 'back',
  60. name: '后置摄像头',
  61. checked: 'true'
  62. },
  63. {
  64. value: 'front',
  65. name: '前置摄像头'
  66. },
  67. ],
  68. businessData: [],
  69. }
  70. },
  71. async onLoad(data) {
  72. if (data.params) {
  73. let obj = JSON.parse(decodeURIComponent(data.params));
  74. console.log('111111',obj)
  75. // this.video = obj.video ? obj.video : ''
  76. obj.photo = obj.headPhoto ? obj.headPhoto.split(',').filter(id => id !== '') : []
  77. this.form = obj
  78. }
  79. },
  80. async onShow() {
  81. let res = await this.$http.get('/merchant/localMerchantTime/list?merchantId=' + uni.getStorageSync(USER_INFO)
  82. .merchantId, )
  83. if (res.data.success) {
  84. this.businessData = res.data.result
  85. } else {
  86. uni.showToast({
  87. icon:'none',
  88. title:res.data.message
  89. })
  90. }
  91. },
  92. methods: {
  93. syncHeadPhoto() {
  94. this.form.headPhoto = (this.form.photo || []).join(',')
  95. },
  96. back() {
  97. uni.navigateBack()
  98. },
  99. hoursChange(index) {
  100. const queryString = encodeURIComponent(JSON.stringify({
  101. index,
  102. arr: this.businessData
  103. }))
  104. uni.navigateTo({
  105. url: `/pages/store/addHours?params=${queryString}`
  106. })
  107. },
  108. DelImg(e) {
  109. uni.showModal({
  110. title: '提示',
  111. content: '确定要删除?',
  112. cancelText: '取消',
  113. confirmText: '确定',
  114. success: res => {
  115. if (res.confirm) {
  116. this.form.photo.splice(e.currentTarget.dataset.index, 1)
  117. this.syncHeadPhoto()
  118. }
  119. }
  120. })
  121. },
  122. ChooseImage() {
  123. uni.chooseImage({
  124. // count: 4, //默认9
  125. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  126. sourceType: ['camera','album'], //从相册选择
  127. success: (res) => {
  128. if (res) {
  129. // this[type + 'Img'] = chooseImageRes.tempFilePaths[0];
  130. uni.uploadFile({
  131. url: configService.apiUrl + '/sys/common/upload',
  132. filePath: res.tempFilePaths[0],
  133. name: "file",
  134. formData: {
  135. 'biz': 'temp',
  136. },
  137. success: (files) => {
  138. let data = JSON.parse(files.data);
  139. if (data.success) {
  140. if (!this.form.photo) {
  141. this.form.photo = []
  142. }
  143. this.form.photo.push(configService.apiUrl + '/' + data.message)
  144. this.syncHeadPhoto()
  145. }
  146. }
  147. })
  148. }
  149. }
  150. });
  151. },
  152. ViewImage(e) {
  153. uni.previewImage({
  154. urls: this.form.photo,
  155. current: e.currentTarget.dataset.url
  156. });
  157. },
  158. sumbit() {
  159. let data = {
  160. merchantId: uni.getStorageSync(USER_INFO).merchantId,
  161. headPhoto: (this.form.photo || []).join(','),
  162. id:this.form.headPhotoId
  163. }
  164. if (this.form.headPhotoStatus == null) {
  165. this.$http.post('merchant/localMerchantHeadPhoto/add', data).then(res => {
  166. if (res.data.code == 200) {
  167. uni.showToast({
  168. icon:'none',
  169. title:res.data.message || '成功'
  170. })
  171. setTimeout(()=>{
  172. uni.navigateBack({
  173. delta: 1 // 返回的页面数,默认为1
  174. })
  175. },1000)
  176. } else {
  177. uni.showToast({
  178. icon:'none',
  179. title:res.data.message
  180. })
  181. }
  182. })
  183. } else {
  184. this.$http.post('merchant/localMerchantHeadPhoto/edit',data).then(res => {
  185. if (res.data.code == 200) {
  186. uni.showToast({
  187. icon:'none',
  188. title:res.data.message || '成功'
  189. })
  190. setTimeout(()=>{
  191. uni.navigateBack({
  192. delta: 1 // 返回的页面数,默认为1
  193. })
  194. },1000)
  195. } else {
  196. uni.showToast({
  197. icon:'none',
  198. title:res.data.message
  199. })
  200. }
  201. })
  202. }
  203. },
  204. delClick(val) {
  205. this.$http.delete('/merchant/localMerchantTime/delete?id=' + val.id).then(res => {
  206. if (res.data.success) {
  207. uni.showToast({
  208. icon:'none',
  209. title:res.data.result || '成功'
  210. })
  211. this.$http.get('/merchant/localMerchantTime/list?merchantId=' + uni.getStorageSync(USER_INFO).merchantId)
  212. .then(res => {
  213. if (res.data.success) {
  214. this.businessData = res.data.result
  215. } else {
  216. uni.showToast({
  217. icon:'none',
  218. title:res.data.message
  219. })
  220. }
  221. })
  222. } else {
  223. uni.showToast({
  224. icon:'none',
  225. title:res.data.message
  226. })
  227. }
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style scoped lang="scss">
  234. page {
  235. background: #F8F8FA;
  236. }
  237. ::v-deep .cu-custom {
  238. border: none !important;
  239. }
  240. .tab-top {
  241. padding: 0 26upx;
  242. padding-bottom: 130upx
  243. }
  244. .progress-status {
  245. position: fixed;
  246. width: 100%;
  247. z-index: 9999;
  248. background: #FFFFFF;
  249. border: none;
  250. .status {
  251. font-size: 38upx;
  252. color: #F6863E;
  253. font-weight: 500;
  254. margin-bottom: 10upx;
  255. text {
  256. margin-left: 5upx
  257. }
  258. image {
  259. vertical-align: text-top;
  260. width: 42upx;
  261. height: 42upx;
  262. }
  263. }
  264. }
  265. .borderRadiu {
  266. border-radius: 8px;
  267. background-color: #ffffff;
  268. .customize {
  269. padding: 0 18upx 18upx;
  270. .title {
  271. padding: 18upx 0;
  272. font-size: 28upx;
  273. // padding: 10px;
  274. }
  275. }
  276. .business-img {
  277. height: 210upx;
  278. width: 310upx;
  279. background-size: cover;
  280. image {
  281. width: 100%;
  282. height: 100%;
  283. }
  284. }
  285. .business-prompt {
  286. padding-top: 16upx;
  287. font-size: 20rpx;
  288. color: #999999;
  289. }
  290. }
  291. .booder-top {
  292. border-bottom: 1px solid rgb(238, 238, 238);
  293. padding-bottom: 7px;
  294. .uploader_video {
  295. width: 310upx;
  296. height: 210upx;
  297. }
  298. .video-container {
  299. max-width: 100%;
  300. /* 最大宽度为父容器宽度 */
  301. max-height: 100%;
  302. ::v-deep.uni-video-bar {
  303. height: 62upx;
  304. padding: 0
  305. }
  306. }
  307. // ::v-deep video{
  308. // position: relative;
  309. // z-index: 1;
  310. // width: 310upx ;
  311. // height: 210upx;
  312. // .uni-video-bar .uni-video-bar-full{
  313. // }
  314. // }
  315. }
  316. .sub-bottom {
  317. position: fixed;
  318. width: 100%;
  319. bottom: 0;
  320. background: #FFFFFF;
  321. border-top: 1px solid #EEEEEE;
  322. }
  323. .uni-uploader__img {
  324. width: 200upx;
  325. height: 200upx;
  326. }
  327. .uni-uploader__file,
  328. .uploader_video {
  329. position: relative;
  330. z-index: 1;
  331. width: 200upx;
  332. height: 200upx;
  333. }
  334. .icon-cuo {
  335. position: absolute;
  336. right: 0;
  337. top: 5upx;
  338. color: #FFFFFF;
  339. z-index: 999;
  340. border-top-right-radius: 20upx;
  341. border-bottom-left-radius: 20upx;
  342. }
  343. .business-hours {
  344. padding: 27upx 22upx;
  345. background: #F7F8FC;
  346. font-size: 28upx;
  347. border-radius: 8px 8px 8px 8px;
  348. margin-bottom: 18upx;
  349. }
  350. .del-style {
  351. // padding: 0 30upx;
  352. width: 116upx;
  353. background: #FFFFFF;
  354. border-radius: 4px 4px 4px 4px;
  355. border: 1px solid #EEEEEE;
  356. color: #333333;
  357. font-size: 26upx;
  358. line-height: 50upx;
  359. text-align: center;
  360. // -radius: 4px 4px 4px 4px;
  361. }
  362. .business-date {
  363. text {
  364. margin-right: 22upx;
  365. }
  366. }
  367. .col-4{
  368. width: auto;
  369. }
  370. </style>