headPhoto.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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="form.headPhoto[index]">
  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="grid col-4 grid-square flex-sub booder-top" >
  26. <view class="solids" @tap="ChooseImage" >
  27. <text class='cuIcon-cameraadd'></text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="business-prompt">
  32. 门店照片需包含完整的门店入口和招牌名称,建议现场拍摄门头照;最多可上传10张,支持格式bmp、png、jpeg、jpg,单个图片不超过5MB,建议宽高比7:5
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="padding flex sub-bottom" style="justify-content: space-around;">
  38. <button class="cu-btn round line-gray shadow" @click="$Router.push({ name: 'settings' })"
  39. style="width: 205rpx;">取消</button>
  40. <button style="width:443rpx;background: linear-gradient( 90deg, #77B6FF 0%, #449AFF 100%);border-radius:53rpx ;"
  41. class="cu-btn bg-blue round " @click="sumbit">提交审核</button>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import configService from '../../common/service/config.service'
  47. import {
  48. USER_INFO
  49. } from "@/common/util/constants"
  50. import status from "./components/status.vue"
  51. export default {
  52. components: {
  53. status
  54. },
  55. data() {
  56. return {
  57. photoList: [],
  58. form: {},
  59. src: '',
  60. cameraList: [{
  61. value: 'back',
  62. name: '后置摄像头',
  63. checked: 'true'
  64. },
  65. {
  66. value: 'front',
  67. name: '前置摄像头'
  68. },
  69. ],
  70. businessData: [],
  71. }
  72. },
  73. async onLoad(data) {
  74. if (data.params) {
  75. let obj = JSON.parse(decodeURIComponent(data.params));
  76. // this.video = obj.video ? obj.video : ''
  77. obj.photo = obj.photo ? obj.headPhoto.split(',').filter(id => id !== '') : []
  78. this.form = obj
  79. }
  80. },
  81. async onShow() {
  82. let res = await this.$http.get('/merchant/localMerchantTime/list?merchantId=' + uni.getStorageSync(USER_INFO)
  83. .merchantId, )
  84. if (res.data.success) {
  85. this.businessData = res.data.result
  86. } else {
  87. uni.showToast({
  88. icon:'none',
  89. title:res.data.message
  90. })
  91. }
  92. },
  93. methods: {
  94. hoursChange(index) {
  95. const queryString = encodeURIComponent(JSON.stringify({
  96. index,
  97. arr: this.businessData
  98. }))
  99. uni.navigateTo({
  100. url: `/pages/store/addHours?params=${queryString}`
  101. })
  102. },
  103. DelImg(e) {
  104. uni.showModal({
  105. title: '提示',
  106. content: '确定要删除?',
  107. cancelText: '取消',
  108. confirmText: '确定',
  109. success: res => {
  110. if (res.confirm) {
  111. console.log(this.form)
  112. // this.photoList.splice(e.currentTarget.dataset.index, 1)
  113. this.form.photo.splice(e.currentTarget.dataset.index, 1)
  114. }
  115. }
  116. })
  117. },
  118. ChooseImage() {
  119. uni.chooseImage({
  120. // count: 4, //默认9
  121. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  122. sourceType: ['camera','album'], //从相册选择
  123. success: (res) => {
  124. if (res) {
  125. // this[type + 'Img'] = chooseImageRes.tempFilePaths[0];
  126. uni.uploadFile({
  127. url: configService.apiUrl + '/sys/common/upload',
  128. filePath: res.tempFilePaths[0],
  129. name: "file",
  130. formData: {
  131. 'biz': 'temp',
  132. },
  133. success: (files) => {
  134. let data = JSON.parse(files.data);
  135. if (data.success) {
  136. let temp = this.form.headPhoto.split(',')
  137. if (this.form.headPhoto.split(',').length > 0) {
  138. // this.photoList = this.photoList.concat(res.tempFilePaths)
  139. this.form.photo.push(configService.apiUrl + '/' + data.message)
  140. this.form.headPhoto+(configService.apiUrl + '/' + data.message)
  141. temp.push(configService.apiUrl + '/' + data.message)
  142. this.form.headPhoto = temp.join(',')
  143. console.log(this.form.headPhoto)
  144. } else {
  145. console.log('22222')
  146. // this.photoList =res.tempFilePaths
  147. this.form.headPhoto = [configService.apiUrl + '/' + data.message]
  148. }
  149. }
  150. }
  151. })
  152. }
  153. }
  154. });
  155. },
  156. ViewImage(e) {
  157. uni.previewImage({
  158. urls: this.form.headPhoto,
  159. current: e.currentTarget.dataset.url
  160. });
  161. },
  162. sumbit() {
  163. let data = {
  164. merchantId: uni.getStorageSync(USER_INFO).merchantId,
  165. headPhoto: this.form.headPhoto,
  166. id:this.form.headPhotoId
  167. }
  168. if (this.form.headPhotoStatus == null) {
  169. this.$http.post('merchant/localMerchantHeadPhoto/add', data).then(res => {
  170. if (res.data.success) {
  171. uni.showToast({
  172. icon:'none',
  173. title:'提交成功'
  174. })
  175. uni.navigateBack({
  176. delta: 1 // 返回的页面数,默认为1
  177. })
  178. } else {
  179. uni.showToast({
  180. icon:'none',
  181. title:res.data.message
  182. })
  183. }
  184. })
  185. } else {
  186. this.$http.post('merchant/localMerchantHeadPhoto/edit',data).then(res => {
  187. if (res.data.success) {
  188. uni.showToast({
  189. icon:'none',
  190. title:'提交成功'
  191. })
  192. uni.navigateBack({
  193. delta: 1 // 返回的页面数,默认为1
  194. })
  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>