advertising.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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"></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" :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="$Router.push({ name: 'settings' })"
  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. this.$tip.error(res.data.message);
  111. }
  112. },
  113. methods: {
  114. addImage() {
  115. // 将图片地址添加到图片数组
  116. this.list.push('http://web.shmily.ren/shmily-drag-image/static/4.jpg')
  117. },
  118. delImage(done) {
  119. uni.showModal({
  120. content: '是否删除?',
  121. success: (res) => {
  122. if(res.confirm) {
  123. // 执行 done() 删除
  124. done()
  125. }
  126. }
  127. })
  128. },
  129. hoursChange(index) {
  130. const queryString = encodeURIComponent(JSON.stringify({
  131. index,
  132. arr: this.businessData
  133. }))
  134. uni.navigateTo({
  135. url: `/pages/store/addHours?params=${queryString}`
  136. })
  137. },
  138. delectVideo() {
  139. uni.showModal({
  140. title: "提示",
  141. content: "是否要删除此视频",
  142. success: (res) => {
  143. if (res.confirm) {
  144. this.video = ''
  145. }
  146. }
  147. })
  148. },
  149. DelImg(e) {
  150. uni.showModal({
  151. title: '提示',
  152. content: '确定要删除?',
  153. cancelText: '取消',
  154. confirmText: '确定',
  155. success: res => {
  156. if (res.confirm) {
  157. // this.photoList.splice(e.currentTarget.dataset.index, 1)
  158. this.form.photo.splice(e.currentTarget.dataset.index, 1)
  159. }
  160. }
  161. })
  162. },
  163. ChooseImage() {
  164. uni.chooseImage({
  165. // count: 4, //默认9
  166. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  167. sourceType: ['album'], //从相册选择
  168. success: (res) => {
  169. if (res) {
  170. // this[type + 'Img'] = chooseImageRes.tempFilePaths[0];
  171. uni.uploadFile({
  172. url: configService.apiUrl + '/sys/common/upload',
  173. filePath: res.tempFilePaths[0],
  174. name: "file",
  175. formData: {
  176. 'biz': 'temp',
  177. },
  178. success: (files) => {
  179. let data = JSON.parse(files.data);
  180. if (data.success) {
  181. if (this.form.photo.length != 0) {
  182. // this.photoList = this.photoList.concat(res.tempFilePaths)
  183. this.form.photo.push(configService.apiUrl + '/' + data.message)
  184. } else {
  185. // this.photoList =res.tempFilePaths
  186. this.form.photo = [configService.apiUrl + '/' + data.message]
  187. }
  188. }
  189. }
  190. })
  191. }
  192. }
  193. });
  194. },
  195. ViewImage(e) {
  196. uni.previewImage({
  197. urls: this.form.photo,
  198. current: e.currentTarget.dataset.url
  199. });
  200. },
  201. chooseVideo() {
  202. // 上传视频
  203. console.log('上传视频')
  204. uni.chooseVideo({
  205. sourceType: ['camera', 'album'],
  206. success: (res) => {
  207. this.video = res.tempFilePath;
  208. }
  209. })
  210. },
  211. sumbit() {
  212. let data = {
  213. merchantId: uni.getStorageSync(USER_INFO).merchantId,
  214. video: this.video,
  215. photo: this.form.photo.join(",")
  216. }
  217. console.log(this.form.photo)
  218. if (this.form.videoStatus == null) {
  219. this.$http.post('/merchant/LocalMerchantOperate/add', data).then(res => {
  220. if (res.data.success) {
  221. this.$tip.success(res.data.result || '成功')
  222. uni.navigateBack({
  223. delta: 1 // 返回的页面数,默认为1
  224. })
  225. } else {
  226. this.$tip.error(res.data.message);
  227. }
  228. })
  229. } else {
  230. this.$http.post('/merchant/LocalMerchantOperate/edit', {
  231. ...data,
  232. id: this.form.videoId
  233. }).then(res => {
  234. if (res.data.success) {
  235. this.$tip.success(res.data.result || '成功')
  236. uni.navigateBack({
  237. delta: 1 // 返回的页面数,默认为1
  238. })
  239. } else {
  240. this.$tip.error(res.data.message);
  241. }
  242. })
  243. }
  244. },
  245. delClick(val) {
  246. this.$http.delete('/merchant/localMerchantTime/delete?id=' + val.id).then(res => {
  247. if (res.data.success) {
  248. this.$tip.success(res.data.result || '成功')
  249. this.$http.get('/merchant/localMerchantTime/list?merchantId=' + uni.getStorageSync(USER_INFO).merchantId)
  250. .then(res => {
  251. if (res.data.success) {
  252. this.businessData = res.data.result
  253. } else {
  254. this.$tip.error(res.data.message);
  255. }
  256. })
  257. } else {
  258. this.$tip.error(res.data.message);
  259. }
  260. })
  261. }
  262. }
  263. }
  264. </script>
  265. <style scoped lang="scss">
  266. page {
  267. background: #F8F8FA;
  268. }
  269. ::v-deep .cu-custom {
  270. border: none !important;
  271. }
  272. .tab-top {
  273. padding: 0 26upx;
  274. padding-bottom: 130upx
  275. }
  276. .progress-status {
  277. position: fixed;
  278. width: 100%;
  279. z-index: 9999;
  280. background: #FFFFFF;
  281. border: none;
  282. .status {
  283. font-size: 38upx;
  284. color: #F6863E;
  285. font-weight: 500;
  286. margin-bottom: 10upx;
  287. text {
  288. margin-left: 5upx
  289. }
  290. image {
  291. vertical-align: text-top;
  292. width: 42upx;
  293. height: 42upx;
  294. }
  295. }
  296. }
  297. .borderRadiu {
  298. border-radius: 8px;
  299. .customize {
  300. padding: 0 18upx 18upx;
  301. margin-bottom: 16rpx;
  302. background-color: #ffffff;
  303. border-radius: 16rpx;
  304. .title {
  305. padding: 18upx 0;
  306. font-size: 28upx;
  307. // padding: 10px;
  308. }
  309. }
  310. .business-img {
  311. height: 210upx;
  312. width: 310upx;
  313. background-size: cover;
  314. image {
  315. width: 100%;
  316. height: 100%;
  317. }
  318. }
  319. .business-prompt {
  320. padding-top: 16upx;
  321. font-size: 20upx;
  322. color: #999999;
  323. }
  324. }
  325. .booder-top {
  326. border-bottom: 1px solid rgb(238, 238, 238);
  327. padding-bottom: 7px;
  328. .uploader_video {
  329. width: 310upx;
  330. height: 210upx;
  331. }
  332. .video-container {
  333. max-width: 100%;
  334. /* 最大宽度为父容器宽度 */
  335. max-height: 100%;
  336. ::v-deep.uni-video-bar {
  337. height: 62upx;
  338. padding: 0
  339. }
  340. }
  341. // ::v-deep video{
  342. // position: relative;
  343. // z-index: 1;
  344. // width: 310upx ;
  345. // height: 210upx;
  346. // .uni-video-bar .uni-video-bar-full{
  347. // }
  348. // }
  349. }
  350. .sub-bottom {
  351. position: fixed;
  352. width: 100%;
  353. bottom: 0;
  354. background: #FFFFFF;
  355. border-top: 1px solid #EEEEEE;
  356. }
  357. .uni-uploader__img {
  358. width: 200upx;
  359. height: 200upx;
  360. }
  361. .uni-uploader__file,
  362. .uploader_video {
  363. position: relative;
  364. z-index: 1;
  365. width: 200upx;
  366. height: 200upx;
  367. }
  368. .icon-cuo {
  369. position: absolute;
  370. right: 0;
  371. top: 5upx;
  372. color: #FFFFFF;
  373. z-index: 999;
  374. border-top-right-radius: 20upx;
  375. border-bottom-left-radius: 20upx;
  376. }
  377. .business-hours {
  378. padding: 27upx 22upx;
  379. background: #F7F8FC;
  380. font-size: 28upx;
  381. border-radius: 8px 8px 8px 8px;
  382. margin-bottom: 18upx;
  383. }
  384. .del-style {
  385. // padding: 0 30upx;
  386. width: 116upx;
  387. background: #FFFFFF;
  388. border-radius: 4px 4px 4px 4px;
  389. border: 1px solid #EEEEEE;
  390. color: #333333;
  391. font-size: 26upx;
  392. line-height: 50upx;
  393. text-align: center;
  394. // -radius: 4px 4px 4px 4px;
  395. }
  396. .business-date {
  397. text {
  398. margin-right: 22upx;
  399. }
  400. }
  401. </style>