裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

337 lines
8.5 KiB

  1. <template>
  2. <view class="page">
  3. <navbar title="视频分享" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="content">
  5. <uv-form
  6. ref="form"
  7. :model="form"
  8. :rules="rules"
  9. labelPosition="left"
  10. labelWidth="340rpx"
  11. :labelStyle="{
  12. color: '#1B1B1B',
  13. fontSize: '32rpx',
  14. fontWeight: 'bold',
  15. }"
  16. errorType="toast"
  17. >
  18. <view class="flex upload__view">
  19. <view class="upload upload-cover">
  20. <uv-form-item labelWidth="0" prop="indexImage">
  21. <formUpload v-model="form.indexImage">
  22. <template v-slot="{ value }">
  23. <!-- todo: 默认 -->
  24. <image
  25. :src="value"
  26. mode="aspectFill"
  27. style="width: 344rpx; height: 344rpx;"
  28. radius="14rpx"
  29. />
  30. </template>
  31. </formUpload>
  32. <view class="upload-cover-text flex">设置封面</view>
  33. </uv-form-item>
  34. </view>
  35. <view class="upload upload-video">
  36. <uv-form-item labelWidth="0" prop="vio">
  37. <formUpload v-model="form.vio" accept="video">
  38. <template v-slot="{ value }">
  39. <video v-if="value"
  40. :src="form.vio"
  41. style="width: 344rpx; height: 344rpx;"
  42. radius="14rpx"
  43. :controls="false"
  44. :autoplay="false"
  45. :show-center-play-btn="false"
  46. ></video>
  47. <view v-else class="flex flex-column" style="width: 344rpx; height: 344rpx;">
  48. <image src="../static/record/icon-camera.png" style="width: 130rpx; height: 105rpx;" ></image>
  49. <text class="upload-video-text">上传视频</text>
  50. </view>
  51. </template>
  52. </formUpload>
  53. </uv-form-item>
  54. </view>
  55. </view>
  56. <view class="form-item">
  57. <uv-form-item label="标题" labelWidth="84rpx" prop="headTitle">
  58. <view class="form-item-content">
  59. <formInput v-model="form.headTitle" placeholder="请输入你的视频名称" width="584rpx"></formInput>
  60. </view>
  61. </uv-form-item>
  62. </view>
  63. <view class="form-item">
  64. <uv-form-item label="设置广告弹出时间(s)" prop="timeNum">
  65. <view class="form-item-content">
  66. <formNumberBox v-model="form.timeNum" ></formNumberBox>
  67. </view>
  68. </uv-form-item>
  69. </view>
  70. <view class="form-item">
  71. <uv-form-item label="设置转发次数(次)" prop="num">
  72. <view class="form-item-content">
  73. <formNumberBox v-model="form.num" ></formNumberBox>
  74. </view>
  75. </uv-form-item>
  76. </view>
  77. <view class="form-item">
  78. <uv-form-item label="选择二维码" prop="wxCodeImage">
  79. <view class="form-item-content">
  80. <formUpload v-model="form.wxCodeImage">
  81. <template v-slot="{ value }">
  82. <view class="flex" style="min-width: 93rpx; height: 45rpx;">
  83. <image
  84. :src="value"
  85. mode="aspectFill"
  86. style="width: 45rpx; height: 45rpx;"
  87. radius="14rpx"
  88. />
  89. <uv-icon style="margin-left: 20rpx" name="arrow-right" color="#000000" size="28rpx"></uv-icon>
  90. </view>
  91. </template>
  92. </formUpload>
  93. </view>
  94. </uv-form-item>
  95. </view>
  96. <view class="form-item">
  97. <uv-form-item label="视频描述" prop="textDetails" labelPosition="top">
  98. <view style="margin-top: 32rpx;">
  99. <formTextarea
  100. v-model="form.textDetails"
  101. placeholder="请描述你的视频"
  102. ></formTextarea>
  103. </view>
  104. </uv-form-item>
  105. </view>
  106. </uv-form>
  107. </view>
  108. <!-- 审核通过 -->
  109. <button v-if="status === 1" class="button-submit" open-type="share">
  110. 发布
  111. </button>
  112. <!-- 不是 审核中 已发布 -> 创建分享 审核不通过 -->
  113. <button v-else-if="![0,1].includes(status)" class="button-submit" @click="onSubmit">
  114. 提交审核
  115. </button>
  116. </view>
  117. </template>
  118. <script>
  119. import { mapState } from 'vuex'
  120. import formUpload from '../components/formUpload.vue'
  121. import formInput from '../components/formInput.vue'
  122. import formNumberBox from '../components/formNumberBox.vue'
  123. import formTextarea from '../components/formTextarea.vue'
  124. export default {
  125. components: {
  126. formUpload,
  127. formInput,
  128. formNumberBox,
  129. formTextarea,
  130. },
  131. data() {
  132. return {
  133. id: null,
  134. status: null,
  135. form: {
  136. headTitle: null,
  137. indexImage: null,
  138. vio: null,
  139. timeNum: 10,
  140. num: 10,
  141. wxCodeImage: null,
  142. textDetails: null,
  143. },
  144. rules: {
  145. 'indexImage': {
  146. type: 'string',
  147. required: true,
  148. message: '请设置封面',
  149. },
  150. 'vio': {
  151. type: 'string',
  152. required: true,
  153. message: '请上传视频',
  154. },
  155. 'headTitle': {
  156. type: 'string',
  157. required: true,
  158. message: '请输入你的视频名称',
  159. },
  160. 'timeNum': {
  161. type: 'number',
  162. required: true,
  163. message: '请设置广告弹出时间',
  164. },
  165. 'num': {
  166. type: 'number',
  167. required: true,
  168. message: '请设置转发次数',
  169. },
  170. 'wxCodeImage': {
  171. type: 'string',
  172. required: true,
  173. message: '请选择二维码',
  174. },
  175. 'textDetails': {
  176. type: 'string',
  177. required: true,
  178. message: '请描述你的视频',
  179. },
  180. },
  181. }
  182. },
  183. computed: {
  184. ...mapState(['userInfo']),
  185. },
  186. onLoad(option) {
  187. const { id } = option
  188. if (!id) {
  189. return
  190. }
  191. this.id = id
  192. this.fetchDetails(id)
  193. },
  194. onShareAppMessage(res) {
  195. const {
  196. headTitle,
  197. indexImage,
  198. } = this.form
  199. let o = {
  200. title : headTitle,
  201. imageUrl: indexImage,
  202. path: `/pages_order/sharing/video?id=${this.id}&state=1&shareId=${this.userInfo.id}`
  203. }
  204. // todo: get times and check is unlocked
  205. this.isLocked = false
  206. return o
  207. },
  208. methods: {
  209. async fetchDetails(id) {
  210. try {
  211. const result = await this.$fetch('getVideoShareInfo', { id })
  212. const {
  213. headTitle,
  214. indexImage,
  215. vio,
  216. timeNum,
  217. num,
  218. wxCodeImage,
  219. textDetails,
  220. status,
  221. } = result || {}
  222. this.form = {
  223. headTitle,
  224. indexImage,
  225. vio,
  226. timeNum,
  227. num,
  228. wxCodeImage,
  229. textDetails,
  230. }
  231. this.status = status
  232. } catch (err) {
  233. }
  234. },
  235. async onSubmit() {
  236. try {
  237. await this.$refs.form.validate()
  238. const {
  239. headTitle,
  240. indexImage,
  241. vio,
  242. timeNum,
  243. num,
  244. wxCodeImage,
  245. textDetails,
  246. } = this.form
  247. const params = {
  248. id: this.id,
  249. headTitle,
  250. indexImage,
  251. vio,
  252. timeNum,
  253. num,
  254. wxCodeImage,
  255. textDetails,
  256. }
  257. await this.$fetch('saveOrUpdateVideoShare', params)
  258. uni.showToast({
  259. title: '提交成功',
  260. icon: 'none'
  261. })
  262. setTimeout(uni.navigateBack, 1000, -1)
  263. } catch (err) {
  264. }
  265. },
  266. onPublish() {
  267. // todo
  268. },
  269. }
  270. }
  271. </script>
  272. <style scoped lang="scss">
  273. @import '../styles/pageForm.scss';
  274. .upload__view {
  275. justify-content: space-between;
  276. margin-bottom: 20rpx;
  277. }
  278. .upload {
  279. background-color: $uni-fg-color;
  280. border-radius: 12rpx;
  281. overflow: hidden;
  282. /deep/ .uv-form-item__body {
  283. padding: 0 !important;
  284. }
  285. }
  286. .upload-video {
  287. &-text {
  288. color: #1B1B1B;
  289. font-size: 32rpx;
  290. font-weight: 700;
  291. margin-top: 35rpx;
  292. }
  293. }
  294. .upload-cover {
  295. position: relative;
  296. &-text {
  297. position: absolute;
  298. bottom: 0;
  299. width: 100%;
  300. background-color: rgba($color: #000000, $alpha: 0.6);
  301. color: #FFFFFF;
  302. padding: 21rpx 0;
  303. }
  304. }
  305. </style>