10], [['share_url'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城id', 'name' => '名称', 'key_word' => '关键词', 'look_num' => '浏览次数', 'scan_code_num' => '扫码次数', 'poster_content' => '海报内容', 'sort' => '海报排序', 'status' => '状态【1启用 0禁用 -1删除】', 'share_url' => '分享图片', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @Author lun * @DateTime 2021-09-16 14:16:24 * @copyright: Copyright (c) 2020 广东七件事集团 * @param array $params * @return object|boolean */ public static function setData($mall_id, array $params){ try{ if(!empty($params['id'])){ $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $mall_id],['<>','status',StatusEnum::DELETE]]); if(empty($model)) throw new \Exception('海报不存在或已删除'); }else{ $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } // 将内容转为json字符串 $params['poster_content'] = Json::encode($params['poster_content']); if(!$model->load($params,'') || !$model->save()) throw new \Exception($model->getErrorMessage()); return $model; }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } /** * 海报默认参数 * @return array[] */ public static function getDefaultPoster() { $urlPrefix = \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster/'; return [ 'share' => [ 'bg_pic' => [ 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster_bg.png', 'is_show' => '1', ], 'head' => [ 'is_show' => '1', 'size' => 60 * 2, 'top' => 10 * 2, 'left' => 10 * 2, 'file_type' => 'image', ], 'qr_code' => [ 'is_show' => '1', 'size' => 120 * 2, 'top' => 150 * 2, 'left' => 127 * 2, 'type' => '1', 'file_type' => 'image', ], 'name' => [ 'is_show' => '1', 'font' => 20, 'top' => 30 * 2, 'left' => 80 * 2, 'color' => '#000', 'file_type' => 'text', ], ], 'goods' => [ 'bg_pic' => [ 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster_bg.png', 'is_show' => '1', ], 'pic' => [ 'url' => $urlPrefix . 'default_goods.jpg', 'is_show' => '1', 'width' => 375 * 2, 'height' => 375 * 2, 'top' => 0, 'left' => 0, 'file_type' => 'image', ], 'head' => [ 'is_show' => '1', 'size' => 30 * 2, 'top' => 550 * 2, 'left' => 20 * 2, 'file_type' => 'image', ], 'nickname' => [ 'is_show' => '1', 'font' => 18, 'top' => 557 * 2, 'left' => 59 * 2, 'color' => '#000', 'file_type' => 'text', ], 'name' => [ 'is_show' => '1', 'font' => 20, 'top' => 390 * 2, 'left' => 20 * 2, 'color' => '#000', 'file_type' => 'text', ], 'price' => [ 'is_show' => '1', 'font' => 20, 'top' => 420 * 2, 'left' => 20 * 2, 'color' => 'rgb(255, 69, 68)', 'file_type' => 'text', ], 'qr_code' => [ 'is_show' => '1', 'size' => 120 * 2, 'top' => 515 * 2, 'left' => 230 * 2, 'type' => '1', 'file_type' => 'image', ], 'desc' => [ 'is_show' => '1', 'width' => 200 * 2, 'font' => 16, 'top' => 595, 'left' => 20 * 2, 'color' => 'rgb(169, 169, 169)', 'text' => '长按识别小程序码进入', 'file_type' => 'text', ], ], 'topic' => [ 'bg_pic' => [ 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster_bg.png', 'is_show' => '1', ], 'pic' => [ 'url' => $urlPrefix . 'default_goods.jpg', 'is_show' => '1', 'width' => 335 * 2, 'height' => 167 * 2, 'top' => 90 * 2, 'left' => 20 * 2, 'file_type' => 'image', ], 'title' => [ 'is_show' => '1', 'font' => 26, 'top' => 40 * 2, 'left' => 20 * 2, 'color' => '#000', 'file_type' => 'text', ], 'look' => [ 'is_show' => '1', 'font' => 16, 'top' => 280 * 2, 'left' => 20 * 2, 'color' => '#999', 'file_type' => 'text', ], 'content' => [ 'is_show' => '1', 'font' => 18, 'top' => 320 * 2, 'left' => 20 * 2, 'color' => '#666666', 'file_type' => 'text', ], 'open_desc' => [ 'is_show' => '1', 'font' => 20, 'top' => 410 * 2, 'left' => 85 * 2, 'color' => '#D68543', 'text' => '打开小程序阅读全文', 'file_type' => 'text', ], 'desc' => [ 'is_show' => '1', 'width' => 205 * 2, 'font' => 18, 'top' => 550 * 2, 'left' => 20 * 2, 'color' => '#000', 'text' => '长按识别小程序码进入', 'file_type' => 'text', ], 'qr_code' => [ 'is_show' => '1', 'size' => 114 * 2, 'top' => 510 * 2, 'left' => 234 * 2, 'type' => '1', 'file_type' => 'image', ], 'line' => [ 'is_show' => '1', 'width' => 335 * 2, 'height' => 1, 'top' => 480 * 2, 'left' => 20 * 2, 'color' => '#e2e2e2', 'file_type' => 'line', ] ], 'footprint' => [ 'bg_pic' => [ 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/app/footprint/footprint_poster_bg.png', 'is_show' => '1', ], 'qr_code' => [ 'is_show' => '1', 'size' => 160 * 2, 'top' => 1140 * 2, 'left' => 540 * 2, 'type' => '1', 'file_type' => 'image', ], 'text_one' => [ 'is_show' => '1', 'font' => 24, 'top' => 380 * 2, 'left' => 124 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '1', 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf', ], 'text_1' => [ 'is_show' => '1', 'font' => 24, 'top' => 380 * 2, 'left' => 148 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '.您在本店共购买', 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf', ], 'text_2' => [ 'is_show' => '1', 'font' => 36, 'top' => 443 * 2, 'left' => 124 * 2, 'color' => '#FF4544', 'file_type' => 'text', 'text' => '590', 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf', ], 'text_3' => [ 'is_show' => '1', 'font' => 24, 'top' => 455 * 2, 'left' => 295 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '件商品', 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf', ], 'text_two' => [ 'is_show' => '1', 'font' => 24, 'top' => 535 * 2, 'left' => 124 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '2', 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf', ], 'text_4' => [ 'is_show' => '1', 'font' => 24, 'top' => 535 * 2, 'left' => 148 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '.您在本店共消费', 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf', ], 'text_5' => [ 'is_show' => '1', 'font' => 24, 'top' => 600 * 2, 'left' => 124 * 2, 'color' => '#FF4544', 'file_type' => 'text', 'text' => '¥', // 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf', ], 'text_6' => [ 'is_show' => '1', 'font' => 36, 'top' => 588 * 2, 'left' => 157 * 2, 'color' => '#FF4544', 'file_type' => 'text', 'text' => '888888', 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf', ], 'text_three' => [ 'is_show' => '1', 'font' => 24, 'top' => 677 * 2, 'left' => 124 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '3', 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf', ], 'text_7' => [ 'is_show' => '1', 'font' => 24, 'top' => 677 * 2, 'left' => 148 * 2, 'color' => '#252525', 'file_type' => 'text', 'text' => '.您在本店最高一次消费达', 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf', ], 'text_8' => [ 'is_show' => '1', 'font' => 24, 'top' => 742 * 2, 'left' => 124 * 2, 'color' => '#FF4544', 'file_type' => 'text', 'text' => '¥', // 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf', ], 'text_9' => [ 'is_show' => '1', 'font' => 36, 'top' => 730 * 2, 'left' => 157 * 2, 'color' => '#FF4544', 'file_type' => 'text', 'text' => '168888', 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf', ], ], ]; } /** * 修改状态 * * @return boolean */ public function changeStatus() { $this->status = (int)!$this->status; return $this->save(); } }