video.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view>
  3. <scroll-view scroll-x class="bg-white nav solid-bottom echo-fixed-top">
  4. <view class="flex text-center">
  5. <view class="cu-item flex-sub" :class="wtype==1?'text-blue cur':''" @tap="tabSelect" data-wtype="1">发布视频</view>
  6. <view class="cu-item flex-sub" :class="wtype==2?'text-blue cur':''" @tap="tabSelect" data-wtype="2">我发布的</view>
  7. </view>
  8. </scroll-view>
  9. <view class="echo-fixed-top-empty"></view>
  10. <view v-if="wtype==1">
  11. <form>
  12. <view class="echo-formmain padding bg-white" style="min-height: calc(100vh - 100rpx);">
  13. <view>
  14. <view class="cu-bar bg-white">
  15. <view class="action" style="margin-left: 0rpx;">
  16. <text class="text-bold text-black">视频标题</text>
  17. </view>
  18. </view>
  19. <view class="padding-sm radius bg-white solid-bottom">
  20. <input name="title" @input="setInput" placeholder="请输入..." :value="videoinfo.title"></input>
  21. </view>
  22. </view>
  23. <view>
  24. <view class="cu-bar bg-white">
  25. <view class="action" style="margin-left: 0rpx;">
  26. <text class="text-bold text-black">上传视频文件</text>
  27. </view>
  28. </view>
  29. <!-- <view class="grid col-4 grid-square flex-sub">
  30. <view class="bg-img" v-if="videoinfo.imageurl!=''">
  31. <image :src="videoinfo.imageurl" mode="aspectFill"></image>
  32. <view class="cu-tag bg-red" @tap.stop="delVideo">
  33. <text class='cuIcon-close'></text>
  34. </view>
  35. </view>
  36. <view class="solids" v-if="videoinfo.imageurl==''" @click="chooseVideo">
  37. <text class='cuIcon-record'></text>
  38. </view>
  39. </view> -->
  40. <view class="grid col-4 grid-square flex-sub" v-if="videoinfo.videourl==''">
  41. <view class="solids" @click="chooseVideo">
  42. <text class='cuIcon-record'></text>
  43. </view>
  44. </view>
  45. <view class="grid col-1 grid-square flex-sub" v-if="videoinfo.videourl!=''">
  46. <view class="bg-img">
  47. <video id="myVideo" class="myVideo" :src="videoinfo.videourl" enable-danmu controls></video>
  48. <view class="cu-tag bg-red" @tap.stop="udelVideo">
  49. <text class='cuIcon-close'></text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="flex flex-direction padding-top-xl">
  55. <button class="cu-btn lg bg-blue" @tap="formSubmit">立即提交</button>
  56. </view>
  57. </view>
  58. </form>
  59. </view>
  60. <view v-if="wtype==2">
  61. <view class="listbox">
  62. <block v-for="(item,index) in plist" :key="index">
  63. <view class="cu-card case vitembox">
  64. <view class="cu-item shadow">
  65. <view class="image" @tap="goDetail(item.id)">
  66. <image :src="item.imageurl" mode="aspectFill" style="height: 500rpx;"></image>
  67. <view class="cu-tag bg-blue">{{item.status_text}}</view>
  68. <view class="cu-bar bg-shadeBottom"> <text class="text-cut">{{item.title}}</text></view>
  69. </view>
  70. <!-- <view class="text-content padding-lr-sm padding-top-xs text-cut">{{item.title}}</view> -->
  71. <view class="cu-list menu-avatar">
  72. <view class="cu-item">
  73. <view class="cu-avatar round lg" @tap="goDetail(item.id)" :style="'background-image:url('+item.worker.tilpic+');'"></view>
  74. <view class="content flex-sub">
  75. <view class="text-grey text-cur flex justify-between">
  76. <text>{{item.worker.title}}</text>
  77. </view>
  78. <view class="text-gray text-sm flex justify-between">
  79. {{item.createtime}}
  80. <view class="text-gray text-sm" :data-index="index" @tap="delVideo">
  81. <text class="cuIcon-delete margin-lr-xs"></text> 删除
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </block>
  90. </view>
  91. <uni-load-more :status="pstatus"></uni-load-more>
  92. </view>
  93. <view class="padding-sm"></view>
  94. <view class="padding-xl"></view>
  95. <view class="cu-bar tabbar bg-white foot">
  96. <view class="action text-gray" @tap="goNavPage('/pages/worker/worker')">
  97. <view class="cuIcon-cu-image">
  98. <image src="../../static/tabbar/windex.png"></image>
  99. </view>
  100. 首页
  101. </view>
  102. <view class="action text-gray" @tap="goNavPage('/pages/demand/demand')">
  103. <view class="cuIcon-cu-image">
  104. <image src="../../static/tabbar/wdemand.png"></image>
  105. </view>
  106. 订单
  107. </view>
  108. <!-- #ifndef MP-WEIXIN -->
  109. <view class="action text-blue videoimg" @tap="goNavPage('/pages/video/video')">
  110. <view class="cuIcon-cu-image">
  111. <image src="../../static/tabbar/video.png"></image>
  112. </view>
  113. 录视频
  114. </view>
  115. <!-- #endif -->
  116. <view class="action text-gray" @tap="goNavPage('/pages/supply/supply')">
  117. <view class="cuIcon-cu-image">
  118. <image src="../../static/tabbar/wsupply.png"></image>
  119. </view>
  120. 供人
  121. </view>
  122. <!--
  123. <view class="action text-gray" @tap="goNavPage('/pages/worker/workerlist')">
  124. <view class="cuIcon-cu-image">
  125. <image src="../../static/tabbar/wworker.png"></image>
  126. </view>
  127. 企业1
  128. </view>
  129. -->
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
  135. var _this;
  136. export default {
  137. components: {
  138. uniLoadMore
  139. },
  140. data() {
  141. return {
  142. isRotate: false,
  143. userinfo: false,
  144. workerinfo: null,
  145. wtype: 1,
  146. videoinfo:{
  147. title: "",
  148. videourl: ""
  149. },
  150. pstatus: 'more',
  151. ppage: 1,
  152. psize: 20,
  153. plist: [],
  154. }
  155. },
  156. onLoad: function(option) {
  157. _this = this;
  158. _this = this;
  159. _this.userinfo = uni.getStorageSync('userinfo') || false;
  160. _this.workerinfo = uni.getStorageSync('workerinfo') || false;
  161. if (_this.workerinfo === false) {
  162. uni.reLaunch({
  163. url: "/pages/my/my"
  164. });
  165. return false;
  166. }
  167. _this.getMore();
  168. },
  169. onPullDownRefresh: function() {
  170. _this.pageRefresh();
  171. },
  172. onReachBottom: function() {
  173. if (_this.pstatus !== 'more') {
  174. return;
  175. }
  176. _this.getMore();
  177. },
  178. methods: {
  179. goDetail: function(videoid) {
  180. uni.navigateTo({
  181. url: '/pages/video/detail?videoid=' + videoid
  182. });
  183. },
  184. udelVideo: function(e) {
  185. uni.showModal({
  186. title: '信息提示',
  187. content: "删除后不可恢复,确认要删除吗?",
  188. showCancel: true,
  189. success: function (res) {
  190. if (res.confirm) {
  191. _this.videoinfo.videourl = "";
  192. } else if (res.cancel) {
  193. console.log('用户点击取消');
  194. }
  195. }
  196. });
  197. },
  198. delVideo: function(e) {
  199. var index = e.currentTarget.dataset.index;
  200. uni.showModal({
  201. title: '信息提示',
  202. content: "删除后不可恢复,确认要删除吗?",
  203. showCancel: true,
  204. success: function (res) {
  205. if (res.confirm) {
  206. _this.$req.ajax({
  207. path: "video/delvideo",
  208. data: {
  209. videoid: _this.plist[index].id,
  210. workerid: _this.workerinfo.id
  211. }
  212. }).then((data) => {
  213. uni.showModal({
  214. title: '信息提示',
  215. content: "视频信息删除成功。",
  216. showCancel: false
  217. });
  218. _this.plist.splice(index, 1);
  219. }).catch((err) => {
  220. uni.showModal({
  221. title: '信息提示',
  222. content: err,
  223. showCancel: false
  224. });
  225. });
  226. } else if (res.cancel) {
  227. console.log('用户点击取消');
  228. }
  229. }
  230. });
  231. },
  232. tabSelect: function(e) {
  233. _this.wtype = e.currentTarget.dataset.wtype;
  234. },
  235. pageRefresh: function() {
  236. _this.pstatus = 'more';
  237. _this.ppage = 1;
  238. _this.plist = [];
  239. _this.getMore();
  240. },
  241. getMore: function() {
  242. _this.$req.ajax({
  243. path: "video/listvideo",
  244. data: {
  245. ppage: _this.ppage,
  246. psize: _this.psize,
  247. workerid: _this.workerinfo.id
  248. }
  249. }).then((data) => {
  250. _this.pstatus = data.pstatus;
  251. _this.plist = _this.plist.concat(data.plist);
  252. _this.ppage += 1;
  253. uni.stopPullDownRefresh();
  254. }).catch((err) => {
  255. uni.showModal({
  256. title: '信息提示',
  257. content: err,
  258. showCancel: false
  259. });
  260. });
  261. },
  262. // 提交表单
  263. formSubmit: function(e) {
  264. if (_this.isRotate) {
  265. return false;
  266. }
  267. _this.isRotate = true;
  268. _this.$req.ajax({
  269. path: "video/setvideo",
  270. data: {
  271. workerid: _this.workerinfo.id,
  272. title: _this.videoinfo.title,
  273. videourl: _this.videoinfo.videourl,
  274. },
  275. }).then((data) => {
  276. _this.isRotate = false;
  277. uni.showModal({
  278. title: '信息提示',
  279. content: "提交成功。",
  280. showCancel: false,
  281. success: function (res) {
  282. if (res.confirm) {
  283. _this.wtype = 2;
  284. _this.videoinfo = {
  285. title: "",
  286. videourl: ""
  287. };
  288. _this.pageRefresh();
  289. } else if (res.cancel) {
  290. console.log('用户点击取消');
  291. }
  292. }
  293. });
  294. }).catch((err) => {
  295. _this.isRotate = false;
  296. uni.showModal({
  297. title: '信息提示',
  298. content: err,
  299. showCancel: false
  300. });
  301. });
  302. },
  303. setInput: function(e) {
  304. _this.videoinfo.title = e.detail.value;
  305. },
  306. chooseVideo: function(e) {
  307. uni.chooseVideo({
  308. count: 1,
  309. sourceType: ['camera', 'album'],
  310. success: (res) => {
  311. _this.$req.ajaxFile({
  312. path: "attachment/tplfieldvideo",
  313. title: '正在上传',
  314. filePath: res.tempFilePath,
  315. fileName: 'file',
  316. }).then((vfiledata) => {
  317. var vdata = JSON.parse(vfiledata.data);
  318. _this.videoinfo.videourl = vdata.data.src;
  319. }).catch((err) => {
  320. uni.showModal({
  321. title: '信息提示',
  322. content: err,
  323. showCancel: false
  324. });
  325. });
  326. }
  327. });
  328. },
  329. goNavPage: function(pageurl) {
  330. _this.userinfo = _this.checkLogin("/pages/my/my");
  331. if (_this.userinfo === false) {
  332. return false;
  333. }
  334. uni.redirectTo({
  335. url: pageurl
  336. });
  337. },
  338. }
  339. }
  340. </script>
  341. <style lang="scss">
  342. // .vitembox{ width: 360rpx; }
  343. // .vitembox image{ width: 360rpx; height: 165rpx; }
  344. .myVideo{ width: 690rpx; height: 690rpx; }
  345. </style>