Sellervideo.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Sellervideo extends BaseSeller {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellervideo.lang.php');
  20. }
  21. public function index() {
  22. $goods_model = model('goods');
  23. $video_list = $goods_model->getGoodsVideoList(array(array('store_id', '=', session('store_id'))), '*', 'goodsvideo_id desc', 0, 16);
  24. foreach ($video_list as $key => $val) {
  25. $video_list[$key]['goodsvideo_url'] = goods_video($val['goodsvideo_name']);
  26. }
  27. View::assign('video_list', $video_list);
  28. View::assign('show_page', $goods_model->page_info->render());
  29. /* 设置卖家当前菜单 */
  30. $this->setSellerCurMenu('sellervideo');
  31. /* 设置卖家当前栏目 */
  32. $this->setSellerCurItem('index');
  33. return View::fetch($this->template_dir . 'index');
  34. }
  35. /**
  36. * 视频列表,外部调用
  37. */
  38. public function video_list() {
  39. $goods_model = model('goods');
  40. $video_list = $goods_model->getGoodsVideoList(array(array('store_id', '=', session('store_id'))), '*', 'goodsvideo_id desc', 0, 3);
  41. foreach ($video_list as $key => $val) {
  42. $video_list[$key]['goodsvideo_url'] = goods_video($val['goodsvideo_name']);
  43. }
  44. View::assign('video_list', $video_list);
  45. View::assign('show_page', $goods_model->page_info->render());
  46. echo View::fetch($this->template_dir . 'video_list');
  47. }
  48. /**
  49. * 视频删除
  50. */
  51. public function del_video() {
  52. $return_json = input('param.return_json'); //是否为json 返回
  53. $ids = input('param.id/a');
  54. if (empty($ids)) {
  55. $this->error(lang('param_error'));
  56. }
  57. $goods_model = model('goods');
  58. //删除视频
  59. $condition = array();
  60. $condition[] = array('goodsvideo_id', 'in', $ids);
  61. $condition[] = array('store_id', '=', session('store_id'));
  62. $return = $goods_model->delGoodsVideo($condition);
  63. if ($return) {
  64. if ($return_json) {
  65. ds_json_encode(10000, lang('ds_common_op_succ'));
  66. } else {
  67. $this->success(lang('ds_common_op_succ'));
  68. }
  69. } else {
  70. if ($return_json) {
  71. ds_json_encode(10000, lang('ds_common_op_fail'));
  72. } else {
  73. $this->error(lang('ds_common_op_fail'));
  74. }
  75. }
  76. }
  77. /**
  78. * 上传视频
  79. */
  80. public function video_upload() {
  81. $store_id = session('store_id');
  82. $save_name = $store_id . '_' . date('YmdHis') . rand(10000, 99999) . '.mp4';
  83. $file_name = input('post.name');
  84. $upload_path = ATTACH_GOODS . DIRECTORY_SEPARATOR . $store_id;
  85. $res = ds_upload_pic($upload_path, $file_name, $save_name, 'mp4');
  86. if ($res['code']) {
  87. $save_name = $res['data']['file_name'];
  88. $data = array();
  89. $data ['url'] = goods_video($save_name);
  90. $data ['name'] = $save_name;
  91. $goods_model = model('goods');
  92. $goods_model->addGoodsVideo(array(
  93. 'store_id' => $store_id,
  94. 'store_name' => session('store_name'),
  95. 'goodsvideo_name' => $save_name,
  96. 'goodsvideo_add_time' => TIMESTAMP
  97. ));
  98. // 整理为json格式
  99. $output = json_encode($data);
  100. echo $output;
  101. exit();
  102. } else {
  103. echo json_encode(array('error' => $res['msg']));
  104. exit();
  105. }
  106. }
  107. /**
  108. * 用户中心右边,小导航
  109. *
  110. * @param string $menu_type 导航类型
  111. * @param string $menu_key 当前导航的menu_key
  112. * @return
  113. */
  114. function getSellerItemList() {
  115. $item_list = array(
  116. array(
  117. 'name' => 'index',
  118. 'text' => lang('seller_goodsvideo'),
  119. 'url' => (string) url('Sellervideo/index'),
  120. )
  121. );
  122. return $item_list;
  123. }
  124. }
  125. ?>