advertising.vue 12 KB

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