advertising.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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.videoStatus !== null" :status="form.videoStatus" :updateTime="form.videoUpdateTime"
  7. :remark="form.videoRemark"></status>
  8. <view class="tab-top" :style="form && form.videoStatus == 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="booder-top">
  18. <view class="business-img ">
  19. <view class="uni-uploader__file" v-if="video">
  20. <view class="uploader_video">
  21. <video :src="video" class="video-container"></video>
  22. <cover-view class="delete-video-icon" @tap="delectVideo">
  23. <!-- <uni-icons class="icon iconfont icon-cuo" type="trash-filled" size="20" color="#ffffff"></uni-icons> -->
  24. <cover-image class="delete-icon-img" src="/static/ad/close.png"></cover-image>
  25. </cover-view>
  26. </view>
  27. </view>
  28. <image v-else src="/static/store/upload2.png" mode="" @tap="chooseVideo()"></image>
  29. </view>
  30. </view>
  31. <view class="business-prompt">
  32. 最多上传1个视频,大小不超过50M,建议宽高比9:16
  33. </view>
  34. </view>
  35. <view class="customize">
  36. <view class=" cu-form-group justify-between">
  37. <view class="content ">
  38. <text class="text-bold">经营相册</text>
  39. <i class="text-bg "></i>
  40. </view>
  41. </view>
  42. <!-- <view class="grid col-4 grid-square flex-sub booder-top">
  43. <view class="bg-img" v-for="(item, index) in form.photo" :key="index" @tap="ViewImage"
  44. :data-url="form.photo[index]">
  45. <image :src="form.photo[index]" mode="aspectFill"></image>
  46. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  47. <text class='cuIcon-close'></text>
  48. </view>
  49. </view>
  50. <view class="solids" @tap="ChooseImage" v-if="form.photo.length < 20">
  51. <text class='cuIcon-cameraadd'></text>
  52. </view>
  53. </view> -->
  54. <shmily-drag-image v-model="form.photo" :number="20" :addImage="ChooseImage" :delImage="delImage"></shmily-drag-image>
  55. <view class="business-prompt">
  56. 最多上传20张,每张大小不超过5M,建议宽高比9:16
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="padding flex sub-bottom" style="justify-content: space-around;">
  62. <button class="cu-btn round line-gray shadow" @click="back()"
  63. style="width: 205rpx;">取消</button>
  64. <button style="width:443rpx;background: linear-gradient( 90deg, #77B6FF 0%, #449AFF 100%);border-radius:53rpx ;"
  65. class="cu-btn bg-blue round " @click="sumbit">提交审核</button>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import configService from '../../common/service/config.service'
  71. import {
  72. USER_INFO
  73. } from "@/common/util/constants"
  74. import status from "./components/status.vue"
  75. export default {
  76. components: {
  77. status
  78. },
  79. data() {
  80. return {
  81. video: '',
  82. photoList: [],
  83. form: {},
  84. src: '',
  85. cameraList: [{
  86. value: 'back',
  87. name: '后置摄像头',
  88. checked: 'true'
  89. },
  90. {
  91. value: 'front',
  92. name: '前置摄像头'
  93. },
  94. ],
  95. businessData: []
  96. }
  97. },
  98. async onLoad(data) {
  99. if (data.params) {
  100. let obj = JSON.parse(decodeURIComponent(data.params));
  101. this.video = obj.video ? obj.video : ''
  102. obj.photo = obj.photo ? obj.photo.split(',').filter(id => id !== '') : []
  103. this.form = obj
  104. }
  105. },
  106. async onShow() {
  107. let res = await this.$http.get('/merchant/localMerchantTime/list?merchantId=' + uni.getStorageSync(USER_INFO)
  108. .merchantId, )
  109. if (res.data.success) {
  110. this.businessData = res.data.result
  111. } else {
  112. uni.showToast({
  113. icon:'none',
  114. title:res.data.message
  115. })
  116. }
  117. },
  118. methods: {
  119. back() {
  120. uni.navigateBack()
  121. },
  122. addImage() {
  123. // 将图片地址添加到图片数组
  124. this.list.push('http://web.shmily.ren/shmily-drag-image/static/4.jpg')
  125. },
  126. delImage(done) {
  127. uni.showModal({
  128. content: '是否删除?',
  129. success: (res) => {
  130. if(res.confirm) {
  131. // 执行 done() 删除
  132. done()
  133. }
  134. }
  135. })
  136. },
  137. hoursChange(index) {
  138. const queryString = encodeURIComponent(JSON.stringify({
  139. index,
  140. arr: this.businessData
  141. }))
  142. uni.navigateTo({
  143. url: `/pages/store/addHours?params=${queryString}`
  144. })
  145. },
  146. delectVideo() {
  147. uni.showModal({
  148. title: "提示",
  149. content: "是否要删除此视频",
  150. success: (res) => {
  151. if (res.confirm) {
  152. this.video = ''
  153. }
  154. }
  155. })
  156. },
  157. DelImg(e) {
  158. uni.showModal({
  159. title: '提示',
  160. content: '确定要删除?',
  161. cancelText: '取消',
  162. confirmText: '确定',
  163. success: res => {
  164. if (res.confirm) {
  165. // this.photoList.splice(e.currentTarget.dataset.index, 1)
  166. this.form.photo.splice(e.currentTarget.dataset.index, 1)
  167. }
  168. }
  169. })
  170. },
  171. ChooseImage() {
  172. const remain = 20 - this.form.photo.length
  173. if (remain <= 0) {
  174. uni.showToast({ title: '最多20张图', icon: 'none' })
  175. return
  176. }
  177. uni.chooseImage({
  178. count: remain,
  179. sizeType: ['compressed'],
  180. sourceType: ['album'], //从相册选择
  181. success: (res) => {
  182. if (res) {
  183. console.log('上传图片', res)
  184. // this[type + 'Img'] = chooseImageRes.tempFilePaths[0];
  185. if(res.tempFilePaths && res.tempFilePaths.length > 0) {
  186. res.tempFilePaths.forEach(item => {
  187. uni.uploadFile({
  188. url: configService.apiUrl + '/sys/common/upload',
  189. filePath: item,
  190. name: "file",
  191. formData: {
  192. 'biz': 'temp',
  193. },
  194. success: (files) => {
  195. let data = JSON.parse(files.data);
  196. if (data.success) {
  197. if (this.form.photo.length != 0) {
  198. // this.photoList = this.photoList.concat(res.tempFilePaths)
  199. this.form.photo.push(configService.apiUrl + '/' + data.message)
  200. } else {
  201. // this.photoList =res.tempFilePaths
  202. this.form.photo = [configService.apiUrl + '/' + data.message]
  203. }
  204. }
  205. }
  206. })
  207. })
  208. }
  209. }
  210. }
  211. });
  212. },
  213. ViewImage(e) {
  214. uni.previewImage({
  215. urls: this.form.photo,
  216. current: e.currentTarget.dataset.url
  217. });
  218. },
  219. chooseVideo() {
  220. // 上传视频
  221. console.log('上传视频')
  222. uni.chooseVideo({
  223. sourceType: ['camera', 'album'],
  224. success: (res) => {
  225. uni.showLoading({
  226. title: '上传中...'
  227. })
  228. uni.uploadFile({
  229. url: configService.apiUrl + '/sys/common/upload',
  230. filePath: res.tempFilePath,
  231. name: "file",
  232. formData: {
  233. 'biz': 'temp',
  234. },
  235. success: (files) => {
  236. uni.hideLoading()
  237. let data = JSON.parse(files.data);
  238. if (data.success) {
  239. this.video = configService.apiUrl + '/' + data.message
  240. uni.showToast({
  241. title: '上传成功',
  242. icon: 'success'
  243. })
  244. } else {
  245. uni.showToast({
  246. title: data.message || '上传失败',
  247. icon: 'none'
  248. })
  249. }
  250. },
  251. fail: (err) => {
  252. uni.hideLoading()
  253. uni.showToast({
  254. title: '上传失败',
  255. icon: 'none'
  256. })
  257. console.error('视频上传失败', err)
  258. }
  259. })
  260. }
  261. })
  262. },
  263. sumbit() {
  264. let data = {
  265. merchantId: uni.getStorageSync(USER_INFO).merchantId,
  266. video: this.video,
  267. photo: this.form.photo.join(",")
  268. }
  269. console.log(this.form.photo)
  270. if (this.form.videoStatus == null) {
  271. this.$http.post('/merchant/LocalMerchantOperate/add', data).then(res => {
  272. if (res.data.code == 200) {
  273. uni.showToast({
  274. icon:'none',
  275. title:res.data.message || '成功'
  276. })
  277. setTimeout(()=>{
  278. uni.navigateBack({
  279. delta: 1 // 返回的页面数,默认为1
  280. })
  281. },1000)
  282. } else {
  283. uni.showToast({
  284. icon:'none',
  285. title:res.data.message
  286. })
  287. }
  288. })
  289. } else {
  290. this.$http.post('/merchant/LocalMerchantOperate/edit', {
  291. ...data,
  292. id: this.form.videoId
  293. }).then(res => {
  294. if (res.data.code == 200) {
  295. uni.showToast({
  296. icon:'none',
  297. title:res.data.message || '成功'
  298. })
  299. setTimeout(()=>{
  300. uni.navigateBack({
  301. delta: 1 // 返回的页面数,默认为1
  302. })
  303. },1000)
  304. } else {
  305. uni.showToast({
  306. icon:'none',
  307. title:res.data.message
  308. })
  309. }
  310. })
  311. }
  312. },
  313. delClick(val) {
  314. this.$http.delete('/merchant/localMerchantTime/delete?id=' + val.id).then(res => {
  315. if (res.data.success) {
  316. uni.showToast({
  317. icon:'none',
  318. title:res.data.result || '成功'
  319. })
  320. this.$http.get('/merchant/localMerchantTime/list?merchantId=' + uni.getStorageSync(USER_INFO).merchantId)
  321. .then(res => {
  322. if (res.data.success) {
  323. this.businessData = res.data.result
  324. } else {
  325. uni.showToast({
  326. icon:'none',
  327. title:res.data.message
  328. })
  329. }
  330. })
  331. } else {
  332. uni.showToast({
  333. icon:'none',
  334. title:res.data.message
  335. })
  336. }
  337. })
  338. }
  339. }
  340. }
  341. </script>
  342. <style scoped lang="scss">
  343. page {
  344. background: #F8F8FA;
  345. }
  346. ::v-deep .cu-custom {
  347. border: none !important;
  348. }
  349. .tab-top {
  350. padding: 0 26upx;
  351. padding-bottom: 130upx
  352. }
  353. .progress-status {
  354. position: fixed;
  355. width: 100%;
  356. z-index: 9999;
  357. background: #FFFFFF;
  358. border: none;
  359. .status {
  360. font-size: 38upx;
  361. color: #F6863E;
  362. font-weight: 500;
  363. margin-bottom: 10upx;
  364. text {
  365. margin-left: 5upx
  366. }
  367. image {
  368. vertical-align: text-top;
  369. width: 42upx;
  370. height: 42upx;
  371. }
  372. }
  373. }
  374. .borderRadiu {
  375. border-radius: 8px;
  376. .customize {
  377. padding: 0 18upx 18upx;
  378. margin-bottom: 16rpx;
  379. background-color: #ffffff;
  380. border-radius: 16rpx;
  381. .title {
  382. padding: 18upx 0;
  383. font-size: 28upx;
  384. // padding: 10px;
  385. }
  386. }
  387. .business-img {
  388. height: 210upx;
  389. width: 310upx;
  390. background-size: cover;
  391. image {
  392. width: 100%;
  393. height: 100%;
  394. }
  395. }
  396. .business-prompt {
  397. padding-top: 16upx;
  398. font-size: 20upx;
  399. color: #999999;
  400. }
  401. }
  402. .booder-top {
  403. border-bottom: 1px solid rgb(238, 238, 238);
  404. padding-bottom: 7px;
  405. .uploader_video {
  406. position: relative;
  407. width: 310upx;
  408. height: 210upx;
  409. }
  410. .video-container {
  411. max-width: 100%;
  412. /* 最大宽度为父容器宽度 */
  413. max-height: 100%;
  414. ::v-deep.uni-video-bar {
  415. height: 62upx;
  416. padding: 0
  417. }
  418. }
  419. // ::v-deep video{
  420. // position: relative;
  421. // z-index: 1;
  422. // width: 310upx ;
  423. // height: 210upx;
  424. // .uni-video-bar .uni-video-bar-full{
  425. // }
  426. // }
  427. }
  428. .sub-bottom {
  429. position: fixed;
  430. width: 100%;
  431. bottom: 0;
  432. background: #FFFFFF;
  433. border-top: 1px solid #EEEEEE;
  434. z-index: 99;
  435. }
  436. .uni-uploader__img {
  437. width: 200upx;
  438. height: 200upx;
  439. }
  440. .uni-uploader__file,
  441. .uploader_video {
  442. position: relative;
  443. z-index: 1;
  444. width: 200upx;
  445. height: 200upx;
  446. }
  447. .icon-cuo {
  448. position: absolute;
  449. right: 0;
  450. top: 5upx;
  451. color: #FFFFFF;
  452. z-index: 999;
  453. border-top-right-radius: 20upx;
  454. border-bottom-left-radius: 20upx;
  455. }
  456. .icon-delete-red {
  457. color: red;
  458. }
  459. .delete-video-icon {
  460. position: absolute;
  461. right: 0upx;
  462. top: 0upx;
  463. width: 40upx;
  464. height: 40upx;
  465. background-color: rgba(0, 0, 0, 0.4);
  466. border-radius: 0 0 0 10rpx;
  467. display: flex;
  468. align-items: center;
  469. justify-content: center;
  470. z-index:9999;
  471. }
  472. .delete-icon-img {
  473. width: 24upx;
  474. height: 24upx;
  475. }
  476. .business-hours {
  477. padding: 27upx 22upx;
  478. background: #F7F8FC;
  479. font-size: 28upx;
  480. border-radius: 8px 8px 8px 8px;
  481. margin-bottom: 18upx;
  482. }
  483. .del-style {
  484. // padding: 0 30upx;
  485. width: 116upx;
  486. background: #FFFFFF;
  487. border-radius: 4px 4px 4px 4px;
  488. border: 1px solid #EEEEEE;
  489. color: #333333;
  490. font-size: 26upx;
  491. line-height: 50upx;
  492. text-align: center;
  493. // -radius: 4px 4px 4px 4px;
  494. }
  495. .business-date {
  496. text {
  497. margin-right: 22upx;
  498. }
  499. }
  500. </style>