Sellervideo.php 4.9 KB

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